24 lines
700 B
TypeScript
24 lines
700 B
TypeScript
import HtmlAlertTemplate from "./alertTemplate.html?raw"
|
|
|
|
export type AlertSeverity = 'debug' | 'info' | 'warning' | 'error' | 'critical'
|
|
|
|
export class Alert {
|
|
readonly title: string
|
|
readonly description: string
|
|
readonly severity: AlertSeverity
|
|
|
|
// a html5 template
|
|
readonly template: string
|
|
|
|
constructor(title: string, description: string, severity: AlertSeverity, template: string = HtmlAlertTemplate) {
|
|
this.title = title
|
|
this.description = description
|
|
this.severity = severity
|
|
this.template = template
|
|
}
|
|
|
|
Show(time: number = -1): void {
|
|
alert(`${this.title} [${this.severity}]: ${this.description} (time: ${time})`)
|
|
}
|
|
}
|