2020-04-20 22:26:31 +02:00
|
|
|
import utils from "../../services/utils.js";
|
2019-10-06 21:35:26 +02:00
|
|
|
import server from "../../services/server.js";
|
2019-10-20 10:00:18 +02:00
|
|
|
import toastService from "../../services/toast.js";
|
2019-10-06 21:35:26 +02:00
|
|
|
|
2019-11-03 19:06:22 +01:00
|
|
|
const TPL = `
|
|
|
|
<div>
|
|
|
|
<h4>Spell check</h4>
|
|
|
|
|
2020-01-10 19:56:27 +01:00
|
|
|
<p>These options apply only for desktop builds, browsers will use their own native spell check. App restart is required after change.</p>
|
2019-11-03 19:06:22 +01:00
|
|
|
|
|
|
|
<div class="custom-control custom-checkbox">
|
|
|
|
<input type="checkbox" class="custom-control-input" id="spell-check-enabled">
|
|
|
|
<label class="custom-control-label" for="spell-check-enabled">Enable spellcheck</label>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<br/>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2020-02-28 22:07:08 +01:00
|
|
|
<label for="spell-check-language-code">Language code(s)</label>
|
2019-11-24 10:44:09 +01:00
|
|
|
<input type="text" class="form-control" id="spell-check-language-code" placeholder="for example "en-US", "de-AT"">
|
2019-11-03 19:06:22 +01:00
|
|
|
</div>
|
|
|
|
|
2020-04-20 22:26:31 +02:00
|
|
|
<p>Multiple languages can be separated by comma, e.g. <code>en-US, de-DE, cs</code>. Changes to the spell check options will take effect after application restart.</p>
|
|
|
|
|
|
|
|
<p><strong>Available language codes: </strong> <span id="available-language-codes"></span></p>
|
2019-11-03 19:06:22 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<h4>Image compression</h4>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2019-11-09 17:39:48 +01:00
|
|
|
<label for="image-max-width-height">Max width / height of an image in pixels (image will be resized if it exceeds this setting).</label>
|
2019-11-03 19:06:22 +01:00
|
|
|
<input class="form-control" id="image-max-width-height" type="number">
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="form-group">
|
2019-11-09 17:39:48 +01:00
|
|
|
<label for="image-jpeg-quality">JPEG quality (0 - worst quality, 100 best quality, 50 - 85 is recommended)</label>
|
2019-11-03 19:06:22 +01:00
|
|
|
<input class="form-control" id="image-jpeg-quality" min="0" max="100" type="number">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2020-01-03 22:32:49 +01:00
|
|
|
<div>
|
|
|
|
<h4>Note erasure timeout</h4>
|
|
|
|
|
|
|
|
<p>Deleted notes are at first only marked as deleted and it is possible to recover them
|
2020-07-24 16:03:39 -04:00
|
|
|
from Recent Notes dialog. After a period of time, deleted notes are "erased" which means
|
2020-01-03 22:32:49 +01:00
|
|
|
their content is not recoverable anymore. This setting allows you to configure the length
|
|
|
|
of the period between deleting and erasing the note.</p>
|
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="erase-notes-after-time-in-seconds">Erase notes after X seconds</label>
|
|
|
|
<input class="form-control" id="erase-notes-after-time-in-seconds" type="number" min="0">
|
|
|
|
</div>
|
2020-12-06 22:11:49 +01:00
|
|
|
|
|
|
|
<p>You can also trigger erasing manually:</p>
|
|
|
|
|
|
|
|
<button id="erase-deleted-notes-now-button" class="btn">Erase deleted notes now</button>
|
|
|
|
|
|
|
|
<br/><br/>
|
2020-01-03 22:32:49 +01:00
|
|
|
</div>
|
|
|
|
|
2019-11-03 19:06:22 +01:00
|
|
|
<div>
|
|
|
|
<h4>Protected session timeout</h4>
|
|
|
|
|
2020-07-24 16:03:39 -04:00
|
|
|
<p>Protected session timeout is a time period after which the protected session is wiped from
|
|
|
|
the browser's memory. This is measured from the last interaction with protected notes. See <a href="https://github.com/zadam/trilium/wiki/Protected-notes" class="external">wiki</a> for more info.</p>
|
2019-11-03 19:06:22 +01:00
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="protected-session-timeout-in-seconds">Protected session timeout (in seconds)</label>
|
|
|
|
<input class="form-control" id="protected-session-timeout-in-seconds" type="number">
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<h4>Note revisions snapshot interval</h4>
|
|
|
|
|
2020-07-24 16:03:39 -04:00
|
|
|
<p>Note revision snapshot time interval is time in seconds after which a new note revision will be created for the note. See <a href="https://github.com/zadam/trilium/wiki/Note-revisions" class="external">wiki</a> for more info.</p>
|
2019-11-03 19:06:22 +01:00
|
|
|
|
|
|
|
<div class="form-group">
|
|
|
|
<label for="note-revision-snapshot-time-interval-in-seconds">Note revision snapshot time interval (in seconds)</label>
|
|
|
|
<input class="form-control" id="note-revision-snapshot-time-interval-in-seconds" type="number">
|
|
|
|
</div>
|
|
|
|
</div>`;
|
|
|
|
|
2019-10-06 21:35:26 +02:00
|
|
|
export default class ProtectedSessionOptions {
|
|
|
|
constructor() {
|
2019-11-03 19:06:22 +01:00
|
|
|
$("#options-other").html(TPL);
|
|
|
|
|
2019-10-06 21:35:26 +02:00
|
|
|
this.$spellCheckEnabled = $("#spell-check-enabled");
|
|
|
|
this.$spellCheckLanguageCode = $("#spell-check-language-code");
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$spellCheckEnabled.on('change', () => {
|
2019-10-06 21:35:26 +02:00
|
|
|
const opts = { 'spellCheckEnabled': this.$spellCheckEnabled.is(":checked") ? "true" : "false" };
|
2019-10-20 10:00:18 +02:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
|
2019-10-06 21:35:26 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$spellCheckLanguageCode.on('change', () => {
|
2019-10-06 21:35:26 +02:00
|
|
|
const opts = { 'spellCheckLanguageCode': this.$spellCheckLanguageCode.val() };
|
2019-10-20 10:00:18 +02:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
|
2019-10-06 21:35:26 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-04-20 22:26:31 +02:00
|
|
|
this.$availableLanguageCodes = $("#available-language-codes");
|
|
|
|
|
|
|
|
if (utils.isElectron()) {
|
|
|
|
const {webContents} = utils.dynamicRequire('electron').remote.getCurrentWindow();
|
|
|
|
|
|
|
|
this.$availableLanguageCodes.text(webContents.session.availableSpellCheckerLanguages.join(', '));
|
|
|
|
}
|
|
|
|
|
2020-01-03 22:32:49 +01:00
|
|
|
this.$eraseNotesAfterTimeInSeconds = $("#erase-notes-after-time-in-seconds");
|
|
|
|
|
|
|
|
this.$eraseNotesAfterTimeInSeconds.on('change', () => {
|
|
|
|
const eraseNotesAfterTimeInSeconds = this.$eraseNotesAfterTimeInSeconds.val();
|
|
|
|
|
|
|
|
server.put('options', { 'eraseNotesAfterTimeInSeconds': eraseNotesAfterTimeInSeconds }).then(() => {
|
|
|
|
toastService.showMessage("Options change have been saved.");
|
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2020-12-06 22:11:49 +01:00
|
|
|
this.$eraseDeletedNotesButton = $("#erase-deleted-notes-now-button");
|
|
|
|
this.$eraseDeletedNotesButton.on('click', () => {
|
|
|
|
server.post('notes/erase-deleted-notes-now').then(() => {
|
|
|
|
toastService.showMessage("Deleted notes have been erased.");
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2019-11-03 17:59:11 +01:00
|
|
|
this.$protectedSessionTimeout = $("#protected-session-timeout-in-seconds");
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$protectedSessionTimeout.on('change', () => {
|
2019-10-06 21:35:26 +02:00
|
|
|
const protectedSessionTimeout = this.$protectedSessionTimeout.val();
|
|
|
|
|
|
|
|
server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => {
|
2019-10-20 10:00:18 +02:00
|
|
|
toastService.showMessage("Options change have been saved.");
|
2019-10-06 21:35:26 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-11-03 17:59:11 +01:00
|
|
|
this.$noteRevisionsTimeInterval = $("#note-revision-snapshot-time-interval-in-seconds");
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$noteRevisionsTimeInterval.on('change', () => {
|
2019-10-06 21:35:26 +02:00
|
|
|
const opts = { 'noteRevisionSnapshotTimeInterval': this.$noteRevisionsTimeInterval.val() };
|
2019-10-20 10:00:18 +02:00
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
|
2019-10-06 21:35:26 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2019-11-03 17:59:11 +01:00
|
|
|
|
|
|
|
this.$imageMaxWidthHeight = $("#image-max-width-height");
|
|
|
|
this.$imageJpegQuality = $("#image-jpeg-quality");
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$imageMaxWidthHeight.on('change', () => {
|
2019-11-03 17:59:11 +01:00
|
|
|
const opts = { 'imageMaxWidthHeight': this.$imageMaxWidthHeight.val() };
|
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-11-09 17:39:48 +01:00
|
|
|
this.$imageJpegQuality.on('change', () => {
|
2019-11-03 17:59:11 +01:00
|
|
|
const opts = { 'imageJpegQuality': this.$imageJpegQuality.val() };
|
|
|
|
server.put('options', opts).then(() => toastService.showMessage("Options change have been saved."));
|
|
|
|
|
|
|
|
return false;
|
|
|
|
});
|
2019-10-06 21:35:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
optionsLoaded(options) {
|
|
|
|
this.$spellCheckEnabled.prop("checked", options['spellCheckEnabled'] === 'true');
|
|
|
|
this.$spellCheckLanguageCode.val(options['spellCheckLanguageCode']);
|
|
|
|
|
2020-01-03 22:32:49 +01:00
|
|
|
this.$eraseNotesAfterTimeInSeconds.val(options['eraseNotesAfterTimeInSeconds']);
|
2019-10-06 21:35:26 +02:00
|
|
|
this.$protectedSessionTimeout.val(options['protectedSessionTimeout']);
|
|
|
|
this.$noteRevisionsTimeInterval.val(options['noteRevisionSnapshotTimeInterval']);
|
2019-11-03 17:59:11 +01:00
|
|
|
|
|
|
|
this.$imageMaxWidthHeight.val(options['imageMaxWidthHeight']);
|
|
|
|
this.$imageJpegQuality.val(options['imageJpegQuality']);
|
2019-10-06 21:35:26 +02:00
|
|
|
}
|
2019-11-24 10:44:09 +01:00
|
|
|
}
|