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

89 lines
2 KiB
TypeScript
Raw Normal View History

2025-05-23 12:59:06 +10:00
import { Component, OnDestroy } from '@angular/core';
import { NbThemeService } from '@nebular/theme';
2025-05-23 12:59:06 +10:00
import { takeWhile } from 'rxjs/operators';
interface CardSettings {
title: string;
2025-05-23 12:59:06 +10:00
value: string;
unitOfMeasurement: 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;
2025-05-23 12:59:06 +10:00
// Key metrics for IdentityPulse
verificationCard: CardSettings = {
title: 'Total Verifications',
value: '1,247',
unitOfMeasurement: 'today',
iconClass: 'nb-checkmark-circle',
type: 'primary',
};
2025-05-23 12:59:06 +10:00
matchRateCard: CardSettings = {
title: 'Average Match Rate',
value: '87.3',
unitOfMeasurement: '%',
iconClass: 'nb-bar-chart',
type: 'success',
};
2025-05-23 12:59:06 +10:00
countriesCard: CardSettings = {
title: 'Active Countries',
value: '4',
unitOfMeasurement: 'regions',
iconClass: 'nb-location',
type: 'info',
};
2025-05-23 12:59:06 +10:00
apiResponseCard: CardSettings = {
title: 'API Response Time',
value: '245',
unitOfMeasurement: 'ms',
iconClass: 'nb-gear',
type: 'warning',
};
2025-05-23 12:59:06 +10:00
statusCards: CardSettings[];
commonStatusCardsSet: CardSettings[] = [
2025-05-23 12:59:06 +10:00
this.verificationCard,
this.matchRateCard,
this.countriesCard,
this.apiResponseCard,
];
statusCardsByThemes: {
default: CardSettings[];
cosmic: CardSettings[];
corporate: CardSettings[];
dark: CardSettings[];
2025-05-23 12:59:06 +10:00
marketsoft: CardSettings[];
} = {
default: this.commonStatusCardsSet,
cosmic: this.commonStatusCardsSet,
2025-05-23 12:59:06 +10:00
corporate: this.commonStatusCardsSet,
dark: this.commonStatusCardsSet,
2025-05-23 12:59:06 +10:00
marketsoft: this.commonStatusCardsSet,
};
2025-05-23 12:59:06 +10:00
constructor(private themeService: NbThemeService) {
this.themeService.getJsTheme()
.pipe(takeWhile(() => this.alive))
.subscribe(theme => {
this.statusCards = this.statusCardsByThemes[theme.name];
});
}
ngOnDestroy() {
this.alive = false;
}
2025-05-23 12:59:06 +10:00
}