/*
* This file is part of the Kimai time-tracking app.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
/*!
* [KIMAI] KimaiAlert: notifications for Kimai
*/
import KimaiPlugin from "../KimaiPlugin";
import {Modal, Toast} from "bootstrap";
export default class KimaiAlert extends KimaiPlugin {
/**
* @return {string}
*/
getId() {
return 'alert';
}
/**
* @param {string} title
* @param {string|array|undefined} message
*/
error(title, message) {
const translation = this.getTranslation();
if (translation.has(title)) {
title = translation.get(title);
}
title = title.replace('%reason%', '');
if (message === undefined) {
message = null;
}
if (message !== null) {
if (translation.has(message)) {
message = translation.get(message);
}
if (Array.isArray(message)) {
message = message.join('
');
}
}
const id = 'alert_global_error';
const oldModalElement = document.getElementById(id);
if (oldModalElement !== null) {
Modal.getOrCreateInstance(oldModalElement).hide();
}
const html = `