core/dynamic-component/dynamic-component-alerts.component.ts
OnInit
OnDestroy
changeDetection | ChangeDetectionStrategy.OnPush |
selector | c8y-dynamic-component-alerts |
templateUrl | ./dynamic-component-alerts.component.html |
Properties |
Methods |
Inputs |
constructor(alertService: AlertService, ref: ChangeDetectorRef)
|
|||||||||
Parameters :
|
alerts |
Type : DynamicComponentAlertAggregator
|
ngOnDestroy |
ngOnDestroy()
|
Returns :
void
|
ngOnInit |
ngOnInit()
|
Returns :
void
|
closeDetails |
closeDetails()
|
Collapses alert's details.
Returns :
void
|
hasDetails | ||||||
hasDetails(alert: Alert)
|
||||||
Returns true if alert has extra detailedData or defines custom onDetail method.
Parameters :
Returns :
any
|
isDetailsShow | ||||||
isDetailsShow(alert: Alert)
|
||||||
Returns true if details part of alert is expanded.
Parameters :
Returns :
any
|
showDetails | ||||||||
showDetails(alert: Alert)
|
||||||||
Expands details part of particular alert, and collapses details for another alerts.
Parameters :
Returns :
any
|
Public alertService |
Type : AlertService
|
dismissAlertStrategy |
Default value : DismissAlertStrategy
|
detailDisplayedAlert |
Type : any
|
Default value : {}
|
Currently displayed details of an alert. Only one alert’s details can be displayed at a time. |
<ng-container *ngFor="let alertGroup of alerts.alertGroups">
<div
*ngIf="alertGroup?.value?.alerts?.length"
class="alert"
role="alert"
[ngClass]="'alert-' + alertGroup.type"
>
<button
class="close"
type="button"
*ngIf="
alertGroup.value.alertDismissal.dismissStrategy === dismissAlertStrategy.TEMPORARY ||
alertGroup.value.alertDismissal.dismissStrategy ===
dismissAlertStrategy.TEMPORARY_OR_PERMANENT
"
(click)="alerts.dismissAlertGroup(alertGroup.type, dismissPermanently.checked)"
>
<span aria-hidden="true">×</span>
<span class="sr-only">Close</span>
</button>
<div *ngFor="let alertItem of alertGroup.value.alerts; let i = index" class="m-t-8">
<ng-container *ngIf="!isTemplateRef(alertItem.text); else template(alertItem.text)">
<p
*ngIf="!alertItem.allowHtml"
[textContent]="alertItem.text | translate"
class="message"
></p>
<p *ngIf="alertItem.allowHtml" [innerHTML]="alertItem.text | translate" class="message"></p>
</ng-container>
<p *ngIf="hasDetails(alertItem) && !isDetailsShow(alertItem)" class="text-muted m-t-8">
<button
title="{{ 'Show details' | translate }}"
class="btn btn-clean"
(click)="showDetails(alertItem)"
>
<i c8yIcon="chevron-down"></i>
{{ 'Show details' | translate }}
</button>
</p>
<p *ngIf="hasDetails(alertItem) && isDetailsShow(alertItem)" class="text-muted m-t-8">
<button
title="{{ 'Hide details' | translate }}"
class="btn btn-clean"
(click)="closeDetails()"
>
<i c8yIcon="chevron-up"></i>
{{ 'Hide details' | translate }}
</button>
</p>
<div *ngIf="isDetailsShow(alertItem)">
<div
*ngIf="
!isTemplateRef(detailDisplayedAlert.contents);
else template(alertItem.detailedData)
"
>
<pre><code [textContent]="detailDisplayedAlert.contents | translate"></code></pre>
</div>
</div>
<hr *ngIf="i !== alertGroup.value.alerts.length - 1" />
</div>
<label
title="{{ 'Don\'t show again' | translate }}"
class="c8y-checkbox m-t-16"
[class.hidden]="
alertGroup.value.alertDismissal.dismissStrategy !==
dismissAlertStrategy.TEMPORARY_OR_PERMANENT
"
>
<input type="checkbox" #dismissPermanently />
<span></span>
<span>{{ "Don't show again" | translate }}</span>
</label>
</div>
</ng-container>