Skip to content

Commit cafef71

Browse files
committed
services as property
1 parent 734c5f5 commit cafef71

File tree

1 file changed

+39
-29
lines changed
  • services/static-webserver/client/source/class/osparc/dashboard

1 file changed

+39
-29
lines changed

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

Lines changed: 39 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,14 @@ qx.Class.define("osparc.dashboard.CardBase", {
373373
workbench: {
374374
check: "Object",
375375
nullable: true,
376-
apply: "__applyWorkbench"
376+
},
377+
378+
services: {
379+
check: "Array",
380+
init: true,
381+
nullable: false,
382+
apply: "__applyServices",
383+
event: "changeServices",
377384
},
378385

379386
uiMode: {
@@ -519,6 +526,10 @@ qx.Class.define("osparc.dashboard.CardBase", {
519526
hits: resourceData.hits ? resourceData.hits : defaultHits,
520527
workbench
521528
});
529+
530+
if (resourceData["resourceType"] === "study" || resourceData["resourceType"] === "template") {
531+
this.__fetchServices();
532+
}
522533
},
523534

524535
__applyMultiSelectionMode: function(value) {
@@ -634,12 +645,7 @@ qx.Class.define("osparc.dashboard.CardBase", {
634645
}
635646
},
636647

637-
__applyWorkbench: function(workbench) {
638-
if (workbench === null) {
639-
// it is a service
640-
return;
641-
}
642-
648+
__fetchServices: function() {
643649
if (this.isResourceType("study") || this.isResourceType("template")) {
644650
const params = {
645651
url: {
@@ -649,32 +655,36 @@ qx.Class.define("osparc.dashboard.CardBase", {
649655
osparc.data.Resources.fetch("studies", "getServices", params)
650656
.then(resp => {
651657
const services = resp["services"];
652-
this.setEmptyWorkbench(services.length === 0);
653-
654-
// Updatable study
655-
if (osparc.study.Utils.anyServiceRetired(services)) {
656-
this.setUpdatable("retired");
657-
} else if (osparc.study.Utils.anyServiceDeprecated(services)) {
658-
this.setUpdatable("deprecated");
659-
} else if (osparc.study.Utils.anyServiceUpdatable(services)) {
660-
this.setUpdatable("updatable");
661-
}
662-
663-
// Block card
664-
const unaccessibleServices = osparc.study.Utils.getInaccessibleServices2(services);
665-
if (unaccessibleServices.length) {
666-
this.setBlocked("UNKNOWN_SERVICES");
667-
const image = "@FontAwesome5Solid/ban/";
668-
let toolTipText = this.tr("Unaccessible service(s):");
669-
unaccessibleServices.forEach(unSrv => {
670-
toolTipText += "<br>" + unSrv.key + ":" + osparc.service.Utils.extractVersionDisplay(unSrv.release);
671-
});
672-
this.__showBlockedCard(image, toolTipText);
673-
}
658+
this.setServices(services);
674659
});
675660
}
676661
},
677662

663+
__applyServices: function(services) {
664+
this.setEmptyWorkbench(services.length === 0);
665+
666+
// Updatable study
667+
if (osparc.study.Utils.anyServiceRetired(services)) {
668+
this.setUpdatable("retired");
669+
} else if (osparc.study.Utils.anyServiceDeprecated(services)) {
670+
this.setUpdatable("deprecated");
671+
} else if (osparc.study.Utils.anyServiceUpdatable(services)) {
672+
this.setUpdatable("updatable");
673+
}
674+
675+
// Block card
676+
const unaccessibleServices = osparc.study.Utils.getInaccessibleServices2(services);
677+
if (unaccessibleServices.length) {
678+
this.setBlocked("UNKNOWN_SERVICES");
679+
const image = "@FontAwesome5Solid/ban/";
680+
let toolTipText = this.tr("Unaccessible service(s):");
681+
unaccessibleServices.forEach(unSrv => {
682+
toolTipText += "<br>" + unSrv.key + ":" + osparc.service.Utils.extractVersionDisplay(unSrv.release);
683+
});
684+
this.__showBlockedCard(image, toolTipText);
685+
}
686+
},
687+
678688
__applyEmptyWorkbench: function(isEmpty) {
679689
const emptyWorkbench = this.getChildControl("empty-workbench");
680690
emptyWorkbench.setVisibility(isEmpty ? "visible" : "excluded");

0 commit comments

Comments
 (0)