| 
									
										
										
										
											2019-10-06 21:35:26 +02:00
										 |  |  | import optionsService from "../../services/options.js"; | 
					
						
							|  |  |  | 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> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <p>These options apply only for desktop builds, browsers will use their own native spell check.</p> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <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"> | 
					
						
							|  |  |  |         <label for="spell-check-language-code">Language code</label> | 
					
						
							|  |  |  |         <input type="email" class="form-control" id="spell-check-language-code" placeholder="for example "en-US", "de-AT""> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <p>Changes to the spell check options will take effect after application restart.</p> | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <div> | 
					
						
							|  |  |  |     <h4>Image compression</h4> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <div class="form-group"> | 
					
						
							|  |  |  |         <label for="image-max-width-height">Max width / height of an image in pixels (if image will be resized if it exceeds this setting).</label> | 
					
						
							|  |  |  |         <input class="form-control" id="image-max-width-height" type="number"> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <div class="form-group"> | 
					
						
							|  |  |  |         <label for="image-jpeg-quality">JPEG quality (0 - worst quality, 100 best quality)</label> | 
					
						
							|  |  |  |         <input class="form-control" id="image-jpeg-quality" min="0" max="100" type="number"> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  | </div> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | <div> | 
					
						
							|  |  |  |     <h4>Protected session timeout</h4> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <p>Protected session timeout is a time period after which the protected session is wiped out from | 
					
						
							|  |  |  |         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> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <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> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <p>Note revision snapshot time interval is time in seconds after which 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> | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     <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"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.$spellCheckEnabled.change(() => { | 
					
						
							|  |  |  |             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; | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.$spellCheckLanguageCode.change(() => { | 
					
						
							|  |  |  |             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; | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-11-03 17:59:11 +01:00
										 |  |  |         this.$protectedSessionTimeout = $("#protected-session-timeout-in-seconds"); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-10-06 21:35:26 +02:00
										 |  |  |         this.$protectedSessionTimeout.change(() => { | 
					
						
							|  |  |  |             const protectedSessionTimeout = this.$protectedSessionTimeout.val(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             server.put('options', { 'protectedSessionTimeout': protectedSessionTimeout }).then(() => { | 
					
						
							|  |  |  |                 optionsService.reloadOptions(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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-10-06 21:35:26 +02:00
										 |  |  |         this.$noteRevisionsTimeInterval.change(() => { | 
					
						
							|  |  |  |             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"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.$imageMaxWidthHeight.change(() => { | 
					
						
							|  |  |  |             const opts = { 'imageMaxWidthHeight': this.$imageMaxWidthHeight.val() }; | 
					
						
							|  |  |  |             server.put('options', opts).then(() => toastService.showMessage("Options change have been saved.")); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         this.$imageJpegQuality.change(() => { | 
					
						
							|  |  |  |             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']); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         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
										 |  |  |     } | 
					
						
							|  |  |  | } |