Notifications by SweetAlert2 (#1508)

This commit is contained in:
Kevin Papst
2020-10-02 19:37:30 +02:00
committed by GitHub
parent 0aa6baea2f
commit 825e492891
21 changed files with 161 additions and 62 deletions

View File

@@ -46,7 +46,32 @@ export default class KimaiAlert extends KimaiPlugin {
}
}
warning(message) {
this._show('warning', message);
}
success(message) {
this._toast('success', message);
}
info(message) {
this._show('info', message);
}
_show(type, message) {
const translation = this.getContainer().getTranslation();
if (translation.has(message)) {
message = translation.get(message);
}
Swal.fire({
icon: type,
title: message,
});
}
_toast(type, message) {
const translation = this.getContainer().getTranslation();
if (translation.has(message)) {
@@ -59,7 +84,7 @@ export default class KimaiAlert extends KimaiPlugin {
toast: true,
position: 'top',
showConfirmButton: false,
icon: 'success',
icon: type,
title: message,
});
}