From 3c7dee7856511726d05a43a6fcb38f87c9c79a48 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Tue, 3 Dec 2024 08:40:53 +0100 Subject: [PATCH 1/4] refactor --- .../client/source/class/osparc/Application.js | 6 ++++-- .../client/source/class/osparc/utils/Utils.js | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/Application.js b/services/static-webserver/client/source/class/osparc/Application.js index 251b74d42aa..0636416ad44 100644 --- a/services/static-webserver/client/source/class/osparc/Application.js +++ b/services/static-webserver/client/source/class/osparc/Application.js @@ -209,13 +209,15 @@ qx.Class.define("osparc.Application", { }, __updateTabName: function() { + let newName = ""; const platformName = osparc.store.StaticInfo.getInstance().getPlatformName(); if (osparc.utils.Utils.isInZ43()) { - document.title += " Z43"; + newName += " Z43"; } if (platformName) { - document.title += ` (${platformName})`; + newName += ` (${platformName})`; } + osparc.utils.Utils.updateTabName(newName); }, diff --git a/services/static-webserver/client/source/class/osparc/utils/Utils.js b/services/static-webserver/client/source/class/osparc/utils/Utils.js index b5140e3713a..117380c01a8 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Utils.js +++ b/services/static-webserver/client/source/class/osparc/utils/Utils.js @@ -91,6 +91,10 @@ qx.Class.define("osparc.utils.Utils", { FLOATING_Z_INDEX: 110000, + updateTabName: function(name) { + document.title = name; + }, + replaceTokens: function(str, key, value) { // `str` might be a a localized string, get the string first str = str.toString ? str.toString() : str; From bb5e9c8b59c7396d9e0d57b2492e061db8869e3b Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Tue, 3 Dec 2024 08:58:27 +0100 Subject: [PATCH 2/4] minor --- .../client/source/class/osparc/Application.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/Application.js b/services/static-webserver/client/source/class/osparc/Application.js index 0636416ad44..2b97d872624 100644 --- a/services/static-webserver/client/source/class/osparc/Application.js +++ b/services/static-webserver/client/source/class/osparc/Application.js @@ -209,7 +209,7 @@ qx.Class.define("osparc.Application", { }, __updateTabName: function() { - let newName = ""; + let newName = document.title; const platformName = osparc.store.StaticInfo.getInstance().getPlatformName(); if (osparc.utils.Utils.isInZ43()) { newName += " Z43"; @@ -220,8 +220,6 @@ qx.Class.define("osparc.Application", { osparc.utils.Utils.updateTabName(newName); }, - - __setDeviceSpecificIcons: function() { const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; const isAndroid = /android/i.test(navigator.userAgent); From 663df857b5cfd288b3fc390552134b6e2da86227 Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Tue, 3 Dec 2024 09:14:22 +0100 Subject: [PATCH 3/4] tab name dependson study name --- .../client/source/class/osparc/Application.js | 9 +-------- .../client/source/class/osparc/store/Store.js | 18 +++++++++++++++++- .../client/source/class/osparc/utils/Utils.js | 12 ++++++++++++ 3 files changed, 30 insertions(+), 9 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/Application.js b/services/static-webserver/client/source/class/osparc/Application.js index 2b97d872624..20750d2f941 100644 --- a/services/static-webserver/client/source/class/osparc/Application.js +++ b/services/static-webserver/client/source/class/osparc/Application.js @@ -209,14 +209,7 @@ qx.Class.define("osparc.Application", { }, __updateTabName: function() { - let newName = document.title; - const platformName = osparc.store.StaticInfo.getInstance().getPlatformName(); - if (osparc.utils.Utils.isInZ43()) { - newName += " Z43"; - } - if (platformName) { - newName += ` (${platformName})`; - } + const newName = osparc.utils.Utils.composeTabName(); osparc.utils.Utils.updateTabName(newName); }, diff --git a/services/static-webserver/client/source/class/osparc/store/Store.js b/services/static-webserver/client/source/class/osparc/store/Store.js index 7b94b336852..d3f9fa4974a 100644 --- a/services/static-webserver/client/source/class/osparc/store/Store.js +++ b/services/static-webserver/client/source/class/osparc/store/Store.js @@ -59,7 +59,8 @@ qx.Class.define("osparc.store.Store", { check: "osparc.data.model.Study", init: null, nullable: true, - event: "changeCurrentStudy" + event: "changeCurrentStudy", + apply: "__applyCurrentStudy", }, currentStudyId: { check: "String", @@ -339,6 +340,21 @@ qx.Class.define("osparc.store.Store", { } }, + __applyCurrentStudy: function(study) { + if (study) { + study.addListener("changeName", () => { + if (this.getCurrentStudy() === study) { + // the study might have been closed + osparc.utils.Utils.updateTabName(study.getName()); + } + }); + osparc.utils.Utils.updateTabName(study.getName()); + } else { + const newName = osparc.utils.Utils.composeTabName(); + osparc.utils.Utils.updateTabName(newName); + } + }, + __applyWallets: function(wallets) { const preferenceSettings = osparc.Preferences.getInstance(); const preferenceWalletId = preferenceSettings.getPreferredWalletId(); diff --git a/services/static-webserver/client/source/class/osparc/utils/Utils.js b/services/static-webserver/client/source/class/osparc/utils/Utils.js index 117380c01a8..075db07763e 100644 --- a/services/static-webserver/client/source/class/osparc/utils/Utils.js +++ b/services/static-webserver/client/source/class/osparc/utils/Utils.js @@ -95,6 +95,18 @@ qx.Class.define("osparc.utils.Utils", { document.title = name; }, + composeTabName: function() { + let newName = osparc.store.StaticInfo.getInstance().getDisplayName(); + const platformName = osparc.store.StaticInfo.getInstance().getPlatformName(); + if (osparc.utils.Utils.isInZ43()) { + newName += " Z43"; + } + if (platformName) { + newName += ` (${platformName})`; + } + return newName; + }, + replaceTokens: function(str, key, value) { // `str` might be a a localized string, get the string first str = str.toString ? str.toString() : str; From b4d689499fba178b59596b28b2613def77186caa Mon Sep 17 00:00:00 2001 From: odeimaiz Date: Tue, 3 Dec 2024 09:47:12 +0100 Subject: [PATCH 4/4] search workspaces --- .../source/class/osparc/dashboard/StudyBrowser.js | 3 +-- .../client/source/class/osparc/data/Resources.js | 2 +- .../client/source/class/osparc/store/Workspaces.js | 12 ++++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js index c7ef8f916f2..0a2e6f7f727 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -168,7 +168,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { !osparc.auth.Manager.getInstance().isLoggedIn() || !osparc.utils.DisabledPlugins.isFoldersEnabled() || this.getCurrentContext() === "studiesAndFolders" || - this.getCurrentContext() === "search" || // not yet implemented for workspaces this.__loadingWorkspaces ) { return; @@ -179,7 +178,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { case "search": { const filterData = this._searchBarFilter.getFilterData(); const text = filterData.text ? encodeURIComponent(filterData.text) : ""; - request = osparc.store.Workspaces.getInstance().searchWorkspaces(text); + request = osparc.store.Workspaces.getInstance().searchWorkspaces(text, this.getOrderBy()); break; } case "workspaces": { diff --git a/services/static-webserver/client/source/class/osparc/data/Resources.js b/services/static-webserver/client/source/class/osparc/data/Resources.js index d87f6c690bf..6075ef4eb1a 100644 --- a/services/static-webserver/client/source/class/osparc/data/Resources.js +++ b/services/static-webserver/client/source/class/osparc/data/Resources.js @@ -368,7 +368,7 @@ qx.Class.define("osparc.data.Resources", { getPageSearch: { useCache: false, method: "GET", - url: statics.API + "/workspaces:search?offset={offset}&limit={limit}&text={text}&order_by={orderBy}" + url: statics.API + "/workspaces?offset={offset}&limit={limit}&filters={filters}&order_by={orderBy}" }, getPageTrashed: { useCache: false, diff --git a/services/static-webserver/client/source/class/osparc/store/Workspaces.js b/services/static-webserver/client/source/class/osparc/store/Workspaces.js index 924312639de..df028e160d7 100644 --- a/services/static-webserver/client/source/class/osparc/store/Workspaces.js +++ b/services/static-webserver/client/source/class/osparc/store/Workspaces.js @@ -103,16 +103,24 @@ qx.Class.define("osparc.store.Workspaces", { }); }, - searchWorkspaces: function(text) { + searchWorkspaces: function( + text, + orderBy = { + field: "modified_at", + direction: "desc" + }, + ) { if (osparc.auth.Data.getInstance().isGuest()) { return new Promise(resolve => { resolve([]); }); } + const curatedOrderBy = this.self().curateOrderBy(orderBy); const params = { url: { - text, + filters: JSON.stringify({text: text}), + orderBy: JSON.stringify(curatedOrderBy), } }; return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageSearch")