Skip to content

Commit cbefa65

Browse files
Merge branch 'master' into improve-listing-task-manager-3
2 parents 80de8a1 + c49b779 commit cbefa65

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+438
-533
lines changed

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

Lines changed: 64 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
* @ignore(fetch)
2323
*/
2424

25-
qx.Class.define("osparc.dashboard.ServiceBrowser", {
25+
qx.Class.define("osparc.dashboard.AppBrowser", {
2626
extend: osparc.dashboard.ResourceBrowserBase,
2727

2828
construct: function() {
@@ -43,8 +43,12 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
4343
this._resourcesInitialized = true;
4444

4545
this._resourcesList = [];
46-
osparc.store.Services.getServicesLatest()
47-
.then(services => {
46+
Promise.all([
47+
osparc.store.Services.getServicesLatest(),
48+
osparc.store.Templates.getTemplatesHypertools(),
49+
])
50+
.then(resps => {
51+
const services = resps[0];
4852
// Show "Contact Us" message if services.length === 0
4953
// Most probably is a product-stranger user (it can also be that the catalog is down)
5054
if (Object.keys(services).length === 0) {
@@ -65,30 +69,52 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
6569

6670
reloadResources: function() {
6771
this.__loadServices();
72+
this.__loadHypertools();
6873
},
6974

7075
__loadServices: function() {
7176
const excludeFrontend = true;
7277
const excludeDeprecated = true
7378
osparc.store.Services.getServicesLatestList(excludeFrontend, excludeDeprecated)
74-
.then(servicesList => this.__setServicesToList(servicesList.filter(service => service !== null)));
79+
.then(servicesList => {
80+
servicesList.forEach(service => service["resourceType"] = "service");
81+
this._resourcesList.push(...servicesList.filter(service => service !== null));
82+
this.__sortAndReload();
83+
});
84+
},
85+
86+
__loadHypertools: function() {
87+
osparc.store.Templates.getTemplatesHypertools()
88+
.then(hypertoolsList => {
89+
hypertoolsList.forEach(hypertool => hypertool["resourceType"] = "hypertool");
90+
this._resourcesList.push(...hypertoolsList.filter(hypertool => hypertool !== null));
91+
this.__sortAndReload();
92+
});
93+
},
94+
95+
__sortAndReload: function() {
96+
osparc.service.Utils.sortObjectsBasedOn(this._resourcesList, this.__sortBy);
97+
this._reloadCards();
7598
},
7699

77100
_updateServiceData: function(serviceData) {
78101
serviceData["resourceType"] = "service";
79-
const servicesList = this._resourcesList;
80-
const index = servicesList.findIndex(service => service["key"] === serviceData["key"] && service["version"] === serviceData["version"]);
102+
const appsList = this._resourcesList;
103+
const index = appsList.findIndex(service => service["key"] === serviceData["key"] && service["version"] === serviceData["version"]);
81104
if (index !== -1) {
82-
servicesList[index] = serviceData;
105+
appsList[index] = serviceData;
83106
this._reloadCards();
84107
}
85108
},
86109

87-
__setServicesToList: function(servicesList) {
88-
servicesList.forEach(service => service["resourceType"] = "service");
89-
osparc.service.Utils.sortObjectsBasedOn(servicesList, this.__sortBy);
90-
this._resourcesList = servicesList;
91-
this._reloadCards();
110+
_updateHypertoolData: function(hypertoolData) {
111+
hypertoolData["resourceType"] = "hypertool";
112+
const appsList = this._resourcesList;
113+
const index = appsList.findIndex(service => service["uuid"] === hypertoolData["uuid"]);
114+
if (index !== -1) {
115+
appsList[index] = hypertoolData;
116+
this._reloadCards();
117+
}
92118
},
93119

94120
_reloadCards: function() {
@@ -103,8 +129,8 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
103129
},
104130

105131
__itemClicked: function(card) {
106-
const serviceData = card.getResourceData();
107-
this._openResourceDetails(serviceData);
132+
const appData = card.getResourceData();
133+
this._openResourceDetails(appData);
108134
this.resetSelection();
109135
},
110136

@@ -126,6 +152,28 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
126152
return this._resourcesContainer;
127153
},
128154

155+
__addSortingButtons: function() {
156+
const containerSortButtons = new osparc.service.SortServicesButtons();
157+
containerSortButtons.set({
158+
appearance: "form-button-outlined"
159+
});
160+
containerSortButtons.addListener("sortBy", e => {
161+
this.__sortBy = e.getData();
162+
this.__sortAndReload();
163+
}, this);
164+
this._toolbar.add(containerSortButtons);
165+
},
166+
167+
_populateCardMenu: function(card) {
168+
const menu = card.getMenu();
169+
const appData = card.getResourceData();
170+
171+
const openButton = this._getOpenMenuButton(appData);
172+
if (openButton) {
173+
menu.add(openButton);
174+
}
175+
},
176+
129177
__addNewServiceButtons: function() {
130178
const platformName = osparc.store.StaticInfo.getInstance().getPlatformName();
131179
const hasRights = osparc.data.Permissions.getInstance().canDo("studies.template.create.productAll");
@@ -140,7 +188,7 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
140188
this._toolbar.add(testDataButton);
141189
}
142190

143-
const addServiceButton = new qx.ui.form.Button(this.tr("Submit new service"), "@FontAwesome5Solid/plus-circle/14");
191+
const addServiceButton = new qx.ui.form.Button(this.tr("Submit new app"), "@FontAwesome5Solid/plus-circle/14");
144192
addServiceButton.set({
145193
appearance: "form-button-outlined",
146194
visibility: hasRights ? "visible" : "excluded"
@@ -149,30 +197,8 @@ qx.Class.define("osparc.dashboard.ServiceBrowser", {
149197
this._toolbar.add(addServiceButton);
150198
},
151199

152-
__addSortingButtons: function() {
153-
const containerSortButtons = new osparc.service.SortServicesButtons();
154-
containerSortButtons.set({
155-
appearance: "form-button-outlined"
156-
});
157-
containerSortButtons.addListener("sortBy", e => {
158-
this.__sortBy = e.getData();
159-
this.__setServicesToList(this._resourcesList);
160-
}, this);
161-
this._toolbar.add(containerSortButtons);
162-
},
163-
164-
_populateCardMenu: function(card) {
165-
const menu = card.getMenu();
166-
const serviceData = card.getResourceData();
167-
168-
const openButton = this._getOpenMenuButton(serviceData);
169-
if (openButton) {
170-
menu.add(openButton);
171-
}
172-
},
173-
174200
__displayServiceSubmissionForm: function(formData) {
175-
const addServiceWindow = new osparc.ui.window.Window(this.tr("Submit a new service")).set({
201+
const addServiceWindow = new osparc.ui.window.Window(this.tr("Submit a new app")).set({
176202
modal: true,
177203
autoDestroy: true,
178204
showMinimize: false,

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

Lines changed: 41 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
4141
"updateStudy": "qx.event.type.Data",
4242
"updateTemplate": "qx.event.type.Data",
4343
"updateService": "qx.event.type.Data",
44+
"updateHypertool": "qx.event.type.Data",
4445
"publishTemplate": "qx.event.type.Data",
4546
"tagClicked": "qx.event.type.Data",
4647
"emptyStudyClicked": "qx.event.type.Data"
@@ -160,10 +161,10 @@ qx.Class.define("osparc.dashboard.CardBase", {
160161
return false;
161162
},
162163

163-
filterServiceType: function(resourceType, metadata, serviceType) {
164-
if (serviceType && resourceType === "service") {
164+
filterAppType: function(resourceType, metadata, appType) {
165+
if (appType && ["service", "hypertool"].includes(resourceType)) {
165166
if (metadata && metadata.type) {
166-
const matches = metadata.type === serviceType;
167+
const matches = metadata.type === appType;
167168
return !matches;
168169
}
169170
return false;
@@ -221,11 +222,11 @@ qx.Class.define("osparc.dashboard.CardBase", {
221222
const organizations = groupsStore.getOrganizations();
222223
const myGroupId = groupsStore.getMyGroupId();
223224

224-
const sharedGrps = [];
225225
const groups = [];
226226
groups.push(groupEveryone);
227227
groups.push(groupProductEveryone);
228228
groups.push(...Object.values(organizations));
229+
const sharedGrps = [];
229230
groups.forEach(group => {
230231
const idx = gids.indexOf(group.getGroupId());
231232
if (idx > -1) {
@@ -260,7 +261,10 @@ qx.Class.define("osparc.dashboard.CardBase", {
260261
sharedGrpLabels.push("...");
261262
break;
262263
}
263-
const sharedGrpLabel = sharedGrps[i].getLabel();
264+
let sharedGrpLabel = sharedGrps[i].getLabel();
265+
if ([groupEveryone, groupProductEveryone].includes(sharedGrps[i])) {
266+
sharedGrpLabel = "Public";
267+
}
264268
if (!sharedGrpLabels.includes(sharedGrpLabel)) {
265269
sharedGrpLabels.push(sharedGrpLabel);
266270
}
@@ -315,7 +319,12 @@ qx.Class.define("osparc.dashboard.CardBase", {
315319
},
316320

317321
resourceType: {
318-
check: ["study", "template", "service"],
322+
check: [
323+
"study",
324+
"template",
325+
"service",
326+
"hypertool",
327+
],
319328
init: true,
320329
nullable: true,
321330
event: "changeResourceType"
@@ -506,11 +515,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
506515
let icon = null;
507516
switch (resourceData["resourceType"]) {
508517
case "study":
509-
uuid = resourceData.uuid ? resourceData.uuid : null;
510-
owner = resourceData.prjOwner ? resourceData.prjOwner : "";
511-
workbench = resourceData.workbench ? resourceData.workbench : {};
512-
break;
513518
case "template":
519+
case "hypertool":
514520
uuid = resourceData.uuid ? resourceData.uuid : null;
515521
owner = resourceData.prjOwner ? resourceData.prjOwner : "";
516522
workbench = resourceData.workbench ? resourceData.workbench : {};
@@ -543,7 +549,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
543549
workbench
544550
});
545551

546-
if (resourceData["resourceType"] === "study" || resourceData["resourceType"] === "template") {
552+
if (["study", "template", "hypertool"].includes(resourceData["resourceType"])) {
547553
osparc.store.Services.getStudyServices(resourceData.uuid)
548554
.then(resp => {
549555
const services = resp["services"];
@@ -993,7 +999,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
993999
[
9941000
"updateStudy",
9951001
"updateTemplate",
996-
"updateService"
1002+
"updateService",
1003+
"updateHypertool",
9971004
].forEach(ev => {
9981005
resourceDetails.addListener(ev, e => this.fireDataEvent(ev, e.getData()));
9991006
});
@@ -1045,6 +1052,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
10451052
toolTipText += osparc.product.Utils.getStudyAlias();
10461053
} else if (this.isResourceType("template")) {
10471054
toolTipText += osparc.product.Utils.getTemplateAlias();
1055+
} else if (this.isResourceType("hypertool")) {
1056+
toolTipText += osparc.product.Utils.getAppAlias();
10481057
}
10491058
const control = new qx.ui.basic.Image().set({
10501059
source: "@FontAwesome5Solid/times-circle/14",
@@ -1103,10 +1112,10 @@ qx.Class.define("osparc.dashboard.CardBase", {
11031112
return this.self().filterSharedWith(checks, sharedWith);
11041113
},
11051114

1106-
_filterServiceType: function(serviceType) {
1115+
__filterAppType: function(appType) {
11071116
const resourceType = this.getResourceType();
11081117
const resourceData = this.getResourceData();
1109-
return this.self().filterServiceType(resourceType, resourceData, serviceType);
1118+
return this.self().filterAppType(resourceType, resourceData, appType);
11101119
},
11111120

11121121
_filterClassifiers: function(classifiers) {
@@ -1117,7 +1126,14 @@ qx.Class.define("osparc.dashboard.CardBase", {
11171126
_shouldApplyFilter: function(data) {
11181127
let filterId = "searchBarFilter";
11191128
if (this.isPropertyInitialized("resourceType")) {
1120-
filterId += "-" + this.getResourceType();
1129+
switch (this.getResourceType()) {
1130+
case "hypertool":
1131+
filterId += "-service";
1132+
break;
1133+
default:
1134+
filterId += "-" + this.getResourceType();
1135+
break;
1136+
}
11211137
}
11221138
data = filterId in data ? data[filterId] : data;
11231139
if (this._filterText(data.text)) {
@@ -1129,7 +1145,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
11291145
if (this._filterSharedWith(data.sharedWith)) {
11301146
return true;
11311147
}
1132-
if (this._filterServiceType(data.serviceType)) {
1148+
if (this.__filterAppType(data.appType)) {
11331149
return true;
11341150
}
11351151
if (this._filterClassifiers(data.classifiers)) {
@@ -1141,7 +1157,14 @@ qx.Class.define("osparc.dashboard.CardBase", {
11411157
_shouldReactToFilter: function(data) {
11421158
let filterId = "searchBarFilter";
11431159
if (this.isPropertyInitialized("resourceType")) {
1144-
filterId += "-" + this.getResourceType();
1160+
switch (this.getResourceType()) {
1161+
case "hypertool":
1162+
filterId += "-service";
1163+
break;
1164+
default:
1165+
filterId += "-" + this.getResourceType();
1166+
break;
1167+
}
11451168
}
11461169
data = filterId in data ? data[filterId] : data;
11471170
if (data.text && data.text.length > 1) {
@@ -1153,7 +1176,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
11531176
if (data.sharedWith) {
11541177
return true;
11551178
}
1156-
if ("serviceType" in data) {
1179+
if ("appType" in data) {
11571180
return true;
11581181
}
11591182
if (data.classifiers && data.classifiers.length) {

0 commit comments

Comments
 (0)