Skip to content

Commit 81e5b8e

Browse files
authored
🎨 [Frontend] Study name to Tab (#6888)
1 parent 74dd164 commit 81e5b8e

File tree

6 files changed

+47
-15
lines changed

6 files changed

+47
-15
lines changed

services/static-webserver/client/source/class/osparc/Application.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,17 +209,10 @@ qx.Class.define("osparc.Application", {
209209
},
210210

211211
__updateTabName: function() {
212-
const platformName = osparc.store.StaticInfo.getInstance().getPlatformName();
213-
if (osparc.utils.Utils.isInZ43()) {
214-
document.title += " Z43";
215-
}
216-
if (platformName) {
217-
document.title += ` (${platformName})`;
218-
}
212+
const newName = osparc.utils.Utils.composeTabName();
213+
osparc.utils.Utils.updateTabName(newName);
219214
},
220215

221-
222-
223216
__setDeviceSpecificIcons: function() {
224217
const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
225218
const isAndroid = /android/i.test(navigator.userAgent);

services/static-webserver/client/source/class/osparc/dashboard/StudyBrowser.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
167167
if (
168168
!osparc.auth.Manager.getInstance().isLoggedIn() ||
169169
this.getCurrentContext() === "studiesAndFolders" ||
170-
this.getCurrentContext() === "search" || // not yet implemented for workspaces
171170
this.__loadingWorkspaces
172171
) {
173172
return;
@@ -178,7 +177,7 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
178177
case "search": {
179178
const filterData = this._searchBarFilter.getFilterData();
180179
const text = filterData.text ? encodeURIComponent(filterData.text) : "";
181-
request = osparc.store.Workspaces.getInstance().searchWorkspaces(text);
180+
request = osparc.store.Workspaces.getInstance().searchWorkspaces(text, this.getOrderBy());
182181
break;
183182
}
184183
case "workspaces": {

services/static-webserver/client/source/class/osparc/data/Resources.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ qx.Class.define("osparc.data.Resources", {
368368
getPageSearch: {
369369
useCache: false,
370370
method: "GET",
371-
url: statics.API + "/workspaces:search?offset={offset}&limit={limit}&text={text}&order_by={orderBy}"
371+
url: statics.API + "/workspaces?offset={offset}&limit={limit}&filters={filters}&order_by={orderBy}"
372372
},
373373
getPageTrashed: {
374374
useCache: false,

services/static-webserver/client/source/class/osparc/store/Store.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ qx.Class.define("osparc.store.Store", {
5959
check: "osparc.data.model.Study",
6060
init: null,
6161
nullable: true,
62-
event: "changeCurrentStudy"
62+
event: "changeCurrentStudy",
63+
apply: "__applyCurrentStudy",
6364
},
6465
currentStudyId: {
6566
check: "String",
@@ -334,6 +335,21 @@ qx.Class.define("osparc.store.Store", {
334335
}
335336
},
336337

338+
__applyCurrentStudy: function(study) {
339+
if (study) {
340+
study.addListener("changeName", () => {
341+
if (this.getCurrentStudy() === study) {
342+
// the study might have been closed
343+
osparc.utils.Utils.updateTabName(study.getName());
344+
}
345+
});
346+
osparc.utils.Utils.updateTabName(study.getName());
347+
} else {
348+
const newName = osparc.utils.Utils.composeTabName();
349+
osparc.utils.Utils.updateTabName(newName);
350+
}
351+
},
352+
337353
__applyWallets: function(wallets) {
338354
const preferenceSettings = osparc.Preferences.getInstance();
339355
const preferenceWalletId = preferenceSettings.getPreferredWalletId();

services/static-webserver/client/source/class/osparc/store/Workspaces.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,24 @@ qx.Class.define("osparc.store.Workspaces", {
103103
});
104104
},
105105

106-
searchWorkspaces: function(text) {
106+
searchWorkspaces: function(
107+
text,
108+
orderBy = {
109+
field: "modified_at",
110+
direction: "desc"
111+
},
112+
) {
107113
if (osparc.auth.Data.getInstance().isGuest()) {
108114
return new Promise(resolve => {
109115
resolve([]);
110116
});
111117
}
112118

119+
const curatedOrderBy = this.self().curateOrderBy(orderBy);
113120
const params = {
114121
url: {
115-
text,
122+
filters: JSON.stringify({text: text}),
123+
orderBy: JSON.stringify(curatedOrderBy),
116124
}
117125
};
118126
return osparc.data.Resources.getInstance().getAllPages("workspaces", params, "getPageSearch")

services/static-webserver/client/source/class/osparc/utils/Utils.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ qx.Class.define("osparc.utils.Utils", {
9191

9292
FLOATING_Z_INDEX: 110000,
9393

94+
updateTabName: function(name) {
95+
document.title = name;
96+
},
97+
98+
composeTabName: function() {
99+
let newName = osparc.store.StaticInfo.getInstance().getDisplayName();
100+
const platformName = osparc.store.StaticInfo.getInstance().getPlatformName();
101+
if (osparc.utils.Utils.isInZ43()) {
102+
newName += " Z43";
103+
}
104+
if (platformName) {
105+
newName += ` (${platformName})`;
106+
}
107+
return newName;
108+
},
109+
94110
replaceTokens: function(str, key, value) {
95111
// `str` might be a a localized string, get the string first
96112
str = str.toString ? str.toString() : str;

0 commit comments

Comments
 (0)