Skip to content

Commit

Permalink
🎨 [Frontend] Study name to Tab (#6888)
Browse files Browse the repository at this point in the history
  • Loading branch information
odeimaiz authored Dec 4, 2024
1 parent 74dd164 commit 81e5b8e
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 81e5b8e

Please sign in to comment.