2017-09-20 14:31:06 +03:00
|
|
|
import { Component, OnDestroy } from '@angular/core';
|
2017-08-29 15:55:09 +03:00
|
|
|
import { NbThemeService } from '@nebular/theme';
|
2017-07-14 19:46:28 +03:00
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'ngx-traffic',
|
|
|
|
|
styleUrls: ['./traffic.component.scss'],
|
|
|
|
|
template: `
|
2017-08-01 17:42:21 +03:00
|
|
|
<nb-card size="xsmall">
|
|
|
|
|
<nb-card-header>
|
2017-07-24 19:10:59 +03:00
|
|
|
<span>Traffic Consumption</span>
|
|
|
|
|
<div class="ghost-dropdown" ngbDropdown>
|
2017-08-29 15:55:09 +03:00
|
|
|
<button type="button" class="btn btn-sm" ngbDropdownToggle
|
|
|
|
|
[ngClass]="{ 'btn-success': currentTheme == 'default', 'btn-primary': currentTheme != 'default'}">
|
2017-07-24 19:10:59 +03:00
|
|
|
{{ type }}
|
|
|
|
|
</button>
|
|
|
|
|
<ul class="dropdown-menu">
|
|
|
|
|
<li class="dropdown-item" *ngFor="let t of types" (click)="type = t">{{ t }}</li>
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
2017-08-01 17:42:21 +03:00
|
|
|
</nb-card-header>
|
|
|
|
|
<nb-card-body class="p-0">
|
2017-07-24 19:10:59 +03:00
|
|
|
<ngx-traffic-chart></ngx-traffic-chart>
|
2017-08-01 17:42:21 +03:00
|
|
|
</nb-card-body>
|
|
|
|
|
</nb-card>
|
2017-07-14 19:46:28 +03:00
|
|
|
`,
|
|
|
|
|
})
|
2017-09-20 14:31:06 +03:00
|
|
|
export class TrafficComponent implements OnDestroy {
|
2017-07-24 19:10:59 +03:00
|
|
|
type: string = 'month';
|
|
|
|
|
types = ['week', 'month', 'year'];
|
2017-08-29 15:55:09 +03:00
|
|
|
currentTheme: string;
|
2017-09-20 14:31:06 +03:00
|
|
|
themeSubscription: any;
|
2017-08-29 15:55:09 +03:00
|
|
|
|
|
|
|
|
constructor(private themeService: NbThemeService) {
|
2017-09-20 14:31:06 +03:00
|
|
|
this.themeSubscription = this.themeService.getJsTheme().subscribe(theme => {
|
2017-08-29 15:55:09 +03:00
|
|
|
this.currentTheme = theme.name;
|
|
|
|
|
});
|
|
|
|
|
}
|
2017-09-20 14:31:06 +03:00
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
|
this.themeSubscription.unsubscribe();
|
|
|
|
|
}
|
2017-07-14 19:46:28 +03:00
|
|
|
}
|