From f21ada43a013532c19e8ed80519b25e4a5f3337d Mon Sep 17 00:00:00 2001 From: Ignacio Pascual <4764217+ignapas@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:15:38 +0100 Subject: [PATCH 1/4] added inactivity and concurrency preferences --- .../client/source/class/osparc/Preferences.js | 16 ++++++++ .../desktop/preferences/pages/GeneralPage.js | 41 +++++++++++++++++++ .../users/_preferences_models.py | 5 +++ 3 files changed, 62 insertions(+) diff --git a/services/static-webserver/client/source/class/osparc/Preferences.js b/services/static-webserver/client/source/class/osparc/Preferences.js index 8961120e2c2..6e12c18b23a 100644 --- a/services/static-webserver/client/source/class/osparc/Preferences.js +++ b/services/static-webserver/client/source/class/osparc/Preferences.js @@ -98,6 +98,22 @@ qx.Class.define("osparc.Preferences", { init: "always", event: "changeWalletIndicatorVisibility", apply: "__patchPreference" + }, + + userInactivityThreshold: { + check: "Number", + nullable: false, + init: 1800, + event: "changeUserInactivityThreshold", + apply: "__patchPreference" + }, + + jobConcurrencyLimit: { + check: "Number", + nullable: false, + init: 4, + event: "changeJobConcurrencyLimit", + apply: "__patchPreference" } }, diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js index d4bc5361898..3470e46f78e 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js @@ -26,6 +26,9 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", { const walletIndicatorSettings = this.__createCreditsIndicatorSettings(); this.add(walletIndicatorSettings); + + this.add(this.__createInactivitySetting()) + this.add(this.__createJobConcurrencySetting()) }, statics: { @@ -100,6 +103,44 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", { box.add(new qx.ui.form.renderer.Single(form)); + return box; + }, + __createInactivitySetting: function() { + const box = this._createSectionBox(this.tr("Inactivity shutdown")); + const label = this._createHelpLabel(this.tr("Choose after how long should inactive studies be closed.")); + box.add(label); + const form = new qx.ui.form.Form(); + const inactivitySpinner = new qx.ui.form.Spinner().set({ + minimum: 1, + maximum: Number.MAX_SAFE_INTEGER, + singleStep: 1, + allowGrowX: false + }); + const preferences = osparc.Preferences.getInstance(); + preferences.bind("userInactivityThreshold", inactivitySpinner, "value", { + converter: value => Math.round(value / 60) // Stored in seconds, displayed in minutes + }); + inactivitySpinner.addListener("changeValue", e => this.self().patchPreference("userInactivityThreshold", inactivitySpinner, e.getData() * 60)); + form.add(inactivitySpinner, this.tr("Idle time before closing (in minutes)")); + box.add(new qx.ui.form.renderer.Single(form)); + return box; + }, + __createJobConcurrencySetting: function() { + const box = this._createSectionBox(this.tr("Job concurrency")); + const label = this._createHelpLabel(this.tr("Choose how many jobs can run at the same time.")); + box.add(label); + const form = new qx.ui.form.Form(); + const jobConcurrencySpinner = new qx.ui.form.Spinner().set({ + minimum: 1, + maximum: Number.MAX_SAFE_INTEGER, + singleStep: 1, + allowGrowX: false + }); + const preferences = osparc.Preferences.getInstance(); + preferences.bind("jobConcurrencyLimit", jobConcurrencySpinner, "value"); + jobConcurrencySpinner.addListener("changeValue", e => this.self().patchPreference("jobConcurrencyLimit", jobConcurrencySpinner, e.getData())); + form.add(jobConcurrencySpinner, this.tr("Maximum concurrent jobs")) + box.add(new qx.ui.form.renderer.Single(form)) return box; } } diff --git a/services/web/server/src/simcore_service_webserver/users/_preferences_models.py b/services/web/server/src/simcore_service_webserver/users/_preferences_models.py index 13b1c3ed2c6..2767537c54b 100644 --- a/services/web/server/src/simcore_service_webserver/users/_preferences_models.py +++ b/services/web/server/src/simcore_service_webserver/users/_preferences_models.py @@ -79,6 +79,10 @@ class UserInactivityThresholdFrontendUserPreference(FrontendUserPreference): preference_identifier = "userInactivityThreshold" value: int | None = 30 * _MINUTE # in seconds +class JobConcurrencyLimitFrontendUserPreference(FrontendUserPreference): + preference_identifier = "jobConcurrencyLimit" + value: int | None = 4 + ALL_FRONTEND_PREFERENCES: list[type[FrontendUserPreference]] = [ ConfirmationBackToDashboardFrontendUserPreference, @@ -95,6 +99,7 @@ class UserInactivityThresholdFrontendUserPreference(FrontendUserPreference): CreditsWarningThresholdFrontendUserPreference, WalletIndicatorVisibilityFrontendUserPreference, UserInactivityThresholdFrontendUserPreference, + JobConcurrencyLimitFrontendUserPreference, ] From 4567ad431b767c36b3cd8e6b07a083364cecfc2e Mon Sep 17 00:00:00 2001 From: Ignacio Pascual <4764217+ignapas@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:38:25 +0100 Subject: [PATCH 2/4] made eslint happy --- .../class/osparc/desktop/preferences/pages/GeneralPage.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js index 3470e46f78e..aaaa7ef5d20 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js @@ -27,8 +27,8 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", { const walletIndicatorSettings = this.__createCreditsIndicatorSettings(); this.add(walletIndicatorSettings); - this.add(this.__createInactivitySetting()) - this.add(this.__createJobConcurrencySetting()) + this.add(this.__createInactivitySetting()); + this.add(this.__createJobConcurrencySetting()); }, statics: { @@ -139,8 +139,8 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", { const preferences = osparc.Preferences.getInstance(); preferences.bind("jobConcurrencyLimit", jobConcurrencySpinner, "value"); jobConcurrencySpinner.addListener("changeValue", e => this.self().patchPreference("jobConcurrencyLimit", jobConcurrencySpinner, e.getData())); - form.add(jobConcurrencySpinner, this.tr("Maximum concurrent jobs")) - box.add(new qx.ui.form.renderer.Single(form)) + form.add(jobConcurrencySpinner, this.tr("Maximum concurrent jobs")); + box.add(new qx.ui.form.renderer.Single(form)); return box; } } From 54580dc59bbf62c91f02a0a9bba7fc785d8a63d4 Mon Sep 17 00:00:00 2001 From: Ignacio Pascual <4764217+ignapas@users.noreply.github.com> Date: Wed, 15 Nov 2023 17:45:35 +0100 Subject: [PATCH 3/4] default value of one --- .../src/simcore_service_webserver/users/_preferences_models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/web/server/src/simcore_service_webserver/users/_preferences_models.py b/services/web/server/src/simcore_service_webserver/users/_preferences_models.py index 2767537c54b..06bf7a9fa91 100644 --- a/services/web/server/src/simcore_service_webserver/users/_preferences_models.py +++ b/services/web/server/src/simcore_service_webserver/users/_preferences_models.py @@ -81,7 +81,7 @@ class UserInactivityThresholdFrontendUserPreference(FrontendUserPreference): class JobConcurrencyLimitFrontendUserPreference(FrontendUserPreference): preference_identifier = "jobConcurrencyLimit" - value: int | None = 4 + value: int | None = 1 ALL_FRONTEND_PREFERENCES: list[type[FrontendUserPreference]] = [ From 1f3ac480f1315acf6f646a17e7cd20707af78f12 Mon Sep 17 00:00:00 2001 From: Ignacio Pascual <4764217+ignapas@users.noreply.github.com> Date: Wed, 15 Nov 2023 17:46:10 +0100 Subject: [PATCH 4/4] added clarifying text --- .../osparc/desktop/preferences/pages/GeneralPage.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js index aaaa7ef5d20..d04843fe1f0 100644 --- a/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js +++ b/services/static-webserver/client/source/class/osparc/desktop/preferences/pages/GeneralPage.js @@ -107,11 +107,11 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", { }, __createInactivitySetting: function() { const box = this._createSectionBox(this.tr("Inactivity shutdown")); - const label = this._createHelpLabel(this.tr("Choose after how long should inactive studies be closed.")); + const label = this._createHelpLabel(this.tr("Choose after how long should inactive studies be closed. A value of zero disables this function.")); box.add(label); const form = new qx.ui.form.Form(); const inactivitySpinner = new qx.ui.form.Spinner().set({ - minimum: 1, + minimum: 0, maximum: Number.MAX_SAFE_INTEGER, singleStep: 1, allowGrowX: false @@ -132,9 +132,10 @@ qx.Class.define("osparc.desktop.preferences.pages.GeneralPage", { const form = new qx.ui.form.Form(); const jobConcurrencySpinner = new qx.ui.form.Spinner().set({ minimum: 1, - maximum: Number.MAX_SAFE_INTEGER, + maximum: 10, singleStep: 1, - allowGrowX: false + allowGrowX: false, + enabled: false }); const preferences = osparc.Preferences.getInstance(); preferences.bind("jobConcurrencyLimit", jobConcurrencySpinner, "value");