From f3662d1048c0aaa91d76dd0d494ca569879a75d5 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:01:27 -0400 Subject: [PATCH 1/6] Add network configuration --- src/public/app/widgets/buttons/global_menu.js | 11 +++++--- .../app/widgets/dialogs/options/other.js | 27 +++++++++++++++++-- src/routes/api/options.js | 3 ++- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.js index 6dc1295c3..9608c2f34 100644 --- a/src/public/app/widgets/buttons/global_menu.js +++ b/src/public/app/widgets/buttons/global_menu.js @@ -1,6 +1,7 @@ import BasicWidget from "../basic_widget.js"; import utils from "../../services/utils.js"; import UpdateAvailableWidget from "./update_available.js"; +import options from "../../services/options.js"; const TPL = ` -`; + +
+

Network connections

+ +
+ + +
+
+ +`; export default class ProtectedSessionOptions { constructor() { @@ -142,7 +152,7 @@ export default class ProtectedSessionOptions { this.$availableLanguageCodes = $("#available-language-codes"); if (utils.isElectron()) { - const {webContents} = utils.dynamicRequire('@electron/remote').getCurrentWindow(); + const { webContents } = utils.dynamicRequire('@electron/remote').getCurrentWindow(); this.$availableLanguageCodes.text(webContents.session.availableSpellCheckerLanguages.join(', ')); } @@ -250,6 +260,14 @@ export default class ProtectedSessionOptions { this.setImageCompression(isChecked); }); + + this.$checkForUpdates = $("#check-for-updates"); + this.$checkForUpdates.on("change", () => { + const isChecked = this.$checkForUpdates.prop("checked"); + const opts = { 'checkForUpdates': isChecked ? 'true' : 'false' }; + + server.put('options', opts).then(() => toastService.showMessage("Options changed have been saved.")); + }); } optionsLoaded(options) { @@ -272,5 +290,10 @@ export default class ProtectedSessionOptions { const compressImages = options['compressImages'] === 'true'; this.$enableImageCompression.prop('checked', compressImages); this.setImageCompression(compressImages); + + + const checkForUpdates = options['checkForUpdates'] === 'true'; + this.$checkForUpdates.prop('checked', checkForUpdates); + } } diff --git a/src/routes/api/options.js b/src/routes/api/options.js index 6fd89cdf1..916a89f11 100644 --- a/src/routes/api/options.js +++ b/src/routes/api/options.js @@ -57,7 +57,8 @@ const ALLOWED_OPTIONS = new Set([ 'maxContentWidth', 'compressImages', 'downloadImagesAutomatically', - 'minTocHeadings' + 'minTocHeadings', + 'checkForUpdates' ]); function getOptions() { From 500946c10bcb4710afb70e978de8fedd46569b43 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:09:59 -0400 Subject: [PATCH 2/6] Fix type --- src/public/app/widgets/buttons/global_menu.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/app/widgets/buttons/global_menu.js b/src/public/app/widgets/buttons/global_menu.js index 9608c2f34..658b24d00 100644 --- a/src/public/app/widgets/buttons/global_menu.js +++ b/src/public/app/widgets/buttons/global_menu.js @@ -157,7 +157,7 @@ export default class GlobalMenuWidget extends BasicWidget { } async updateVersionStatus() { - if (!options.get("checkForUpdates")) { + if (options.get("checkForUpdates") == 'true') { const latestVersion = await this.fetchLatestVersion(); this.updateAvailableWidget.updateVersionStatus(latestVersion); From e42c527a19f2e0bedfef13221bf51a545bf42f24 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:23:10 -0400 Subject: [PATCH 3/6] Add default setting --- src/services/options_init.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/options_init.js b/src/services/options_init.js index 6ee05c06c..e5a13b4da 100644 --- a/src/services/options_init.js +++ b/src/services/options_init.js @@ -85,7 +85,8 @@ const defaultOptions = [ { name: 'maxContentWidth', value: '1200', isSynced: false }, { name: 'compressImages', value: 'true', isSynced: true }, { name: 'downloadImagesAutomatically', value: 'true', isSynced: true }, - { name: 'minTocHeadings', value: '5', isSynced: true } + { name: 'minTocHeadings', value: '5', isSynced: true }, + { name: 'checkForUpdates', value: 'true', isSynced: true }, ]; function initStartupOptions() { From 20975fc635e167dc732d5b3c7e1a917d96802fbb Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:55:57 -0400 Subject: [PATCH 4/6] Add option to check for updates when setting up server --- src/routes/login.js | 2 ++ src/views/set_password.ejs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/routes/login.js b/src/routes/login.js index 3431f3431..03d236e97 100644 --- a/src/routes/login.js +++ b/src/routes/login.js @@ -5,6 +5,7 @@ const optionService = require('../services/options'); const myScryptService = require('../services/my_scrypt'); const log = require('../services/log'); const passwordService = require("../services/password"); +const options = require('../services/options'); function loginPage(req, res) { res.render('login', { failedAuth: false }); @@ -36,6 +37,7 @@ function setPassword(req, res) { return; } + options.setOption("checkForUpdates", req.body['check-for-updates'] == true); passwordService.setPassword(password1); res.redirect('login'); diff --git a/src/views/set_password.ejs b/src/views/set_password.ejs index d9079c264..e0a8d60f5 100644 --- a/src/views/set_password.ejs +++ b/src/views/set_password.ejs @@ -33,6 +33,11 @@ +
+ + +
+
From cce55eee63b7d142b99c39ae1790840f97be84b3 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Tue, 19 Jul 2022 16:59:27 -0400 Subject: [PATCH 5/6] Make updates default checked --- src/views/set_password.ejs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/set_password.ejs b/src/views/set_password.ejs index e0a8d60f5..0768f4825 100644 --- a/src/views/set_password.ejs +++ b/src/views/set_password.ejs @@ -34,7 +34,7 @@
- +
From fb1b6ea34ade240b785b9bcbf101e9b95fded7d4 Mon Sep 17 00:00:00 2001 From: sigaloid <69441971+sigaloid@users.noreply.github.com> Date: Tue, 19 Jul 2022 17:08:58 -0400 Subject: [PATCH 6/6] Fix login setting --- src/routes/login.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/login.js b/src/routes/login.js index 03d236e97..bd29e0765 100644 --- a/src/routes/login.js +++ b/src/routes/login.js @@ -37,7 +37,7 @@ function setPassword(req, res) { return; } - options.setOption("checkForUpdates", req.body['check-for-updates'] == true); + options.setOption("checkForUpdates", req.body['check-for-updates'] == 'on'); passwordService.setPassword(password1); res.redirect('login');