mirror of
https://github.com/akveo/ngx-admin.git
synced 2025-12-26 20:28:48 +01:00
42 lines
1.3 KiB
TypeScript
42 lines
1.3 KiB
TypeScript
import { Component, OnDestroy } from '@angular/core';
|
|
import { NbThemeService } from '@nebular/theme';
|
|
|
|
@Component({
|
|
selector: 'ngx-traffic',
|
|
styleUrls: ['./traffic.component.scss'],
|
|
template: `
|
|
<nb-card size="xsmall">
|
|
<nb-card-header>
|
|
<span>Traffic Consumption</span>
|
|
<div class="ghost-dropdown" ngbDropdown>
|
|
<button type="button" class="btn btn-sm" ngbDropdownToggle
|
|
[ngClass]="{ 'btn-success': currentTheme == 'default', 'btn-primary': currentTheme != 'default'}">
|
|
{{ type }}
|
|
</button>
|
|
<ul class="dropdown-menu">
|
|
<li class="dropdown-item" *ngFor="let t of types" (click)="type = t">{{ t }}</li>
|
|
</ul>
|
|
</div>
|
|
</nb-card-header>
|
|
<nb-card-body class="p-0">
|
|
<ngx-traffic-chart></ngx-traffic-chart>
|
|
</nb-card-body>
|
|
</nb-card>
|
|
`,
|
|
})
|
|
export class TrafficComponent implements OnDestroy {
|
|
type: string = 'month';
|
|
types = ['week', 'month', 'year'];
|
|
currentTheme: string;
|
|
themeSubscription: any;
|
|
|
|
constructor(private themeService: NbThemeService) {
|
|
this.themeSubscription = this.themeService.getJsTheme().subscribe(theme => {
|
|
this.currentTheme = theme.name;
|
|
});
|
|
}
|
|
|
|
ngOnDestroy() {
|
|
this.themeSubscription.unsubscribe();
|
|
}
|
|
}
|