rename info service to toast service

This commit is contained in:
zadam 2019-10-20 10:00:18 +02:00
parent 1903c59163
commit 78f5b7b288
26 changed files with 92 additions and 92 deletions

View File

@ -29,7 +29,7 @@
<pre class="prettyprint source linenums"><code>import treeService from './tree.js'; <pre class="prettyprint source linenums"><code>import treeService from './tree.js';
import server from './server.js'; import server from './server.js';
import utils from './utils.js'; import utils from './utils.js';
import infoService from './info.js'; import toastService from './toast.js';
import linkService from './link.js'; import linkService from './link.js';
import treeCache from './tree_cache.js'; import treeCache from './tree_cache.js';
import noteDetailService from './note_detail.js'; import noteDetailService from './note_detail.js';
@ -272,7 +272,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
* @method * @method
* @param {string} message * @param {string} message
*/ */
this.showMessage = infoService.showMessage; this.showMessage = toastService.showMessage;
/** /**
* Show error message to the user. * Show error message to the user.
@ -280,7 +280,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
* @method * @method
* @param {string} message * @param {string} message
*/ */
this.showError = infoService.showError; this.showError = toastService.showError;
/** /**
* Refresh tree * Refresh tree

View File

@ -1,6 +1,6 @@
import noteDetailService from '../services/note_detail.js'; import noteDetailService from '../services/note_detail.js';
import server from '../services/server.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 treeUtils from "../services/tree_utils.js";
import attributeAutocompleteService from "../services/attribute_autocomplete.js"; import attributeAutocompleteService from "../services/attribute_autocomplete.js";
import utils from "../services/utils.js"; import utils from "../services/utils.js";
@ -168,7 +168,7 @@ function AttributesModel() {
await showAttributes(attributes); await showAttributes(attributes);
infoService.showMessage("Attributes have been saved."); toastService.showMessage("Attributes have been saved.");
const ctx = noteDetailService.getActiveTabContext(); const ctx = noteDetailService.getActiveTabContext();

View File

@ -2,7 +2,7 @@ import treeService from '../services/tree.js';
import server from '../services/server.js'; import server from '../services/server.js';
import treeCache from "../services/tree_cache.js"; import treeCache from "../services/tree_cache.js";
import treeUtils from "../services/tree_utils.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"; import utils from "../services/utils.js";
const $dialog = $("#branch-prefix-dialog"); const $dialog = $("#branch-prefix-dialog");
@ -38,7 +38,7 @@ async function savePrefix() {
$dialog.modal('hide'); $dialog.modal('hide');
infoService.showMessage("Branch prefix has been saved."); toastService.showMessage("Branch prefix has been saved.");
} }
$form.submit(() => { $form.submit(() => {

View File

@ -1,7 +1,7 @@
import treeUtils from "../services/tree_utils.js"; import treeUtils from "../services/tree_utils.js";
import utils from "../services/utils.js"; import utils from "../services/utils.js";
import ws from "../services/ws.js"; import ws from "../services/ws.js";
import infoService from "../services/info.js"; import toastService from "../services/toast.js";
const $dialog = $("#export-dialog"); const $dialog = $("#export-dialog");
const $form = $("#export-form"); const $form = $("#export-form");
@ -122,16 +122,16 @@ ws.subscribeToMessages(async message => {
} }
if (message.type === 'task-error') { if (message.type === 'task-error') {
infoService.closePersistent(message.taskId); toastService.closePersistent(message.taskId);
infoService.showError(message.message); toastService.showError(message.message);
} }
else if (message.type === 'task-progress-count') { 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') { else if (message.type === 'task-succeeded') {
const toast = makeToast(message.taskId, "Import finished successfully."); const toast = makeToast(message.taskId, "Import finished successfully.");
toast.closeAfter = 5000; toast.closeAfter = 5000;
infoService.showPersistent(toast); toastService.showPersistent(toast);
} }
}); });

View File

@ -1,5 +1,5 @@
import libraryLoader from "../services/library_loader.js"; 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 utils from "../services/utils.js";
import noteDetailService from "../services/note_detail.js"; import noteDetailService from "../services/note_detail.js";
@ -22,7 +22,7 @@ async function convertMarkdownToHtml(text) {
textEditor.model.insertContent(modelFragment, textEditor.model.document.selection); 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() { export async function importMarkdownInline() {

View File

@ -1,5 +1,5 @@
import server from "../../services/server.js"; import server from "../../services/server.js";
import infoService from "../../services/info.js"; import toastService from "../../services/toast.js";
export default class AdvancedOptions { export default class AdvancedOptions {
constructor() { constructor() {
@ -13,26 +13,26 @@ export default class AdvancedOptions {
this.$forceFullSyncButton.click(async () => { this.$forceFullSyncButton.click(async () => {
await server.post('sync/force-full-sync'); await server.post('sync/force-full-sync');
infoService.showMessage("Full sync triggered"); toastService.showMessage("Full sync triggered");
}); });
this.$fillSyncRowsButton.click(async () => { this.$fillSyncRowsButton.click(async () => {
await server.post('sync/fill-sync-rows'); await server.post('sync/fill-sync-rows');
infoService.showMessage("Sync rows filled successfully"); toastService.showMessage("Sync rows filled successfully");
}); });
this.$anonymizeButton.click(async () => { this.$anonymizeButton.click(async () => {
await server.post('anonymization/anonymize'); await server.post('anonymization/anonymize');
infoService.showMessage("Created anonymized database"); toastService.showMessage("Created anonymized database");
}); });
this.$cleanupSoftDeletedButton.click(async () => { this.$cleanupSoftDeletedButton.click(async () => {
if (confirm("Do you really want to clean up soft-deleted items?")) { if (confirm("Do you really want to clean up soft-deleted items?")) {
await server.post('cleanup/cleanup-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?")) { if (confirm("Do you really want to clean up unused images?")) {
await server.post('cleanup/cleanup-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 () => { this.$vacuumDatabaseButton.click(async () => {
await server.post('cleanup/vacuum-database'); await server.post('cleanup/vacuum-database');
infoService.showMessage("Database has been vacuumed"); toastService.showMessage("Database has been vacuumed");
}); });
} }
} }

View File

@ -1,6 +1,6 @@
import server from "../../services/server.js"; import server from "../../services/server.js";
import protectedSessionHolder from "../../services/protected_session_holder.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 { export default class ChangePasswordOptions {
constructor() { constructor() {
@ -39,7 +39,7 @@ export default class ChangePasswordOptions {
protectedSessionHolder.resetProtectedSession(); protectedSessionHolder.resetProtectedSession();
} }
else { else {
infoService.showError(result.message); toastService.showError(result.message);
} }
}); });

View File

@ -1,6 +1,6 @@
import optionsService from "../../services/options.js"; import optionsService from "../../services/options.js";
import server from "../../services/server.js"; import server from "../../services/server.js";
import infoService from "../../services/info.js"; import toastService from "../../services/toast.js";
export default class ProtectedSessionOptions { export default class ProtectedSessionOptions {
constructor() { constructor() {
@ -12,14 +12,14 @@ export default class ProtectedSessionOptions {
this.$spellCheckEnabled.change(() => { this.$spellCheckEnabled.change(() => {
const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" }; 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; return false;
}); });
this.$spellCheckLanguageCode.change(() => { this.$spellCheckLanguageCode.change(() => {
const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() }; 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; return false;
}); });
@ -30,7 +30,7 @@ export default class ProtectedSessionOptions {
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => { server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
optionsService.reloadOptions(); optionsService.reloadOptions();
infoService.showMessage("Options change have been saved."); toastService.showMessage("Options change have been saved.");
}); });
return false; return false;
@ -38,7 +38,7 @@ export default class ProtectedSessionOptions {
this.$noteRevisionsTimeInterval.change(() => { this.$noteRevisionsTimeInterval.change(() => {
const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() }; 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; return false;
}); });

View File

@ -1,5 +1,5 @@
import server from "../../services/server.js"; import server from "../../services/server.js";
import infoService from "../../services/info.js"; import toastService from "../../services/toast.js";
export default class SyncOptions { export default class SyncOptions {
constructor() { constructor() {
@ -15,10 +15,10 @@ export default class SyncOptions {
const result = await server.post('sync/test'); const result = await server.post('sync/test');
if (result.success) { if (result.success) {
infoService.showMessage(result.message); toastService.showMessage(result.message);
} }
else { 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() '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; return false;
} }

View File

@ -1,6 +1,6 @@
import libraryLoader from '../services/library_loader.js'; import libraryLoader from '../services/library_loader.js';
import server from '../services/server.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"; import utils from "../services/utils.js";
const $dialog = $("#sql-console-dialog"); const $dialog = $("#sql-console-dialog");
@ -63,11 +63,11 @@ async function execute() {
}); });
if (!result.success) { if (!result.success) {
infoService.showError(result.error); toastService.showError(result.error);
return; return;
} }
else { else {
infoService.showMessage("Query was executed successfully."); toastService.showMessage("Query was executed successfully.");
} }
const rows = result.rows; const rows = result.rows;

View File

@ -1,7 +1,7 @@
import treeService from './tree.js'; import treeService from './tree.js';
import utils from './utils.js'; import utils from './utils.js';
import server from './server.js'; import server from './server.js';
import infoService from "./info.js"; import toastService from "./toast.js";
import treeCache from "./tree_cache.js"; import treeCache from "./tree_cache.js";
import treeUtils from "./tree_utils.js"; import treeUtils from "./tree_utils.js";
import hoistedNoteService from "./hoisted_note.js"; import hoistedNoteService from "./hoisted_note.js";
@ -272,15 +272,15 @@ ws.subscribeToMessages(async message => {
} }
if (message.type === 'task-error') { if (message.type === 'task-error') {
infoService.closePersistent(message.taskId); toastService.closePersistent(message.taskId);
infoService.showError(message.message); toastService.showError(message.message);
} else if (message.type === 'task-progress-count') { } 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') { } else if (message.type === 'task-succeeded') {
const toast = makeToast(message.taskId, "Delete finished successfully."); const toast = makeToast(message.taskId, "Delete finished successfully.");
toast.closeAfter = 5000; toast.closeAfter = 5000;
infoService.showPersistent(toast); toastService.showPersistent(toast);
} }
}); });

View File

@ -1,6 +1,6 @@
import ScriptContext from "./script_context.js"; import ScriptContext from "./script_context.js";
import server from "./server.js"; import server from "./server.js";
import infoService from "./info.js"; import toastService from "./toast.js";
async function getAndExecuteBundle(noteId, originEntity = null) { async function getAndExecuteBundle(noteId, originEntity = null) {
const bundle = await server.get('script/bundle/' + noteId); const bundle = await server.get('script/bundle/' + noteId);
@ -17,7 +17,7 @@ async function executeBundle(bundle, originEntity, tabContext, $container) {
}.call(apiContext)); }.call(apiContext));
} }
catch (e) { catch (e) {
infoService.showAndLogError(`Execution of ${bundle.noteId} failed with error: ${e.message}`); toastService.showAndLogError(`Execution of ${bundle.noteId} failed with error: ${e.message}`);
} }
} }

View File

@ -1,7 +1,7 @@
import treeUtils from "./tree_utils.js"; import treeUtils from "./tree_utils.js";
import treeChangesService from "./branches.js"; import treeChangesService from "./branches.js";
import cloningService from "./cloning.js"; import cloningService from "./cloning.js";
import infoService from "./info.js"; import toastService from "./toast.js";
let clipboardIds = []; let clipboardIds = [];
let clipboardMode = null; let clipboardMode = null;
@ -26,7 +26,7 @@ async function pasteAfter(node) {
// just do nothing // just do nothing
} }
else { else {
infoService.throwError("Unrecognized clipboard mode=" + clipboardMode); toastService.throwError("Unrecognized clipboard mode=" + clipboardMode);
} }
} }
@ -54,7 +54,7 @@ async function pasteInto(node) {
// just do nothing // just do nothing
} }
else { 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); clipboardIds = nodes.map(node => node.data.noteId);
clipboardMode = 'copy'; clipboardMode = 'copy';
infoService.showMessage("Note(s) have been copied into clipboard."); toastService.showMessage("Note(s) have been copied into clipboard.");
} }
function cut(nodes) { function cut(nodes) {
clipboardIds = nodes.map(node => node.key); clipboardIds = nodes.map(node => node.key);
clipboardMode = 'cut'; clipboardMode = 'cut';
infoService.showMessage("Note(s) have been cut into clipboard."); toastService.showMessage("Note(s) have been cut into clipboard.");
} }
function isEmpty() { function isEmpty() {

View File

@ -1,7 +1,7 @@
import treeService from './tree.js'; import treeService from './tree.js';
import server from './server.js'; import server from './server.js';
import utils from './utils.js'; import utils from './utils.js';
import infoService from './info.js'; import toastService from './toast.js';
import linkService from './link.js'; import linkService from './link.js';
import treeCache from './tree_cache.js'; import treeCache from './tree_cache.js';
import noteDetailService from './note_detail.js'; import noteDetailService from './note_detail.js';
@ -246,7 +246,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
* @method * @method
* @param {string} message * @param {string} message
*/ */
this.showMessage = infoService.showMessage; this.showMessage = toastService.showMessage;
/** /**
* Show error message to the user. * Show error message to the user.
@ -254,7 +254,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, tabConte
* @method * @method
* @param {string} message * @param {string} message
*/ */
this.showError = infoService.showError; this.showError = toastService.showError;
/** /**
* Refresh tree * Refresh tree

View File

@ -1,4 +1,4 @@
import infoService from "./info.js"; import toastService from "./toast.js";
import treeService from "./tree.js"; import treeService from "./tree.js";
import server from "./server.js"; import server from "./server.js";
import ws from "./ws.js"; import ws from "./ws.js";
@ -53,15 +53,15 @@ ws.subscribeToMessages(async message => {
} }
if (message.type === 'task-error') { if (message.type === 'task-error') {
infoService.closePersistent(message.taskId); toastService.closePersistent(message.taskId);
infoService.showError(message.message); toastService.showError(message.message);
} else if (message.type === 'task-progress-count') { } 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') { } else if (message.type === 'task-succeeded') {
const toast = makeToast(message.taskId, "Import finished successfully."); const toast = makeToast(message.taskId, "Import finished successfully.");
toast.closeAfter = 5000; toast.closeAfter = 5000;
infoService.showPersistent(toast); toastService.showPersistent(toast);
await treeService.reloadNote(message.parentNoteId); await treeService.reloadNote(message.parentNoteId);

View File

@ -1,6 +1,6 @@
import libraryLoader from "./library_loader.js"; import libraryLoader from "./library_loader.js";
import bundleService from "./bundle.js"; import bundleService from "./bundle.js";
import infoService from "./info.js"; import toastService from "./toast.js";
import server from "./server.js"; import server from "./server.js";
import noteDetailService from "./note_detail.js"; import noteDetailService from "./note_detail.js";
import utils from "./utils.js"; import utils from "./utils.js";
@ -102,7 +102,7 @@ class NoteDetailCode {
await server.post('script/run/' + this.ctx.note.noteId); await server.post('script/run/' + this.ctx.note.noteId);
} }
infoService.showMessage("Note executed"); toastService.showMessage("Note executed");
} }
onNoteChange(func) { onNoteChange(func) {

View File

@ -1,5 +1,5 @@
import utils from "./utils.js"; import utils from "./utils.js";
import infoService from "./info.js"; import toastService from "./toast.js";
import server from "./server.js"; import server from "./server.js";
class NoteDetailImage { class NoteDetailImage {
@ -28,10 +28,10 @@ class NoteDetailImage {
const success = document.execCommand('copy'); const success = document.execCommand('copy');
if (success) { if (success) {
infoService.showMessage("Image copied to the clipboard"); toastService.showMessage("Image copied to the clipboard");
} }
else { else {
infoService.showAndLogError("Could not copy the image to clipboard."); toastService.showAndLogError("Could not copy the image to clipboard.");
} }
} }
finally { finally {

View File

@ -4,7 +4,7 @@ import linkService from "./link.js";
import libraryLoader from "./library_loader.js"; import libraryLoader from "./library_loader.js";
import treeService from "./tree.js"; import treeService from "./tree.js";
import contextMenuWidget from "./context_menu.js"; import contextMenuWidget from "./context_menu.js";
import infoService from "./info.js"; import toastService from "./toast.js";
import attributeAutocompleteService from "./attribute_autocomplete.js"; import attributeAutocompleteService from "./attribute_autocomplete.js";
const uniDirectionalOverlays = [ const uniDirectionalOverlays = [
@ -134,7 +134,7 @@ class NoteDetailRelationMap {
target: 'into' 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 // reloading tree so that the new note appears there
// no need to wait for it to finish // 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); const exists = this.mapData.notes.some(n => n.noteId === note.noteId);
if (exists) { if (exists) {
infoService.showError(`Note "${note.title}" is already in the diagram.`); toastService.showError(`Note "${note.title}" is already in the diagram.`);
continue; continue;
} }

View File

@ -3,7 +3,7 @@ import noteDetailService from './note_detail.js';
import utils from './utils.js'; import utils from './utils.js';
import server from './server.js'; import server from './server.js';
import protectedSessionHolder from './protected_session_holder.js'; import protectedSessionHolder from './protected_session_holder.js';
import infoService from "./info.js"; import toastService from "./toast.js";
import ws from "./ws.js"; import ws from "./ws.js";
const $enterProtectedSessionButton = $("#enter-protected-session-button"); const $enterProtectedSessionButton = $("#enter-protected-session-button");
@ -38,7 +38,7 @@ async function setupProtectedSession(password) {
const response = await enterProtectedSessionOnServer(password); const response = await enterProtectedSessionOnServer(password);
if (!response.success) { if (!response.success) {
infoService.showError("Wrong password.", 3000); toastService.showError("Wrong password.", 3000);
return; return;
} }
@ -60,7 +60,7 @@ async function setupProtectedSession(password) {
$enterProtectedSessionButton.hide(); $enterProtectedSessionButton.hide();
$leaveProtectedSessionButton.show(); $leaveProtectedSessionButton.show();
infoService.showMessage("Protected session has been started."); toastService.showMessage("Protected session has been started.");
} }
async function enterProtectedSessionOnServer(password) { async function enterProtectedSessionOnServer(password) {
@ -90,7 +90,7 @@ async function unprotectNoteAndSendToServer() {
const activeNote = noteDetailService.getActiveNote(); const activeNote = noteDetailService.getActiveNote();
if (!activeNote.isProtected) { if (!activeNote.isProtected) {
infoService.showAndLogError(`Note ${activeNote.noteId} is not protected`); toastService.showAndLogError(`Note ${activeNote.noteId} is not protected`);
return; return;
} }
@ -139,15 +139,15 @@ ws.subscribeToMessages(async message => {
const protectingLabel = message.data.protect ? "Protecting" : "Unprotecting"; const protectingLabel = message.data.protect ? "Protecting" : "Unprotecting";
if (message.type === 'task-error') { if (message.type === 'task-error') {
infoService.closePersistent(message.taskId); toastService.closePersistent(message.taskId);
infoService.showError(message.message); toastService.showError(message.message);
} else if (message.type === 'task-progress-count') { } 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') { } else if (message.type === 'task-succeeded') {
const toast = makeToast(message, protectingLabel, protectingLabel + " finished successfully."); const toast = makeToast(message, protectingLabel, protectingLabel + " finished successfully.");
toast.closeAfter = 3000; toast.closeAfter = 3000;
infoService.showPersistent(toast); toastService.showPersistent(toast);
} }
}); });

View File

@ -1,7 +1,7 @@
import treeService from './tree.js'; import treeService from './tree.js';
import treeCache from "./tree_cache.js"; import treeCache from "./tree_cache.js";
import server from './server.js'; import server from './server.js';
import infoService from "./info.js"; import toastService from "./toast.js";
const $searchInput = $("input[name='search-text']"); const $searchInput = $("input[name='search-text']");
const $resetSearchButton = $("#reset-search-button"); const $resetSearchButton = $("#reset-search-button");
@ -73,7 +73,7 @@ async function doSearch(searchText) {
} }
if (searchText.trim().length === 0) { if (searchText.trim().length === 0) {
infoService.showMessage("Please enter search criteria first."); toastService.showMessage("Please enter search criteria first.");
$searchInput.focus(); $searchInput.focus();
@ -85,7 +85,7 @@ async function doSearch(searchText) {
const response = await server.get('search/' + encodeURIComponent(searchText)); const response = await server.get('search/' + encodeURIComponent(searchText));
if (!response.success) { if (!response.success) {
infoService.showError("Search failed.", 3000); toastService.showError("Search failed.", 3000);
return; return;
} }
@ -105,7 +105,7 @@ async function doSearch(searchText) {
// have at least some feedback which is good especially in situations // have at least some feedback which is good especially in situations
// when the result list does not change with a query // when the result list does not change with a query
infoService.showMessage("Search finished successfully."); toastService.showMessage("Search finished successfully.");
} }
async function saveSearch() { async function saveSearch() {
@ -139,7 +139,7 @@ async function refreshSearch() {
activeNode.load(true); activeNode.load(true);
activeNode.setExpanded(true); activeNode.setExpanded(true);
infoService.showMessage("Saved search note refreshed."); toastService.showMessage("Saved search note refreshed.");
} }
function init() { function init() {

View File

@ -1,5 +1,5 @@
import utils from './utils.js'; import utils from './utils.js';
import infoService from "./info.js"; import toastService from "./toast.js";
const REQUEST_LOGGING_ENABLED = false; const REQUEST_LOGGING_ENABLED = false;
@ -87,8 +87,8 @@ async function ajax(url, method, data) {
return await $.ajax(options).catch(e => { return await $.ajax(options).catch(e => {
const message = "Error when calling " + method + " " + url + ": " + e.status + " - " + e.statusText; const message = "Error when calling " + method + " " + url + ": " + e.status + " - " + e.statusText;
infoService.showError(message); toastService.showError(message);
infoService.throwError(message); toastService.throwError(message);
}); });
} }

View File

@ -1,18 +1,18 @@
import server from './server.js'; import server from './server.js';
import infoService from "./info.js"; import toastService from "./toast.js";
async function syncNow() { async function syncNow() {
const result = await server.post('sync/now'); const result = await server.post('sync/now');
if (result.success) { if (result.success) {
infoService.showMessage("Sync finished successfully."); toastService.showMessage("Sync finished successfully.");
} }
else { else {
if (result.message.length > 50) { if (result.message.length > 50) {
result.message = result.message.substr(0, 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) { async function forceNoteSync(noteId) {
await server.post('sync/force-note-sync/' + 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 { export default {

View File

@ -7,7 +7,7 @@ import treeUtils from './tree_utils.js';
import utils from './utils.js'; import utils from './utils.js';
import server from './server.js'; import server from './server.js';
import treeCache from './tree_cache.js'; import treeCache from './tree_cache.js';
import infoService from "./info.js"; import toastService from "./toast.js";
import treeBuilder from "./tree_builder.js"; import treeBuilder from "./tree_builder.js";
import treeKeyBindings from "./tree_keybindings.js"; import treeKeyBindings from "./tree_keybindings.js";
import Branch from '../entities/branch.js'; import Branch from '../entities/branch.js';
@ -295,7 +295,7 @@ async function getSomeNotePath(note) {
const parents = await cur.getParentNotes(); const parents = await cur.getParentNotes();
if (!parents.length) { if (!parents.length) {
infoService.throwError(`Can't find parents for note ${cur.noteId}`); toastService.throwError(`Can't find parents for note ${cur.noteId}`);
return; return;
} }
@ -695,7 +695,7 @@ async function createNote(node, parentNoteId, target, extraOptions = {}) {
node.renderTitle(); node.renderTitle();
} }
else { else {
infoService.throwError("Unrecognized target: " + target); toastService.throwError("Unrecognized target: " + target);
} }
clearSelectedNodes(); // to unmark previously active node clearSelectedNodes(); // to unmark previously active node
@ -853,7 +853,7 @@ async function duplicateNote(noteId, parentNoteId) {
await activateNote(note.noteId); await activateNote(note.noteId);
const origNote = await treeCache.getNote(noteId); const origNote = await treeCache.getNote(noteId);
infoService.showMessage(`Note "${origNote.title}" has been duplicated`); toastService.showMessage(`Note "${origNote.title}" has been duplicated`);
} }

View File

@ -1,7 +1,7 @@
import utils from "./utils.js"; import utils from "./utils.js";
import Branch from "../entities/branch.js"; import Branch from "../entities/branch.js";
import NoteShort from "../entities/note_short.js"; import NoteShort from "../entities/note_short.js";
import infoService from "./info.js"; import toastService from "./toast.js";
import ws from "./ws.js"; import ws from "./ws.js";
import server from "./server.js"; import server from "./server.js";
@ -197,7 +197,7 @@ class TreeCache {
const branchId = this.childParentToBranch[key]; const branchId = this.childParentToBranch[key];
if (!branchId) { if (!branchId) {
infoService.throwError("Cannot find branch for child-parent=" + key); toastService.throwError("Cannot find branch for child-parent=" + key);
} }
return branchId; return branchId;

View File

@ -1,5 +1,5 @@
import utils from './utils.js'; import utils from './utils.js';
import infoService from "./info.js"; import toastService from "./toast.js";
import treeService from "./tree.js"; import treeService from "./tree.js";
const $outstandingSyncsCount = $("#outstanding-syncs-count"); const $outstandingSyncsCount = $("#outstanding-syncs-count");
@ -65,10 +65,10 @@ function handleMessage(event) {
$outstandingSyncsCount.html(message.outstandingSyncs); $outstandingSyncsCount.html(message.outstandingSyncs);
} }
else if (message.type === 'sync-hash-check-failed') { 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') { 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);
} }
} }