]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/components/alert-panel/alert-panel.component.ts
import ceph 16.2.6
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / components / alert-panel / alert-panel.component.ts
CommitLineData
522d829b 1import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
f67539c2
TL
2
3import { Icons } from '~/app/shared/enum/icons.enum';
9f95a23c
TL
4
5@Component({
6 selector: 'cd-alert-panel',
7 templateUrl: './alert-panel.component.html',
8 styleUrls: ['./alert-panel.component.scss']
9})
10export class AlertPanelComponent implements OnInit {
11 @Input()
12 title = '';
13 @Input()
14 bootstrapClass = '';
9f95a23c 15 @Input()
522d829b 16 type: 'warning' | 'error' | 'info' | 'success' | 'danger';
9f95a23c
TL
17 @Input()
18 typeIcon: Icons | string;
19 @Input()
20 size: 'slim' | 'normal' = 'normal';
21 @Input()
22 showIcon = true;
23 @Input()
24 showTitle = true;
522d829b
TL
25 @Input()
26 dismissible = false;
27
28 /**
29 * The event that is triggered when the close button (x) has been
30 * pressed.
31 */
32 @Output()
33 dismissed = new EventEmitter();
9f95a23c
TL
34
35 icons = Icons;
36
9f95a23c
TL
37 ngOnInit() {
38 switch (this.type) {
39 case 'warning':
f67539c2 40 this.title = this.title || $localize`Warning`;
9f95a23c
TL
41 this.typeIcon = this.typeIcon || Icons.warning;
42 this.bootstrapClass = this.bootstrapClass || 'warning';
43 break;
44 case 'error':
f67539c2 45 this.title = this.title || $localize`Error`;
9f95a23c
TL
46 this.typeIcon = this.typeIcon || Icons.destroyCircle;
47 this.bootstrapClass = this.bootstrapClass || 'danger';
48 break;
49 case 'info':
f67539c2 50 this.title = this.title || $localize`Information`;
9f95a23c
TL
51 this.typeIcon = this.typeIcon || Icons.infoCircle;
52 this.bootstrapClass = this.bootstrapClass || 'info';
53 break;
54 case 'success':
f67539c2 55 this.title = this.title || $localize`Success`;
9f95a23c
TL
56 this.typeIcon = this.typeIcon || Icons.check;
57 this.bootstrapClass = this.bootstrapClass || 'success';
58 break;
522d829b
TL
59 case 'danger':
60 this.title = this.title || $localize`Danger`;
61 this.typeIcon = this.typeIcon || Icons.warning;
62 this.bootstrapClass = this.bootstrapClass || 'danger';
63 break;
9f95a23c
TL
64 }
65 }
522d829b
TL
66
67 onClose(): void {
68 this.dismissed.emit();
69 }
9f95a23c 70}