Skip to content

Commit 66bdc07

Browse files
authored
Breadcrumb Navigation (#1902)
- Breadcrumb Navigation - Some Grouping features were brought back - New TI Treatment Planning logo
1 parent bfb7bbb commit 66bdc07

File tree

18 files changed

+635
-260
lines changed

18 files changed

+635
-260
lines changed

services/web/client/source/class/osparc/Application.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ qx.Class.define("osparc.Application", {
4747
window.localStorage.getItem("themeName") !== qx.theme.manager.Meta.getInstance().getTheme().name) {
4848
const preferredTheme = qx.Theme.getByName(window.localStorage.getItem("themeName"));
4949
const themes = qx.Theme.getAll();
50-
if (Object.keys(themes).includes(preferredTheme)) {
50+
if (preferredTheme && Object.keys(themes).includes(preferredTheme.name)) {
5151
qx.theme.manager.Meta.getInstance().setTheme(preferredTheme);
5252
}
5353
}

services/web/client/source/class/osparc/component/node/FilePickerNodeView.js

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,6 @@
2222
qx.Class.define("osparc.component.node.FilePickerNodeView", {
2323
extend: osparc.component.node.BaseNodeView,
2424

25-
/**
26-
* @param node {osparc.data.model.Node} Node owning the widget
27-
*/
28-
construct: function(node) {
29-
this.base(arguments);
30-
31-
this.set({
32-
node
33-
});
34-
},
35-
3625
members: {
3726
__filePicker: null,
3827

@@ -58,11 +47,18 @@ qx.Class.define("osparc.component.node.FilePickerNodeView", {
5847

5948
// overridden
6049
_applyNode: function(node) {
61-
return;
50+
if (!node.isFilePicker()) {
51+
console.error("Only file picker nodes are supported");
52+
}
6253
},
6354

6455
__buildMyLayout: function() {
65-
const filePicker = this.__filePicker = new osparc.file.FilePicker(this.getNode());
56+
const node = this.getNode();
57+
if (!node) {
58+
return;
59+
}
60+
61+
const filePicker = this.__filePicker = new osparc.file.FilePicker(node);
6662
filePicker.buildLayout();
6763
filePicker.init();
6864

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2020 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
/**
19+
*
20+
*/
21+
22+
qx.Class.define("osparc.component.widget.BreadcrumbNavigation", {
23+
extend: qx.ui.core.Widget,
24+
25+
construct: function() {
26+
this.base(arguments);
27+
28+
this._setLayout(new qx.ui.layout.HBox(0).set({
29+
alignY: "middle"
30+
}));
31+
},
32+
33+
events: {
34+
"nodeSelected": "qx.event.type.Data"
35+
},
36+
37+
statics: {
38+
BUTTON_OPTIONS: {
39+
font: "text-14",
40+
allowGrowY: false,
41+
minWidth: 32,
42+
minHeight: 32
43+
}
44+
},
45+
46+
members: {
47+
populateButtons: function(nodesIds = [], shape = "slash") {
48+
const btns = [];
49+
if (shape === "slash") {
50+
for (let i=0; i<nodesIds.length; i++) {
51+
const nodeId = nodesIds[i];
52+
const btn = this.__createNodePathBtn(nodeId);
53+
if (i === nodesIds.length-1) {
54+
btn.setValue(true);
55+
}
56+
btns.push(btn);
57+
}
58+
} else if (shape === "arrow") {
59+
const study = osparc.store.Store.getInstance().getCurrentStudy();
60+
const currentNodeId = study.getUi().getCurrentNodeId();
61+
for (let i=0; i<nodesIds.length; i++) {
62+
const nodeId = nodesIds[i];
63+
const btn = this.__createNodeSlideBtn(nodeId);
64+
if (nodeId === currentNodeId) {
65+
btn.setValue(true);
66+
}
67+
btns.push(btn);
68+
}
69+
}
70+
this.__buttonsToBreadcrumb(btns, shape);
71+
},
72+
73+
__createNodeBtn: function(nodeId) {
74+
const btn = new qx.ui.form.ToggleButton().set({
75+
...this.self().BUTTON_OPTIONS,
76+
maxWidth: 200
77+
});
78+
btn.addListener("execute", () => {
79+
this.fireDataEvent("nodeSelected", nodeId);
80+
}, this);
81+
return btn;
82+
},
83+
84+
__createNodePathBtn: function(nodeId) {
85+
const btn = this.__createNodeBtn(nodeId);
86+
const study = osparc.store.Store.getInstance().getCurrentStudy();
87+
if (nodeId === study.getUuid()) {
88+
study.bind("name", btn, "label");
89+
study.bind("name", btn, "toolTipText");
90+
} else {
91+
const node = study.getWorkbench().getNode(nodeId);
92+
if (node) {
93+
node.bind("label", btn, "label");
94+
node.bind("label", btn, "toolTipText");
95+
}
96+
}
97+
return btn;
98+
},
99+
100+
__createNodeSlideBtn: function(nodeId) {
101+
const btn = this.__createNodeBtn(nodeId);
102+
const study = osparc.store.Store.getInstance().getCurrentStudy();
103+
const slideShow = study.getUi().getSlideshow();
104+
const node = study.getWorkbench().getNode(nodeId);
105+
if (node && nodeId in slideShow) {
106+
const pos = slideShow[nodeId].position;
107+
node.bind("label", btn, "label", {
108+
converter: val => (pos+1).toString() + "- " + val
109+
});
110+
node.bind("label", btn, "toolTipText");
111+
}
112+
return btn;
113+
},
114+
115+
__buttonsToBreadcrumb: function(btns, shape = "slash") {
116+
this._removeAll();
117+
for (let i=0; i<btns.length; i++) {
118+
const thisBtn = btns[i];
119+
let nextBtn = null;
120+
if (i+1<btns.length) {
121+
nextBtn = btns[i+1];
122+
}
123+
124+
this._add(thisBtn);
125+
126+
const breadcrumbSplitter = new osparc.component.widget.BreadcrumbSplitter(16, 32).set({
127+
shape,
128+
marginLeft: -1,
129+
marginRight: -1
130+
});
131+
if (breadcrumbSplitter.getReady()) {
132+
breadcrumbSplitter.setLeftWidget(thisBtn);
133+
if (nextBtn) {
134+
breadcrumbSplitter.setRightWidget(nextBtn);
135+
}
136+
} else {
137+
breadcrumbSplitter.addListenerOnce("SvgWidgetReady", () => {
138+
breadcrumbSplitter.setLeftWidget(thisBtn);
139+
if (nextBtn) {
140+
breadcrumbSplitter.setRightWidget(nextBtn);
141+
}
142+
}, this);
143+
}
144+
this._add(breadcrumbSplitter);
145+
}
146+
}
147+
}
148+
});

0 commit comments

Comments
 (0)