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