Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 0
VPD 0
PL 0
Other 0

File Content

import { Component, Input, OnChanges, SimpleChanges } from '@angular/core';
import { WindowRefService} from './../../window-ref.service';
// Restrict the MessageStatus String to "known" types
type MessageStatus = 'errorStatus' | 'successStatus' | 'warningStatus' | 'infoStatus' | 'infoStatusSolid' | 'ewvStatus' | 'ewvNoInfo';

@Component({
selector: 'app-messages',
templateUrl: './messages.component.html',
styleUrls: ['./messages.component.scss']
})
export class MessagesComponent implements OnChanges{
constructor(private windowRefService: WindowRefService) {}

@Input() highlight;


@Input() errorStatus = false; // show the errorMsg
@Input() errorMsg = '';

@Input() successStatus = false;
@Input() successMsg = '';

@Input() warningStatus = false;
@Input() warningMsg = '';

@Input() infoStatus = false;
@Input() infoMsg = '';

@Input() infoStatusSolid = false;
// shares infoMsg with infoStatus.

@Input() ewvStatus = false;
@Input() ewvMsg = '';

@Input() ewvNoInfo = '';
animateClose = false; // Used in [class.animate-close]="animateClose" to trigger fade-out
animateFade = 200; // Delay before fade out (ms)

ngOnChanges(change: SimpleChanges) {
if ((change.errorStatus && change.errorStatus.currentValue === true) ||
(change.successStatus && change.successStatus.currentValue === true) ||
(change.infoStatus && change.infoStatus.currentValue === true)) {
this.windowRefService.nativeWindow.scrollTo(0, 0);
}
}
animate(key: MessageStatus, timeout: number) {
this.animateClose = true;
setTimeout(() => {
this[key] = false; // Stop showing the message
this.animateClose = false;
}, timeout);
}

close(key: MessageStatus) {
// User clicked on the message close button. Do it with animation.
this.animate(key, this.animateFade);
}
}