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;
20 private mgrModuleService: MgrModuleService,
21 private authStorageService: AuthStorageService,
22 private notificationService: NotificationService,
23 private telemetryNotificationService: TelemetryNotificationService
27 this.telemetryNotificationService.update.subscribe((visible: boolean) => {
28 this.displayNotification = visible;
31 if (!this.isNotificationHidden()) {
32 const configOptPermissions = this.authStorageService.getPermissions().configOpt;
33 if (_.every(Object.values(configOptPermissions))) {
34 this.mgrModuleService.getConfig('telemetry').subscribe((options) => {
35 if (!options['enabled']) {
36 this.telemetryNotificationService.setVisibility(true);
44 this.telemetryNotificationService.setVisibility(false);
47 isNotificationHidden(): boolean {
48 return localStorage.getItem('telemetry_notification_hidden') === 'true';
52 this.telemetryNotificationService.setVisibility(false);
53 localStorage.setItem('telemetry_notification_hidden', 'true');
54 this.notificationService.show(
55 NotificationType.success,
56 $localize`Telemetry activation reminder muted`,
57 $localize`You can activate the module on the Telemetry configuration \
58 page (<b>Dashboard Settings</b> -> <b>Telemetry configuration</b>) at any time.`