1 import { Component, OnDestroy, OnInit } from '@angular/core';
3 import { UserFormModel } from '../../../core/auth/user-form/user-form.model';
4 import { MgrModuleService } from '../../api/mgr-module.service';
5 import { UserService } from '../../api/user.service';
6 import { NotificationType } from '../../enum/notification-type.enum';
7 import { AuthStorageService } from '../../services/auth-storage.service';
8 import { NotificationService } from '../../services/notification.service';
9 import { TelemetryNotificationService } from '../../services/telemetry-notification.service';
12 selector: 'cd-telemetry-notification',
13 templateUrl: './telemetry-notification.component.html',
14 styleUrls: ['./telemetry-notification.component.scss']
16 export class TelemetryNotificationComponent implements OnInit, OnDestroy {
17 displayNotification = false;
20 private mgrModuleService: MgrModuleService,
21 private authStorageService: AuthStorageService,
22 private userService: UserService,
23 private notificationService: NotificationService,
24 private telemetryNotificationService: TelemetryNotificationService
28 this.telemetryNotificationService.update.subscribe((visible: boolean) => {
29 this.displayNotification = visible;
32 if (!this.isNotificationHidden()) {
33 const username = this.authStorageService.getUsername();
34 this.userService.get(username).subscribe((user: UserFormModel) => {
35 if (user.roles.includes('administrator')) {
36 this.mgrModuleService.getConfig('telemetry').subscribe((options) => {
37 if (!options['enabled']) {
38 this.telemetryNotificationService.setVisibility(true);
47 this.telemetryNotificationService.setVisibility(false);
50 isNotificationHidden(): boolean {
51 return localStorage.getItem('telemetry_notification_hidden') === 'true';
55 this.telemetryNotificationService.setVisibility(false);
56 localStorage.setItem('telemetry_notification_hidden', 'true');
57 this.notificationService.show(
58 NotificationType.success,
59 $localize`Telemetry activation reminder muted`,
60 $localize`You can activate the module on the Telemetry configuration \
61 page (<b>Dashboard Settings</b> -> <b>Telemetry configuration</b>) at any time.`