Skip to content

Commit 25664fb

Browse files
committed
Show location on Study Card
1 parent 6a2c00c commit 25664fb

File tree

3 files changed

+51
-1
lines changed

3 files changed

+51
-1
lines changed

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,41 @@ qx.Class.define("osparc.data.model.Study", {
443443
});
444444
},
445445

446+
__getFoldersPath: function(childId, foldersPath = []) {
447+
foldersPath.unshift(childId);
448+
const childFolder = osparc.store.Folders.getInstance().getFolder(childId);
449+
if (childFolder) {
450+
const parentFolder = osparc.store.Folders.getInstance().getFolder(childFolder.getParentFolderId());
451+
if (parentFolder) {
452+
this.__getFoldersPath(parentFolder.getFolderId(), foldersPath);
453+
}
454+
}
455+
return foldersPath;
456+
},
457+
458+
getLocationString: function() {
459+
const location = [];
460+
461+
if (this.getWorkspaceId()) {
462+
const workspace = osparc.store.Workspaces.getInstance().getWorkspace(this.getWorkspaceId());
463+
location.push(workspace.getName());
464+
} else {
465+
location.push(qx.locale.Manager.tr("My Workspace"));
466+
}
467+
468+
const foldersPathIds = this.__getFoldersPath(this.getFolderId());
469+
// remove the first one
470+
foldersPathIds.shift();
471+
foldersPathIds.forEach(folderId => {
472+
const folder = osparc.store.Folders.getInstance().getFolder(folderId);
473+
if (folder) {
474+
location.push(folder.getName());
475+
}
476+
});
477+
478+
return location.join(" / ");
479+
},
480+
446481
// Used for updating some node data through the "nodeUpdated" websocket event
447482
nodeUpdated: function(nodeUpdatedData) {
448483
const studyId = nodeUpdatedData["project_id"];

services/static-webserver/client/source/class/osparc/info/StudyLarge.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,16 @@ qx.Class.define("osparc.info.StudyLarge", {
189189
};
190190
}
191191

192+
if (osparc.utils.DisabledPlugins.isFoldersEnabled() && !this.__isTemplate) {
193+
const pathLabel = new qx.ui.basic.Label();
194+
pathLabel.setValue(this.getStudy().getLocationString());
195+
extraInfo["LOCATION"] = {
196+
label: this.tr("Location:"),
197+
view: pathLabel,
198+
action: null
199+
};
200+
}
201+
192202
return extraInfo;
193203
},
194204

services/static-webserver/client/source/class/osparc/info/StudyUtils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,12 @@ qx.Class.define("osparc.info.StudyUtils", {
299299
inline: true,
300300
column: 0,
301301
row: 6,
302-
}
302+
},
303+
LOCATION: {
304+
inline: true,
305+
column: 0,
306+
row: 7,
307+
},
303308
};
304309

305310
const grid = new qx.ui.layout.Grid(15, 5);

0 commit comments

Comments
 (0)