Skip to content

Commit da17b1e

Browse files
committed
Merge branch 'master' into 7654-bugfix-get-legacy-tasks
2 parents b2b94b9 + 5125753 commit da17b1e

File tree

19 files changed

+646
-154
lines changed

19 files changed

+646
-154
lines changed

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

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,16 @@ qx.Class.define("osparc.dashboard.Dashboard", {
123123
icon: "@FontAwesome5Solid/copy/"+tabIconSize,
124124
buildLayout: this.__createTemplateBrowser
125125
});
126-
tabs.push({
127-
id: "hypertoolsTab",
128-
buttonId: "hypertoolsTabBtn",
129-
label: this.tr("HYPERTOOLS"),
130-
icon: "@FontAwesome5Solid/copy/"+tabIconSize,
131-
initVisibility: "excluded",
132-
buildLayout: this.__createHypertoolsBrowser
133-
});
126+
if (osparc.product.Utils.isS4LProduct() && osparc.store.StaticInfo.getInstance().isDevFeaturesEnabled()) {
127+
tabs.push({
128+
id: "hypertoolsTab",
129+
buttonId: "hypertoolsTabBtn",
130+
label: this.tr("HYPERTOOLS"),
131+
icon: "@FontAwesome5Solid/copy/"+tabIconSize,
132+
// initVisibility: "excluded",
133+
buildLayout: this.__createHypertoolsBrowser
134+
});
135+
}
134136
}
135137
if (permissions.canDo("dashboard.services.read")) {
136138
tabs.push({
@@ -172,26 +174,25 @@ qx.Class.define("osparc.dashboard.Dashboard", {
172174
osparc.utils.Utils.setIdToWidget(tabButton, buttonId);
173175
tabPage.setLayout(new qx.ui.layout.Grow());
174176

175-
const viewLayout = buildLayout.call(this);
177+
const resourceBrowser = buildLayout.call(this);
176178
tabButton.addListener("execute", () => {
177-
if (viewLayout.resetSelection) {
178-
viewLayout.resetSelection();
179+
if (resourceBrowser.resetSelection) {
180+
resourceBrowser.resetSelection();
179181
}
180182
}, this);
181-
viewLayout.addListener("changeTab", e => {
183+
184+
resourceBrowser.addListener("changeTab", e => {
182185
const activeTab = e.getData();
183186
const tabFound = this.getSelectables().find(s => s.id === activeTab);
184187
if (tabFound) {
185188
this.setSelection([tabFound]);
186189
}
187190
}, this);
188-
viewLayout.addListener("showTab", e => {
189-
const showTab = e.getData();
190-
tabButton.setVisibility(showTab ? "visible" : "excluded");
191-
})
191+
192192
const scrollerMainView = new qx.ui.container.Scroll();
193-
scrollerMainView.add(viewLayout);
193+
scrollerMainView.add(resourceBrowser);
194194
tabPage.add(scrollerMainView);
195+
tabPage.resourceBrowser = resourceBrowser;
195196

196197
this.add(tabPage);
197198
}, this);
@@ -200,20 +201,24 @@ qx.Class.define("osparc.dashboard.Dashboard", {
200201
const groupsStore = osparc.store.Groups.getInstance();
201202
preResourcePromises.push(groupsStore.fetchGroupsAndMembers());
202203
preResourcePromises.push(osparc.store.Services.getServicesLatest(false));
203-
preResourcePromises.push(osparc.store.Templates.getInstance().fetchAllTemplates());
204204
Promise.all(preResourcePromises)
205205
.then(() => {
206-
[
207-
this.__studyBrowser,
208-
this.__templateBrowser,
209-
this.__hypertoolBrowser,
210-
this.__serviceBrowser,
211-
this.__dataBrowser
212-
].forEach(resourceBrowser => {
213-
if (resourceBrowser) {
214-
resourceBrowser.initResources();
206+
if (this.__studyBrowser) {
207+
this.__studyBrowser.initResources();
208+
}
209+
if (this.__serviceBrowser) {
210+
this.__serviceBrowser.initResources();
211+
}
212+
if (this.__dataBrowser) {
213+
this.__dataBrowser.initResources();
214+
}
215+
216+
this.addListener("changeSelection", e => {
217+
const selectedTab = e.getData()[0];
218+
if (selectedTab && selectedTab.resourceBrowser) {
219+
selectedTab.resourceBrowser.initResources();
215220
}
216-
});
221+
}, this);
217222
})
218223
.catch(err => console.error(err));
219224
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ qx.Class.define("osparc.dashboard.DataBrowser", {
5555

5656
// overridden
5757
initResources: function() {
58+
if (this._resourcesInitialized) {
59+
return;
60+
}
61+
this._resourcesInitialized = true;
62+
5863
this._hideLoadingPage();
5964
this.__buildLayout();
6065

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

Lines changed: 43 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
172172
__addUIConfigItems: function() {
173173
const plusButtonConfig = osparc.store.Products.getInstance().getPlusButtonUiConfig();
174174
if (plusButtonConfig) {
175-
const templates = osparc.store.Templates.getInstance().getTemplates()
176175
if (plusButtonConfig["categories"]) {
177176
this.__addCategories(plusButtonConfig["categories"]);
178177
}
@@ -182,7 +181,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
182181
} else if (buttonConfig["resourceType"] === "study") {
183182
this.__addEmptyStudyButton(buttonConfig);
184183
} else if (buttonConfig["resourceType"] === "template") {
185-
this.__addFromTemplateButton(buttonConfig, templates);
184+
this.__addFromTemplateButton(buttonConfig);
186185
} else if (buttonConfig["resourceType"] === "service") {
187186
this.__addFromServiceButton(buttonConfig);
188187
}
@@ -191,28 +190,30 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
191190
},
192191

193192
__addHypertools: function() {
194-
const hypertools = osparc.store.Templates.getInstance().getTemplatesByType(osparc.data.model.StudyUI.HYPERTOOL_TYPE);
195-
if (hypertools.length) {
196-
const hypertoolsMenuButton = this.self().createMenuButton("@FontAwesome5Solid/star/16", this.tr("Hypertools"));
197-
this.addAt(hypertoolsMenuButton, this.__itemIdx);
198-
this.__itemIdx++;
199-
200-
const hypertoolsMenu = new qx.ui.menu.Menu().set({
201-
appearance: "menu-wider",
202-
});
203-
hypertoolsMenuButton.setMenu(hypertoolsMenu);
204-
205-
hypertools.forEach(templateData => {
206-
const hypertoolButton = this.self().createMenuButton(templateData["icon"], templateData["name"]);
207-
hypertoolButton.addListener("tap", () => {
208-
this.fireDataEvent("newStudyFromTemplateClicked", {
209-
templateData,
210-
newStudyLabel: templateData["name"],
193+
osparc.store.Templates.getTemplatesHypertools()
194+
.then(hypertools => {
195+
if (hypertools.length) {
196+
const hypertoolsMenuButton = this.self().createMenuButton("@FontAwesome5Solid/star/16", this.tr("Hypertools"));
197+
this.addAt(hypertoolsMenuButton, this.__itemIdx);
198+
this.__itemIdx++;
199+
200+
const hypertoolsMenu = new qx.ui.menu.Menu().set({
201+
appearance: "menu-wider",
211202
});
212-
});
213-
hypertoolsMenu.add(hypertoolButton);
203+
hypertoolsMenuButton.setMenu(hypertoolsMenu);
204+
205+
hypertools.forEach(templateData => {
206+
const hypertoolButton = this.self().createMenuButton(templateData["icon"], templateData["name"]);
207+
hypertoolButton.addListener("tap", () => {
208+
this.fireDataEvent("newStudyFromTemplateClicked", {
209+
templateData,
210+
newStudyLabel: templateData["name"],
211+
});
212+
});
213+
hypertoolsMenu.add(hypertoolButton);
214+
});
215+
}
214216
});
215-
}
216217
},
217218

218219
__addOtherTabsAccess: function() {
@@ -321,24 +322,27 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
321322
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
322323
},
323324

324-
__addFromTemplateButton: function(buttonConfig, templates) {
325-
const menuButton = this.self().createMenuButton(null, buttonConfig["title"]);
326-
osparc.utils.Utils.setIdToWidget(menuButton, buttonConfig["idToWidget"]);
327-
// disable it until found in templates store
328-
menuButton.setEnabled(false);
329-
330-
let templateMetadata = templates.find(t => t.name === buttonConfig["expectedTemplateLabel"]);
331-
if (templateMetadata) {
332-
menuButton.setEnabled(true);
333-
menuButton.addListener("tap", () => {
334-
this.fireDataEvent("newStudyFromTemplateClicked", {
335-
templateData: templateMetadata,
336-
newStudyLabel: buttonConfig["newStudyLabel"],
337-
});
325+
__addFromTemplateButton: function(buttonConfig) {
326+
osparc.store.Templates.getTemplates()
327+
.then(templates => {
328+
const menuButton = this.self().createMenuButton(null, buttonConfig["title"]);
329+
osparc.utils.Utils.setIdToWidget(menuButton, buttonConfig["idToWidget"]);
330+
// disable it until found in templates store
331+
menuButton.setEnabled(false);
332+
333+
let templateMetadata = templates.find(t => t.name === buttonConfig["expectedTemplateLabel"]);
334+
if (templateMetadata) {
335+
menuButton.setEnabled(true);
336+
menuButton.addListener("tap", () => {
337+
this.fireDataEvent("newStudyFromTemplateClicked", {
338+
templateData: templateMetadata,
339+
newStudyLabel: buttonConfig["newStudyLabel"],
340+
});
341+
});
342+
this.__addIcon(menuButton, buttonConfig["icon"], templateMetadata);
343+
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
344+
}
338345
});
339-
this.__addIcon(menuButton, buttonConfig["icon"], templateMetadata);
340-
this.__addFromResourceButton(menuButton, buttonConfig["category"]);
341-
}
342346
},
343347

344348
__addFromServiceButton: function(buttonConfig) {

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

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ qx.Class.define("osparc.dashboard.NewStudies", {
3636
});
3737
this._add(this.__flatList);
3838

39-
const templates = osparc.store.Templates.getInstance().getTemplates()
40-
this.__newStudies = newButtonsInfo.filter(newButtonInfo => {
41-
if (newButtonInfo.showDisabled) {
42-
return true;
43-
}
44-
return templates.find(t => t.name === newButtonInfo.expectedTemplateLabel);
45-
});
39+
osparc.store.Templates.getTemplates()
40+
.then(templates => {
41+
this.__newStudies = newButtonsInfo.filter(newButtonInfo => {
42+
if (newButtonInfo.showDisabled) {
43+
return true;
44+
}
45+
return templates.find(t => t.name === newButtonInfo.expectedTemplateLabel);
46+
});
47+
48+
this.setGroupBy("category");
49+
});
4650
},
4751

4852
properties: {

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
3131
construct: function() {
3232
this.base(arguments);
3333

34+
this._resourcesInitialized = false;
35+
3436
this._showLoadingPage(this.tr("Starting") + " " + osparc.store.StaticInfo.getInstance().getDisplayName());
3537

3638
const padding = osparc.dashboard.Dashboard.PADDING;
@@ -88,7 +90,6 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
8890

8991
events: {
9092
"changeTab": "qx.event.type.Data",
91-
"showTab": "qx.event.type.Data",
9293
"publishTemplate": "qx.event.type.Data",
9394
},
9495

@@ -210,6 +211,7 @@ qx.Class.define("osparc.dashboard.ResourceBrowserBase", {
210211
__centerLayout: null,
211212
_resourceType: null,
212213
_resourcesList: null,
214+
_resourcesInitialized: null,
213215
_toolbar: null,
214216
_searchBarFilter: null,
215217
__viewModeLayout: null,

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

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
336336
this.__getConversationsPage,
337337
this.__getPermissionsPage,
338338
this.__getSaveAsTemplatePage,
339+
this.__getCreateFunctionsPage,
339340
this.__getTagsPage,
340341
this.__getQualityPage,
341342
this.__getClassifiersPage,
@@ -688,7 +689,7 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
688689

689690
const id = "ServicesUpdate";
690691
const title = this.tr("Services Updates");
691-
const iconSrc = "@MaterialIcons/update/22";
692+
const iconSrc = "@MaterialIcons/update/24";
692693
const page = this.__servicesUpdatePage = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
693694
this.__addOpenButton(page);
694695

@@ -801,6 +802,29 @@ qx.Class.define("osparc.dashboard.ResourceDetails", {
801802
return page;
802803
}
803804
return null;
805+
},
806+
807+
__getCreateFunctionsPage: function() {
808+
if (!osparc.utils.Resources.isStudy(this.__resourceData)) {
809+
return null;
810+
}
811+
812+
if (!osparc.study.Utils.canCreateFunction(this.__resourceData["workbench"])) {
813+
return null;
814+
}
815+
816+
const id = "CreateFunction";
817+
const iconSrc = "@MaterialIcons/functions/24";
818+
const title = this.tr("Create Function");
819+
const page = new osparc.dashboard.resources.pages.BasePage(title, iconSrc, id);
820+
const createFunction = new osparc.study.CreateFunction(this.__resourceData);
821+
const createFunctionButton = createFunction.getCreateFunctionButton();
822+
osparc.dashboard.resources.pages.BasePage.decorateHeaderButton(createFunctionButton);
823+
const toolbar = this.self().createToolbar();
824+
toolbar.add(createFunctionButton);
825+
page.addToHeader(toolbar);
826+
page.addToContent(createFunction);
827+
return page;
804828
}
805829
}
806830
});

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
3737

3838
// overridden
3939
initResources: function() {
40+
if (this._resourcesInitialized) {
41+
return;
42+
}
43+
this._resourcesInitialized = true;
44+
4045
this._resourcesList = [];
4146
osparc.store.Services.getServicesLatest()
4247
.then(services => {

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

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,11 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
9292

9393
// overridden
9494
initResources: function() {
95+
if (this._resourcesInitialized) {
96+
return;
97+
}
98+
this._resourcesInitialized = true;
99+
95100
this._resourcesList = [];
96101
this.__getActiveStudy()
97102
.then(() => {
@@ -907,25 +912,26 @@ qx.Class.define("osparc.dashboard.StudyBrowser", {
907912
newPlansBtn.setEnabled(true);
908913

909914
newPlansBtn.addListener("tap", () => {
910-
const templates = osparc.store.Templates.getInstance().getTemplates();
911-
if (templates) {
912-
const newStudies = new osparc.dashboard.NewStudies(newStudiesConfig);
913-
newStudies.setGroupBy("category");
914-
const winTitle = this.tr("New Plan");
915-
const win = osparc.ui.window.Window.popUpInWindow(newStudies, winTitle, osparc.dashboard.NewStudies.WIDTH+40, 300).set({
916-
clickAwayClose: false,
917-
resizable: true
918-
});
919-
newStudies.addListener("newStudyClicked", e => {
920-
win.close();
921-
const templateInfo = e.getData();
922-
const templateData = templates.find(t => t.name === templateInfo.expectedTemplateLabel);
923-
if (templateData) {
924-
this.__newPlanBtnClicked(templateData, templateInfo.newStudyLabel);
915+
osparc.store.Templates.getTemplates()
916+
.then(templates => {
917+
if (templates) {
918+
const newStudies = new osparc.dashboard.NewStudies(newStudiesConfig);
919+
const winTitle = this.tr("New Plan");
920+
const win = osparc.ui.window.Window.popUpInWindow(newStudies, winTitle, osparc.dashboard.NewStudies.WIDTH+40, 300).set({
921+
clickAwayClose: false,
922+
resizable: true
923+
});
924+
newStudies.addListener("newStudyClicked", e => {
925+
win.close();
926+
const templateInfo = e.getData();
927+
const templateData = templates.find(t => t.name === templateInfo.expectedTemplateLabel);
928+
if (templateData) {
929+
this.__newPlanBtnClicked(templateData, templateInfo.newStudyLabel);
930+
}
931+
});
932+
osparc.utils.Utils.setIdToWidget(win, "newStudiesWindow");
925933
}
926934
});
927-
osparc.utils.Utils.setIdToWidget(win, "newStudiesWindow");
928-
}
929935
});
930936
}
931937
},

0 commit comments

Comments
 (0)