Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #162

Merged
merged 29 commits into from
Feb 4, 2021
Merged

Dev #162

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
d5268ce
ws-hardening: Verify socket is open before trying to send ping/pong.
benloh Sep 22, 2020
a5a2ba2
Check to see if either label is undefined before displaying the node …
Oct 15, 2020
1baa959
Address issue with blank labels crashing node table.
Oct 15, 2020
9207a2b
dev-bl/ws-hardening: Fix NodeSelector label validation. 'undefined' …
benloh Oct 16, 2020
dbefd66
Added hidden columns to the edge table, so that when using a chrome (…
Oct 18, 2020
121badb
Fixes a newly discovered bug where degree counts were increasing with…
Oct 27, 2020
40a6c91
Minor fix.
Oct 27, 2020
a8eb83a
Fixes bug where node table would re-sort when selecting a node to vie…
Oct 30, 2020
55cde7a
If edit is pressed in NodeTable when this should be locked, ignore it.
Oct 31, 2020
6bd05a6
Added hidden id field to table so that exports could be imported into…
Nov 6, 2020
79055d2
Changed outline color on selected nodes for greater readability.
Nov 9, 2020
18f9d44
First pass at setting transparency for nodes and edges via the filter…
Nov 19, 2020
177ff7a
Moved default transparency to the nodePrompts and edgePrompts areas o…
Nov 19, 2020
3b5a330
This adds a degree value to each node so that it can be used for the …
Nov 19, 2020
c747991
Added a clear filters button to the infopanel so that you can remove …
Nov 19, 2020
71084eb
Fixed an issue where the degrees weren't updating immediately, and us…
Nov 19, 2020
70e744f
Moved searchColor and sourceColor (current label for all selected nod…
Nov 21, 2020
da05320
added table padding so that the edit button isn't flush for node and …
Nov 21, 2020
e79335d
When viewing the edge editor, the linked node is now a hyperlink that…
Nov 22, 2020
99accd2
Changed from targetID to linkID to be more consistent.
Nov 22, 2020
424a629
Switch edge links back to disabled if it is being edited to avoid all…
Nov 22, 2020
cafe49b
Call autocomplete select so that when you click on an edge link it'll…
Nov 22, 2020
2c94b30
Added a message call so that when a node from within an edge is sele…
Nov 22, 2020
294e29a
Started to add Date type for filters, but didn't get to functionality…
Nov 22, 2020
86b83ef
Fixed drag on info-panel so that it won't go past the top of the actu…
Nov 22, 2020
a0ee588
Just removing some unnecessary comments.
Nov 22, 2020
eae2b2d
Fix sorting on nodetable so that it is coming from degree and not the…
Dec 2, 2020
756213c
Updated default template to a) have better empty description, b) have…
Dec 7, 2020
f23c011
Standalone mode was showing a funny blank bar. Changed the session in…
Dec 10, 2020
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
10 changes: 8 additions & 2 deletions build/app/assets/templates/_default.template
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{

"_comments": [ "/// NetCreate Template File ///",
"/// RELEASE NOTES: As of 12-7/2020 added default colors and transparency (for filters) ///",
"/// RELEASE NOTES: As of 8/13/2020, a 'type' specification needs to added to each ///",
"/// nodePrompt and edgePrompt for filters to work. Valid types are: ///",
"/// 'string', 'number', 'select', and 'node'. The 'node' type is only valid for ///",
Expand All @@ -21,15 +22,18 @@

"name": "Blank",

"description": "This graph left intentionally blank for serving static files.",
"description": "The graph description would go here.",

"requireLogin": true,
"requireLogin": false,

"citationPrompts":{
"citation": "Citation Text",
"hidden": false
},

"searchColor":"#FFa500",
"sourceColor":"#008800",

"nodePrompts": {
"label": {
"type": "string",
Expand Down Expand Up @@ -80,6 +84,7 @@
}
]
},
"defaultTransparency": "0.1",
"degrees": {
"type": "number",
"label": "Degrees",
Expand Down Expand Up @@ -117,6 +122,7 @@

"edgePrompts": {
"edgeIsLockedMessage": "This edge is currently being edited by someone else, please try again later.",
"defaultTransparency": "0.3",
"source": {
"type": "node",
"label": "Source",
Expand Down
6 changes: 5 additions & 1 deletion build/app/unisys/client-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ function m_HandleRegistrationMessage(msgEvent) {
know that we're still alive.
/*/
function m_RespondToHeartbeat() {
NETSOCK.ws.send('pong');
if (NETSOCK.ws.readyState === NETSOCK.ws.OPEN) {
NETSOCK.ws.send("pong", (err) => {
if (err) console.log(PR, 'error "', err, '" while sending response pong');
});
}
}
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*/ If a 'hearbeat' message is not received from the server every 5 seconds
Expand Down
9 changes: 3 additions & 6 deletions build/app/unisys/component/SessionShell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,11 @@ class SessionShell extends UNISYS.Component {
if (UNISYS.IsStandaloneMode()) {
const { prompt, timestamp } = window.NC_UNISYS.standalone;
return (
<FormGroup row style={GROUP_STYLE}>
<Col sm={9}>
<div style={NAV_LOGIN_STYLE}>
<Col sm={16}>
<Label style={LABEL_STYLE} className="small">{prompt}</Label>
</Col>
<Col sm={3} className="text-right">
<Label style={LABEL_STYLE} className="small">{timestamp}</Label>
</Col>
</FormGroup>
</div>
);
}

Expand Down
11 changes: 9 additions & 2 deletions build/app/unisys/server-network.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,11 @@ const SERVER_UADDR = NetMessage.DefaultServerUADDR(); // is 'SVR_01'
m_heartbeat_interval = setInterval(function sendHeartbeat() {
mu_sockets.forEach((socket, key, map) => {
if (DBG) console.log(PR, 'sending heartbeat to', socket.UADDR);
socket.send('ping');
if (socket.readyState === socket.OPEN) {
socket.send("ping", (err) => {
if (err) console.log(PR, 'error "', err, '" while sending heartbeat to', socket.UADDR);
});
}
});
}, DEFS.SERVER_HEARTBEAT_INTERVAL);
}
Expand Down Expand Up @@ -237,7 +241,10 @@ const SERVER_UADDR = NetMessage.DefaultServerUADDR(); // is 'SVR_01'
/*/ function m_SocketMessage(socket, json) {
// Check Heartbeat
if (json === 'pong') {
if (socket.UADDR === undefined) return; // Don't start the timer if we get a bad UADDR
if (socket.UADDR === undefined) {
console.log(PR, '!!!!!!!!!!!!!!!!!! Bad socket.UADDR', socket.UADDR, '! Skipping pong timer reset.');
return; // Don't start the timer if we get a bad UADDR
}
m_ResetPongTimer(socket.UADDR);
return;
}
Expand Down
14 changes: 14 additions & 0 deletions build/app/view/netcreate/components/AutoComplete.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ const UNISYS = require('unisys/client');

const MODE_STATIC = 'static'; // Can't be edited ever
const MODE_DISABLED = 'disabled'; // Can be edited, but not at the moment
const MODE_LINK = 'link'; // Can be edited, but not at the moment, and it links to a view until then
const MODE_ACTIVE = 'active'; // Currently able to edit

var _IsMounted = false;
Expand Down Expand Up @@ -408,6 +409,8 @@ class AutoComplete extends UNISYS.Component {
jsx = (<p>{this.props.disabledValue}</p>);
} else if (this.props.inactiveMode === MODE_DISABLED) {
jsx = (<Input type="text" value={this.props.disabledValue} readOnly={true} />);
} else if (this.props.inactiveMode === MODE_LINK){
jsx = (<a href="#" onClick={(e)=>this.selectNode(this.props.linkID,e)}>{this.props.disabledValue}</a>);
} else {
throw Error(`AutoComplete: Unhandled mode '${this.state.mode}'`);
}
Expand Down Expand Up @@ -447,6 +450,17 @@ class AutoComplete extends UNISYS.Component {
return jsx;
} // render()

selectNode (id, event) {
event.preventDefault();
// REVIEW: For some reason React converts the integer IDs into string
// values when returned in event.target.value. So we have to convert
// it here.
// Load Source
var UDATA = UNISYS.NewDataLink(this);
UDATA.LocalCall('EDGE_CLOSE');
UDATA.LocalCall('SOURCE_SELECT',{ nodeIDs: [parseInt(id)] });
}

/// END OF CLASS //////////////////////////////////////////////////////////////
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
}
Expand Down
14 changes: 12 additions & 2 deletions build/app/view/netcreate/components/EdgeEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,14 @@ class EdgeEditor extends UNISYS.Component {
this.handleEdgeEdit(data);
});


/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
UDATA.HandleMessage('EDGE_CLOSE',(data) => {
if (this.state.isExpanded)
this.setState({ isExpanded: false });
});


// Template handler
this.OnAppStateChange('TEMPLATE', this.setTemplate);

Expand Down Expand Up @@ -934,7 +942,8 @@ class EdgeEditor extends UNISYS.Component {
<AutoComplete
identifier={'edge'+edgeID+'source'}
disabledValue={sourceNode.label}
inactiveMode={parentNodeLabel===sourceNode.label ? 'static' : 'disabled'}
inactiveMode={parentNodeLabel===sourceNode.label ? 'static' : this.state.isEditable ? 'disabled' : 'link'}
linkID={sourceNode.id}
shouldIgnoreSelection={!this.state.sourceIsEditable}
placeholder={this.state.placeholder}
/>
Expand Down Expand Up @@ -979,7 +988,8 @@ class EdgeEditor extends UNISYS.Component {
<AutoComplete
identifier={'edge'+edgeID+'target'}
disabledValue={targetNode.label}
inactiveMode={ ( parentNodeLabel===targetNode.label && !sameSourceAndTarget ) ? 'static' : 'disabled'}
inactiveMode={ ( parentNodeLabel===targetNode.label && !sameSourceAndTarget ) ? 'static' : this.state.isEditable ? 'disabled' : 'link'}
linkID={targetNode.id}
shouldIgnoreSelection={!this.state.targetIsEditable}
placeholder={this.state.placeholder}
/>
Expand Down
7 changes: 6 additions & 1 deletion build/app/view/netcreate/components/EdgeTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class EdgeTable extends UNISYS.Component {
`
return (
<div style={{overflow:'auto',
position:'relative',display: 'block', right:'10px',maxHeight: tableHeight, backgroundColor:'#f3f3ff'
position:'relative',display: 'block', left: '1px', right:'10px',maxHeight: tableHeight, backgroundColor:'#f3f3ff'
}}>
<style>{styles}</style>
<Button size="sm" outline hidden
Expand All @@ -359,12 +359,14 @@ class EdgeTable extends UNISYS.Component {
>ID {this.sortSymbol("id")}</Button></th>
<th hidden={!DBG}>Size</th>
<th width="5%"><div style={{color: '#f3f3ff'}}>_Edit_</div></th>
<th hidden={!DBG}>Src ID</th>
<th width="10%"><Button size="sm"
onClick={()=>this.setSortKey("source")}
>{edgePrompts.source.label} {this.sortSymbol("source")}</Button></th>
<th width="10%"><Button size="sm"
onClick={()=>this.setSortKey("Relationship")}
>{edgePrompts.type.label} {this.sortSymbol("Relationship")}</Button></th>
<th hidden={!DBG}>Target ID</th>
<th width="10%"><Button size="sm"
onClick={()=>this.setSortKey("target")}
>{edgePrompts.target.label} {this.sortSymbol("target")}</Button></th>
Expand All @@ -383,6 +385,7 @@ class EdgeTable extends UNISYS.Component {
<th width="16%"hidden={!isLocalHost}><Button size="sm"
onClick={()=>this.setSortKey("Updated")}
>Updated {this.sortSymbol("Updated")}</Button></th>

</tr>
</thead>
<tbody style={{ maxHeight: tableHeight }}>
Expand All @@ -395,9 +398,11 @@ class EdgeTable extends UNISYS.Component {
onClick={this.onButtonClick}
>Edit</Button>
</td>
<td hidden={!DBG}>{edge.source.id}</td>
<td><a href="#" onClick={(e)=>this.selectNode(edge.source.id,e)}
>{edge.source.label || edge.source}</a></td>
<td>{edge.attributes["Relationship"]}</td>
<td hidden={!DBG}>{edge.target.id}</td>
<td><a href="#" onClick={(e)=>this.selectNode(edge.target.id,e)}
>{edge.target.label || edge.target}</a></td>
<td hidden={edgePrompts.category.hidden}>{edge.attributes["Category"]}</td>
Expand Down
16 changes: 11 additions & 5 deletions build/app/view/netcreate/components/InfoPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
\*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ * //////////////////////////////////////*/

var DBG = false;
var UDATA = null;

/// UNISYS INITIALIZE REQUIRES for REACT ROOT /////////////////////////////////
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -59,8 +60,9 @@ class InfoPanel extends UNISYS.Component {
this.endDrag = this.endDrag.bind(this);
this.handleDrag = this.handleDrag.bind(this);
this.UpdateFilterSummary = this.UpdateFilterSummary.bind(this);
this.OnClearBtnClick = this.OnClearBtnClick.bind(this);

var UDATA = UNISYS.NewDataLink(this);
UDATA = UNISYS.NewDataLink(this);
UDATA.HandleMessage("FILTER_SUMMARY_UPDATE", this.UpdateFilterSummary);

} // constructor
Expand Down Expand Up @@ -111,9 +113,9 @@ class InfoPanel extends UNISYS.Component {
}
handleDrag(e) {
e.stopPropagation();
// limit to 80 to keep from dragging up past the tabpanel
// 80 = navbar + tabpanel height
let top = Math.max(80, e.clientY + this.state.draggerMouseOffsetY);
// limit to 120 to keep from dragging up past the tabpanel
// 120 = navbar + tabpanel height
let top = Math.max(120, e.clientY + this.state.draggerMouseOffsetY);
this.setState({
tabpanelHeight: (top - this.state.tabpanelTop - 40) + 'px',
tableHeight: (top - this.state.tabpanelTop) + 'px',
Expand All @@ -131,6 +133,10 @@ class InfoPanel extends UNISYS.Component {
this.setState({ filtersSummary: data.filtersSummary });
}

OnClearBtnClick() {
UDATA.LocalCall('FILTER_CLEAR');
}


/// REACT LIFECYCLE METHODS ///////////////////////////////////////////////////
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -259,7 +265,7 @@ class InfoPanel extends UNISYS.Component {
<div hidden={!hideDragger || filtersSummary===''}
style={{ padding: '3px', fontSize: '0.8em', color:'#999', backgroundColor:'#eef'}}
>
FILTERED BY: {filtersSummary}
FILTERED BY: {filtersSummary} <Button size="sm" outline onClick={this.OnClearBtnClick}>Clear Filters</Button>
</div>
</div>
);
Expand Down
6 changes: 3 additions & 3 deletions build/app/view/netcreate/components/NodeSelector.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class NodeSelector extends UNISYS.Component {
Ignore the request if we're already editing a node.
/*/
UDATA.HandleMessage("NODE_EDIT", (data) => {
if ( (data.nodeID!==undefined) && (typeof data.nodeID==="number") && !this.state.isEditable ) {
if ( (data.nodeID!==undefined) && (typeof data.nodeID==="number") && !this.state.isEditable && !this.state.isLocked ) {
this.requestEditNode(data.nodeID);
} else {
console.error("NodeSelector.NODE_EDIT called with bad data.nodeID:", data.nodeID);
Expand Down Expand Up @@ -582,7 +582,7 @@ class NodeSelector extends UNISYS.Component {
let isValid = false;
let formData = this.state.formData;

if (formData.label!=='') isValid=true;
if (formData.label!=='' && formData.label!==undefined) isValid=true;
if (DBG) console.log('NodeSElector.validateForm: Validating',isValid,'because label is',formData.label,'!');
this.setState({
isValid: isValid
Expand Down Expand Up @@ -877,7 +877,7 @@ class NodeSelector extends UNISYS.Component {
// Update the data with the selectedNode
let formData = this.state.formData;
let node = {
label : formData.label,
label : formData.label?formData.label:'',
id : formData.id,
attributes: {
'Node_Type' : formData.type,
Expand Down
25 changes: 14 additions & 11 deletions build/app/view/netcreate/components/NodeTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,11 @@ class NodeTable extends UNISYS.Component {
// {}

if (data.nodes) {
const edgeCounts = this.countEdges(data.edges);
const nodes = this.sortTable('label', data.nodes);
// const edgeCounts = this.countEdges(data.edges);
const nodes = this.sortTable(this.state.sortkey, data.nodes);
this.setState({
nodes: nodes,
edgeCounts: edgeCounts
// edgeCounts: edgeCounts
});
}
}
Expand All @@ -107,8 +107,9 @@ OnTemplateUpdate(data) {
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/*/ Build table of counts
/*/
// JD removed because "size" seemed to work just fine? (I added a degrees that is size - 1)
countEdges(edges) {
let edgeCounts = this.state.edgeCounts;
let edgeCounts = {}; // this.state.edgeCounts;
edges.forEach(edge => {
edgeCounts[edge.source.id] = edgeCounts[edge.source.id] !== undefined ? edgeCounts[edge.source.id] + 1 : 1;
edgeCounts[edge.target.id] = edgeCounts[edge.target.id] !== undefined ? edgeCounts[edge.target.id] + 1 : 1;
Expand All @@ -135,10 +136,10 @@ countEdges(edges) {
/*/
/*/ sortByEdgeCount(nodes) {
if (nodes) {
let edgeCounts = this.state.edgeCounts;
// let edgeCounts = this.state.edgeCounts;
return nodes.sort( (a, b) => {
let akey = edgeCounts[a.id] || 0,
bkey = edgeCounts[b.id] || 0;
let akey = a.degrees || 0,
bkey = b.degrees || 0;
// sort descending
if (akey > bkey) return 1*this.sortDirection;
if (akey < bkey) return -1*this.sortDirection;
Expand All @@ -151,8 +152,8 @@ countEdges(edges) {
/*/ sortByLabel (nodes) {
if (nodes) {
return nodes.sort( (a,b) => {
let akey = a.label,
bkey = b.label;
let akey = a.label?a.label:'',
bkey = b.label?b.label:'';
return (akey.localeCompare(bkey)*this.sortDirection);
});
}
Expand Down Expand Up @@ -297,7 +298,7 @@ render() {
`
return (
<div style={{overflow:'auto',
position:'relative',display: 'block', right:'10px',maxHeight: tableHeight, backgroundColor:'#eafcff'
position:'relative',display: 'block', left: '1px', right:'10px',maxHeight: tableHeight, backgroundColor:'#eafcff'
}}>
<style>{styles}</style>
<Button size="sm" outline hidden
Expand All @@ -310,6 +311,7 @@ render() {
<thead>
<tr>
<th width="4%"><div style={{color: '#f3f3ff'}}>_Edit_</div></th>
<th hidden={!DBG}>ID</th>
<th width="12%"><Button size="sm"
onClick={() => this.setSortKey("edgeCount")}
>{nodePrompts.degrees.label} {this.sortSymbol("edgeCount")}</Button></th>
Expand Down Expand Up @@ -341,7 +343,8 @@ render() {
onClick={this.onButtonClick}
>Edit</Button>
</td>
<td>{this.state.edgeCounts[node.id]}</td>
<td hidden={!DBG}>{node.id}</td>
<td>{node.degrees}</td>
<td><a href="#" onClick={(e)=>this.selectNode(node.id,e)}
>{node.label}</a></td>
<td hidden={nodePrompts.type.hidden}>{node.attributes["Node_Type"]}</td>
Expand Down
Loading