mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-18 08:20:13 +01:00
refactor(@core): refactor data services for better integration (#1997)
With this change all components, which used data services before, now use abstract classes of service interfaces, mock services extend interface services, CoreModule contains code to inject a needed implementation of some service.
This commit is contained in:
parent
f17aa32c6d
commit
cac36f0717
67 changed files with 389 additions and 201 deletions
|
|
@ -3,7 +3,7 @@ import { NbThemeService, NbMediaBreakpoint, NbMediaBreakpointsService } from '@n
|
|||
import { takeWhile } from 'rxjs/operators';
|
||||
import { forkJoin } from 'rxjs';
|
||||
|
||||
import { Contacts, RecentUsers, UserService } from '../../../@core/data/users.service';
|
||||
import { Contacts, RecentUsers, UserData } from '../../../@core/data/users';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-contacts',
|
||||
|
|
@ -19,7 +19,7 @@ export class ContactsComponent implements OnDestroy {
|
|||
breakpoint: NbMediaBreakpoint;
|
||||
breakpoints: any;
|
||||
|
||||
constructor(private userService: UserService,
|
||||
constructor(private userService: UserData,
|
||||
private themeService: NbThemeService,
|
||||
private breakpointService: NbMediaBreakpointsService) {
|
||||
this.breakpoints = this.breakpointService.getBreakpointsMap();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import {Component, OnDestroy} from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
import { takeWhile } from 'rxjs/operators' ;
|
||||
import { SolarService } from '../../@core/data/solar.service';
|
||||
import { SolarData } from '../../@core/data/solar';
|
||||
|
||||
interface CardSettings {
|
||||
title: string;
|
||||
|
|
@ -77,7 +77,7 @@ export class DashboardComponent implements OnDestroy {
|
|||
};
|
||||
|
||||
constructor(private themeService: NbThemeService,
|
||||
private solarService: SolarService) {
|
||||
private solarService: SolarData) {
|
||||
this.themeService.getJsTheme()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe(theme => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { delay, takeWhile } from 'rxjs/operators';
|
|||
import { AfterViewInit, Component, Input, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
import { LayoutService } from '../../../../@core/utils';
|
||||
import { ElectricityChart } from '../../../../@core/data/electricity.service';
|
||||
import { ElectricityChart } from '../../../../@core/data/electricity';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-electricity-chart',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
|
||||
import { Electricity, ElectricityChart, ElectricityService } from '../../../@core/data/electricity.service';
|
||||
import { Electricity, ElectricityChart, ElectricityData } from '../../../@core/data/electricity';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
import { forkJoin } from 'rxjs';
|
||||
|
||||
|
|
@ -23,7 +23,7 @@ export class ElectricityComponent implements OnDestroy {
|
|||
currentTheme: string;
|
||||
themeSubscription: any;
|
||||
|
||||
constructor(private electricityService: ElectricityService,
|
||||
constructor(private electricityService: ElectricityData,
|
||||
private themeService: NbThemeService) {
|
||||
this.themeService.getJsTheme()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
|
|
@ -36,7 +36,7 @@ export class ElectricityComponent implements OnDestroy {
|
|||
this.electricityService.getChartData(),
|
||||
)
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe(([listData, chartData]) => {
|
||||
.subscribe(([listData, chartData]: [Electricity[], ElectricityChart[]] ) => {
|
||||
this.listData = listData;
|
||||
this.chartData = chartData;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { Camera, SecurityCamerasService } from '../../../@core/data/security-cameras.service';
|
||||
import { Camera, SecurityCamerasData } from '../../../@core/data/security-cameras';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
|
|
@ -15,7 +15,7 @@ export class SecurityCamerasComponent implements OnDestroy {
|
|||
selectedCamera: Camera;
|
||||
isSingleView = false;
|
||||
|
||||
constructor(private securityCamerasService: SecurityCamerasService) {
|
||||
constructor(private securityCamerasService: SecurityCamerasData) {
|
||||
this.securityCamerasService.getCamerasData()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe((cameras: Camera[]) => {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
import { Temperature, TemperatureHumidityService } from '../../../@core/data/temperature-humidity.service';
|
||||
import { Temperature, TemperatureHumidityData } from '../../../@core/data/temperature-humidity';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
import { forkJoin } from 'rxjs';
|
||||
|
||||
|
|
@ -27,7 +27,7 @@ export class TemperatureComponent implements OnDestroy {
|
|||
themeSubscription: any;
|
||||
|
||||
constructor(private theme: NbThemeService,
|
||||
private temperatureHumidityService: TemperatureHumidityService) {
|
||||
private temperatureHumidityService: TemperatureHumidityData) {
|
||||
this.theme.getJsTheme()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe(config => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
import { TrafficChartService } from '../../../@core/data/traffic-chart.service';
|
||||
import { TrafficChartData } from '../../../@core/data/traffic-chart';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-traffic',
|
||||
|
|
@ -36,7 +36,7 @@ export class TrafficComponent implements OnDestroy {
|
|||
currentTheme: string;
|
||||
|
||||
constructor(private themeService: NbThemeService,
|
||||
private trafficChartService: TrafficChartService) {
|
||||
private trafficChartService: TrafficChartData) {
|
||||
this.themeService.getJsTheme()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe(theme => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue