import { Component, OnInit, Input, Output, EventEmitter, ViewChild, TemplateRef, trigger, transition, animate, style, keyframes, ApplicationRef, state } from '@angular/core'; import { Subject } from 'rxjs/Subject'; import { DomSanitizer } from '@angular/platform-browser'; import { Toast, ToastData, ToastrService, ToastRef } from 'ngx-toastr'; import { CfAlertsComponent } from '../alerts/alerts.component'; import { CfAlertsService } from '../../services/alerts.service'; @Component({ selector: '[cf-alert]', template: "
{{options.icon.type === 'mi' ? options.icon.name : ''}}
", styles: [":host /deep/ { position: relative; display: flex; flex-direction: column; width: auto; max-width: 568px; min-width: 288px; margin: 0 0 6px; border-radius: 2px; box-shadow: 0 3px 5px -1px rgba(0, 0, 0, 0.2), 0 6px 10px 0 rgba(0, 0, 0, 0.14), 0 1px 18px 0 rgba(0, 0, 0, 0.12); overflow: hidden; pointer-events: all; } :host /deep/ md-toolbar.mat-toolbar { min-height: 48px; padding: 8px 16px; font-size: 16px; justify-content: center; } :host /deep/ md-toolbar.mat-toolbar .mat-toolbar-row { height: auto; justify-content: space-between; } :host /deep/ .toast-icon-container { margin-right: 8px; } :host /deep/ md-icon { display: flex; align-items: center; } :host /deep/ .toast-data { display: flex; flex-grow: 1; align-items: center; justify-content: space-between; } :host /deep/ .toast-data button { display: flex; justify-content: center; } :host /deep/ .toast-actions { display: flex; flex-direction: row; margin-left: 8px; } "], animations: [ trigger('flyInOut', [ state('inactive', style({ display: 'none', opacity: 0 })), state('active', style({ opacity: 1 })), state('removed', style({ opacity: 0 })), transition('inactive => active', animate('300ms ease-in')), transition('active => removed', animate('300ms ease-in')), ]) ] }) export class CfAlertComponent extends Toast implements OnInit { alerts: any; constructor( protected toastrService: ToastrService, public data: ToastData, protected toastRef: ToastRef, protected appRef: ApplicationRef, protected sanitizer: DomSanitizer, public alertsService: CfAlertsService, ) { super(toastrService, data, toastRef, appRef, sanitizer); this.alerts = CfAlertsComponent; } confirm(id) { this.alertsService.alertOkEvent(id); this.remove(); } cancel(id) { this.alertsService.alertCancelEvent(id); this.remove(); } ngOnInit() {} }