mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	renamed settings to options for consistency
This commit is contained in:
		| @@ -5,8 +5,8 @@ import utils from '../services/utils.js'; | ||||
| import server from '../services/server.js'; | ||||
| import infoService from "../services/info.js"; | ||||
| 
 | ||||
| const $dialog = $("#settings-dialog"); | ||||
| const $tabs = $("#settings-tabs"); | ||||
| const $dialog = $("#options-dialog"); | ||||
| const $tabs = $("#options-tabs"); | ||||
| 
 | ||||
| const tabHandlers = []; | ||||
| 
 | ||||
| @@ -17,7 +17,7 @@ function addTabHandler(handler) { | ||||
| async function showDialog() { | ||||
|     glob.activeDialog = $dialog; | ||||
| 
 | ||||
|     const settings = await server.get('settings'); | ||||
|     const options = await server.get('options'); | ||||
| 
 | ||||
|     $dialog.dialog({ | ||||
|         modal: true, | ||||
| @@ -27,24 +27,24 @@ async function showDialog() { | ||||
|     $tabs.tabs(); | ||||
| 
 | ||||
|     for (const handler of tabHandlers) { | ||||
|         if (handler.settingsLoaded) { | ||||
|             handler.settingsLoaded(settings); | ||||
|         if (handler.optionsLoaded) { | ||||
|             handler.optionsLoaded(options); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| async function saveSettings(settingName, settingValue) { | ||||
|     await server.post('settings', { | ||||
|         name: settingName, | ||||
|         value: settingValue | ||||
| async function saveOptions(optionName, optionValue) { | ||||
|     await server.post('options', { | ||||
|         name: optionName, | ||||
|         value: optionValue | ||||
|     }); | ||||
| 
 | ||||
|     infoService.showMessage("Settings change have been saved."); | ||||
|     infoService.showMessage("Options change have been saved."); | ||||
| } | ||||
| 
 | ||||
| export default { | ||||
|     showDialog, | ||||
|     saveSettings | ||||
|     saveOptions | ||||
| }; | ||||
| 
 | ||||
| addTabHandler((function() { | ||||
| @@ -53,7 +53,7 @@ addTabHandler((function() { | ||||
|     const $newPassword1 = $("#new-password1"); | ||||
|     const $newPassword2 = $("#new-password2"); | ||||
| 
 | ||||
|     function settingsLoaded(settings) { | ||||
|     function optionsLoaded(options) { | ||||
|     } | ||||
| 
 | ||||
|     $form.submit(() => { | ||||
| @@ -89,23 +89,23 @@ addTabHandler((function() { | ||||
|     }); | ||||
| 
 | ||||
|     return { | ||||
|         settingsLoaded | ||||
|         optionsLoaded | ||||
|     }; | ||||
| })()); | ||||
| 
 | ||||
| addTabHandler((function() { | ||||
|     const $form = $("#protected-session-timeout-form"); | ||||
|     const $protectedSessionTimeout = $("#protected-session-timeout-in-seconds"); | ||||
|     const settingName = 'protected_session_timeout'; | ||||
|     const optionName = 'protected_session_timeout'; | ||||
| 
 | ||||
|     function settingsLoaded(settings) { | ||||
|         $protectedSessionTimeout.val(settings[settingName]); | ||||
|     function optionsLoaded(options) { | ||||
|         $protectedSessionTimeout.val(options[optionName]); | ||||
|     } | ||||
| 
 | ||||
|     $form.submit(() => { | ||||
|         const protectedSessionTimeout = $protectedSessionTimeout.val(); | ||||
| 
 | ||||
|         saveSettings(settingName, protectedSessionTimeout).then(() => { | ||||
|         saveOptions(optionName, protectedSessionTimeout).then(() => { | ||||
|             protectedSessionHolder.setProtectedSessionTimeout(protectedSessionTimeout); | ||||
|         }); | ||||
| 
 | ||||
| @@ -113,27 +113,27 @@ addTabHandler((function() { | ||||
|     }); | ||||
| 
 | ||||
|     return { | ||||
|         settingsLoaded | ||||
|         optionsLoaded | ||||
|     }; | ||||
| })()); | ||||
| 
 | ||||
| addTabHandler((function () { | ||||
|     const $form = $("#note-revision-snapshot-time-interval-form"); | ||||
|     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) { | ||||
|         $timeInterval.val(settings[settingName]); | ||||
|     function optionsLoaded(options) { | ||||
|         $timeInterval.val(options[optionName]); | ||||
|     } | ||||
| 
 | ||||
|     $form.submit(() => { | ||||
|         saveSettings(settingName, $timeInterval.val()); | ||||
|         saveOptions(optionName, $timeInterval.val()); | ||||
| 
 | ||||
|         return false; | ||||
|     }); | ||||
| 
 | ||||
|     return { | ||||
|         settingsLoaded | ||||
|         optionsLoaded | ||||
|     }; | ||||
| })()); | ||||
| 
 | ||||
							
								
								
									
										2
									
								
								src/public/javascripts/services/bootstrap.js
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								src/public/javascripts/services/bootstrap.js
									
									
									
									
										vendored
									
									
								
							| @@ -5,7 +5,7 @@ import noteRevisionsDialog from '../dialogs/note_revisions.js'; | ||||
| import noteSourceDialog from '../dialogs/note_source.js'; | ||||
| import recentChangesDialog from '../dialogs/recent_changes.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 cloning from './cloning.js'; | ||||
|   | ||||
| @@ -76,7 +76,7 @@ function cut(nodes) { | ||||
|     infoService.showMessage("Note(s) have been cut into clipboard."); | ||||
| } | ||||
|  | ||||
| const contextMenuSettings = { | ||||
| const contextMenuOptions = { | ||||
|     delegate: "span.fancytree-title", | ||||
|     autoFocus: true, | ||||
|     menu: [ | ||||
| @@ -185,5 +185,5 @@ export default { | ||||
|     pasteInto, | ||||
|     cut, | ||||
|     copy, | ||||
|     contextMenuSettings | ||||
|     contextMenuOptions | ||||
| }; | ||||
| @@ -3,7 +3,7 @@ import treeService from "./tree.js"; | ||||
| import linkService from "./link.js"; | ||||
| import fileService from "./file.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 recentNotesDialog from "../dialogs/recent_notes.js"; | ||||
| import jumpToNoteDialog from "../dialogs/jump_to_note.js"; | ||||
| @@ -40,7 +40,7 @@ function registerEntrypoints() { | ||||
|     $(".show-labels-button").click(labelsDialog.showDialog); | ||||
|     utils.bindShortcut('alt+l', labelsDialog.showDialog); | ||||
|  | ||||
|     $("#settings-button").click(settingsDialog.showDialog); | ||||
|     $("#options-button").click(optionsDialog.showDialog); | ||||
|  | ||||
|     utils.bindShortcut('alt+o', sqlConsoleDialog.showDialog); | ||||
|  | ||||
|   | ||||
| @@ -8,7 +8,7 @@ function showMessage(message) { | ||||
|         // options | ||||
|         message: message | ||||
|     }, { | ||||
|         // settings | ||||
|         // options | ||||
|         type: 'success', | ||||
|         delay: 3000 | ||||
|     }); | ||||
| @@ -21,7 +21,7 @@ function showError(message, delay = 10000) { | ||||
|         // options | ||||
|         message: message | ||||
|     }, { | ||||
|         // settings | ||||
|         // options | ||||
|         type: 'danger', | ||||
|         delay: delay | ||||
|     }); | ||||
|   | ||||
| @@ -82,7 +82,7 @@ setTimeout(() => { | ||||
|                     // options | ||||
|                     message: "Lost connection to server" | ||||
|                 },{ | ||||
|                     // settings | ||||
|                     // options | ||||
|                     type: 'danger', | ||||
|                     delay: 100000000 // keep it until we explicitly close it | ||||
|                 }); | ||||
|   | ||||
| @@ -6,7 +6,7 @@ let protectedSessionTimeout = null; | ||||
| let protectedSessionId = null; | ||||
|  | ||||
| $(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(() => { | ||||
|   | ||||
| @@ -349,7 +349,7 @@ function initFancyTree(branch) { | ||||
|         } | ||||
|     }); | ||||
|  | ||||
|     $tree.contextmenu(contextMenuService.contextMenuSettings); | ||||
|     $tree.contextmenu(contextMenuService.contextMenuOptions); | ||||
| } | ||||
|  | ||||
| function getTree() { | ||||
|   | ||||
| @@ -3,21 +3,21 @@ | ||||
| const sql = require('../../services/sql'); | ||||
| 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']; | ||||
| 
 | ||||
| async function getAllSettings() { | ||||
| async function getAllOptions() { | ||||
|     return await sql.getMap("SELECT name, value FROM options"); | ||||
| } | ||||
| 
 | ||||
| async function getAllowedSettings() { | ||||
|     const settings = await sql.getMap("SELECT name, value FROM options WHERE name IN (" | ||||
| async function getAllowedOptions() { | ||||
|     const options = await sql.getMap("SELECT name, value FROM options WHERE name IN (" | ||||
|         + ALLOWED_OPTIONS.map(x => '?').join(",") + ")", ALLOWED_OPTIONS); | ||||
| 
 | ||||
|     return settings; | ||||
|     return options; | ||||
| } | ||||
| 
 | ||||
| async function updateSetting(req) { | ||||
| async function updateOption(req) { | ||||
|     const body = req.body; | ||||
| 
 | ||||
|     if (!ALLOWED_OPTIONS.includes(body['name'])) { | ||||
| @@ -28,7 +28,7 @@ async function updateSetting(req) { | ||||
| } | ||||
| 
 | ||||
| module.exports = { | ||||
|     getAllowedSettings, | ||||
|     getAllSettings, | ||||
|     updateSetting | ||||
|     getAllowedOptions, | ||||
|     getAllOptions, | ||||
|     updateOption | ||||
| }; | ||||
| @@ -11,7 +11,7 @@ const treeChangesApiRoute = require('./api/tree_changes'); | ||||
| const cloningApiRoute = require('./api/cloning'); | ||||
| const noteRevisionsApiRoute = require('./api/note_revisions'); | ||||
| const recentChangesApiRoute = require('./api/recent_changes'); | ||||
| const settingsApiRoute = require('./api/settings'); | ||||
| const optionsApiRoute = require('./api/options'); | ||||
| const passwordApiRoute = require('./api/password'); | ||||
| const migrationApiRoute = require('./api/migration'); | ||||
| const syncApiRoute = require('./api/sync'); | ||||
| @@ -126,9 +126,9 @@ function register(app) { | ||||
|  | ||||
|     apiRoute(GET, '/api/recent-changes', recentChangesApiRoute.getRecentChanges); | ||||
|  | ||||
|     apiRoute(GET, '/api/settings', settingsApiRoute.getAllowedSettings); | ||||
|     apiRoute(GET, '/api/settings/all', settingsApiRoute.getAllSettings); | ||||
|     apiRoute(POST, '/api/settings', settingsApiRoute.updateSetting); | ||||
|     apiRoute(GET, '/api/options', optionsApiRoute.getAllowedOptions); | ||||
|     apiRoute(GET, '/api/options/all', optionsApiRoute.getAllOptions); | ||||
|     apiRoute(POST, '/api/options', optionsApiRoute.updateOption); | ||||
|  | ||||
|     apiRoute(POST, '/api/password/change', passwordApiRoute.changePassword); | ||||
|  | ||||
|   | ||||
										
											Binary file not shown.
										
									
								
							| @@ -29,8 +29,8 @@ | ||||
|             Sync now (<span id="changes-to-push-count">0</span>) | ||||
|           </button> | ||||
|  | ||||
|           <button class="btn btn-xs" id="settings-button"> | ||||
|             <span class="ui-icon ui-icon-gear"></span> Settings</button> | ||||
|           <button class="btn btn-xs" id="options-button"> | ||||
|             <span class="ui-icon ui-icon-gear"></span> Options</button> | ||||
|  | ||||
|           <form action="logout" id="logout-button" method="POST" style="display: inline;"> | ||||
|             <input type="submit" class="btn btn-xs" value="Logout"> | ||||
| @@ -272,8 +272,8 @@ | ||||
|       </form> | ||||
|     </div> | ||||
|  | ||||
|     <div id="settings-dialog" title="Settings" style="display: none;"> | ||||
|       <div id="settings-tabs"> | ||||
|     <div id="options-dialog" title="Options" style="display: none;"> | ||||
|       <div id="options-tabs"> | ||||
|         <ul> | ||||
|           <li><a href="#change-password">Change password</a></li> | ||||
|           <li><a href="#protected-session-timeout">Protected session</a></li> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user