2022-07-12 10:55:28 +02:00
|
|
|
import { App } from "vue";
|
2019-06-17 17:15:27 +02:00
|
|
|
|
|
|
|
export class Notifier {
|
2022-07-12 10:55:28 +02:00
|
|
|
private app: App;
|
2019-06-17 17:15:27 +02:00
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
constructor(app: App) {
|
|
|
|
this.app = app;
|
2019-06-17 17:15:27 +02:00
|
|
|
}
|
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
success(message: string): void {
|
2022-08-26 16:08:58 +02:00
|
|
|
this.notification(message, "success");
|
2019-06-17 17:15:27 +02:00
|
|
|
}
|
2019-09-11 09:59:01 +02:00
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
error(message: string): void {
|
2022-08-26 16:08:58 +02:00
|
|
|
this.notification(message, "danger");
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
|
2020-10-13 20:39:59 +02:00
|
|
|
info(message: string): void {
|
2022-08-26 16:08:58 +02:00
|
|
|
this.notification(message, "info");
|
2019-12-03 11:29:51 +01:00
|
|
|
}
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
private notification(message: string, type: string) {
|
|
|
|
this.app.config.globalProperties.$oruga.notification.open({
|
2019-09-11 09:59:01 +02:00
|
|
|
message,
|
|
|
|
duration: 5000,
|
2022-08-26 16:08:58 +02:00
|
|
|
position: "bottom-right",
|
2019-12-03 11:29:51 +01:00
|
|
|
type,
|
2019-09-11 09:59:01 +02:00
|
|
|
hasIcon: true,
|
|
|
|
});
|
|
|
|
}
|
2019-06-17 17:15:27 +02:00
|
|
|
}
|
|
|
|
|
2022-07-12 10:55:28 +02:00
|
|
|
export const notifierPlugin = {
|
|
|
|
install(app: App) {
|
|
|
|
const notifier = new Notifier(app);
|
|
|
|
app.config.globalProperties.$notifier = notifier;
|
|
|
|
app.provide("notifier", notifier);
|
|
|
|
},
|
|
|
|
};
|