mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	rename info service to toast service
This commit is contained in:
		| @@ -29,7 +29,7 @@ | ||||
|             <pre class="prettyprint source linenums"><code>import treeService from './tree.js'; | ||||
| import server from './server.js'; | ||||
| import utils from './utils.js'; | ||||
| import infoService from './info.js'; | ||||
| import toastService from './toast.js'; | ||||
| import linkService from './link.js'; | ||||
| import treeCache from './tree_cache.js'; | ||||
| import noteDetailService from './note_detail.js'; | ||||
| @@ -272,7 +272,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte | ||||
|      * @method | ||||
|      * @param {string} message | ||||
|      */ | ||||
|     this.showMessage = infoService.showMessage; | ||||
|     this.showMessage = toastService.showMessage; | ||||
|  | ||||
|     /** | ||||
|      * Show error message to the user. | ||||
| @@ -280,7 +280,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte | ||||
|      * @method | ||||
|      * @param {string} message | ||||
|      */ | ||||
|     this.showError = infoService.showError; | ||||
|     this.showError = toastService.showError; | ||||
|  | ||||
|     /** | ||||
|      * Refresh tree | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import noteDetailService from '../services/note_detail.js'; | ||||
| import server from '../services/server.js'; | ||||
| import infoService from "../services/info.js"; | ||||
| import toastService from "../services/toast.js"; | ||||
| import treeUtils from "../services/tree_utils.js"; | ||||
| import attributeAutocompleteService from "../services/attribute_autocomplete.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| @@ -168,7 +168,7 @@ function AttributesModel() { | ||||
|  | ||||
|         await showAttributes(attributes); | ||||
|  | ||||
|         infoService.showMessage("Attributes have been saved."); | ||||
|         toastService.showMessage("Attributes have been saved."); | ||||
|  | ||||
|         const ctx = noteDetailService.getActiveTabContext(); | ||||
|  | ||||
|   | ||||
| @@ -2,7 +2,7 @@ import treeService from '../services/tree.js'; | ||||
| import server from '../services/server.js'; | ||||
| import treeCache from "../services/tree_cache.js"; | ||||
| import treeUtils from "../services/tree_utils.js"; | ||||
| import infoService from "../services/info.js"; | ||||
| import toastService from "../services/toast.js"; | ||||
| import utils from "../services/utils.js"; | ||||
|  | ||||
| const $dialog = $("#branch-prefix-dialog"); | ||||
| @@ -38,7 +38,7 @@ async function savePrefix() { | ||||
|  | ||||
|     $dialog.modal('hide'); | ||||
|  | ||||
|     infoService.showMessage("Branch prefix has been saved."); | ||||
|     toastService.showMessage("Branch prefix has been saved."); | ||||
| } | ||||
|  | ||||
| $form.submit(() => { | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import treeUtils from "../services/tree_utils.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| import ws from "../services/ws.js"; | ||||
| import infoService from "../services/info.js"; | ||||
| import toastService from "../services/toast.js"; | ||||
|  | ||||
| const $dialog = $("#export-dialog"); | ||||
| const $form = $("#export-form"); | ||||
| @@ -122,16 +122,16 @@ ws.subscribeToMessages(async message => { | ||||
|     } | ||||
|  | ||||
|     if (message.type === 'task-error') { | ||||
|         infoService.closePersistent(message.taskId); | ||||
|         infoService.showError(message.message); | ||||
|         toastService.closePersistent(message.taskId); | ||||
|         toastService.showError(message.message); | ||||
|     } | ||||
|     else if (message.type === 'task-progress-count') { | ||||
|         infoService.showPersistent(makeToast(message.taskId, "Export in progress: " + message.progressCount)); | ||||
|         toastService.showPersistent(makeToast(message.taskId, "Export in progress: " + message.progressCount)); | ||||
|     } | ||||
|     else if (message.type === 'task-succeeded') { | ||||
|         const toast = makeToast(message.taskId, "Import finished successfully."); | ||||
|         toast.closeAfter = 5000; | ||||
|  | ||||
|         infoService.showPersistent(toast); | ||||
|         toastService.showPersistent(toast); | ||||
|     } | ||||
| }); | ||||
| @@ -1,5 +1,5 @@ | ||||
| import libraryLoader from "../services/library_loader.js"; | ||||
| import infoService from "../services/info.js"; | ||||
| import toastService from "../services/toast.js"; | ||||
| import utils from "../services/utils.js"; | ||||
| import noteDetailService from "../services/note_detail.js"; | ||||
|  | ||||
| @@ -22,7 +22,7 @@ async function convertMarkdownToHtml(text) { | ||||
|  | ||||
|     textEditor.model.insertContent(modelFragment, textEditor.model.document.selection); | ||||
|  | ||||
|     infoService.showMessage("Markdown content has been imported into the document."); | ||||
|     toastService.showMessage("Markdown content has been imported into the document."); | ||||
| } | ||||
|  | ||||
| export async function importMarkdownInline() { | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import server from "../../services/server.js"; | ||||
| import infoService from "../../services/info.js"; | ||||
| import toastService from "../../services/toast.js"; | ||||
|  | ||||
| export default class AdvancedOptions { | ||||
|     constructor() { | ||||
| @@ -13,26 +13,26 @@ export default class AdvancedOptions { | ||||
|         this.$forceFullSyncButton.click(async () => { | ||||
|             await server.post('sync/force-full-sync'); | ||||
|  | ||||
|             infoService.showMessage("Full sync triggered"); | ||||
|             toastService.showMessage("Full sync triggered"); | ||||
|         }); | ||||
|  | ||||
|         this.$fillSyncRowsButton.click(async () => { | ||||
|             await server.post('sync/fill-sync-rows'); | ||||
|  | ||||
|             infoService.showMessage("Sync rows filled successfully"); | ||||
|             toastService.showMessage("Sync rows filled successfully"); | ||||
|         }); | ||||
|  | ||||
|         this.$anonymizeButton.click(async () => { | ||||
|             await server.post('anonymization/anonymize'); | ||||
|  | ||||
|             infoService.showMessage("Created anonymized database"); | ||||
|             toastService.showMessage("Created anonymized database"); | ||||
|         }); | ||||
|  | ||||
|         this.$cleanupSoftDeletedButton.click(async () => { | ||||
|             if (confirm("Do you really want to clean up soft-deleted items?")) { | ||||
|                 await server.post('cleanup/cleanup-soft-deleted-items'); | ||||
|  | ||||
|                 infoService.showMessage("Soft deleted items have been cleaned up"); | ||||
|                 toastService.showMessage("Soft deleted items have been cleaned up"); | ||||
|             } | ||||
|         }); | ||||
|  | ||||
| @@ -40,14 +40,14 @@ export default class AdvancedOptions { | ||||
|             if (confirm("Do you really want to clean up unused images?")) { | ||||
|                 await server.post('cleanup/cleanup-unused-images'); | ||||
|  | ||||
|                 infoService.showMessage("Unused images have been cleaned up"); | ||||
|                 toastService.showMessage("Unused images have been cleaned up"); | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|         this.$vacuumDatabaseButton.click(async () => { | ||||
|             await server.post('cleanup/vacuum-database'); | ||||
|  | ||||
|             infoService.showMessage("Database has been vacuumed"); | ||||
|             toastService.showMessage("Database has been vacuumed"); | ||||
|         }); | ||||
|     } | ||||
| } | ||||
| @@ -1,6 +1,6 @@ | ||||
| import server from "../../services/server.js"; | ||||
| import protectedSessionHolder from "../../services/protected_session_holder.js"; | ||||
| import infoService from "../../services/info.js"; | ||||
| import toastService from "../../services/toast.js"; | ||||
|  | ||||
| export default class ChangePasswordOptions { | ||||
|     constructor() { | ||||
| @@ -39,7 +39,7 @@ export default class ChangePasswordOptions { | ||||
|                 protectedSessionHolder.resetProtectedSession(); | ||||
|             } | ||||
|             else { | ||||
|                 infoService.showError(result.message); | ||||
|                 toastService.showError(result.message); | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import optionsService from "../../services/options.js"; | ||||
| import server from "../../services/server.js"; | ||||
| import infoService from "../../services/info.js"; | ||||
| import toastService from "../../services/toast.js"; | ||||
|  | ||||
| export default class ProtectedSessionOptions { | ||||
|     constructor() { | ||||
| @@ -12,14 +12,14 @@ export default class ProtectedSessionOptions { | ||||
|  | ||||
|         this.$spellCheckEnabled.change(() => { | ||||
|             const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" }; | ||||
|             server.put('options', opts).then(() => infoService.showMessage("Options change have been saved.")); | ||||
|             server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); | ||||
|  | ||||
|             return false; | ||||
|         }); | ||||
|  | ||||
|         this.$spellCheckLanguageCode.change(() => { | ||||
|             const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() }; | ||||
|             server.put('options', opts).then(() => infoService.showMessage("Options change have been saved.")); | ||||
|             server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); | ||||
|  | ||||
|             return false; | ||||
|         }); | ||||
| @@ -30,7 +30,7 @@ export default class ProtectedSessionOptions { | ||||
|             server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => { | ||||
|                 optionsService.reloadOptions(); | ||||
|  | ||||
|                 infoService.showMessage("Options change have been saved."); | ||||
|                 toastService.showMessage("Options change have been saved."); | ||||
|             }); | ||||
|  | ||||
|             return false; | ||||
| @@ -38,7 +38,7 @@ export default class ProtectedSessionOptions { | ||||
|  | ||||
|         this.$noteRevisionsTimeInterval.change(() => { | ||||
|             const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() }; | ||||
|             server.put('options', opts).then(() => infoService.showMessage("Options change have been saved.")); | ||||
|             server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); | ||||
|  | ||||
|             return false; | ||||
|         }); | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import server from "../../services/server.js"; | ||||
| import infoService from "../../services/info.js"; | ||||
| import toastService from "../../services/toast.js"; | ||||
|  | ||||
| export default class SyncOptions { | ||||
|     constructor() { | ||||
| @@ -15,10 +15,10 @@ export default class SyncOptions { | ||||
|             const result = await server.post('sync/test'); | ||||
|  | ||||
|             if (result.success) { | ||||
|                 infoService.showMessage(result.message); | ||||
|                 toastService.showMessage(result.message); | ||||
|             } | ||||
|             else { | ||||
|                 infoService.showError("Sync server handshake failed, error: " + result.message); | ||||
|                 toastService.showError("Sync server handshake failed, error: " + result.message); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
| @@ -36,7 +36,7 @@ export default class SyncOptions { | ||||
|             'syncProxy': this.$syncProxy.val() | ||||
|         }; | ||||
|  | ||||
|         server.put('options', opts).then(()  => infoService.showMessage("Options change have been saved.")); | ||||
|         server.put('options', opts).then(()  => toastService.showMessage("Options change have been saved.")); | ||||
|  | ||||
|         return false; | ||||
|     } | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import libraryLoader from '../services/library_loader.js'; | ||||
| import server from '../services/server.js'; | ||||
| import infoService from "../services/info.js"; | ||||
| import toastService from "../services/toast.js"; | ||||
| import utils from "../services/utils.js"; | ||||
|  | ||||
| const $dialog = $("#sql-console-dialog"); | ||||
| @@ -63,11 +63,11 @@ async function execute() { | ||||
|     }); | ||||
|  | ||||
|     if (!result.success) { | ||||
|         infoService.showError(result.error); | ||||
|         toastService.showError(result.error); | ||||
|         return; | ||||
|     } | ||||
|     else { | ||||
|         infoService.showMessage("Query was executed successfully."); | ||||
|         toastService.showMessage("Query was executed successfully."); | ||||
|     } | ||||
|  | ||||
|     const rows = result.rows; | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import treeService from './tree.js'; | ||||
| import utils from './utils.js'; | ||||
| import server from './server.js'; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import treeCache from "./tree_cache.js"; | ||||
| import treeUtils from "./tree_utils.js"; | ||||
| import hoistedNoteService from "./hoisted_note.js"; | ||||
| @@ -272,15 +272,15 @@ ws.subscribeToMessages(async message => { | ||||
|     } | ||||
|  | ||||
|     if (message.type === 'task-error') { | ||||
|         infoService.closePersistent(message.taskId); | ||||
|         infoService.showError(message.message); | ||||
|         toastService.closePersistent(message.taskId); | ||||
|         toastService.showError(message.message); | ||||
|     } else if (message.type === 'task-progress-count') { | ||||
|         infoService.showPersistent(makeToast(message.taskId, "Delete notes in progress: " + message.progressCount)); | ||||
|         toastService.showPersistent(makeToast(message.taskId, "Delete notes in progress: " + message.progressCount)); | ||||
|     } else if (message.type === 'task-succeeded') { | ||||
|         const toast = makeToast(message.taskId, "Delete finished successfully."); | ||||
|         toast.closeAfter = 5000; | ||||
|  | ||||
|         infoService.showPersistent(toast); | ||||
|         toastService.showPersistent(toast); | ||||
|     } | ||||
| }); | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import ScriptContext from "./script_context.js"; | ||||
| import server from "./server.js"; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
|  | ||||
| async function getAndExecuteBundle(noteId, originEntity = null) { | ||||
|     const bundle = await server.get('script/bundle/' + noteId); | ||||
| @@ -17,7 +17,7 @@ async function executeBundle(bundle, originEntity, tabContext, $container) { | ||||
|         }.call(apiContext)); | ||||
|     } | ||||
|     catch (e) { | ||||
|         infoService.showAndLogError(`Execution of ${bundle.noteId} failed with error: ${e.message}`); | ||||
|         toastService.showAndLogError(`Execution of ${bundle.noteId} failed with error: ${e.message}`); | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import treeUtils from "./tree_utils.js"; | ||||
| import treeChangesService from "./branches.js"; | ||||
| import cloningService from "./cloning.js"; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
|  | ||||
| let clipboardIds = []; | ||||
| let clipboardMode = null; | ||||
| @@ -26,7 +26,7 @@ async function pasteAfter(node) { | ||||
|         // just do nothing | ||||
|     } | ||||
|     else { | ||||
|         infoService.throwError("Unrecognized clipboard mode=" + clipboardMode); | ||||
|         toastService.throwError("Unrecognized clipboard mode=" + clipboardMode); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -54,7 +54,7 @@ async function pasteInto(node) { | ||||
|         // just do nothing | ||||
|     } | ||||
|     else { | ||||
|         infoService.throwError("Unrecognized clipboard mode=" + mode); | ||||
|         toastService.throwError("Unrecognized clipboard mode=" + mode); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -62,14 +62,14 @@ function copy(nodes) { | ||||
|     clipboardIds = nodes.map(node => node.data.noteId); | ||||
|     clipboardMode = 'copy'; | ||||
|  | ||||
|     infoService.showMessage("Note(s) have been copied into clipboard."); | ||||
|     toastService.showMessage("Note(s) have been copied into clipboard."); | ||||
| } | ||||
|  | ||||
| function cut(nodes) { | ||||
|     clipboardIds = nodes.map(node => node.key); | ||||
|     clipboardMode = 'cut'; | ||||
|  | ||||
|     infoService.showMessage("Note(s) have been cut into clipboard."); | ||||
|     toastService.showMessage("Note(s) have been cut into clipboard."); | ||||
| } | ||||
|  | ||||
| function isEmpty() { | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import treeService from './tree.js'; | ||||
| import server from './server.js'; | ||||
| import utils from './utils.js'; | ||||
| import infoService from './info.js'; | ||||
| import toastService from './toast.js'; | ||||
| import linkService from './link.js'; | ||||
| import treeCache from './tree_cache.js'; | ||||
| import noteDetailService from './note_detail.js'; | ||||
| @@ -246,7 +246,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte | ||||
|      * @method | ||||
|      * @param {string} message | ||||
|      */ | ||||
|     this.showMessage = infoService.showMessage; | ||||
|     this.showMessage = toastService.showMessage; | ||||
|  | ||||
|     /** | ||||
|      * Show error message to the user. | ||||
| @@ -254,7 +254,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte | ||||
|      * @method | ||||
|      * @param {string} message | ||||
|      */ | ||||
|     this.showError = infoService.showError; | ||||
|     this.showError = toastService.showError; | ||||
|  | ||||
|     /** | ||||
|      * Refresh tree | ||||
|   | ||||
| @@ -1,4 +1,4 @@ | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import treeService from "./tree.js"; | ||||
| import server from "./server.js"; | ||||
| import ws from "./ws.js"; | ||||
| @@ -53,15 +53,15 @@ ws.subscribeToMessages(async message => { | ||||
|     } | ||||
|  | ||||
|     if (message.type === 'task-error') { | ||||
|         infoService.closePersistent(message.taskId); | ||||
|         infoService.showError(message.message); | ||||
|         toastService.closePersistent(message.taskId); | ||||
|         toastService.showError(message.message); | ||||
|     } else if (message.type === 'task-progress-count') { | ||||
|         infoService.showPersistent(makeToast(message.taskId, "Import in progress: " + message.progressCount)); | ||||
|         toastService.showPersistent(makeToast(message.taskId, "Import in progress: " + message.progressCount)); | ||||
|     } else if (message.type === 'task-succeeded') { | ||||
|         const toast = makeToast(message.taskId, "Import finished successfully."); | ||||
|         toast.closeAfter = 5000; | ||||
|  | ||||
|         infoService.showPersistent(toast); | ||||
|         toastService.showPersistent(toast); | ||||
|  | ||||
|         await treeService.reloadNote(message.parentNoteId); | ||||
|  | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| import libraryLoader from "./library_loader.js"; | ||||
| import bundleService from "./bundle.js"; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import server from "./server.js"; | ||||
| import noteDetailService from "./note_detail.js"; | ||||
| import utils from "./utils.js"; | ||||
| @@ -102,7 +102,7 @@ class NoteDetailCode { | ||||
|             await server.post('script/run/' + this.ctx.note.noteId); | ||||
|         } | ||||
|  | ||||
|         infoService.showMessage("Note executed"); | ||||
|         toastService.showMessage("Note executed"); | ||||
|     } | ||||
|  | ||||
|     onNoteChange(func) { | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import utils from "./utils.js"; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import server from "./server.js"; | ||||
|  | ||||
| class NoteDetailImage { | ||||
| @@ -28,10 +28,10 @@ class NoteDetailImage { | ||||
|                 const success = document.execCommand('copy'); | ||||
|  | ||||
|                 if (success) { | ||||
|                     infoService.showMessage("Image copied to the clipboard"); | ||||
|                     toastService.showMessage("Image copied to the clipboard"); | ||||
|                 } | ||||
|                 else { | ||||
|                     infoService.showAndLogError("Could not copy the image to clipboard."); | ||||
|                     toastService.showAndLogError("Could not copy the image to clipboard."); | ||||
|                 } | ||||
|             } | ||||
|             finally { | ||||
|   | ||||
| @@ -4,7 +4,7 @@ import linkService from "./link.js"; | ||||
| import libraryLoader from "./library_loader.js"; | ||||
| import treeService from "./tree.js"; | ||||
| import contextMenuWidget from "./context_menu.js"; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import attributeAutocompleteService from "./attribute_autocomplete.js"; | ||||
|  | ||||
| const uniDirectionalOverlays = [ | ||||
| @@ -134,7 +134,7 @@ class NoteDetailRelationMap { | ||||
|                 target: 'into' | ||||
|             }); | ||||
|  | ||||
|             infoService.showMessage("Click on canvas to place new note"); | ||||
|             toastService.showMessage("Click on canvas to place new note"); | ||||
|  | ||||
|             // reloading tree so that the new note appears there | ||||
|             // no need to wait for it to finish | ||||
| @@ -576,7 +576,7 @@ class NoteDetailRelationMap { | ||||
|             const exists = this.mapData.notes.some(n => n.noteId === note.noteId); | ||||
|  | ||||
|             if (exists) { | ||||
|                 infoService.showError(`Note "${note.title}" is already in the diagram.`); | ||||
|                 toastService.showError(`Note "${note.title}" is already in the diagram.`); | ||||
|  | ||||
|                 continue; | ||||
|             } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ import noteDetailService from './note_detail.js'; | ||||
| import utils from './utils.js'; | ||||
| import server from './server.js'; | ||||
| import protectedSessionHolder from './protected_session_holder.js'; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import ws from "./ws.js"; | ||||
|  | ||||
| const $enterProtectedSessionButton = $("#enter-protected-session-button"); | ||||
| @@ -38,7 +38,7 @@ async function setupProtectedSession(password) { | ||||
|     const response = await enterProtectedSessionOnServer(password); | ||||
|  | ||||
|     if (!response.success) { | ||||
|         infoService.showError("Wrong password.", 3000); | ||||
|         toastService.showError("Wrong password.", 3000); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
| @@ -60,7 +60,7 @@ async function setupProtectedSession(password) { | ||||
|     $enterProtectedSessionButton.hide(); | ||||
|     $leaveProtectedSessionButton.show(); | ||||
|  | ||||
|     infoService.showMessage("Protected session has been started."); | ||||
|     toastService.showMessage("Protected session has been started."); | ||||
| } | ||||
|  | ||||
| async function enterProtectedSessionOnServer(password) { | ||||
| @@ -90,7 +90,7 @@ async function unprotectNoteAndSendToServer() { | ||||
|     const activeNote = noteDetailService.getActiveNote(); | ||||
|  | ||||
|     if (!activeNote.isProtected) { | ||||
|         infoService.showAndLogError(`Note ${activeNote.noteId} is not protected`); | ||||
|         toastService.showAndLogError(`Note ${activeNote.noteId} is not protected`); | ||||
|  | ||||
|         return; | ||||
|     } | ||||
| @@ -139,15 +139,15 @@ ws.subscribeToMessages(async message => { | ||||
|     const protectingLabel = message.data.protect ? "Protecting" : "Unprotecting"; | ||||
|  | ||||
|     if (message.type === 'task-error') { | ||||
|         infoService.closePersistent(message.taskId); | ||||
|         infoService.showError(message.message); | ||||
|         toastService.closePersistent(message.taskId); | ||||
|         toastService.showError(message.message); | ||||
|     } else if (message.type === 'task-progress-count') { | ||||
|         infoService.showPersistent(makeToast(message, protectingLabel,protectingLabel + " in progress: " + message.progressCount)); | ||||
|         toastService.showPersistent(makeToast(message, protectingLabel,protectingLabel + " in progress: " + message.progressCount)); | ||||
|     } else if (message.type === 'task-succeeded') { | ||||
|         const toast = makeToast(message, protectingLabel, protectingLabel + " finished successfully."); | ||||
|         toast.closeAfter = 3000; | ||||
|  | ||||
|         infoService.showPersistent(toast); | ||||
|         toastService.showPersistent(toast); | ||||
|     } | ||||
| }); | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import treeService from './tree.js'; | ||||
| import treeCache from "./tree_cache.js"; | ||||
| import server from './server.js'; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
|  | ||||
| const $searchInput = $("input[name='search-text']"); | ||||
| const $resetSearchButton = $("#reset-search-button"); | ||||
| @@ -73,7 +73,7 @@ async function doSearch(searchText) { | ||||
|     } | ||||
|  | ||||
|     if (searchText.trim().length === 0) { | ||||
|         infoService.showMessage("Please enter search criteria first."); | ||||
|         toastService.showMessage("Please enter search criteria first."); | ||||
|  | ||||
|         $searchInput.focus(); | ||||
|  | ||||
| @@ -85,7 +85,7 @@ async function doSearch(searchText) { | ||||
|     const response = await server.get('search/' + encodeURIComponent(searchText)); | ||||
|  | ||||
|     if (!response.success) { | ||||
|         infoService.showError("Search failed.", 3000); | ||||
|         toastService.showError("Search failed.", 3000); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
| @@ -105,7 +105,7 @@ async function doSearch(searchText) { | ||||
|  | ||||
|     // have at least some feedback which is good especially in situations | ||||
|     // when the result list does not change with a query | ||||
|     infoService.showMessage("Search finished successfully."); | ||||
|     toastService.showMessage("Search finished successfully."); | ||||
| } | ||||
|  | ||||
| async function saveSearch() { | ||||
| @@ -139,7 +139,7 @@ async function refreshSearch() { | ||||
|     activeNode.load(true); | ||||
|     activeNode.setExpanded(true); | ||||
|  | ||||
|     infoService.showMessage("Saved search note refreshed."); | ||||
|     toastService.showMessage("Saved search note refreshed."); | ||||
| } | ||||
|  | ||||
| function init() { | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import utils from './utils.js'; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
|  | ||||
| const REQUEST_LOGGING_ENABLED = false; | ||||
|  | ||||
| @@ -87,8 +87,8 @@ async function ajax(url, method, data) { | ||||
|  | ||||
|     return await $.ajax(options).catch(e => { | ||||
|         const message = "Error when calling " + method + " " + url + ": " + e.status + " - " + e.statusText; | ||||
|         infoService.showError(message); | ||||
|         infoService.throwError(message); | ||||
|         toastService.showError(message); | ||||
|         toastService.throwError(message); | ||||
|     }); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -1,18 +1,18 @@ | ||||
| import server from './server.js'; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
|  | ||||
| async function syncNow() { | ||||
|     const result = await server.post('sync/now'); | ||||
|  | ||||
|     if (result.success) { | ||||
|         infoService.showMessage("Sync finished successfully."); | ||||
|         toastService.showMessage("Sync finished successfully."); | ||||
|     } | ||||
|     else { | ||||
|         if (result.message.length > 50) { | ||||
|             result.message = result.message.substr(0, 50); | ||||
|         } | ||||
|  | ||||
|         infoService.showError("Sync failed: " + result.message); | ||||
|         toastService.showError("Sync failed: " + result.message); | ||||
|     } | ||||
| } | ||||
|  | ||||
| @@ -21,7 +21,7 @@ $("#sync-now-button").click(syncNow); | ||||
| async function forceNoteSync(noteId) { | ||||
|     await server.post('sync/force-note-sync/' + noteId); | ||||
|  | ||||
|     infoService.showMessage("Note added to sync queue."); | ||||
|     toastService.showMessage("Note added to sync queue."); | ||||
| } | ||||
|  | ||||
| export default { | ||||
|   | ||||
| @@ -7,7 +7,7 @@ import treeUtils from './tree_utils.js'; | ||||
| import utils from './utils.js'; | ||||
| import server from './server.js'; | ||||
| import treeCache from './tree_cache.js'; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import treeBuilder from "./tree_builder.js"; | ||||
| import treeKeyBindings from "./tree_keybindings.js"; | ||||
| import Branch from '../entities/branch.js'; | ||||
| @@ -295,7 +295,7 @@ async function getSomeNotePath(note) { | ||||
|         const parents = await cur.getParentNotes(); | ||||
|  | ||||
|         if (!parents.length) { | ||||
|             infoService.throwError(`Can't find parents for note ${cur.noteId}`); | ||||
|             toastService.throwError(`Can't find parents for note ${cur.noteId}`); | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| @@ -695,7 +695,7 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) { | ||||
|         node.renderTitle(); | ||||
|     } | ||||
|     else { | ||||
|         infoService.throwError("Unrecognized target: " + target); | ||||
|         toastService.throwError("Unrecognized target: " + target); | ||||
|     } | ||||
|  | ||||
|     clearSelectedNodes(); // to unmark previously active node | ||||
| @@ -853,7 +853,7 @@ async function duplicateNote(noteId, parentNoteId) { | ||||
|     await activateNote(note.noteId); | ||||
|  | ||||
|     const origNote = await treeCache.getNote(noteId); | ||||
|     infoService.showMessage(`Note "${origNote.title}" has been duplicated`); | ||||
|     toastService.showMessage(`Note "${origNote.title}" has been duplicated`); | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import utils from "./utils.js"; | ||||
| import Branch from "../entities/branch.js"; | ||||
| import NoteShort from "../entities/note_short.js"; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import ws from "./ws.js"; | ||||
| import server from "./server.js"; | ||||
|  | ||||
| @@ -197,7 +197,7 @@ class TreeCache { | ||||
|         const branchId = this.childParentToBranch[key]; | ||||
|  | ||||
|         if (!branchId) { | ||||
|             infoService.throwError("Cannot find branch for child-parent=" + key); | ||||
|             toastService.throwError("Cannot find branch for child-parent=" + key); | ||||
|         } | ||||
|  | ||||
|         return branchId; | ||||
|   | ||||
| @@ -1,5 +1,5 @@ | ||||
| import utils from './utils.js'; | ||||
| import infoService from "./info.js"; | ||||
| import toastService from "./toast.js"; | ||||
| import treeService from "./tree.js"; | ||||
|  | ||||
| const $outstandingSyncsCount = $("#outstanding-syncs-count"); | ||||
| @@ -65,10 +65,10 @@ function handleMessage(event) { | ||||
|         $outstandingSyncsCount.html(message.outstandingSyncs); | ||||
|     } | ||||
|     else if (message.type === 'sync-hash-check-failed') { | ||||
|         infoService.showError("Sync check failed!", 60000); | ||||
|         toastService.showError("Sync check failed!", 60000); | ||||
|     } | ||||
|     else if (message.type === 'consistency-checks-failed') { | ||||
|         infoService.showError("Consistency checks failed! See logs for details.", 50 * 60000); | ||||
|         toastService.showError("Consistency checks failed! See logs for details.", 50 * 60000); | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user