moved services into the service directory

This commit is contained in:
azivner 2018-03-25 13:02:39 -04:00
parent f52d7e3c28
commit fddd1c278f
33 changed files with 91 additions and 92 deletions

View File

@ -1,10 +1,10 @@
"use strict";
import treeService from '../note_tree.js';
import cloning from '../cloning.js';
import link from '../link.js';
import noteEditor from '../note_editor.js';
import treeUtils from '../tree_utils.js';
import treeService from '../services/tree_service.js';
import cloning from '../services/cloning.js';
import link from '../services/link.js';
import noteDetail from '../services/note_detail.js';
import treeUtils from '../services/tree_utils.js';
const $dialog = $("#add-link-dialog");
const $form = $("#add-link-form");
@ -27,7 +27,7 @@ function setLinkType(linkType) {
async function showDialog() {
glob.activeDialog = $dialog;
if (noteEditor.getCurrentNoteType() === 'text') {
if (noteDetail.getCurrentNoteType() === 'text') {
$linkTypeHtml.prop('disabled', false);
setLinkType('html');
@ -99,14 +99,14 @@ $form.submit(() => {
else if (linkType === 'selected-to-current') {
const prefix = $clonePrefix.val();
cloning.cloneNoteTo(noteId, noteEditor.getCurrentNoteId(), prefix);
cloning.cloneNoteTo(noteId, noteDetail.getCurrentNoteId(), prefix);
$dialog.dialog("close");
}
else if (linkType === 'current-to-selected') {
const prefix = $clonePrefix.val();
cloning.cloneNoteTo(noteEditor.getCurrentNoteId(), noteId, prefix);
cloning.cloneNoteTo(noteDetail.getCurrentNoteId(), noteId, prefix);
$dialog.dialog("close");
}

View File

@ -1,6 +1,6 @@
"use strict";
import treeService from '../note_tree.js';
import treeService from '../services/tree_service.js';
const $dialog = $("#edit-tree-prefix-dialog");
const $form = $("#edit-tree-prefix-form");

View File

@ -1,7 +1,7 @@
"use strict";
import link from '../link.js';
import utils from '../utils.js';
import link from '../services/link.js';
import utils from '../services/utils.js';
const $dialog = $("#event-log-dialog");
const $list = $("#event-log-list");

View File

@ -1,8 +1,8 @@
"use strict";
import treeService from '../note_tree.js';
import link from '../link.js';
import utils from '../utils.js';
import treeService from '../services/tree_service.js';
import link from '../services/link.js';
import utils from '../services/utils.js';
const $showDialogButton = $("#jump-to-note-button");
const $dialog = $("#jump-to-note-dialog");

View File

@ -1,7 +1,7 @@
"use strict";
import noteEditor from '../note_editor.js';
import utils from '../utils.js';
import noteDetail from '../services/note_detail.js';
import utils from '../services/utils.js';
const $showDialogButton = $(".show-labels-button");
const $dialog = $("#labels-dialog");
@ -17,7 +17,7 @@ function LabelsModel() {
this.labels = ko.observableArray();
this.loadLabels = async function() {
const noteId = noteEditor.getCurrentNoteId();
const noteId = noteDetail.getCurrentNoteId();
const labels = await server.get('notes/' + noteId + '/labels');
@ -81,7 +81,7 @@ function LabelsModel() {
return;
}
const noteId = noteEditor.getCurrentNoteId();
const noteId = noteDetail.getCurrentNoteId();
const labelsToSave = self.labels()
.map(attr => attr())
@ -95,7 +95,7 @@ function LabelsModel() {
utils.showMessage("Labels have been saved.");
noteEditor.loadLabelList();
noteDetail.loadLabelList();
};
function addLastEmptyRow() {

View File

@ -1,7 +1,7 @@
"use strict";
import noteEditor from '../note_editor.js';
import utils from '../utils.js';
import noteDetail from '../services/note_detail.js';
import utils from '../services/utils.js';
const $showDialogButton = $("#show-history-button");
const $dialog = $("#note-history-dialog");
@ -12,7 +12,7 @@ const $title = $("#note-history-title");
let historyItems = [];
async function showCurrentNoteHistory() {
await showNoteHistoryDialog(noteEditor.getCurrentNoteId());
await showNoteHistoryDialog(noteDetail.getCurrentNoteId());
}
async function showNoteHistoryDialog(noteId, noteRevisionId) {

View File

@ -1,6 +1,6 @@
"use strict";
import noteEditor from '../note_editor.js';
import noteDetail from '../services/note_detail.js';
const $showDialogButton = $("#show-source-button");
const $dialog = $("#note-source-dialog");
@ -15,7 +15,7 @@ function showDialog() {
height: 500
});
const noteText = noteEditor.getCurrentNote().detail.content;
const noteText = noteDetail.getCurrentNote().detail.content;
$noteSource.text(formatHtml(noteText));
}

View File

@ -1,7 +1,7 @@
"use strict";
import link from '../link.js';
import utils from '../utils.js';
import link from '../services/link.js';
import utils from '../services/utils.js';
const $showDialogButton = $("#recent-changes-button");
const $dialog = $("#recent-changes-dialog");

View File

@ -1,8 +1,8 @@
"use strict";
import treeService from '../note_tree.js';
import server from '../server.js';
import messaging from '../messaging.js';
import treeService from '../services/tree_service.js';
import server from '../services/server.js';
import messaging from '../services/messaging.js';
const $showDialogButton = $("#recent-notes-button");
const $dialog = $("#recent-notes-dialog");

View File

@ -1,8 +1,8 @@
"use strict";
import protected_session from '../protected_session.js';
import utils from '../utils.js';
import server from '../server.js';
import protected_session from '../services/protected_session.js';
import utils from '../services/utils.js';
import server from '../services/server.js';
const $showDialogButton = $("#settings-button");
const $dialog = $("#settings-dialog");

View File

@ -1,6 +1,6 @@
"use strict";
import utils from '../utils.js';
import utils from '../services/utils.js';
const $dialog = $("#sql-console-dialog");
const $query = $('#sql-console-query');

View File

@ -1,14 +1,14 @@
import addLink from './dialogs/add_link.js';
import editTreePrefix from './dialogs/edit_tree_prefix.js';
import eventLog from './dialogs/event_log.js';
import jumpToNote from './dialogs/jump_to_note.js';
import labelsDialog from './dialogs/labels.js';
import noteHistory from './dialogs/note_history.js';
import noteSource from './dialogs/note_source.js';
import recentChanges from './dialogs/recent_changes.js';
import recentNotes from './dialogs/recent_notes.js';
import settings from './dialogs/settings.js';
import sqlConsole from './dialogs/sql_console.js';
import addLink from '../dialogs/add_link.js';
import editTreePrefix from '../dialogs/edit_tree_prefix.js';
import eventLog from '../dialogs/event_log.js';
import jumpToNote from '../dialogs/jump_to_note.js';
import labelsDialog from '../dialogs/labels.js';
import noteHistory from '../dialogs/note_history.js';
import noteSource from '../dialogs/note_source.js';
import recentChanges from '../dialogs/recent_changes.js';
import recentNotes from '../dialogs/recent_notes.js';
import settings from '../dialogs/settings.js';
import sqlConsole from '../dialogs/sql_console.js';
import cloning from './cloning.js';
import contextMenu from './context_menu.js';
@ -16,7 +16,7 @@ import dragAndDropSetup from './drag_and_drop.js';
import exportService from './export.js';
import link from './link.js';
import messaging from './messaging.js';
import noteEditor from './note_editor.js';
import noteDetail from './note_detail.js';
import noteType from './note_type.js';
import protected_session from './protected_session.js';
import ScriptApi from './script_api.js';
@ -28,7 +28,7 @@ import utils from './utils.js';
import searchTreeService from './search_tree.js';
import './init.js';
import treeService from './note_tree.js';
import treeService from './tree_service.js';
const $toggleSearchButton = $("#toggle-search-button");
$toggleSearchButton.click(searchTreeService.toggleSearch);

View File

@ -1,6 +1,6 @@
"use strict";
import treeService from './note_tree.js';
import treeService from './tree_service.js';
async function cloneNoteTo(childNoteId, parentNoteId, prefix) {
const resp = await server.put('notes/' + childNoteId + '/clone-to/' + parentNoteId, {

View File

@ -1,6 +1,6 @@
"use strict";
import treeService from './note_tree.js';
import treeService from './tree_service.js';
import cloning from './cloning.js';
import exportService from './export.js';
import messaging from './messaging.js';

View File

@ -1,6 +1,6 @@
"use strict";
import treeService from './note_tree.js';
import treeService from './tree_service.js';
import treeChanges from './tree_changes.js';
const dragAndDropSetup = {

View File

@ -1,6 +1,6 @@
"use strict";
import treeService from './note_tree.js';
import treeService from './tree_service.js';
import protected_session from './protected_session.js';
import utils from './utils.js';

View File

@ -1,9 +1,9 @@
"use strict";
import treeService from './note_tree.js';
import treeService from './tree_service.js';
import link from './link.js';
import messaging from './messaging.js';
import noteEditor from './note_editor.js';
import noteDetail from './note_detail.js';
import treeUtils from './tree_utils.js';
import utils from './utils.js';
import server from './server.js';
@ -107,7 +107,7 @@ $("#note-title").bind('keydown', 'return', () => $("#note-detail").focus());
$(window).on('beforeunload', () => {
// this makes sure that when user e.g. reloads the page or navigates away from the page, the note's content is saved
// this sends the request asynchronously and doesn't wait for result
noteEditor.saveNoteIfChanged();
noteDetail.saveNoteIfChanged();
});
// Overrides the default autocomplete filter function to search for matched on atleast 1 word in each of the input term's words
@ -164,7 +164,7 @@ $(document).tooltip({
if (notePath !== null) {
const noteId = treeUtils.getNoteIdFromNotePath(notePath);
noteEditor.loadNote(noteId).then(note => callback(note.detail.content));
noteDetail.loadNote(noteId).then(note => callback(note.detail.content));
}
},
close: function(event, ui)
@ -244,7 +244,7 @@ $("#attachment-upload").change(async function() {
formData.append('upload', this.files[0]);
const resp = await $.ajax({
url: baseApiUrl + 'attachments/upload/' + noteEditor.getCurrentNoteId(),
url: baseApiUrl + 'attachments/upload/' + noteDetail.getCurrentNoteId(),
headers: server.getHeaders(),
data: formData,
type: 'POST',

View File

@ -1,7 +1,7 @@
"use strict";
import treeService from './note_tree.js';
import noteEditor from './note_editor.js';
import treeService from './tree_service.js';
import noteDetail from './note_detail.js';
import treeUtils from './tree_utils.js';
function getNotePathFromLink(url) {
@ -77,14 +77,14 @@ function goToLink(e) {
}
function addLinkToEditor(linkTitle, linkHref) {
const editor = noteEditor.getEditor();
const editor = noteDetail.getEditor();
const doc = editor.document;
doc.enqueueChanges(() => editor.data.insertLink(linkTitle, linkHref), doc.selection);
}
function addTextToEditor(text) {
const editor = noteEditor.getEditor();
const editor = noteDetail.getEditor();
const doc = editor.document;
doc.enqueueChanges(() => editor.data.insertText(text), doc.selection);

View File

@ -1,8 +1,7 @@
"use strict";
import treeService from './note_tree.js';
import noteEditor from './note_editor.js';
import sync from './sync.js';
import treeService from './tree_service.js';
import noteDetailService from './note_detail.js';
import utils from './utils.js';
const $changesToPushCount = $("#changes-to-push-count");
@ -41,10 +40,10 @@ function messageHandler(event) {
treeService.reload();
}
if (syncData.some(sync => sync.entityName === 'notes' && sync.entityId === noteEditor.getCurrentNoteId())) {
if (syncData.some(sync => sync.entityName === 'notes' && sync.entityId === noteDetailService.getCurrentNoteId())) {
utils.showMessage('Reloading note because of background changes');
noteEditor.reload();
noteDetailService.reload();
}
if (syncData.some(sync => sync.entityName === 'recent_notes')) {

View File

@ -1,6 +1,6 @@
"use strict";
import treeService from './note_tree.js';
import treeService from './tree_service.js';
import noteType from './note_type.js';
import protected_session from './protected_session.js';
import utils from './utils.js';

View File

@ -1,7 +1,7 @@
"use strict";
import treeService from './note_tree.js';
import noteEditor from './note_editor.js';
import treeService from './tree_service.js';
import noteDetail from './note_detail.js';
import utils from './utils.js';
const $executeScriptButton = $("#execute-script-button");
@ -85,13 +85,13 @@ function NoteTypeModel() {
};
async function save() {
const note = noteEditor.getCurrentNote();
const note = noteDetail.getCurrentNote();
await server.put('notes/' + note.detail.noteId
+ '/type/' + encodeURIComponent(self.type())
+ '/mime/' + encodeURIComponent(self.mime()));
await noteEditor.reload();
await noteDetail.reload();
// for the note icon to be updated in the tree
await treeService.reload();

View File

@ -1,7 +1,7 @@
"use strict";
import treeService from './note_tree.js';
import noteEditor from './note_editor.js';
import treeService from './tree_service.js';
import noteDetail from './note_detail.js';
import utils from './utils.js';
import server from './server.js';
@ -68,7 +68,7 @@ async function setupProtectedSession() {
$dialog.dialog("close");
noteEditor.reload();
noteDetail.reload();
treeService.reload();
if (protectedSessionDeferred !== null) {
@ -117,33 +117,33 @@ function isProtectedSessionAvailable() {
async function protectNoteAndSendToServer() {
await ensureProtectedSession(true, true);
const note = noteEditor.getCurrentNote();
const note = noteDetail.getCurrentNote();
noteEditor.updateNoteFromInputs(note);
noteDetail.updateNoteFromInputs(note);
note.detail.isProtected = true;
await noteEditor.saveNoteToServer(note);
await noteDetail.saveNoteToServer(note);
treeService.setProtected(note.detail.noteId, note.detail.isProtected);
noteEditor.setNoteBackgroundIfProtected(note);
noteDetail.setNoteBackgroundIfProtected(note);
}
async function unprotectNoteAndSendToServer() {
await ensureProtectedSession(true, true);
const note = noteEditor.getCurrentNote();
const note = noteDetail.getCurrentNote();
noteEditor.updateNoteFromInputs(note);
noteDetail.updateNoteFromInputs(note);
note.detail.isProtected = false;
await noteEditor.saveNoteToServer(note);
await noteDetail.saveNoteToServer(note);
treeService.setProtected(note.detail.noteId, note.detail.isProtected);
noteEditor.setNoteBackgroundIfProtected(note);
noteDetail.setNoteBackgroundIfProtected(note);
}
function touchProtectedSession() {
@ -160,7 +160,7 @@ async function protectSubTree(noteId, protect) {
utils.showMessage("Request to un/protect sub tree has finished successfully");
treeService.reload();
noteEditor.reload();
noteDetail.reload();
}
$passwordForm.submit(() => {

View File

@ -1,4 +1,4 @@
import treeService from './note_tree.js';
import treeService from './tree_service.js';
function ScriptApi(startNote, currentNote) {
const $pluginButtons = $("#plugin-buttons");

View File

@ -1,6 +1,6 @@
"use strict";
import treeService from './note_tree.js';
import treeService from './tree_service.js';
const $tree = $("#tree");
const $searchInput = $("input[name='search-text']");

View File

@ -1,6 +1,6 @@
import utils from "./utils.js";
import Branch from "./entities/branch.js";
import NoteShort from "./entities/note_short.js";
import Branch from "../entities/branch.js";
import NoteShort from "../entities/note_short.js";
class TreeCache {
load(noteRows, branchRows) {

View File

@ -1,6 +1,6 @@
"use strict";
import treeService from './note_tree.js';
import treeService from './tree_service.js';
import utils from './utils.js';
async function moveBeforeNode(nodesToMove, beforeNode) {

View File

@ -4,13 +4,13 @@ import contextMenu from './context_menu.js';
import dragAndDropSetup from './drag_and_drop.js';
import link from './link.js';
import messaging from './messaging.js';
import noteEditor from './note_editor.js';
import noteDetail from './note_detail.js';
import protected_session from './protected_session.js';
import treeChanges from './tree_changes.js';
import treeUtils from './tree_utils.js';
import utils from './utils.js';
import server from './server.js';
import recentNotes from './dialogs/recent_notes.js';
import recentNotes from '../dialogs/recent_notes.js';
import treeCache from './tree_cache.js';
const $tree = $("#tree");
@ -494,7 +494,7 @@ function initFancyTree(branch) {
return false;
},
"return": node => {
noteEditor.focus();
noteDetail.focus();
return false;
},
@ -557,7 +557,7 @@ function initFancyTree(branch) {
setCurrentNotePathToHash(data.node);
noteEditor.switchToNote(node.noteId);
noteDetail.switchToNote(node.noteId);
showParentList(node.noteId, data.node);
},
@ -793,7 +793,7 @@ async function createNote(node, parentNoteId, target, isProtected) {
treeCache.add(note, branch);
noteEditor.newNoteCreated();
noteDetail.newNoteCreated();
const newNode = {
title: newNoteName,

View File

@ -519,7 +519,7 @@
<link href="/stylesheets/style.css" rel="stylesheet">
<script src="/javascripts/bootstrap.js" type="module"></script>
<script src="/javascripts/services/bootstrap.js" type="module"></script>
<script type="text/javascript">
// we hide container initally because otherwise it is rendered first without CSS and then flickers into