Skip to content

Commit a7440ae

Browse files
committed
working again
1 parent 1c687bf commit a7440ae

File tree

4 files changed

+58
-60
lines changed

4 files changed

+58
-60
lines changed

services/static-webserver/client/source/class/osparc/dashboard/ResourceBrowserBase.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,20 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
939939
},
940940

941941
_openResourceDetails: function(resourceData) {
942+
// OM: remove this
943+
const hack = true;
944+
if (hack) {
945+
const functionData = {
946+
"uuid": resourceData["uuid"],
947+
"resourceType": "function",
948+
};
949+
const resourceDetails = new osparc.dashboard.ResourceDetails(functionData).set({
950+
showOpenButton: false,
951+
});
952+
osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails);
953+
return;
954+
}
955+
942956
const resourceDetails = new osparc.dashboard.ResourceDetails(resourceData);
943957
const win = osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails);
944958
resourceDetails.addListener("updateStudy", e => this._updateStudyData(e.getData()));

services/static-webserver/client/source/class/osparc/dashboard/ResourceDetails.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
3737
latestPromise = osparc.data.Resources.fetch("studies", "getOne", params);
3838
break;
3939
}
40+
case "function": {
41+
latestPromise = osparc.store.Templates.fetchTemplate(resourceData["uuid"]);
42+
break;
43+
}
4044
case "service": {
4145
latestPromise = osparc.store.Services.getService(resourceData["key"], resourceData["version"]);
4246
break;
@@ -57,6 +61,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
5761
case "template":
5862
case "tutorial":
5963
case "hypertool":
64+
case "function":
6065
// when getting the latest study data, the debt information was lost
6166
if (osparc.study.Utils.isInDebt(this.__resourceData)) {
6267
const mainStore = osparc.store.Store.getInstance();
@@ -372,6 +377,16 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
372377
// removeAll
373378
osparc.utils.Utils.removeAllChildren(tabsView);
374379

380+
if (this.__resourceData["resourceType"] === "function") {
381+
// for now, we only want the preview page
382+
const page = this.__getPreviewPage();
383+
if (page) {
384+
tabsView.add(page);
385+
}
386+
this.fireEvent("pagesAdded");
387+
return;
388+
}
389+
375390
// add Open service button
376391
[
377392
this.__getInfoPage,

services/static-webserver/client/source/class/osparc/study/StudyPreview.js

Lines changed: 21 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -31,67 +31,33 @@ qx.Class.define("osparc.study.StudyPreview", {
3131
this.__buildPreview();
3232
},
3333

34-
statics: {
35-
__popUpPreview: function(studyData) {
36-
const cantReadServices = osparc.study.Utils.getCantReadServices(studyData["services"]);
37-
if (cantReadServices && cantReadServices.length) {
38-
osparc.FlashMessenger.logError("Function Data not available");
39-
return;
40-
}
41-
42-
const study = new osparc.data.model.Study(studyData);
43-
// make sure it will be shown
44-
study.getUi().setMode("pipeline");
45-
46-
const studyReady = () => {
47-
const preview = new osparc.study.StudyPreview(study);
48-
const title = qx.locale.Manager.tr("Function Preview");
49-
const width = osparc.dashboard.ResourceDetails.WIDTH;
50-
const height = osparc.dashboard.ResourceDetails.HEIGHT;
51-
osparc.ui.window.Window.popUpInWindow(preview, title, width, height).set({
52-
clickAwayClose: false,
53-
resizable: true,
54-
showClose: true,
55-
});
56-
}
57-
58-
if (study.getWorkbench().isDeserialized()) {
59-
studyReady();
60-
} else {
61-
study.getWorkbench().addListener("changeDeserialized", e => {
62-
if (e.getData()) {
63-
studyReady();
64-
}
65-
}, this);
66-
}
67-
},
68-
69-
popUpPreview: function(studyData) {
70-
if ("services" in studyData) {
71-
this.__popUpPreview(studyData);
72-
} else {
73-
osparc.store.Services.getStudyServices(studyData["uuid"])
74-
.then(resp => {
75-
const services = resp["services"];
76-
studyData["services"] = services;
77-
this.__popUpPreview(studyData);
78-
});
79-
}
80-
}
81-
},
82-
8334
members: {
8435
__study: null,
8536

8637
__buildPreview: function() {
8738
const study = this.__study;
39+
40+
const studyReady = () => {
41+
if (!study.isPipelineEmpty()) {
42+
const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview();
43+
workbenchUIPreview.setStudy(study);
44+
workbenchUIPreview.loadModel(study.getWorkbench());
45+
workbenchUIPreview.setMaxHeight(550);
46+
this._add(workbenchUIPreview);
47+
}
48+
};
49+
8850
const uiMode = study.getUi().getMode();
89-
if (["workbench", "pipeline"].includes(uiMode) && !study.isPipelineEmpty()) {
90-
const workbenchUIPreview = new osparc.workbench.WorkbenchUIPreview();
91-
workbenchUIPreview.setStudy(study);
92-
workbenchUIPreview.loadModel(study.getWorkbench());
93-
workbenchUIPreview.setMaxHeight(550);
94-
this._add(workbenchUIPreview);
51+
if (["workbench", "pipeline"].includes(uiMode)) {
52+
if (study.getWorkbench().isDeserialized()) {
53+
studyReady();
54+
} else {
55+
study.getWorkbench().addListener("changeDeserialized", e => {
56+
if (e.getData()) {
57+
studyReady();
58+
}
59+
}, this);
60+
}
9561
}
9662
}
9763
}

services/static-webserver/client/source/class/osparc/widget/PersistentIframe.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -334,11 +334,14 @@ qx.Class.define("osparc.widget.PersistentIframe", {
334334
// this is the MetaModeling service trying to show function/template information
335335
if (data["message"] && data["message"]["functionId"]) {
336336
const templateId = data["message"]["functionId"];
337-
osparc.store.Templates.fetchTemplate(templateId)
338-
.then(templateData => {
339-
osparc.study.StudyPreview.popUpPreview(templateData);
340-
})
341-
.catch(() => osparc.FlashMessenger.logError(this.tr("Function not found")));
337+
const functionData = {
338+
"uuid": templateId,
339+
"resourceType": "function",
340+
};
341+
const resourceDetails = new osparc.dashboard.ResourceDetails(functionData).set({
342+
showOpenButton: false,
343+
});
344+
osparc.dashboard.ResourceDetails.popUpInWindow(resourceDetails);
342345
}
343346
break;
344347
}

0 commit comments

Comments
 (0)