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:
Valentin Kononov 2019-01-18 16:25:35 +03:00 committed by Dmitry Nehaychik
parent f17aa32c6d
commit cac36f0717
67 changed files with 389 additions and 201 deletions

View file

@ -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();

View file

@ -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 => {

View file

@ -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',

View file

@ -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;
});

View file

@ -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[]) => {

View file

@ -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 => {

View file

@ -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 => {