Skip to content
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,19 @@ qx.Class.define("osparc.data.model.Node", {
return outputs[outputKey]["value"];
}
return null;
}
},

getLinkedNodeIds: function(nodeData) {
const linkedNodeIds = new Set([]);
if ("inputs" in nodeData) {
Object.values(nodeData["inputs"]).forEach(link => {
if (link && typeof link === "object" && "nodeUuid" in link) {
linkedNodeIds.add(link["nodeUuid"]);
}
});
}
return Array.from(linkedNodeIds);
},
},

members: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,18 @@ qx.Class.define("osparc.data.model.Study", {
"STARTED",
"RETRY"
].includes(state);
}
},

__isAnyLinkedNodeMissing: function(studyData) {
const existingNodeIds = Object.keys(studyData["workbench"]);
const linkedNodeIds = osparc.data.model.Workbench.getLinkedNodeIds(studyData["workbench"]);
const allExist = linkedNodeIds.every(linkedNodeId => existingNodeIds.includes(linkedNodeId));
return !allExist;
},

isCorrupt: function(studyData) {
return this.__isAnyLinkedNodeMissing(studyData);
},
},

members: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,16 @@ qx.Class.define("osparc.data.model.Workbench", {

statics: {
CANT_ADD_NODE: qx.locale.Manager.tr("Nodes can't be added while the pipeline is running"),
CANT_DELETE_NODE: qx.locale.Manager.tr("Nodes can't be deleted while the pipeline is running")
CANT_DELETE_NODE: qx.locale.Manager.tr("Nodes can't be deleted while the pipeline is running"),

getLinkedNodeIds: function(workbenchData) {
const linkedNodeIDs = new Set([]);
Object.values(workbenchData).forEach(nodeData => {
const linkedNodes = osparc.data.model.Node.getLinkedNodeIds(nodeData);
linkedNodes.forEach(linkedNodeID => linkedNodeIDs.add(linkedNodeID))
});
return Array.from(linkedNodeIDs);
},
},

members: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,20 +85,29 @@ qx.Class.define("osparc.desktop.MainPageHandler", {
},

loadStudy: function(studyData) {
const studyAlias = osparc.product.Utils.getStudyAlias({firstUpperCase: true});
// check if it's locked
let locked = false;
let lockedBy = false;
if ("state" in studyData && "locked" in studyData["state"]) {
locked = studyData["state"]["locked"]["value"];
lockedBy = studyData["state"]["locked"]["owner"];
}
if (locked && lockedBy["user_id"] !== osparc.auth.Data.getInstance().getUserId()) {
const msg = `${qx.locale.Manager.tr("Study is already open by ")} ${
const msg = `${studyAlias} ${qx.locale.Manager.tr("is already open by")} ${
"first_name" in lockedBy && lockedBy["first_name"] != null ?
lockedBy["first_name"] :
qx.locale.Manager.tr("another user.")
}`;
throw new Error(msg);
}

// check if it's corrupt
if (osparc.data.model.Study.isCorrupt(studyData)) {
const msg = `${qx.locale.Manager.tr("We encountered an issue with the")} ${studyAlias} <br>${qx.locale.Manager.tr("Please contact support.")}`;
throw new Error(msg);
}

this.setLoadingPageHeader(qx.locale.Manager.tr("Loading ") + studyData.name);
this.showLoadingPage();
const inaccessibleServices = osparc.study.Utils.getInaccessibleServices(studyData["workbench"])
Expand Down
Loading