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', () => {
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;
});

View File

@ -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;
});

View File

@ -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);
});

View File

@ -1,8 +1,17 @@
import utils from "../../../services/utils.js";
import server from "../../../services/server.js";
import toastService from "../../../services/toast.js";
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>
<h4>Note erasure timeout</h4>
@ -35,27 +44,33 @@ const TPL = `
</div>
<div>
<h4>Network connections</h4>
<div class="form-group">
<input id="check-for-updates" type="checkbox" name="check-for-updates">
<label for="check-for-updates">Check for updates automatically</label>
</div>
</div>
`;
<h4>Network connections</h4>
<div class="form-group">
<input id="check-for-updates" type="checkbox" name="check-for-updates">
<label for="check-for-updates">Check for updates automatically</label>
</div>
</div>`;
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']);

View File

@ -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;

View File

@ -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;
});

View File

@ -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;
}

View File

@ -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;
});

View File

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