From 02d908df1e0a46b1ff18a69f47b524b0ddd258fb Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 18 Nov 2022 21:47:14 +0100 Subject: [PATCH] added option to disable tray, closes #2612 --- .../app/widgets/dialogs/options/backup.js | 6 +-- .../app/widgets/dialogs/options/code_notes.js | 2 +- .../app/widgets/dialogs/options/images.js | 8 ++-- .../app/widgets/dialogs/options/other.js | 43 +++++++++++++------ .../app/widgets/dialogs/options/password.js | 2 +- .../app/widgets/dialogs/options/spellcheck.js | 4 +- .../app/widgets/dialogs/options/sync.js | 2 +- .../app/widgets/dialogs/options/text_notes.js | 2 +- src/routes/api/options.js | 3 +- 9 files changed, 45 insertions(+), 27 deletions(-) diff --git a/src/public/app/widgets/dialogs/options/backup.js b/src/public/app/widgets/dialogs/options/backup.js index b5cd87939..ac24da58b 100644 --- a/src/public/app/widgets/dialogs/options/backup.js +++ b/src/public/app/widgets/dialogs/options/backup.js @@ -50,21 +50,21 @@ export default class BackupOptions { this.$dailyBackupEnabled.on('change', () => { const opts = { 'dailyBackupEnabled': this.$dailyBackupEnabled.is(":checked") ? "true" : "false" }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); this.$weeklyBackupEnabled.on('change', () => { const opts = { 'weeklyBackupEnabled': this.$weeklyBackupEnabled.is(":checked") ? "true" : "false" }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); this.$monthlyBackupEnabled.on('change', () => { const opts = { 'monthlyBackupEnabled': this.$monthlyBackupEnabled.is(":checked") ? "true" : "false" }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); diff --git a/src/public/app/widgets/dialogs/options/code_notes.js b/src/public/app/widgets/dialogs/options/code_notes.js index 335c8b922..be4079ee5 100644 --- a/src/public/app/widgets/dialogs/options/code_notes.js +++ b/src/public/app/widgets/dialogs/options/code_notes.js @@ -61,7 +61,7 @@ export default class CodeNotesOptions { this.$autoReadonlySizeCode = $("#auto-readonly-size-code"); this.$autoReadonlySizeCode.on('change', () => { const opts = { 'autoReadonlySizeCode': this.$autoReadonlySizeCode.val() }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); diff --git a/src/public/app/widgets/dialogs/options/images.js b/src/public/app/widgets/dialogs/options/images.js index 699d6c06d..8965bf9f1 100644 --- a/src/public/app/widgets/dialogs/options/images.js +++ b/src/public/app/widgets/dialogs/options/images.js @@ -39,14 +39,14 @@ export default class ImageOptions { this.$imageMaxWidthHeight.on('change', () => { const opts = { 'imageMaxWidthHeight': this.$imageMaxWidthHeight.val() }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); this.$imageJpegQuality.on('change', () => { const opts = { 'imageJpegQuality': this.$imageJpegQuality.val() }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); @@ -57,7 +57,7 @@ export default class ImageOptions { const isChecked = this.$downloadImagesAutomatically.prop("checked"); const opts = { 'downloadImagesAutomatically': isChecked ? 'true' : 'false' }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); }); this.$enableImageCompression = $("#image-compresion-enabled"); @@ -75,7 +75,7 @@ export default class ImageOptions { const isChecked = this.$enableImageCompression.prop("checked"); const opts = { 'compressImages': isChecked ? 'true' : 'false' }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); this.setImageCompression(isChecked); }); diff --git a/src/public/app/widgets/dialogs/options/other.js b/src/public/app/widgets/dialogs/options/other.js index 6f4a8919d..1ba16369d 100644 --- a/src/public/app/widgets/dialogs/options/other.js +++ b/src/public/app/widgets/dialogs/options/other.js @@ -1,8 +1,17 @@ -import utils from "../../../services/utils.js"; import server from "../../../services/server.js"; import toastService from "../../../services/toast.js"; const TPL = ` +
+

Tray

+ +
+ + +
+
+
+

Note erasure timeout

@@ -35,27 +44,33 @@ const TPL = `
-

Network connections

- -
- - -
-
- -`; +

Network connections

+ +
+ + +
+`; export default class OtherOptions { constructor() { $("#options-other").html(TPL); + this.$trayEnabled = $("#tray-enabled"); + this.$trayEnabled.on('change', () => { + const opts = { 'disableTray': !this.$trayEnabled.is(":checked") ? "true" : "false" }; + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); + + return false; + }); + this.$eraseEntitiesAfterTimeInSeconds = $("#erase-entities-after-time-in-seconds"); this.$eraseEntitiesAfterTimeInSeconds.on('change', () => { const eraseEntitiesAfterTimeInSeconds = this.$eraseEntitiesAfterTimeInSeconds.val(); server.put('options', { 'eraseEntitiesAfterTimeInSeconds': eraseEntitiesAfterTimeInSeconds }).then(() => { - toastService.showMessage("Options changed have been saved."); + toastService.showMessage("Options change have been saved."); }); return false; @@ -72,7 +87,7 @@ export default class OtherOptions { this.$noteRevisionsTimeInterval.on('change', () => { const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); @@ -82,11 +97,13 @@ export default class OtherOptions { const isChecked = this.$checkForUpdates.prop("checked"); const opts = { 'checkForUpdates': isChecked ? 'true' : 'false' }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); }); } optionsLoaded(options) { + this.$trayEnabled.prop("checked", options['disableTray'] !== 'true'); + this.$eraseEntitiesAfterTimeInSeconds.val(options['eraseEntitiesAfterTimeInSeconds']); this.$noteRevisionsTimeInterval.val(options['noteRevisionSnapshotTimeInterval']); diff --git a/src/public/app/widgets/dialogs/options/password.js b/src/public/app/widgets/dialogs/options/password.js index 31816344b..82c9b0cf6 100644 --- a/src/public/app/widgets/dialogs/options/password.js +++ b/src/public/app/widgets/dialogs/options/password.js @@ -77,7 +77,7 @@ export default class PasswordOptions { const protectedSessionTimeout = this.$protectedSessionTimeout.val(); server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => { - toastService.showMessage("Options changed have been saved."); + toastService.showMessage("Options change have been saved."); }); return false; diff --git a/src/public/app/widgets/dialogs/options/spellcheck.js b/src/public/app/widgets/dialogs/options/spellcheck.js index cba354f5a..5e4db3838 100644 --- a/src/public/app/widgets/dialogs/options/spellcheck.js +++ b/src/public/app/widgets/dialogs/options/spellcheck.js @@ -41,14 +41,14 @@ export default class SpellcheckOptions { this.$spellCheckEnabled.on('change', () => { const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); this.$spellCheckLanguageCode.on('change', () => { const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); diff --git a/src/public/app/widgets/dialogs/options/sync.js b/src/public/app/widgets/dialogs/options/sync.js index af3dc7838..fa2122ce3 100644 --- a/src/public/app/widgets/dialogs/options/sync.js +++ b/src/public/app/widgets/dialogs/options/sync.js @@ -74,7 +74,7 @@ export default class SyncOptions { 'syncProxy': this.$syncProxy.val() }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; } diff --git a/src/public/app/widgets/dialogs/options/text_notes.js b/src/public/app/widgets/dialogs/options/text_notes.js index 524208ab2..64ca1f1be 100644 --- a/src/public/app/widgets/dialogs/options/text_notes.js +++ b/src/public/app/widgets/dialogs/options/text_notes.js @@ -62,7 +62,7 @@ export default class TextNotesOptions { this.$autoReadonlySizeText.on('change', () => { const opts = { 'autoReadonlySizeText': this.$autoReadonlySizeText.val() }; - server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); return false; }); diff --git a/src/routes/api/options.js b/src/routes/api/options.js index 07def4479..e8e7bfe08 100644 --- a/src/routes/api/options.js +++ b/src/routes/api/options.js @@ -59,7 +59,8 @@ const ALLOWED_OPTIONS = new Set([ 'compressImages', 'downloadImagesAutomatically', 'minTocHeadings', - 'checkForUpdates' + 'checkForUpdates', + 'disableTray' ]); function getOptions() {