2015-06-09 12:08:14 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
export default class GlobalNotificationModel {
|
2016-04-13 10:39:19 +02:00
|
|
|
constructor(message, type = 'success', dismissAfter = 5000) {
|
|
|
|
if (type !== 'success' && type !== 'danger') {
|
|
|
|
throw new Error(`A notification's type either has to be success, or danger. Not: ${type}`);
|
|
|
|
}
|
|
|
|
|
2016-03-10 12:45:21 +01:00
|
|
|
if (message) {
|
2015-06-09 13:36:09 +02:00
|
|
|
this.message = message;
|
|
|
|
} else {
|
2016-03-10 12:45:21 +01:00
|
|
|
console.logGlobal(new Error('Global notification did not contain a message and was ignored'), {
|
|
|
|
dismissAfter,
|
|
|
|
type
|
|
|
|
});
|
2015-06-09 13:36:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
this.dismissAfter = dismissAfter;
|
2016-04-13 10:39:19 +02:00
|
|
|
this.type = type;
|
2015-06-09 12:08:14 +02:00
|
|
|
}
|
2016-03-10 12:45:21 +01:00
|
|
|
}
|