diff --git a/services/static-webserver/client/source/class/osparc/Application.js b/services/static-webserver/client/source/class/osparc/Application.js index 251b74d42aa..20750d2f941 100644 --- a/services/static-webserver/client/source/class/osparc/Application.js +++ b/services/static-webserver/client/source/class/osparc/Application.js @@ -209,17 +209,10 @@ qx.Class.define("osparc.Application", { }, __updateTabName: function() { - const platformName = osparc.store.StaticInfo.getInstance().getPlatformName(); - if (osparc.utils.Utils.isInZ43()) { - document.title += " Z43"; - } - if (platformName) { - document.title += ` (${platformName})`; - } + const newName = osparc.utils.Utils.composeTabName(); + osparc.utils.Utils.updateTabName(newName); }, - - __setDeviceSpecificIcons: function() { const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream; const isAndroid = /android/i.test(navigator.userAgent); 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 a3cfc5b9d88..327de47602c 100644 --- a/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js +++ b/services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js @@ -167,7 +167,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", { if ( !osparc.auth.Manager.getInstance().isLoggedIn() || this.getCurrentContext() === "studiesAndFolders" || - this.getCurrentContext() === "search" || // not yet implemented for workspaces this.__loadingWorkspaces ) { return; @@ -178,7 +177,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 45aede41aaa..1332df084a9 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/Store.js b/services/static-webserver/client/source/class/osparc/store/Store.js index cd82975131d..e560a643980 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", @@ -334,6 +335,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/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") 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..075db07763e 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,22 @@ qx.Class.define("osparc.utils.Utils", { FLOATING_Z_INDEX: 110000, + updateTabName: function(name) { + 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;