Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🎨 [Frontend] Study name to Tab #6888

Merged
merged 8 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}"
odeimaiz marked this conversation as resolved.
Show resolved Hide resolved
},
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
Loading