mirror of
https://github.com/akveo/ngx-admin.git
synced 2026-03-02 11:50:17 +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 => {
|
||||
|
|
|
|||
|
|
@ -3,9 +3,9 @@ import { takeWhile } from 'rxjs/operators';
|
|||
|
||||
import { OrdersChartComponent } from './charts/orders-chart.component';
|
||||
import { ProfitChartComponent } from './charts/profit-chart.component';
|
||||
import { OrdersChart } from '../../../@core/data/orders-chart.service';
|
||||
import { ProfitChart } from '../../../@core/data/profit-chart.service';
|
||||
import { OrdersProfitChartService, OrderProfitChartSummary } from '../../../@core/data/orders-profit-chart.service';
|
||||
import { OrdersChart } from '../../../@core/data/orders-chart';
|
||||
import { ProfitChart } from '../../../@core/data/profit-chart';
|
||||
import { OrderProfitChartSummary, OrdersProfitChartData } from '../../../@core/data/orders-profit-chart';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-ecommerce-charts',
|
||||
|
|
@ -24,7 +24,7 @@ export class ECommerceChartsPanelComponent implements OnDestroy {
|
|||
@ViewChild('ordersChart') ordersChart: OrdersChartComponent;
|
||||
@ViewChild('profitChart') profitChart: ProfitChartComponent;
|
||||
|
||||
constructor(private ordersProfitChartService: OrdersProfitChartService) {
|
||||
constructor(private ordersProfitChartService: OrdersProfitChartData) {
|
||||
this.ordersProfitChartService.getOrderProfitChartSummary()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe((summary) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { AfterViewInit, Component, Input, OnChanges, OnDestroy } from '@angular/
|
|||
import { NbThemeService } from '@nebular/theme';
|
||||
import { delay, takeWhile } from 'rxjs/operators';
|
||||
|
||||
import { OrdersChart } from '../../../../@core/data/orders-chart.service';
|
||||
import { OrdersChart } from '../../../../@core/data/orders-chart';
|
||||
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||
|
||||
@Component({
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { AfterViewInit, Component, Input, OnChanges, OnDestroy } from '@angular/
|
|||
import { NbThemeService } from '@nebular/theme';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
import { ProfitChart } from '../../../../@core/data/profit-chart.service';
|
||||
import { ProfitChart } from '../../../../@core/data/profit-chart';
|
||||
import { LayoutService } from '../../../../@core/utils/layout.service';
|
||||
|
||||
@Component({
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { NbMediaBreakpoint, NbMediaBreakpointsService, NbThemeService } from '@nebular/theme';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
import { CountryOrderService } from '../../../@core/data/country-order.service';
|
||||
import { CountryOrderData } from '../../../@core/data/country-order';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-country-orders',
|
||||
|
|
@ -34,7 +34,7 @@ export class CountryOrdersComponent implements OnDestroy {
|
|||
|
||||
constructor(private themeService: NbThemeService,
|
||||
private breakpointService: NbMediaBreakpointsService,
|
||||
private countryOrderService: CountryOrderService) {
|
||||
private countryOrderService: CountryOrderData) {
|
||||
this.breakpoints = this.breakpointService.getBreakpointsMap();
|
||||
this.themeService.onMediaQueryChange()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
|
|
@ -51,7 +51,7 @@ export class CountryOrdersComponent implements OnDestroy {
|
|||
selectCountryById(countryName: string) {
|
||||
this.countryName = countryName;
|
||||
|
||||
this.countryOrderService.getCountriesCategoriesData()
|
||||
this.countryOrderService.getCountriesCategoriesData(countryName)
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe((countryData) => {
|
||||
this.countryData = countryData;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { EarningService, PieChart } from '../../../../@core/data/earning.service';
|
||||
import { PieChart, EarningData } from '../../../../@core/data/earning';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
|
|
@ -16,7 +16,7 @@ export class EarningCardBackComponent implements OnDestroy {
|
|||
value: number;
|
||||
defaultSelectedCurrency: string = 'Bitcoin';
|
||||
|
||||
constructor(private earningService: EarningService ) {
|
||||
constructor(private earningService: EarningData ) {
|
||||
this.earningService.getEarningPieChartData()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe((earningPieChartData) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Component, Input, OnDestroy, OnInit } from '@angular/core';
|
|||
import { NbThemeService } from '@nebular/theme';
|
||||
import { interval , Subscription } from 'rxjs';
|
||||
import { switchMap, takeWhile } from 'rxjs/operators';
|
||||
import { EarningService, LiveUpdateChart } from '../../../../@core/data/earning.service';
|
||||
import { LiveUpdateChart, EarningData } from '../../../../@core/data/earning';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-earning-card-front',
|
||||
|
|
@ -21,7 +21,7 @@ export class EarningCardFrontComponent implements OnDestroy, OnInit {
|
|||
liveUpdateChartData: { value: [string, number] }[];
|
||||
|
||||
constructor(private themeService: NbThemeService,
|
||||
private earningService: EarningService) {
|
||||
private earningService: EarningData) {
|
||||
this.themeService.getJsTheme()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe(theme => {
|
||||
|
|
@ -42,9 +42,9 @@ export class EarningCardFrontComponent implements OnDestroy, OnInit {
|
|||
}
|
||||
|
||||
private getEarningCardData(currency) {
|
||||
this.earningService.getEarningLiveUpdateCardData(currency)
|
||||
this.earningService.getEarningCardData(currency)
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe((earningLiveUpdateCardData) => {
|
||||
.subscribe((earningLiveUpdateCardData: LiveUpdateChart) => {
|
||||
this.earningLiveUpdateCardData = earningLiveUpdateCardData;
|
||||
this.liveUpdateChartData = earningLiveUpdateCardData.liveChart;
|
||||
|
||||
|
|
@ -60,9 +60,9 @@ export class EarningCardFrontComponent implements OnDestroy, OnInit {
|
|||
this.intervalSubscription = interval(200)
|
||||
.pipe(
|
||||
takeWhile(() => this.alive),
|
||||
switchMap(() => this.earningService.generateRandomEarningData(currency)),
|
||||
switchMap(() => this.earningService.getEarningLiveUpdateCardData(currency)),
|
||||
)
|
||||
.subscribe((liveUpdateChartData) => {
|
||||
.subscribe((liveUpdateChartData: any[]) => {
|
||||
this.liveUpdateChartData = [...liveUpdateChartData];
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { StatsBarService } from '../../../../@core/data/stats-bar.service';
|
||||
import { StatsBarData } from '../../../../@core/data/stats-bar';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
|
|
@ -13,7 +13,7 @@ export class StatsCardBackComponent implements OnDestroy {
|
|||
|
||||
chartData: number[];
|
||||
|
||||
constructor(private statsBarData: StatsBarService) {
|
||||
constructor(private statsBarData: StatsBarData) {
|
||||
this.statsBarData.getStatsBarData()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe((data) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { ProfitBarAnimationChartService } from '../../../../@core/data/profit-bar-animation-chart.service';
|
||||
import { ProfitBarAnimationChartData } from '../../../../@core/data/profit-bar-animation-chart';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
|
|
@ -13,7 +13,7 @@ export class StatsCardFrontComponent {
|
|||
|
||||
linesData: { firstLine: number[]; secondLine: number[] };
|
||||
|
||||
constructor(private profitBarAnimationChartService: ProfitBarAnimationChartService) {
|
||||
constructor(private profitBarAnimationChartService: ProfitBarAnimationChartData) {
|
||||
this.profitBarAnimationChartService.getChartData()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe((linesData) => {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { ProgressInfo, StatsProgressBarService } from '../../../@core/data/stats-progress-bar.service';
|
||||
import { ProgressInfo, StatsProgressBarData } from '../../../@core/data/stats-progress-bar';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
|
|
@ -13,7 +13,7 @@ export class ECommerceProgressSectionComponent implements OnDestroy {
|
|||
|
||||
progressInfoData: ProgressInfo[];
|
||||
|
||||
constructor(private statsProgressBarService: StatsProgressBarService) {
|
||||
constructor(private statsProgressBarService: StatsProgressBarData) {
|
||||
this.statsProgressBarService.getProgressInfoData()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe((data) => {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Component, Input, OnDestroy } from '@angular/core';
|
|||
import { NbThemeService } from '@nebular/theme';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
import { TrafficList } from '../../../../@core/data/traffic-list.service';
|
||||
import { TrafficList } from '../../../../@core/data/traffic-list';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-traffic-front-card',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { TrafficList, TrafficListService } from '../../../@core/data/traffic-list.service';
|
||||
import { TrafficList, TrafficListData } from '../../../@core/data/traffic-list';
|
||||
import { TrafficBarData, TrafficBar } from '../../../@core/data/traffic-bar';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
import { TrafficBar, TrafficBarService } from '../../../@core/data/traffic-bar.service';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-traffic-reveal-card',
|
||||
|
|
@ -17,8 +17,8 @@ export class TrafficRevealCardComponent implements OnDestroy {
|
|||
revealed = false;
|
||||
period: string = 'week';
|
||||
|
||||
constructor(private trafficListService: TrafficListService,
|
||||
private trafficBarService: TrafficBarService) {
|
||||
constructor(private trafficListService: TrafficListData,
|
||||
private trafficBarService: TrafficBarData) {
|
||||
this.getTrafficFrontCardData(this.period);
|
||||
this.getTrafficBackCardData(this.period);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { Component, OnDestroy } from '@angular/core';
|
|||
import { NbThemeService } from '@nebular/theme';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
|
||||
import { UserActivityService, UserActive } from '../../../@core/data/user-activity.service';
|
||||
import { UserActivityData, UserActive } from '../../../@core/data/user-activity';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-user-activity',
|
||||
|
|
@ -59,7 +59,7 @@ export class ECommerceUserActivityComponent implements OnDestroy {
|
|||
currentTheme: string;
|
||||
|
||||
constructor(private themeService: NbThemeService,
|
||||
private userActivityService: UserActivityService) {
|
||||
private userActivityService: UserActivityData) {
|
||||
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 { OutlineData } from '../../../../@core/data/visitors-analytics.service';
|
||||
import { OutlineData } from '../../../../@core/data/visitors-analytics';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-visitors-analytics-chart',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Component, OnDestroy } from '@angular/core';
|
||||
import { takeWhile } from 'rxjs/operators';
|
||||
import { NbThemeService } from '@nebular/theme';
|
||||
import { OutlineData, VisitorsAnalyticsService } from '../../../@core/data/visitors-analytics.service';
|
||||
import { OutlineData, VisitorsAnalyticsData } from '../../../@core/data/visitors-analytics';
|
||||
import { forkJoin } from 'rxjs';
|
||||
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ export class ECommerceVisitorsAnalyticsComponent implements OnDestroy {
|
|||
visitorsAnalyticsData: { innerLine: number[]; outerLine: OutlineData[]; };
|
||||
|
||||
constructor(private themeService: NbThemeService,
|
||||
private visitorsAnalyticsChartService: VisitorsAnalyticsService) {
|
||||
private visitorsAnalyticsChartService: VisitorsAnalyticsData) {
|
||||
this.themeService.getJsTheme()
|
||||
.pipe(takeWhile(() => this.alive))
|
||||
.subscribe(theme => {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { LocalDataSource } from 'ng2-smart-table';
|
||||
|
||||
import { SmartTableService } from '../../../@core/data/smart-table.service';
|
||||
import { SmartTableData } from '../../../@core/data/smart-table';
|
||||
|
||||
@Component({
|
||||
selector: 'ngx-smart-table',
|
||||
|
|
@ -59,7 +59,7 @@ export class SmartTableComponent {
|
|||
|
||||
source: LocalDataSource = new LocalDataSource();
|
||||
|
||||
constructor(private service: SmartTableService) {
|
||||
constructor(private service: SmartTableData) {
|
||||
const data = this.service.getData();
|
||||
this.source.load(data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import { Ng2SmartTableModule } from 'ng2-smart-table';
|
|||
|
||||
import { ThemeModule } from '../../@theme/theme.module';
|
||||
import { TablesRoutingModule, routedComponents } from './tables-routing.module';
|
||||
import { SmartTableService } from '../../@core/data/smart-table.service';
|
||||
|
||||
@NgModule({
|
||||
imports: [
|
||||
|
|
@ -14,8 +13,5 @@ import { SmartTableService } from '../../@core/data/smart-table.service';
|
|||
declarations: [
|
||||
...routedComponents,
|
||||
],
|
||||
providers: [
|
||||
SmartTableService,
|
||||
],
|
||||
})
|
||||
export class TablesModule { }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue