ngx-admin/src/app/pages/dashboard/dashboard.component.ts

100 lines
2.1 KiB
TypeScript
Raw Normal View History

import {Component, OnDestroy} from '@angular/core';
import { NbThemeService } from '@nebular/theme';
import { takeWhile } from 'rxjs/operators' ;
import { SolarData } from '../../@core/data/solar';
interface CardSettings {
title: string;
iconClass: string;
type: string;
}
2017-04-13 14:24:23 +03:00
@Component({
2017-05-06 15:35:15 +03:00
selector: 'ngx-dashboard',
2017-06-12 19:43:44 +03:00
styleUrls: ['./dashboard.component.scss'],
templateUrl: './dashboard.component.html',
2017-04-13 14:24:23 +03:00
})
export class DashboardComponent implements OnDestroy {
private alive = true;
solarValue: number;
2023-02-03 15:39:10 +08:00
apiserip: CardSettings = {
title: 'SERP API',
iconClass: 'nb-play',
type: 'success',
};
2023-02-03 15:39:10 +08:00
apicrawler: CardSettings = {
title: 'Crawler API',
iconClass: 'nb-play',
type: 'success',
};
2023-02-03 15:39:10 +08:00
imagescoring: CardSettings = {
title: 'Image Analysis',
iconClass: 'nb-play',
type: 'success',
};
2023-02-03 15:39:10 +08:00
keywordscoring: CardSettings = {
title: 'Keywords Analysis',
iconClass: 'nb-play',
type: 'success',
};
statusCards: string;
commonStatusCardsSet: CardSettings[] = [
2023-02-03 15:39:10 +08:00
this.apiserip,
this.apicrawler,
this.imagescoring,
this.keywordscoring,
];
statusCardsByThemes: {
default: CardSettings[];
cosmic: CardSettings[];
corporate: CardSettings[];
dark: CardSettings[];
} = {
default: this.commonStatusCardsSet,
cosmic: this.commonStatusCardsSet,
corporate: [
{
2023-02-03 15:39:10 +08:00
...this.apiserip,
type: 'primary',
},
{
2023-02-03 15:39:10 +08:00
...this.apicrawler,
type: 'primary',
},
{
2023-02-03 15:39:10 +08:00
...this.imagescoring,
type: 'primary',
},
{
2023-02-03 15:39:10 +08:00
...this.keywordscoring,
type: 'primary',
},
],
dark: this.commonStatusCardsSet,
};
constructor(private themeService: NbThemeService,
private solarService: SolarData) {
this.themeService.getJsTheme()
.pipe(takeWhile(() => this.alive))
.subscribe(theme => {
this.statusCards = this.statusCardsByThemes[theme.name];
});
this.solarService.getSolarData()
.pipe(takeWhile(() => this.alive))
.subscribe((data) => {
this.solarValue = data;
});
}
ngOnDestroy() {
this.alive = false;
}
2017-04-13 14:24:23 +03:00
}