2018-03-25 21:29:35 -04:00
|
|
|
import messagingService from "./messaging.js";
|
2018-03-25 22:37:02 -04:00
|
|
|
import utils from "./utils.js";
|
2018-03-25 21:29:35 -04:00
|
|
|
|
|
|
|
|
function showMessage(message) {
|
2018-10-30 08:53:30 +01:00
|
|
|
console.debug(utils.now(), "message: ", message);
|
2018-03-25 21:29:35 -04:00
|
|
|
|
|
|
|
|
$.notify({
|
2018-11-22 16:08:02 +01:00
|
|
|
icon: 'jam jam-check',
|
2018-03-25 21:29:35 -04:00
|
|
|
message: message
|
2018-11-22 16:08:02 +01:00
|
|
|
}, getNotifySettings('success', 3000));
|
2018-03-25 21:29:35 -04:00
|
|
|
}
|
|
|
|
|
|
2018-08-17 11:31:42 +02:00
|
|
|
function showAndLogError(message, delay = 10000) {
|
|
|
|
|
showError(message, delay);
|
|
|
|
|
|
|
|
|
|
messagingService.logError(message);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-25 21:29:35 -04:00
|
|
|
function showError(message, delay = 10000) {
|
2018-03-25 22:37:02 -04:00
|
|
|
console.log(utils.now(), "error: ", message);
|
2018-03-25 21:29:35 -04:00
|
|
|
|
|
|
|
|
$.notify({
|
|
|
|
|
// options
|
2018-11-22 16:08:02 +01:00
|
|
|
icon: 'jam jam-alert',
|
2018-03-25 21:29:35 -04:00
|
|
|
message: message
|
2018-11-22 16:08:02 +01:00
|
|
|
}, getNotifySettings('danger', delay));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getNotifySettings(type, delay) {
|
|
|
|
|
return {
|
2018-11-22 21:19:12 +01:00
|
|
|
element: 'body',
|
2018-11-22 16:08:02 +01:00
|
|
|
type: type,
|
2018-11-22 21:19:12 +01:00
|
|
|
z_index: 90000,
|
2018-11-22 16:08:02 +01:00
|
|
|
placement: {
|
|
|
|
|
from: "top",
|
|
|
|
|
align: "center"
|
|
|
|
|
},
|
|
|
|
|
animate: {
|
|
|
|
|
enter: 'animated fadeInDown',
|
|
|
|
|
exit: 'animated fadeOutUp'
|
|
|
|
|
},
|
2018-03-25 21:29:35 -04:00
|
|
|
delay: delay
|
2018-11-22 16:08:02 +01:00
|
|
|
};
|
2018-03-25 21:29:35 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function throwError(message) {
|
|
|
|
|
messagingService.logError(message);
|
|
|
|
|
|
|
|
|
|
throw new Error(message);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
showMessage,
|
|
|
|
|
showError,
|
2018-08-17 11:31:42 +02:00
|
|
|
showAndLogError,
|
2018-03-25 21:29:35 -04:00
|
|
|
throwError
|
|
|
|
|
}
|