mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-16 15:40:11 +01:00
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
import { Component, OnDestroy } from '@angular/core';
|
|
import { NbThemeService } from '@nebular/theme';
|
|
import { Electricity, ElectricityChart, ElectricityData } from '../../../@core/data/electricity';
|
|
import { takeWhile } from 'rxjs/operators';
|
|
import { forkJoin } from 'rxjs';
|
|
|
|
@Component({
|
|
selector: 'ngx-electricity',
|
|
styleUrls: ['./electricity.component.scss'],
|
|
templateUrl: './electricity.component.html',
|
|
})
|
|
export class ElectricityComponent implements OnDestroy {
|
|
|
|
private alive = true;
|
|
|
|
listData: Electricity[];
|
|
chartData: ElectricityChart[];
|
|
|
|
type = 'week';
|
|
types = ['week', 'month', 'year'];
|
|
|
|
currentTheme: string;
|
|
themeSubscription: any;
|
|
|
|
constructor(private electricityService: ElectricityData,
|
|
private themeService: NbThemeService) {
|
|
this.themeService.getJsTheme()
|
|
.pipe(takeWhile(() => this.alive))
|
|
.subscribe(theme => {
|
|
this.currentTheme = theme.name;
|
|
});
|
|
|
|
forkJoin([
|
|
this.electricityService.getListData(),
|
|
this.electricityService.getChartData(),
|
|
])
|
|
.pipe(takeWhile(() => this.alive))
|
|
.subscribe(([listData, chartData]: [Electricity[], ElectricityChart[]]) => {
|
|
this.listData = listData;
|
|
this.chartData = chartData;
|
|
});
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.alive = false;
|
|
}
|
|
}
|