Skip to content

Commit 524ba04

Browse files
authored
Fix zoom/scroll workbench (ITISFoundation#2632)
1 parent a5b1e13 commit 524ba04

File tree

8 files changed

+285
-147
lines changed

8 files changed

+285
-147
lines changed

services/web/client/source/class/osparc/component/workbench/WorkbenchUI.js

Lines changed: 183 additions & 128 deletions
Large diffs are not rendered by default.

services/web/client/source/class/osparc/component/workbench/WorkbenchUIPreview.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,9 @@ qx.Class.define("osparc.component.workbench.WorkbenchUIPreview", {
5151
});
5252
},
5353

54+
// overriden
5455
_loadModel: function(model) {
55-
this.clearAll();
56+
this._clearAll();
5657
this.resetSelectedNodes();
5758
this._currentModel = model;
5859
if (model) {

services/web/client/source/class/osparc/dashboard/SideSearch.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ qx.Class.define("osparc.dashboard.SideSearch", {
1515

1616
this.set({
1717
padding: 15,
18-
marginTop: 15,
19-
maxWidth: 330,
20-
minWidth: 220
18+
marginTop: 15
2119
});
2220

2321
this.__buildLayout();

services/web/client/source/class/osparc/desktop/MainPage.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,26 @@ qx.Class.define("osparc.desktop.MainPage", {
134134
},
135135

136136
__createDashboardStack: function() {
137-
const nStudyItemsPerRow = 5;
138-
const dashboard = this.__dashboard = new osparc.dashboard.Dashboard().set({
139-
width: nStudyItemsPerRow * (osparc.dashboard.GridButtonBase.ITEM_WIDTH + osparc.dashboard.GridButtonBase.SPACING) + 8 // padding + scrollbar
137+
const dashboard = this.__dashboard = new osparc.dashboard.Dashboard();
138+
const minNStudyItemsPerRow = 5;
139+
const itemWidth = osparc.dashboard.GridButtonBase.ITEM_WIDTH + osparc.dashboard.GridButtonBase.SPACING;
140+
dashboard.setMinWidth(minNStudyItemsPerRow * itemWidth + 8);
141+
const sideSearch = new osparc.dashboard.SideSearch().set({
142+
maxWidth: 330,
143+
minWidth: 220
140144
});
141-
const sideSearch = new osparc.dashboard.SideSearch();
145+
const fitResourceCards = () => {
146+
const w = document.documentElement.clientWidth;
147+
const nStudies = Math.floor((w - 2*sideSearch.getSizeHint().width - 8) / itemWidth);
148+
const newWidth = nStudies * itemWidth + 8;
149+
if (newWidth > dashboard.getMinWidth()) {
150+
dashboard.setWidth(newWidth);
151+
} else {
152+
dashboard.setWidth(dashboard.getMinWidth());
153+
}
154+
};
155+
fitResourceCards();
156+
window.addEventListener("resize", () => fitResourceCards());
142157
dashboard.bind("selection", sideSearch, "visibility", {
143158
converter: value => {
144159
const tabIndex = dashboard.getChildren().indexOf(value[0]);

services/web/client/source/class/osparc/desktop/SidePanel.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,6 @@ qx.Class.define("osparc.desktop.SidePanel", {
6969
}
7070
},
7171

72-
events: {
73-
"panelResized": "qx.event.type.Data"
74-
},
75-
7672
members: {
7773
__savedWidth: null,
7874
__savedMinWidth: null,
@@ -200,10 +196,6 @@ qx.Class.define("osparc.desktop.SidePanel", {
200196
}
201197
});
202198
}, this);
203-
204-
this.addListener("resize", e => {
205-
this.fireDataEvent("panelResized", e.getData());
206-
}, this);
207199
}
208200
}
209201
});

services/web/client/source/class/osparc/desktop/WorkbenchView.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,13 @@ qx.Class.define("osparc.desktop.WorkbenchView", {
320320
alignX: "left",
321321
marginLeft: 14
322322
});
323-
addNewNodeBtn.addListener("execute", () => this.__workbenchUI.openServiceCatalog());
323+
addNewNodeBtn.addListener("execute", () => this.__workbenchUI.openServiceCatalog({
324+
x: 50,
325+
y: 50
326+
}, {
327+
x: 50,
328+
y: 50
329+
}));
324330
homeAndNodesTree.add(addNewNodeBtn);
325331

326332
const nodesPage = this.__createTabPage("@FontAwesome5Solid/list", this.tr("Nodes"), homeAndNodesTree, primaryColumnBGColor);

services/web/client/source/class/osparc/navigation/NavigationBar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,12 @@ qx.Class.define("osparc.navigation.NavigationBar", {
250250
});
251251

252252
const newGHIssueBtn = new qx.ui.menu.Button(this.tr("Issue in GitHub"));
253-
newGHIssueBtn.addListener("execute", () => osparc.navigation.UserMenuButton.openGithubIssueInfoDialog, this);
253+
newGHIssueBtn.addListener("execute", () => osparc.navigation.UserMenuButton.openGithubIssueInfoDialog(), this);
254254
menu.add(newGHIssueBtn);
255255

256256
if (osparc.utils.Utils.isInZ43()) {
257257
const newFogbugzIssueBtn = new qx.ui.menu.Button(this.tr("Issue in Fogbugz"));
258-
newFogbugzIssueBtn.addListener("execute", () => osparc.navigation.UserMenuButton.openFogbugzIssueInfoDialog, this);
258+
newFogbugzIssueBtn.addListener("execute", () => osparc.navigation.UserMenuButton.openFogbugzIssueInfoDialog(), this);
259259
menu.add(newFogbugzIssueBtn);
260260
}
261261

tests/e2e/portal/Voila.js

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
// node Voila.js [url_prefix] [template_uuid] [--demo]
2+
3+
const tutorialBase = require('../tutorials/tutorialBase');
4+
const utils = require('../utils/utils');
5+
6+
const args = process.argv.slice(2);
7+
const {
8+
urlPrefix,
9+
templateUuid,
10+
enableDemoMode
11+
} = utils.parseCommandLineArgumentsTemplate(args);
12+
13+
const anonURL = urlPrefix + templateUuid;
14+
const screenshotPrefix = "Voila_";
15+
16+
17+
async function runTutorial () {
18+
const tutorial = new tutorialBase.TutorialBase(anonURL, screenshotPrefix, null, null, null, enableDemoMode);
19+
20+
try {
21+
const page = await tutorial.beforeScript();
22+
const studyData = await tutorial.openStudyLink();
23+
const studyId = studyData["data"]["uuid"];
24+
console.log("Study ID:", studyId);
25+
26+
const workbenchData = utils.extractWorkbenchData(studyData["data"]);
27+
console.log("Workbench Data:", workbenchData);
28+
const voilaIdViewer = workbenchData["nodeIds"][0];
29+
await tutorial.waitForServices(workbenchData["studyId"], [voilaIdViewer]);
30+
31+
await tutorial.waitFor(40000, 'Some time for starting the service');
32+
await utils.takeScreenshot(page, screenshotPrefix + 'service_started');
33+
34+
const iframeHandles = await page.$$("iframe");
35+
const iframes = [];
36+
for (let i=0; i<iframeHandles.length; i++) {
37+
const frame = await iframeHandles[i].contentFrame();
38+
iframes.push(frame);
39+
}
40+
// url/x/voilaIdViewer
41+
const frame = iframes.find(iframe => iframe._url.includes(voilaIdViewer));
42+
43+
// check title says "VISUALIZATION"
44+
const titleSelector = '#VISUALIZATION';
45+
const element = await frame.$(titleSelector);
46+
const titleText = await frame.evaluate(el => el.innerText, element);
47+
console.log("titleText", titleText);
48+
if (titleText !== "VISUALIZATION") {
49+
throw new Error("Voila page title doesn't match the expected");
50+
}
51+
await utils.takeScreenshot(page, screenshotPrefix + 'iFrame1');
52+
}
53+
catch(err) {
54+
tutorial.setTutorialFailed(true);
55+
console.log('Tutorial error: ' + err);
56+
}
57+
finally {
58+
await tutorial.logOut();
59+
await tutorial.close();
60+
}
61+
62+
if (tutorial.getTutorialFailed()) {
63+
throw "Tutorial Failed";
64+
}
65+
}
66+
67+
runTutorial()
68+
.catch(error => {
69+
console.log('Puppeteer error: ' + error);
70+
process.exit(1);
71+
});

0 commit comments

Comments
 (0)