1 import { Component, OnDestroy, OnInit } from '@angular/core';
3 import _ from 'lodash';
5 import { MgrModuleService } from '~/app/shared/api/mgr-module.service';
6 import { NotificationType } from '~/app/shared/enum/notification-type.enum';
7 import { AuthStorageService } from '~/app/shared/services/auth-storage.service';
8 import { NotificationService } from '~/app/shared/services/notification.service';
9 import { TelemetryNotificationService } from '~/app/shared/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;
18 notificationSeverity = 'warning';
21 private mgrModuleService: MgrModuleService,
22 private authStorageService: AuthStorageService,
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 configOptPermissions = this.authStorageService.getPermissions().configOpt;
34 if (_.every(Object.values(configOptPermissions))) {
35 this.mgrModuleService.getConfig('telemetry').subscribe((options) => {
36 if (!options['enabled']) {
37 this.telemetryNotificationService.setVisibility(true);
45 this.telemetryNotificationService.setVisibility(false);
48 isNotificationHidden(): boolean {
49 return localStorage.getItem('telemetry_notification_hidden') === 'true';
53 this.telemetryNotificationService.setVisibility(false);
54 localStorage.setItem('telemetry_notification_hidden', 'true');
55 this.notificationService.show(
56 NotificationType.success,
57 $localize`Telemetry activation reminder muted`,
58 $localize`You can activate the module on the Telemetry configuration \
59 page (<b>Dashboard Settings</b> -> <b>Telemetry configuration</b>) at any time.`