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

47 lines
864 B
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-03-26 10:37:02 +08:00
console.log(utils.now(), "message: ", message);
2018-03-26 09:29:35 +08:00
$.notify({
// options
message: message
}, {
// options
2018-03-26 09:29:35 +08:00
type: 'success',
delay: 3000
});
}
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
message: message
}, {
// options
2018-03-26 09:29:35 +08:00
type: 'danger',
delay: delay
});
}
function throwError(message) {
messagingService.logError(message);
throw new Error(message);
}
export default {
showMessage,
showError,
showAndLogError,
2018-03-26 09:29:35 +08:00
throwError
}