Skip to content

Commit 28256a7

Browse files
committed
[skip ci] more refactoring
1 parent c70e66f commit 28256a7

File tree

3 files changed

+30
-22
lines changed

3 files changed

+30
-22
lines changed

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -491,13 +491,13 @@ qx.Class.define("osparc.dashboard.CardBase", {
491491
uuid = resourceData.uuid ? resourceData.uuid : null;
492492
owner = resourceData.prjOwner ? resourceData.prjOwner : "";
493493
workbench = resourceData.workbench ? resourceData.workbench : {};
494-
icon = osparc.study.Utils.guessIcon(resourceData);
494+
// icon = osparc.study.Utils.guessIcon(resourceData);
495495
break;
496496
case "template":
497497
uuid = resourceData.uuid ? resourceData.uuid : null;
498498
owner = resourceData.prjOwner ? resourceData.prjOwner : "";
499499
workbench = resourceData.workbench ? resourceData.workbench : {};
500-
icon = osparc.study.Utils.guessIcon(resourceData);
500+
// icon = osparc.study.Utils.guessIcon(resourceData);
501501
break;
502502
case "service":
503503
uuid = resourceData.key ? resourceData.key : null;
@@ -539,6 +539,8 @@ qx.Class.define("osparc.dashboard.CardBase", {
539539
resourceData["services"] = services;
540540
this.setServices(services);
541541
});
542+
543+
// icon = osparc.study.Utils.guessIcon(resourceData);
542544
}
543545
},
544546

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ qx.Class.define("osparc.dashboard.NewPlusMenu", {
343343
});
344344
for (let i=0; i<newStudyData["myMostUsed"]; i++) {
345345
const latestMetadata = servicesList[i];
346-
if (latestMetadata["hits"] > 0) {
346+
if (latestMetadata && latestMetadata["hits"] > 0) {
347347
const menuButton = new qx.ui.menu.Button().set({
348348
label: latestMetadata["name"],
349349
font: "text-16",

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

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -331,29 +331,35 @@ qx.Class.define("osparc.study.Utils", {
331331
},
332332

333333
guessIcon: function(studyData) {
334-
if (osparc.product.Utils.isProduct("tis") || osparc.product.Utils.isProduct("tiplite")) {
335-
return this.__guessTIPIcon(studyData);
336-
}
337-
return this.__guessIcon(studyData);
334+
return new Promise(resolve => {
335+
if (osparc.product.Utils.isProduct("tis") || osparc.product.Utils.isProduct("tiplite")) {
336+
resolve(this.__guessTIPIcon(studyData));
337+
} else {
338+
resolve(this.__guessIcon(studyData));
339+
}
340+
});
338341
},
339342

340343
__guessIcon: function(studyData) {
341-
// the was to guess the TI type is to check the boot mode of the ti-postpro in the pipeline
342-
const wbServices = this.self().getNonFrontendNodes(studyData);
343-
if (wbServices.length === 1) {
344-
const wbService = wbServices[0];
345-
const allServices = osparc.store.Services.servicesCached;
346-
if (wbService.key in allServices && wbService.version in allServices[wbService.key]) {
347-
const serviceMetadata = allServices[wbService.key][wbService.version];
348-
if (serviceMetadata["icon"]) {
349-
return serviceMetadata["icon"];
350-
}
344+
const defaultIcon = osparc.dashboard.CardBase.PRODUCT_ICON;
345+
return new Promise(resolve => {
346+
// the was to guess the TI type is to check the boot mode of the ti-postpro in the pipeline
347+
const wbServices = this.self().getNonFrontendNodes(studyData);
348+
if (wbServices.length === 1) {
349+
const wbService = wbServices[0];
350+
osparc.store.Services.getService(wbService.key, wbService.version)
351+
.then(serviceMetadata => {
352+
if (serviceMetadata["icon"]) {
353+
resolve(serviceMetadata["icon"]);
354+
}
355+
resolve(defaultIcon);
356+
});
357+
} else if (wbServices.length > 1) {
358+
resolve("osparc/icons/diagram.png");
359+
} else {
360+
resolve(defaultIcon);
351361
}
352-
}
353-
if (wbServices.length > 1) {
354-
return "osparc/icons/diagram.png";
355-
}
356-
return osparc.dashboard.CardBase.PRODUCT_ICON;
362+
});
357363
},
358364

359365
__guessTIPIcon: function(studyData) {

0 commit comments

Comments
 (0)