added option to disable tray, closes #2612

This commit is contained in:
zadam 2022-11-18 21:47:14 +01:00
parent 1a95e459eb
commit 02d908df1e
9 changed files with 45 additions and 27 deletions

View File

@ -50,21 +50,21 @@ export default class BackupOptions {
this.$dailyBackupEnabled.on('change', () => { this.$dailyBackupEnabled.on('change', () => {
const opts = { 'dailyBackupEnabled': this.$dailyBackupEnabled.is(":checked") ? "true" : "false" }; 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; return false;
}); });
this.$weeklyBackupEnabled.on('change', () => { this.$weeklyBackupEnabled.on('change', () => {
const opts = { 'weeklyBackupEnabled': this.$weeklyBackupEnabled.is(":checked") ? "true" : "false" }; 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; return false;
}); });
this.$monthlyBackupEnabled.on('change', () => { this.$monthlyBackupEnabled.on('change', () => {
const opts = { 'monthlyBackupEnabled': this.$monthlyBackupEnabled.is(":checked") ? "true" : "false" }; 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; return false;
}); });

View File

@ -61,7 +61,7 @@ export default class CodeNotesOptions {
this.$autoReadonlySizeCode = $("#auto-readonly-size-code"); this.$autoReadonlySizeCode = $("#auto-readonly-size-code");
this.$autoReadonlySizeCode.on('change', () => { this.$autoReadonlySizeCode.on('change', () => {
const opts = { 'autoReadonlySizeCode': this.$autoReadonlySizeCode.val() }; 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; return false;
}); });

View File

@ -39,14 +39,14 @@ export default class ImageOptions {
this.$imageMaxWidthHeight.on('change', () => { this.$imageMaxWidthHeight.on('change', () => {
const opts = { 'imageMaxWidthHeight': this.$imageMaxWidthHeight.val() }; 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; return false;
}); });
this.$imageJpegQuality.on('change', () => { this.$imageJpegQuality.on('change', () => {
const opts = { 'imageJpegQuality': this.$imageJpegQuality.val() }; 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; return false;
}); });
@ -57,7 +57,7 @@ export default class ImageOptions {
const isChecked = this.$downloadImagesAutomatically.prop("checked"); const isChecked = this.$downloadImagesAutomatically.prop("checked");
const opts = { 'downloadImagesAutomatically': isChecked ? 'true' : 'false' }; 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"); this.$enableImageCompression = $("#image-compresion-enabled");
@ -75,7 +75,7 @@ export default class ImageOptions {
const isChecked = this.$enableImageCompression.prop("checked"); const isChecked = this.$enableImageCompression.prop("checked");
const opts = { 'compressImages': isChecked ? 'true' : 'false' }; 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); this.setImageCompression(isChecked);
}); });

View File

@ -1,8 +1,17 @@
import utils from "../../../services/utils.js";
import server from "../../../services/server.js"; import server from "../../../services/server.js";
import toastService from "../../../services/toast.js"; import toastService from "../../../services/toast.js";
const TPL = ` const TPL = `
<div>
<h4>Tray</h4>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="tray-enabled">
<label class="custom-control-label" for="tray-enabled">Enable tray (Trilium needs to be restarted for this change to take effect)</label>
</div>
<br/>
</div>
<div> <div>
<h4>Note erasure timeout</h4> <h4>Note erasure timeout</h4>
@ -35,27 +44,33 @@ const TPL = `
</div> </div>
<div> <div>
<h4>Network connections</h4> <h4>Network connections</h4>
<div class="form-group"> <div class="form-group">
<input id="check-for-updates" type="checkbox" name="check-for-updates"> <input id="check-for-updates" type="checkbox" name="check-for-updates">
<label for="check-for-updates">Check for updates automatically</label> <label for="check-for-updates">Check for updates automatically</label>
</div> </div>
</div> </div>`;
`;
export default class OtherOptions { export default class OtherOptions {
constructor() { constructor() {
$("#options-other").html(TPL); $("#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 = $("#erase-entities-after-time-in-seconds");
this.$eraseEntitiesAfterTimeInSeconds.on('change', () => { this.$eraseEntitiesAfterTimeInSeconds.on('change', () => {
const eraseEntitiesAfterTimeInSeconds = this.$eraseEntitiesAfterTimeInSeconds.val(); const eraseEntitiesAfterTimeInSeconds = this.$eraseEntitiesAfterTimeInSeconds.val();
server.put('options', { 'eraseEntitiesAfterTimeInSeconds': eraseEntitiesAfterTimeInSeconds }).then(() => { server.put('options', { 'eraseEntitiesAfterTimeInSeconds': eraseEntitiesAfterTimeInSeconds }).then(() => {
toastService.showMessage("Options changed have been saved."); toastService.showMessage("Options change have been saved.");
}); });
return false; return false;
@ -72,7 +87,7 @@ export default class OtherOptions {
this.$noteRevisionsTimeInterval.on('change', () => { this.$noteRevisionsTimeInterval.on('change', () => {
const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() }; 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; return false;
}); });
@ -82,11 +97,13 @@ export default class OtherOptions {
const isChecked = this.$checkForUpdates.prop("checked"); const isChecked = this.$checkForUpdates.prop("checked");
const opts = { 'checkForUpdates': isChecked ? 'true' : 'false' }; 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) { optionsLoaded(options) {
this.$trayEnabled.prop("checked", options['disableTray'] !== 'true');
this.$eraseEntitiesAfterTimeInSeconds.val(options['eraseEntitiesAfterTimeInSeconds']); this.$eraseEntitiesAfterTimeInSeconds.val(options['eraseEntitiesAfterTimeInSeconds']);
this.$noteRevisionsTimeInterval.val(options['noteRevisionSnapshotTimeInterval']); this.$noteRevisionsTimeInterval.val(options['noteRevisionSnapshotTimeInterval']);

View File

@ -77,7 +77,7 @@ export default class PasswordOptions {
const protectedSessionTimeout = this.$protectedSessionTimeout.val(); const protectedSessionTimeout = this.$protectedSessionTimeout.val();
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => { server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
toastService.showMessage("Options changed have been saved."); toastService.showMessage("Options change have been saved.");
}); });
return false; return false;

View File

@ -41,14 +41,14 @@ export default class SpellcheckOptions {
this.$spellCheckEnabled.on('change', () => { this.$spellCheckEnabled.on('change', () => {
const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" }; 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; return false;
}); });
this.$spellCheckLanguageCode.on('change', () => { this.$spellCheckLanguageCode.on('change', () => {
const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() }; 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; return false;
}); });

View File

@ -74,7 +74,7 @@ export default class SyncOptions {
'syncProxy': this.$syncProxy.val() '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; return false;
} }

View File

@ -62,7 +62,7 @@ export default class TextNotesOptions {
this.$autoReadonlySizeText.on('change', () => { this.$autoReadonlySizeText.on('change', () => {
const opts = { 'autoReadonlySizeText': this.$autoReadonlySizeText.val() }; 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; return false;
}); });

View File

@ -59,7 +59,8 @@ const ALLOWED_OPTIONS = new Set([
'compressImages', 'compressImages',
'downloadImagesAutomatically', 'downloadImagesAutomatically',
'minTocHeadings', 'minTocHeadings',
'checkForUpdates' 'checkForUpdates',
'disableTray'
]); ]);
function getOptions() { function getOptions() {