Skip to content

Commit b952aff

Browse files
authored
🎨 [Frontend] RTC: support removing links (ITISFoundation#8190)
1 parent 1ba2817 commit b952aff

File tree

4 files changed

+59
-18
lines changed

4 files changed

+59
-18
lines changed

services/static-webserver/client/source/class/osparc/Preferences.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ qx.Class.define("osparc.Preferences", {
119119
jobConcurrencyLimit: {
120120
check: "Number",
121121
nullable: false,
122-
init: 4,
122+
init: 1,
123123
event: "changeJobConcurrencyLimit",
124124
apply: "__patchPreference"
125125
},
@@ -210,7 +210,11 @@ qx.Class.define("osparc.Preferences", {
210210
.catch(err => osparc.FlashMessenger.logError(err));
211211
},
212212

213-
__patchPreference: function(value, _, propName) {
213+
__patchPreference: function(value, old, propName) {
214+
// only patch if the value changed
215+
if (value === old) {
216+
return;
217+
}
214218
this.self().patchPreference(propName, value);
215219
}
216220
}

services/static-webserver/client/source/class/osparc/data/model/Node.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1440,14 +1440,18 @@ qx.Class.define("osparc.data.model.Node", {
14401440
case "inputs": {
14411441
const updatedPortKey = path.split("/")[4];
14421442
const currentInputs = this.__getInputData();
1443+
if (osparc.utils.Ports.isDataALink(currentInputs[updatedPortKey])) {
1444+
// if the port is a link, we remove it from the props form
1445+
this.getPropsForm().removePortLink(updatedPortKey);
1446+
}
14431447
currentInputs[updatedPortKey] = value;
14441448
this.__setInputData(currentInputs);
14451449
break;
14461450
}
14471451
case "inputsUnits": {
14481452
// this is never transmitted by the frontend
14491453
const updatedPortKey = path.split("/")[4];
1450-
const currentInputUnits = this.__getInputUnits();
1454+
const currentInputUnits = this.__getInputUnits() || {};
14511455
currentInputUnits[updatedPortKey] = value;
14521456
this.__setInputUnits(currentInputUnits);
14531457
break;

services/static-webserver/client/source/class/osparc/store/Products.js

Lines changed: 43 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,12 @@ qx.Class.define("osparc.store.Products", {
3838
}
3939

4040
Promise.all([
41-
osparc.data.Resources.fetch("productMetadata", "getUiConfig"),
42-
osparc.utils.Utils.fetchJSON("/resource/osparc/ui_config.json"),
41+
this.__getUIConfig(),
4342
osparc.utils.Utils.fetchJSON("/resource/schemas/product-ui.json"),
4443
])
4544
.then(values => {
46-
let uiConfig = {};
47-
const beUiConfig = values[0];
48-
const feUiConfig = values[1];
49-
const schema = values[2];
50-
if (beUiConfig && beUiConfig["ui"] && Object.keys(beUiConfig["ui"]).length) {
51-
uiConfig = beUiConfig["ui"];
52-
} else {
53-
const product = osparc.product.Utils.getProductName();
54-
if (feUiConfig && product in feUiConfig) {
55-
uiConfig = feUiConfig[product];
56-
}
57-
}
45+
const uiConfig = values[0];
46+
const schema = values[1];
5847
const ajvLoader = new qx.util.DynamicScriptLoader([
5948
"/resource/ajv/ajv-6-11-0.min.js",
6049
"/resource/object-path/object-path-0-11-4.min.js"
@@ -85,6 +74,46 @@ qx.Class.define("osparc.store.Products", {
8574
});
8675
},
8776

77+
__getUIConfig: function() {
78+
return Promise.all([
79+
this.__getUiConfigBackend(),
80+
this.__getUiConfigFrontend(),
81+
])
82+
.then(values => {
83+
const beUiConfig = values[0];
84+
if (beUiConfig) {
85+
return beUiConfig;
86+
}
87+
const feUiConfig = values[1];
88+
return feUiConfig || {};
89+
});
90+
},
91+
92+
__getUiConfigBackend: function() {
93+
if (osparc.auth.Data.getInstance().isGuest()) {
94+
// Guest users do not have access to product metadata
95+
return Promise.resolve(null);
96+
}
97+
return osparc.data.Resources.fetch("productMetadata", "getUiConfig")
98+
.then(response => {
99+
if (response && response["ui"] && Object.keys(response["ui"]).length) {
100+
return response["ui"];
101+
}
102+
return null;
103+
});
104+
},
105+
106+
__getUiConfigFrontend: function() {
107+
return osparc.utils.Utils.fetchJSON("/resource/osparc/ui_config.json")
108+
.then(uiConfig => {
109+
const product = osparc.product.Utils.getProductName();
110+
if (uiConfig && product in uiConfig) {
111+
return uiConfig[product];
112+
}
113+
return null;
114+
});
115+
},
116+
88117
getPlusButtonUiConfig: function() {
89118
return this.__uiConfig["plusButton"];
90119
},

services/static-webserver/client/source/class/osparc/viewer/NodeViewer.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ qx.Class.define("osparc.viewer.NodeViewer", {
4141
}, this);
4242
}
4343
})
44-
.catch(err => console.error(err));
44+
.catch(err => {
45+
console.error(err);
46+
osparc.FlashMessenger.logError(err);
47+
qx.core.Init.getApplication().logout();
48+
});
4549
},
4650

4751
properties: {

0 commit comments

Comments
 (0)