2019-06-17 17:15:27 +02:00
|
|
|
import Vue from 'vue';
|
|
|
|
|
|
|
|
declare module 'vue/types/vue' {
|
|
|
|
interface Vue {
|
|
|
|
$notifier: {
|
|
|
|
success: (message: string) => void;
|
2019-09-11 09:59:01 +02:00
|
|
|
error: (message: string) => void;
|
2019-06-17 17:15:27 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export class Notifier {
|
|
|
|
private readonly vue: typeof Vue;
|
|
|
|
|
|
|
|
constructor(vue: typeof Vue) {
|
|
|
|
this.vue = vue;
|
|
|
|
}
|
|
|
|
|
|
|
|
success(message: string) {
|
2019-09-11 09:59:01 +02:00
|
|
|
this.vue.prototype.$buefy.notification.open({
|
2019-06-17 17:15:27 +02:00
|
|
|
message,
|
|
|
|
duration: 5000,
|
|
|
|
position: 'is-bottom-right',
|
|
|
|
type: 'is-success',
|
|
|
|
hasIcon: true,
|
|
|
|
});
|
|
|
|
}
|
2019-09-11 09:59:01 +02:00
|
|
|
|
|
|
|
error(message: string) {
|
|
|
|
this.vue.prototype.$buefy.notification.open({
|
|
|
|
message,
|
|
|
|
duration: 5000,
|
|
|
|
position: 'is-bottom-right',
|
|
|
|
type: 'is-danger',
|
|
|
|
hasIcon: true,
|
|
|
|
});
|
|
|
|
}
|
2019-06-17 17:15:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// tslint:disable
|
|
|
|
export function NotifierPlugin(vue: typeof Vue, options?: any): void {
|
|
|
|
vue.prototype.$notifier = new Notifier(vue);
|
|
|
|
}
|