trilium/src/public/javascripts/services/info.js

57 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-03-26 09:29:35 +08:00
import messagingService from "./messaging.js";
2018-03-26 10:37:02 +08:00
import utils from "./utils.js";
2018-03-26 09:29:35 +08:00
function showMessage(message) {
2018-10-30 15:53:30 +08:00
console.debug(utils.now(), "message: ", message);
2018-03-26 09:29:35 +08:00
$.notify({
icon: 'jam jam-check',
2018-03-26 09:29:35 +08:00
message: message
}, getNotifySettings('success', 3000));
2018-03-26 09:29:35 +08:00
}
function showAndLogError(message, delay = 10000) {
showError(message, delay);
messagingService.logError(message);
}
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
icon: 'jam jam-alert',
2018-03-26 09:29:35 +08:00
message: message
}, getNotifySettings('danger', delay));
}
function getNotifySettings(type, delay) {
return {
2018-11-23 04:19:12 +08:00
element: 'body',
type: type,
2018-11-23 04:19:12 +08:00
z_index: 90000,
placement: {
from: "top",
align: "center"
},
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
2018-03-26 09:29:35 +08:00
delay: delay
};
2018-03-26 09:29:35 +08:00
}
function throwError(message) {
messagingService.logError(message);
throw new Error(message);
}
export default {
showMessage,
showError,
showAndLogError,
2018-03-26 09:29:35 +08:00
throwError
}