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