]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/models/cd-notification.ts
c283c5d801d23f86272aa83dd7cd8abb4b38147b
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / models / cd-notification.ts
1 import { IndividualConfig } from 'ngx-toastr';
2
3 import { Icons } from '../enum/icons.enum';
4 import { NotificationType } from '../enum/notification-type.enum';
5
6 export class CdNotificationConfig {
7 applicationClass: string;
8 isFinishedTask = false;
9
10 private classes = {
11 Ceph: 'ceph-icon',
12 Prometheus: 'prometheus-icon'
13 };
14
15 constructor(
16 public type: NotificationType = NotificationType.info,
17 public title?: string,
18 public message?: string, // Use this for additional information only
19 public options?: any | IndividualConfig,
20 public application: string = 'Ceph'
21 ) {
22 this.applicationClass = this.classes[this.application];
23 }
24 }
25
26 export class CdNotification extends CdNotificationConfig {
27 timestamp: string;
28 textClass: string;
29 iconClass: string;
30 duration: number;
31 borderClass: string;
32
33 private textClasses = ['text-danger', 'text-info', 'text-success'];
34 private iconClasses = [Icons.warning, Icons.info, Icons.check];
35 private borderClasses = ['border-danger', 'border-info', 'border-success'];
36
37 constructor(private config: CdNotificationConfig = new CdNotificationConfig()) {
38 super(config.type, config.title, config.message, config.options, config.application);
39 delete this.config;
40 /* string representation of the Date object so it can be directly compared
41 with the timestamps parsed from localStorage */
42 this.timestamp = new Date().toJSON();
43 this.iconClass = this.iconClasses[this.type];
44 this.textClass = this.textClasses[this.type];
45 this.borderClass = this.borderClasses[this.type];
46 this.isFinishedTask = config.isFinishedTask;
47 }
48 }