} from '../../../shared/services/feature-toggles.service';
import { PrometheusAlertService } from '../../../shared/services/prometheus-alert.service';
import { SummaryService } from '../../../shared/services/summary.service';
+import { TelemetryNotificationService } from '../../../shared/services/telemetry-notification.service';
@Component({
selector: 'cd-navigation',
styleUrls: ['./navigation.component.scss']
})
export class NavigationComponent implements OnInit, OnDestroy {
- @HostBinding('class.isPwdDisplayed') isPwdDisplayed = false;
+ notifications: string[] = [];
+ @HostBinding('class') get class(): string {
+ return 'top-notification-' + this.notifications.length;
+ }
permissions: Permissions;
enabledFeature$: FeatureTogglesMap$;
private authStorageService: AuthStorageService,
private summaryService: SummaryService,
private featureToggles: FeatureTogglesService,
+ private telemetryNotificationService: TelemetryNotificationService,
public prometheusAlertService: PrometheusAlertService
) {
this.permissions = this.authStorageService.getPermissions();
ngOnInit() {
this.subs.add(
- this.summaryService.subscribe((data: any) => {
- if (!data) {
- return;
- }
- this.summaryData = data;
+ this.summaryService.subscribe((summary) => {
+ this.summaryData = summary;
})
);
+ /*
+ Note: If you're going to add more top notifications please do not forget to increase
+ the number of generated css-classes in section topNotification settings in the scss
+ file.
+ */
this.subs.add(
this.authStorageService.isPwdDisplayed$.subscribe((isDisplayed) => {
- this.isPwdDisplayed = isDisplayed;
+ this.showTopNotification('isPwdDisplayed', isDisplayed);
+ })
+ );
+ this.subs.add(
+ this.telemetryNotificationService.update.subscribe((visible: boolean) => {
+ this.showTopNotification('telemetryNotificationEnabled', visible);
})
);
}
this.displayedSubMenu = menu;
}
}
+
+ showTopNotification(name: string, isDisplayed: boolean) {
+ if (isDisplayed) {
+ if (!this.notifications.includes(name)) {
+ this.notifications.push(name);
+ }
+ } else {
+ const index = this.notifications.indexOf(name);
+ if (index >= 0) {
+ this.notifications.splice(index, 1);
+ }
+ }
+ }
}