Skip to content

Commit ef38c09

Browse files
authored
✨Pipeline failure to port (ITISFoundation#3028)
1 parent cd864d3 commit ef38c09

File tree

8 files changed

+152
-53
lines changed

8 files changed

+152
-53
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/* ************************************************************************
2+
3+
osparc - the simcore frontend
4+
5+
https://osparc.io
6+
7+
Copyright:
8+
2022 IT'IS Foundation, https://itis.swiss
9+
10+
License:
11+
MIT: https://opensource.org/licenses/MIT
12+
13+
Authors:
14+
* Odei Maiz (odeimaiz)
15+
16+
************************************************************************ */
17+
18+
qx.Class.define("osparc.component.form.PortInfoHint", {
19+
extend: osparc.ui.hint.InfoHint,
20+
21+
statics: {
22+
ERROR_ICON: "@MaterialIcons/error_outline/14"
23+
},
24+
25+
properties: {
26+
portErrorMsg: {
27+
check: "String",
28+
init: null,
29+
nullable: true,
30+
apply: "__applyPortErrorMsg"
31+
}
32+
},
33+
34+
members: {
35+
__applyPortErrorMsg: function(errorMsg) {
36+
let text = this.getHintText();
37+
if (errorMsg) {
38+
const color = qx.theme.manager.Color.getInstance().resolve("failed-red");
39+
text += `<br><br><font color="${color}">${errorMsg}</font>`;
40+
}
41+
this._hint.setText(text);
42+
this.set({
43+
source: errorMsg ? this.self().ERROR_ICON : osparc.ui.hint.InfoHint.INFO_ICON,
44+
textColor: errorMsg ? "failed-red" : "text"
45+
});
46+
}
47+
}
48+
});

services/web/client/source/class/osparc/component/form/renderer/PropForm.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,14 @@ qx.Class.define("osparc.component.form.renderer.PropForm", {
382382
this.fireEvent("changeChildVisibility");
383383
},
384384

385+
setPortErrorMessage: function(portId, msg) {
386+
const infoButton = this._getInfoFieldChild(portId);
387+
if (infoButton && "child" in infoButton) {
388+
const infoHint = infoButton.child;
389+
infoHint.setPortErrorMsg(msg);
390+
}
391+
},
392+
385393
retrievingPortData: function(portId) {
386394
const status = this._retrieveStatus.retrieving;
387395
if (portId) {

services/web/client/source/class/osparc/component/form/renderer/PropFormBase.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ qx.Class.define("osparc.component.form.renderer.PropFormBase", {
244244
},
245245

246246
_createInfoWHint: function(hint) {
247-
const infoWHint = new osparc.ui.hint.InfoHint(hint);
247+
const infoWHint = new osparc.component.form.PortInfoHint(hint);
248248
return infoWHint;
249249
},
250250

@@ -328,6 +328,10 @@ qx.Class.define("osparc.component.form.renderer.PropFormBase", {
328328
return this._getLayoutChild(portId, this.self().GRID_POS.LABEL);
329329
},
330330

331+
_getInfoFieldChild: function(portId) {
332+
return this._getLayoutChild(portId, this.self().GRID_POS.INFO);
333+
},
334+
331335
_getCtrlFieldChild: function(portId) {
332336
return this._getLayoutChild(portId, this.self().GRID_POS.CTRL_FIELD);
333337
},

services/web/client/source/class/osparc/data/model/Node.js

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,14 @@ qx.Class.define("osparc.data.model.Node", {
150150
nullable: false
151151
},
152152

153+
errors: {
154+
check: "Array",
155+
init: [],
156+
nullable: true,
157+
event: "changeErrors",
158+
apply: "__applyErrors"
159+
},
160+
153161
// GUI elements //
154162
propsForm: {
155163
check: "osparc.component.form.renderer.PropForm",
@@ -712,29 +720,41 @@ qx.Class.define("osparc.data.model.Node", {
712720
return outputsData;
713721
},
714722

715-
setErrors: function(errors) {
716-
errors.forEach(error => {
717-
const loc = error["loc"];
718-
if (loc.length < 2) {
719-
return;
720-
}
721-
if (loc[1] === this.getNodeId()) {
722-
const errorMsgData = {
723-
nodeId: this.getNodeId(),
724-
msg: error["msg"],
725-
level: "ERROR"
726-
};
727-
if (loc.length > 2) {
728-
const portKey = loc[2];
729-
if ("inputs" in this.getMetaData() && portKey in this.getMetaData()["inputs"]) {
730-
errorMsgData["msg"] = this.getMetaData()["inputs"][portKey]["label"] + ": " + errorMsgData["msg"];
731-
} else {
732-
errorMsgData["msg"] = portKey + ": " + errorMsgData["msg"];
723+
__applyErrors: function(errors) {
724+
if (errors && errors.length) {
725+
errors.forEach(error => {
726+
const loc = error["loc"];
727+
if (loc.length < 2) {
728+
return;
729+
}
730+
if (loc[1] === this.getNodeId()) {
731+
const errorMsgData = {
732+
nodeId: this.getNodeId(),
733+
msg: error["msg"],
734+
level: "ERROR"
735+
};
736+
737+
// errors to port
738+
if (loc.length > 2) {
739+
const portKey = loc[2];
740+
if (this.hasInputs() && portKey in this.getMetaData()["inputs"]) {
741+
errorMsgData["msg"] = this.getMetaData()["inputs"][portKey]["label"] + ": " + errorMsgData["msg"];
742+
} else {
743+
errorMsgData["msg"] = portKey + ": " + errorMsgData["msg"];
744+
}
745+
this.getPropsForm().setPortErrorMessage(portKey, errorMsgData["msg"]);
733746
}
747+
748+
// errors to logger
749+
this.fireDataEvent("showInLogger", errorMsgData);
734750
}
735-
this.fireDataEvent("showInLogger", errorMsgData);
736-
}
737-
});
751+
});
752+
} else if (this.hasInputs()) {
753+
// reset port errors
754+
Object.keys(this.getMetaData()["inputs"]).forEach(portKey => {
755+
this.getPropsForm().setPortErrorMessage(portKey, null);
756+
});
757+
}
738758
},
739759

740760
// post edge creation routine

services/web/client/source/class/osparc/data/model/Study.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,9 @@ qx.Class.define("osparc.data.model.Study", {
375375
}
376376
if (node && "errors" in nodeUpdatedData) {
377377
const errors = nodeUpdatedData["errors"];
378-
if (errors && errors.length) {
379-
node.setErrors(errors);
380-
}
378+
node.setErrors(errors);
379+
} else {
380+
node.setErrors([]);
381381
}
382382
},
383383

services/web/client/source/class/osparc/navigation/PrevNextButtons.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ qx.Class.define("osparc.navigation.PrevNextButtons", {
4040
NEXT_BUTTON: "@FontAwesome5Solid/arrow-right/32",
4141
RUN_BUTTON: "@FontAwesome5Solid/play/32",
4242
BUSY_BUTTON: "@FontAwesome5Solid/circle-notch/32",
43-
SELECT_FILE_BUTTON: "@FontAwesome5Solid/arrow-right/32"
43+
SELECT_FILE_BUTTON: "@FontAwesome5Solid/file-medical/32"
4444
},
4545

4646
properties: {

services/web/client/source/class/osparc/ui/basic/NodeStatusUI.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,15 @@ qx.Class.define("osparc.ui.basic.NodeStatusUI", {
7070
} else {
7171
this.__setupBlank();
7272
}
73+
node.bind("errors", this, "toolTipText", {
74+
converter: errors => {
75+
let errorsText = "";
76+
if (errors) {
77+
errors.forEach(error => errorsText += error["msg"] + "<br>");
78+
}
79+
return errorsText;
80+
}
81+
});
7382
},
7483

7584
__setupComputational: function() {

services/web/client/source/class/osparc/ui/hint/InfoHint.js

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ qx.Class.define("osparc.ui.hint.InfoHint", {
2525
* @extends osparc.ui.basic.IconButton
2626
*/
2727
construct: function(hint) {
28-
this.base(arguments, "@MaterialIcons/info_outline/14");
28+
this.base(arguments, this.self().INFO_ICON);
29+
30+
this.__createHint();
2931

3032
this.bind("hintText", this, "visibility", {
3133
converter: hintText => (hintText && hintText !== "") ? "visible" : "excluded"
@@ -36,6 +38,10 @@ qx.Class.define("osparc.ui.hint.InfoHint", {
3638
}
3739
},
3840

41+
statics: {
42+
INFO_ICON: "@MaterialIcons/info_outline/14"
43+
},
44+
3945
properties: {
4046
hintText: {
4147
check: "String",
@@ -46,35 +52,39 @@ qx.Class.define("osparc.ui.hint.InfoHint", {
4652
},
4753

4854
members: {
49-
__applyHintText: function(hintText) {
50-
if (hintText && hintText !== "") {
51-
const hint = new osparc.ui.hint.Hint(this, hintText).set({
52-
active: false
53-
});
54-
55-
const showHint = () => hint.show();
56-
const hideHint = () => hint.exclude();
57-
58-
// Make hint "modal" when info button is clicked
59-
const tapListener = event => {
60-
if (osparc.utils.Utils.isMouseOnElement(hint, event)) {
61-
return;
62-
}
63-
hideHint();
64-
document.removeEventListener("mousedown", tapListener);
65-
this.addListener("mouseover", showHint);
66-
this.addListener("mouseout", hideHint);
67-
};
55+
_hint: null,
56+
57+
__createHint: function() {
58+
const hint = this._hint = new osparc.ui.hint.Hint(this).set({
59+
active: false
60+
});
6861

62+
const showHint = () => hint.show();
63+
const hideHint = () => hint.exclude();
64+
65+
// Make hint "modal" when info button is clicked
66+
const tapListener = event => {
67+
if (osparc.utils.Utils.isMouseOnElement(hint, event)) {
68+
return;
69+
}
70+
hideHint();
71+
document.removeEventListener("mousedown", tapListener);
6972
this.addListener("mouseover", showHint);
7073
this.addListener("mouseout", hideHint);
71-
this.addListener("tap", () => {
72-
showHint();
73-
document.addEventListener("mousedown", tapListener);
74-
this.removeListener("mouseover", showHint);
75-
this.removeListener("mouseout", hideHint);
76-
}, this);
77-
}
74+
};
75+
76+
this.addListener("mouseover", showHint);
77+
this.addListener("mouseout", hideHint);
78+
this.addListener("tap", () => {
79+
showHint();
80+
document.addEventListener("mousedown", tapListener);
81+
this.removeListener("mouseover", showHint);
82+
this.removeListener("mouseout", hideHint);
83+
}, this);
84+
},
85+
86+
__applyHintText: function(hintText) {
87+
this._hint.setText(hintText);
7888
}
7989
}
8090
});

0 commit comments

Comments
 (0)