renamed settings to options for consistency

This commit is contained in:
azivner 2018-04-01 17:41:28 -04:00
parent 96dab5d51e
commit 311952d4dd
12 changed files with 50 additions and 50 deletions

View file

@ -5,8 +5,8 @@ import utils from '../services/utils.js';
import server from '../services/server.js'; import server from '../services/server.js';
import infoService from "../services/info.js"; import infoService from "../services/info.js";
const $dialog = $("#settings-dialog"); const $dialog = $("#options-dialog");
const $tabs = $("#settings-tabs"); const $tabs = $("#options-tabs");
const tabHandlers = []; const tabHandlers = [];
@ -17,7 +17,7 @@ function addTabHandler(handler) {
async function showDialog() { async function showDialog() {
glob.activeDialog = $dialog; glob.activeDialog = $dialog;
const settings = await server.get('settings'); const options = await server.get('options');
$dialog.dialog({ $dialog.dialog({
modal: true, modal: true,
@ -27,24 +27,24 @@ async function showDialog() {
$tabs.tabs(); $tabs.tabs();
for (const handler of tabHandlers) { for (const handler of tabHandlers) {
if (handler.settingsLoaded) { if (handler.optionsLoaded) {
handler.settingsLoaded(settings); handler.optionsLoaded(options);
} }
} }
} }
async function saveSettings(settingName, settingValue) { async function saveOptions(optionName, optionValue) {
await server.post('settings', { await server.post('options', {
name: settingName, name: optionName,
value: settingValue value: optionValue
}); });
infoService.showMessage("Settings change have been saved."); infoService.showMessage("Options change have been saved.");
} }
export default { export default {
showDialog, showDialog,
saveSettings saveOptions
}; };
addTabHandler((function() { addTabHandler((function() {
@ -53,7 +53,7 @@ addTabHandler((function() {
const $newPassword1 = $("#new-password1"); const $newPassword1 = $("#new-password1");
const $newPassword2 = $("#new-password2"); const $newPassword2 = $("#new-password2");
function settingsLoaded(settings) { function optionsLoaded(options) {
} }
$form.submit(() => { $form.submit(() => {
@ -89,23 +89,23 @@ addTabHandler((function() {
}); });
return { return {
settingsLoaded optionsLoaded
}; };
})()); })());
addTabHandler((function() { addTabHandler((function() {
const $form = $("#protected-session-timeout-form"); const $form = $("#protected-session-timeout-form");
const $protectedSessionTimeout = $("#protected-session-timeout-in-seconds"); const $protectedSessionTimeout = $("#protected-session-timeout-in-seconds");
const settingName = 'protected_session_timeout'; const optionName = 'protected_session_timeout';
function settingsLoaded(settings) { function optionsLoaded(options) {
$protectedSessionTimeout.val(settings[settingName]); $protectedSessionTimeout.val(options[optionName]);
} }
$form.submit(() => { $form.submit(() => {
const protectedSessionTimeout = $protectedSessionTimeout.val(); const protectedSessionTimeout = $protectedSessionTimeout.val();
saveSettings(settingName, protectedSessionTimeout).then(() => { saveOptions(optionName, protectedSessionTimeout).then(() => {
protectedSessionHolder.setProtectedSessionTimeout(protectedSessionTimeout); protectedSessionHolder.setProtectedSessionTimeout(protectedSessionTimeout);
}); });
@ -113,27 +113,27 @@ addTabHandler((function() {
}); });
return { return {
settingsLoaded optionsLoaded
}; };
})()); })());
addTabHandler((function () { addTabHandler((function () {
const $form = $("#note-revision-snapshot-time-interval-form"); const $form = $("#note-revision-snapshot-time-interval-form");
const $timeInterval = $("#note-revision-snapshot-time-interval-in-seconds"); const $timeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
const settingName = 'note_revision_snapshot_time_interval'; const optionName = 'note_revision_snapshot_time_interval';
function settingsLoaded(settings) { function optionsLoaded(options) {
$timeInterval.val(settings[settingName]); $timeInterval.val(options[optionName]);
} }
$form.submit(() => { $form.submit(() => {
saveSettings(settingName, $timeInterval.val()); saveOptions(optionName, $timeInterval.val());
return false; return false;
}); });
return { return {
settingsLoaded optionsLoaded
}; };
})()); })());

View file

@ -5,7 +5,7 @@ import noteRevisionsDialog from '../dialogs/note_revisions.js';
import noteSourceDialog from '../dialogs/note_source.js'; import noteSourceDialog from '../dialogs/note_source.js';
import recentChangesDialog from '../dialogs/recent_changes.js'; import recentChangesDialog from '../dialogs/recent_changes.js';
import recentNotesDialog from '../dialogs/recent_notes.js'; import recentNotesDialog from '../dialogs/recent_notes.js';
import settingsDialog from '../dialogs/settings.js'; import optionsDialog from '../dialogs/options.js';
import sqlConsoleDialog from '../dialogs/sql_console.js'; import sqlConsoleDialog from '../dialogs/sql_console.js';
import cloning from './cloning.js'; import cloning from './cloning.js';

View file

@ -76,7 +76,7 @@ function cut(nodes) {
infoService.showMessage("Note(s) have been cut into clipboard."); infoService.showMessage("Note(s) have been cut into clipboard.");
} }
const contextMenuSettings = { const contextMenuOptions = {
delegate: "span.fancytree-title", delegate: "span.fancytree-title",
autoFocus: true, autoFocus: true,
menu: [ menu: [
@ -185,5 +185,5 @@ export default {
pasteInto, pasteInto,
cut, cut,
copy, copy,
contextMenuSettings contextMenuOptions
}; };

View file

@ -3,7 +3,7 @@ import treeService from "./tree.js";
import linkService from "./link.js"; import linkService from "./link.js";
import fileService from "./file.js"; import fileService from "./file.js";
import noteRevisionsDialog from "../dialogs/note_revisions.js"; import noteRevisionsDialog from "../dialogs/note_revisions.js";
import settingsDialog from "../dialogs/settings.js"; import optionsDialog from "../dialogs/options.js";
import addLinkDialog from "../dialogs/add_link.js"; import addLinkDialog from "../dialogs/add_link.js";
import recentNotesDialog from "../dialogs/recent_notes.js"; import recentNotesDialog from "../dialogs/recent_notes.js";
import jumpToNoteDialog from "../dialogs/jump_to_note.js"; import jumpToNoteDialog from "../dialogs/jump_to_note.js";
@ -40,7 +40,7 @@ function registerEntrypoints() {
$(".show-labels-button").click(labelsDialog.showDialog); $(".show-labels-button").click(labelsDialog.showDialog);
utils.bindShortcut('alt+l', labelsDialog.showDialog); utils.bindShortcut('alt+l', labelsDialog.showDialog);
$("#settings-button").click(settingsDialog.showDialog); $("#options-button").click(optionsDialog.showDialog);
utils.bindShortcut('alt+o', sqlConsoleDialog.showDialog); utils.bindShortcut('alt+o', sqlConsoleDialog.showDialog);

View file

@ -8,7 +8,7 @@ function showMessage(message) {
// options // options
message: message message: message
}, { }, {
// settings // options
type: 'success', type: 'success',
delay: 3000 delay: 3000
}); });
@ -21,7 +21,7 @@ function showError(message, delay = 10000) {
// options // options
message: message message: message
}, { }, {
// settings // options
type: 'danger', type: 'danger',
delay: delay delay: delay
}); });

View file

@ -82,7 +82,7 @@ setTimeout(() => {
// options // options
message: "Lost connection to server" message: "Lost connection to server"
},{ },{
// settings // options
type: 'danger', type: 'danger',
delay: 100000000 // keep it until we explicitly close it delay: 100000000 // keep it until we explicitly close it
}); });

View file

@ -6,7 +6,7 @@ let protectedSessionTimeout = null;
let protectedSessionId = null; let protectedSessionId = null;
$(document).ready(() => { $(document).ready(() => {
server.get('settings/all').then(settings => protectedSessionTimeout = settings.protected_session_timeout); server.get('options/all').then(options => protectedSessionTimeout = options.protected_session_timeout);
}); });
setInterval(() => { setInterval(() => {

View file

@ -349,7 +349,7 @@ function initFancyTree(branch) {
} }
}); });
$tree.contextmenu(contextMenuService.contextMenuSettings); $tree.contextmenu(contextMenuService.contextMenuOptions);
} }
function getTree() { function getTree() {

View file

@ -3,21 +3,21 @@
const sql = require('../../services/sql'); const sql = require('../../services/sql');
const options = require('../../services/options'); const options = require('../../services/options');
// options allowed to be updated directly in settings dialog // options allowed to be updated directly in options dialog
const ALLOWED_OPTIONS = ['protected_session_timeout', 'note_revision_snapshot_time_interval']; const ALLOWED_OPTIONS = ['protected_session_timeout', 'note_revision_snapshot_time_interval'];
async function getAllSettings() { async function getAllOptions() {
return await sql.getMap("SELECT name, value FROM options"); return await sql.getMap("SELECT name, value FROM options");
} }
async function getAllowedSettings() { async function getAllowedOptions() {
const settings = await sql.getMap("SELECT name, value FROM options WHERE name IN (" const options = await sql.getMap("SELECT name, value FROM options WHERE name IN ("
+ ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS); + ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS);
return settings; return options;
} }
async function updateSetting(req) { async function updateOption(req) {
const body = req.body; const body = req.body;
if (!ALLOWED_OPTIONS.includes(body['name'])) { if (!ALLOWED_OPTIONS.includes(body['name'])) {
@ -28,7 +28,7 @@ async function updateSetting(req) {
} }
module.exports = { module.exports = {
getAllowedSettings, getAllowedOptions,
getAllSettings, getAllOptions,
updateSetting updateOption
}; };

View file

@ -11,7 +11,7 @@ const treeChangesApiRoute = require('./api/tree_changes');
const cloningApiRoute = require('./api/cloning'); const cloningApiRoute = require('./api/cloning');
const noteRevisionsApiRoute = require('./api/note_revisions'); const noteRevisionsApiRoute = require('./api/note_revisions');
const recentChangesApiRoute = require('./api/recent_changes'); const recentChangesApiRoute = require('./api/recent_changes');
const settingsApiRoute = require('./api/settings'); const optionsApiRoute = require('./api/options');
const passwordApiRoute = require('./api/password'); const passwordApiRoute = require('./api/password');
const migrationApiRoute = require('./api/migration'); const migrationApiRoute = require('./api/migration');
const syncApiRoute = require('./api/sync'); const syncApiRoute = require('./api/sync');
@ -126,9 +126,9 @@ function register(app) {
apiRoute(GET, '/api/recent-changes', recentChangesApiRoute.getRecentChanges); apiRoute(GET, '/api/recent-changes', recentChangesApiRoute.getRecentChanges);
apiRoute(GET, '/api/settings', settingsApiRoute.getAllowedSettings); apiRoute(GET, '/api/options', optionsApiRoute.getAllowedOptions);
apiRoute(GET, '/api/settings/all', settingsApiRoute.getAllSettings); apiRoute(GET, '/api/options/all', optionsApiRoute.getAllOptions);
apiRoute(POST, '/api/settings', settingsApiRoute.updateSetting); apiRoute(POST, '/api/options', optionsApiRoute.updateOption);
apiRoute(POST, '/api/password/change', passwordApiRoute.changePassword); apiRoute(POST, '/api/password/change', passwordApiRoute.changePassword);

Binary file not shown.

View file

@ -29,8 +29,8 @@
Sync now (<span id="changes-to-push-count">0</span>) Sync now (<span id="changes-to-push-count">0</span>)
</button> </button>
<button class="btn btn-xs" id="settings-button"> <button class="btn btn-xs" id="options-button">
<span class="ui-icon ui-icon-gear"></span> Settings</button> <span class="ui-icon ui-icon-gear"></span> Options</button>
<form action="logout" id="logout-button" method="POST" style="display: inline;"> <form action="logout" id="logout-button" method="POST" style="display: inline;">
<input type="submit" class="btn btn-xs" value="Logout"> <input type="submit" class="btn btn-xs" value="Logout">
@ -272,8 +272,8 @@
</form> </form>
</div> </div>
<div id="settings-dialog" title="Settings" style="display: none;"> <div id="options-dialog" title="Options" style="display: none;">
<div id="settings-tabs"> <div id="options-tabs">
<ul> <ul>
<li><a href="#change-password">Change password</a></li> <li><a href="#change-password">Change password</a></li>
<li><a href="#protected-session-timeout">Protected session</a></li> <li><a href="#protected-session-timeout">Protected session</a></li>