diff --git a/build/app/unisys/server-database.js b/build/app/unisys/server-database.js index 9b44d261..cdaa82c7 100644 --- a/build/app/unisys/server-database.js +++ b/build/app/unisys/server-database.js @@ -256,6 +256,20 @@ function m_IsInvalidEdge(edgeID) { return undefined; } /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +DB.PKT_RequestUnlockAllNodes = function (pkt) { + m_locked_nodes = new Set(); + return { unlocked: true }; +} +DB.PKT_RequestUnlockAllEdges = function (pkt) { + m_locked_edges = new Set(); + return { unlocked: true }; +} +DB.PKT_RequestUnlockAll = function (pkt) { + m_locked_nodes = new Set(); + m_locked_edges = new Set(); + return { unlocked: true }; +} +/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - DB.PKT_Update = function(pkt) { let { node, edge, nodeID, replacementNodeID, edgeID } = pkt.Data(); let retval = {}; diff --git a/build/app/unisys/server.js b/build/app/unisys/server.js index 478fde97..4c425844 100644 --- a/build/app/unisys/server.js +++ b/build/app/unisys/server.js @@ -104,6 +104,19 @@ var UNISYS = {}; return UDB.PKT_RequestUnlockEdge(pkt); }); + UNET.HandleMessage('SRV_DBUNLOCKALLNODES', function (pkt) { + if (DBG) console.log(PR, sprint_message(pkt)); + return UDB.PKT_RequestUnlockAllNodes(pkt); + }); + UNET.HandleMessage('SRV_DBUNLOCKALLEDGES', function (pkt) { + if (DBG) console.log(PR, sprint_message(pkt)); + return UDB.PKT_RequestUnlockAllEdges(pkt); + }); + UNET.HandleMessage('SRV_DBUNLOCKALL', function (pkt) { + if (DBG) console.log(PR, sprint_message(pkt)); + return UDB.PKT_RequestUnlockAll(pkt); + }); + UNET.HandleMessage('SRV_DBGETEDGEID', function (pkt) { if (DBG) console.log(PR,sprint_message(pkt)); return UDB.PKT_GetNewEdgeID(pkt); diff --git a/build/app/view/netcreate/components/EdgeEditor.jsx b/build/app/view/netcreate/components/EdgeEditor.jsx index 289976e7..7a904211 100644 --- a/build/app/view/netcreate/components/EdgeEditor.jsx +++ b/build/app/view/netcreate/components/EdgeEditor.jsx @@ -434,17 +434,19 @@ class EdgeEditor extends UNISYS.Component { /*/ handleSelection ( data ) { if (DBG) console.log('EdgeEditor',this.props.edgeID,'got SELECTION data',data); - // If we're one of the edges that have been updated, and we're not currently being edited, // then update the data. // If we're not currently being edited, then if edges have been updated, update self - let updatedEdge = data.edges.find((edge) => { return edge.id === this.state.formData.id; }); - if (!this.state.isEditable && updatedEdge!==undefined) { - if (DBG) console.log('EdgeEditor: Updating edges with', updatedEdge); - this.loadSourceAndTarget(); - return; + if (data.edges !== undefined) { + let updatedEdge = data.edges.find((edge) => { return edge.id === this.state.formData.id; }); + if (!this.state.isEditable && updatedEdge !== undefined) { + if (DBG) console.log('EdgeEditor: Updating edges with', updatedEdge); + this.loadSourceAndTarget(); + return; + } } + // We're being edited, and the updated node is either our source or target // Technically we probably ought to also check to make sure we're the current // activeAutoCompleteId, but we wouldn't be editable if we weren't. if (this.state.isEditable && data.nodes && data.nodes.length > 0) { @@ -899,6 +901,22 @@ class EdgeEditor extends UNISYS.Component { this.loadSourceAndTarget(); this.onStateChange_SESSION(this.AppState('SESSION')); } +/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +/*/ Release the lock if we're unmounting +/*/ componentWillUnmount() { + if (DBG) console.log('EdgeEditor.componentWillUnMount!'); + if (this.state.isEditable) { + this.NetCall('SRV_DBUNLOCKEDGE', { edgeID: this.state.formData.id }) + .then((data) => { + if (data.NOP) { + if (DBG) console.log(`SERVER SAYS: ${data.NOP} ${data.INFO}`); + } else if (data.unlocked) { + if (DBG) console.log(`SERVER SAYS: unlock success! you have released Edge ${data.edgeID}`); + this.setState({ dbIsLocked: false }); + } + }); + } + } } // class EdgeEditor diff --git a/build/app/view/netcreate/components/EdgeTable.jsx b/build/app/view/netcreate/components/EdgeTable.jsx index b95cd322..caf0c725 100644 --- a/build/app/view/netcreate/components/EdgeTable.jsx +++ b/build/app/view/netcreate/components/EdgeTable.jsx @@ -270,8 +270,8 @@ class EdgeTable extends UNISYS.Component { let styles = `thead, tbody { display: block; } thead { position: relative; } tbody { overflow: auto; } - .edgetable td:nth-child(1), .edgetable th:nth-child(1) {width: 2em; min-width: 2em;} - .edgetable td:nth-child(2), .edgetable th:nth-child(2) {width: 2em; min-width: 2em;} + .edgetable td:nth-child(1), .edgetable th:nth-child(1) {width: 3em; min-width: 3em;} + .edgetable td:nth-child(2), .edgetable th:nth-child(2) {width: 3em; min-width: 3em;} .edgetable td:nth-child(3), .edgetable th:nth-child(3) {width: 4em; min-width: 4em;} .edgetable td:nth-child(4), .edgetable th:nth-child(4) {width: 6em; min-width: 6em;} .edgetable td:nth-child(5), .edgetable th:nth-child(5) {width: 14em; min-width: 14em;} diff --git a/build/app/view/netcreate/nc-logic.js b/build/app/view/netcreate/nc-logic.js index 4dc0c5d6..9e13ef2d 100644 --- a/build/app/view/netcreate/nc-logic.js +++ b/build/app/view/netcreate/nc-logic.js @@ -1033,6 +1033,28 @@ JSCLI.AddFunction(function ncPushDatabase(jsonFile) { } ); /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +/*/ Command: Unlock the database. Used to recover from error conditions where + a node or edge is inadvertently left locked. +/*/ +JSCLI.AddFunction( + function ncUnlockAll() { + UDATA.NetCall('SRV_DBUNLOCKALL', {}); + return "Unlocking all nodes and edges in the database."; + } +); +JSCLI.AddFunction( + function ncUnlockAllNodes() { + UDATA.NetCall('SRV_DBUNLOCKALLNODES', {}); + return "Unlocking all nodes in the database."; + } +); +JSCLI.AddFunction( + function ncUnlockAllEdges() { + UDATA.NetCall('SRV_DBUNLOCKALLEDGES', {}); + return "Unlocking all edges in the database."; + } +); +/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /*/ Command: Token Generator /*/ JSCLI.AddFunction(function ncMakeTokens(clsId, projId, numGroups) { @@ -1044,7 +1066,7 @@ JSCLI.AddFunction(function ncMakeTokens(clsId, projId, numGroups) { if (clsId.length > 12) return "classId arg1 should be 12 chars or less"; if (projId.length > 12) return "classId arg1 should be 12 chars or less"; if (!Number.isInteger(numGroups)) return "numGroups arg3 must be integer"; - if (numGroups < 1) return "numGroups arg3 must be positive integeger"; + if (numGroups < 1) return "numGroups arg3 must be positive integer"; // let's do this! let out = `\nTOKEN LIST for class '${clsId}' project '${projId}'\n\n`; let pad = String(numGroups).length;