Skip to content

Commit 2bf4c2e

Browse files
authored
Merge pull request #142 from netcreateorg/dev
Version 1.3.1
2 parents b28c55f + efe54df commit 2bf4c2e

22 files changed

+618
-453
lines changed

build/app/assets/index.ejs

Lines changed: 40 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -5,73 +5,71 @@
55
<!-- Required meta tags -->
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
8-
9-
<script src="netcreate-config.js">
10-
// auto generated netcreate config script
11-
</script>
12-
<script src="https://kit.fontawesome.com/3f7330d0fa.js" crossorigin="anonymous"></script>
13-
14-
<!-- Google Analytics -->
15-
<script>
16-
let googlea = NC_CONFIG.googlea;
17-
if(googlea != "0"){
18-
19-
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
20-
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
21-
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
22-
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
23-
24-
ga('create', 'UA-132368455-3', 'auto');
25-
ga('send', 'pageview');
26-
}
27-
</script>
28-
<!-- End Google Analytics -->
29-
308
<style>
319
body {
3210
min-height: 100%
3311
}
34-
.fas { display:inline; margin-right:2pt; }
35-
36-
3712
</style>
38-
<script>
13+
<link rel="stylesheet" href="/styles/netc-app.css" type="text/css">
14+
</head>
15+
<body>
16+
<div id="app-container">
17+
<div style="padding: 10px">Loading Net.Create...</div>
18+
</div>
19+
<script src="netcreate-config.js">
20+
// auto generated netcreate config script
21+
</script>
22+
<script>
3923
// NC_UNISYS are network parameters
4024
if (window.NC_UNISYS) {
41-
let err = `**FATAL ERROR** NC_UNISYS already initialized.\n\n`;
25+
let err = `**FATAL ERROR** NC_UNISYS already initialized.\n\n`;
4226
err += `Take a screen shot with your phone and report the error!`
4327
alert(err);
4428
throw Error(err);
4529
}
4630
window.NC_UNISYS = {
47-
client : {
48-
ip : '<%=ip%>',
49-
ukey : '<%=ukey%>'
31+
client: {
32+
ip: '<%=ip%>',
33+
ukey: '<%=ukey%>'
5034
},
51-
server : {
52-
hostname : '<%=hostname%>',
53-
ip : '<%=hostip%>',
54-
ustart : '<%=ustart%>'
35+
server: {
36+
hostname: '<%=hostname%>',
37+
ip: '<%=hostip%>',
38+
ustart: '<%=ustart%>'
5539
},
56-
socket : {
57-
uaddr : '<%=uaddr%>',
58-
uport : '<%=uport%>'
40+
socket: {
41+
uaddr: '<%=uaddr%>',
42+
uport: '<%=uport%>'
5943
}
6044
};
6145
//
6246
window.NC_DBG = null; // {} or null
6347
if (window.NC_DBG) {
6448
Object.assign(window.NC_DBG, {
65-
lifecycle : true
49+
lifecycle: true
6650
});
6751
}
6852
</script>
6953
<script src="/scripts/netc-lib.js"></script>
7054
<script src="/scripts/netc-app.js"></script>
71-
<link rel="stylesheet" href="/styles/netc-app.css" type="text/css">
72-
</head>
73-
<body>
74-
<div id="app-container"></div>
55+
56+
<!-- Google Analytics -->
57+
<script>
58+
let googlea = NC_CONFIG.googlea;
59+
if (googlea != "0") {
60+
61+
(function (i, s, o, g, r, a, m) {
62+
i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
63+
(i[r].q = i[r].q || []).push(arguments)
64+
}, i[r].l = 1 * new Date(); a = s.createElement(o),
65+
m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
66+
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
67+
68+
ga('create', 'UA-132368455-3', 'auto');
69+
ga('send', 'pageview');
70+
}
71+
</script>
72+
<!-- End Google Analytics -->
7573
<script>
7674
document.title += ` ${window.NC_CONFIG.dataset} @ ${window.NC_UNISYS.server.ip}`;
7775
require("init");

build/app/assets/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,6 @@
2626

2727
</script>
2828
<!-- End Google Analytics -->
29-
<style>
30-
.fas { display:inline; margin-right:2pt; }
31-
32-
</style>
33-
3429
<script>
3530
// index.html is loaded only by standalone mode without a server
3631
// server-based operation uses index.ejs

build/app/init.jsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,21 @@ document.addEventListener("DOMContentLoaded", () => {
5656
/// UNISYS LIFECYCLE CLOSE EVENT //////////////////////////////////////////////
5757
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
5858
/*/ this custom event accesses post-run lifecycles defined for 'DOMContentLoaded'
59+
`event` is originated by `comment-netmessage-class.GlobalOfflineMode
60+
with a custom event message coming from client-network.m_ResetHearbeatTimer
61+
This is so we can display an error to the user explaining the disconnect
5962
/*/
60-
document.addEventListener("UNISYSDisconnect", () => {
63+
document.addEventListener("UNISYSDisconnect", (event) => {
6164
console.log(
6265
"%cDISCONNECT %cUNISYSDisconnect. Closing UNISYS Lifecycle!",
6366
"color:blue",
6467
"color:auto"
6568
);
69+
// This call will fail if the server is disconnected.
70+
UNISYS.Log('Server disconnected with error', event);
71+
// hack a local module for now
72+
let UDATA = UNISYS.NewDataLink({});
73+
UDATA.LocalCall('DISCONNECT', event);
6674
(async () => {
6775
await UNISYS.ServerDisconnect(); // UNISYS has dropped server
6876
console.log(

build/app/unisys/client-network.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ function m_RespondToHeartbeat() {
178178
function m_ResetHearbeatTimer() {
179179
clearTimeout(m_hearbeat_timer);
180180
m_hearbeat_timer = setTimeout(function heartbeatStopped() {
181-
if (DBG.handle) console.log(PR, 'heartbeat not received before time ran out -- YOURE DEAD!');
182-
NetMessage.GlobalOfflineMode();
183-
}, DEFS.SERVER_HEARTBEAT_INTERVAL + 1000);
181+
if (DBG.handle) console.log(PR, 'ping heartbeat not received from server before time ran out -- YOURE DEAD!');
182+
NetMessage.GlobalOfflineMode({ message: "Client Disconnected" });
183+
}, DEFS.SERVER_HEARTBEAT_INTERVAL * 2);
184184
}
185185
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
186186
function m_HandleMessage(msgEvent) {

build/app/unisys/common-defs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const DBG = true;
1010
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1111
var DEFS = {};
1212

13-
DEFS.SERVER_HEARTBEAT_INTERVAL = 5000;
13+
DEFS.SERVER_HEARTBEAT_INTERVAL = 5000; // ms
1414

1515
/// EXPORT MODULE DEFINITION //////////////////////////////////////////////////
1616
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

build/app/unisys/common-netmessage-class.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,12 +394,23 @@ NetMessage.GlobalCleanup = function() {
394394
/*/ cleanup any allocated storage internally. This class operates both under the
395395
server and the client. This is a client feature.
396396
/*/
397-
NetMessage.GlobalOfflineMode = function() {
397+
NetMessage.GlobalOfflineMode = function(data) {
398398
m_mode = M_STANDALONE;
399399
if (m_netsocket) {
400400
console.warn(PR, "STANDALONE MODE: NetMessage disabling network");
401401
m_netsocket = null;
402-
let event = new CustomEvent("UNISYSDisconnect", {});
402+
// The disconnect is detected by client-network.js.
403+
// If the disconnect is due to a missing ping heartbeat from the server
404+
// (usually as a result of wifi/internet connection going down)
405+
// it will include a data.message explaining 'Client Disconnect'.
406+
// If there's no data.message, then this request came from
407+
// either a standalone connect, a server "close" event,
408+
// or a server "error" event.
409+
let event = new CustomEvent("UNISYSDisconnect", {
410+
detail: {
411+
message: data ? data.message : "Server Disconnected"
412+
}
413+
});
403414
console.log("dispatching event to", document, event);
404415
document.dispatchEvent(event);
405416
}

build/app/unisys/server-network.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ const SERVER_UADDR = NetMessage.DefaultServerUADDR(); // is 'SVR_01'
217217
clearTimeout(m_pong_timer[uaddr]);
218218
m_pong_timer[uaddr] = setTimeout(function pongTimedOut() {
219219
if (DBG) console.log(PR, uaddr, 'pong not received before time ran out -- CONNECTION DEAD!');
220+
LOGGER.Write(PR, uaddr, 'pong not received before time ran out -- CLIENT CONNECTION DEAD!');
220221
DB.RequestUnlock(uaddr);
221-
}, DEFS.SERVER_HEARTBEAT_INTERVAL + 1000);
222+
}, DEFS.SERVER_HEARTBEAT_INTERVAL * 2);
222223
}
223224

224225
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

build/app/view/netcreate/NetCreate.jsx

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,8 @@ const FILTERLOGIC = require('./filter-logic'); // handles filtering functions
6161
this.state = {
6262
isConnected: true,
6363
isLoggedIn: false,
64-
requireLogin: this.AppState('TEMPLATE').requireLogin
64+
requireLogin: this.AppState('TEMPLATE').requireLogin,
65+
disconnectMsg: ''
6566
};
6667
this.OnDOMReady(()=>{
6768
if (DBG) console.log(PR,'OnDOMReady');
@@ -78,11 +79,19 @@ const FILTERLOGIC = require('./filter-logic'); // handles filtering functions
7879
this.OnRun(()=>{
7980
if (DBG) console.log(PR,'OnRun');
8081
});
81-
this.OnDisconnect(()=>{
82-
this.setState({ isConnected: false });
82+
this.OnDisconnect((e) => {
83+
if (DBG) console.log(PR,'OnDisconnect');
84+
// This is now handled by the UDATA "DISCONNECT" message.
85+
// so that we can show a message explaining the cause of disconnect.
86+
// this.setState({ isConnected: false });
8387
});
8488
this.onStateChange_SESSION = this.onStateChange_SESSION.bind(this);
85-
this.OnAppStateChange('SESSION',this.onStateChange_SESSION);
89+
this.onDisconnect = this.onDisconnect.bind(this);
90+
91+
this.OnAppStateChange('SESSION', this.onStateChange_SESSION);
92+
93+
const UDATA = UNISYS.NewDataLink(this);
94+
UDATA.HandleMessage("DISCONNECT", this.onDisconnect);
8695
}
8796

8897

@@ -93,6 +102,13 @@ const FILTERLOGIC = require('./filter-logic'); // handles filtering functions
93102
this.setState({ isLoggedIn: decoded.isValid });
94103
}
95104

105+
onDisconnect(e) {
106+
const time = new Date().toLocaleTimeString();
107+
this.setState({
108+
isConnected: false,
109+
disconnectMsg: `${e.detail.message} ${time}`
110+
});
111+
}
96112

97113
/// REACT LIFECYCLE METHODS ///////////////////////////////////////////////////
98114
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@@ -111,14 +127,14 @@ const FILTERLOGIC = require('./filter-logic'); // handles filtering functions
111127
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
112128
/*/ Define the component structure of the web application
113129
/*/ render() {
114-
const { isLoggedIn } = this.state;
130+
const { isLoggedIn, disconnectMsg } = this.state;
115131
let hideGraph = false;
116132
if (this.state.requireLogin && !isLoggedIn) hideGraph = true;
117133
return (
118134
<div>
119135
<div hidden={this.state.isConnected} style={{ width:'100%',height:'38px',position:'fixed',backgroundColor:'rgba(256,0,0,0.5',display:'flex',flexDirection:'column',justifyContent:'space-evenly',alignItems:'center',zIndex:'3000'}}>
120136
<div style={{color:'#fff',width:'100%',textAlign:'center'}}>
121-
<b>Server Disconnected!</b> Your changes will not be saved! Please contact your administrator to restart the graph.
137+
<b>{disconnectMsg}!</b> Your changes will not be saved! Please report "{disconnectMsg}" to your administrator to restart the graph.
122138
</div>
123139
</div>
124140
<Route path='/edit/:token' exact={true} component={SessionShell}/>

build/app/view/netcreate/components/EdgeEditor.jsx

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable complexity */
12
/*//////////////////////////////// ABOUT \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*\
23
34
## OVERVIEW
@@ -923,7 +924,11 @@ class EdgeEditor extends UNISYS.Component {
923924
<FormText onClick={this.onEdgeClick}><b>EDGE {formData.id}</b></FormText>
924925
<FormGroup row>
925926
<Col sm={3} style={{hyphens: 'auto'}} className="pr-0">
926-
<Label for="source" className="tooltipAnchor small text-muted"><i className="fas fa-question-circle"></i>{edgePrompts.source.label}<span className="tooltiptext">{this.helpText(edgePrompts.source)}</span></Label>
927+
<Label for="source" className="tooltipAnchor small text-muted">
928+
<div className="badge">?</div>
929+
{edgePrompts.source.label}
930+
<span className="tooltiptext">{this.helpText(edgePrompts.source)}</span>
931+
</Label>
927932
</Col>
928933
<Col sm={9}>
929934
<AutoComplete
@@ -944,7 +949,11 @@ class EdgeEditor extends UNISYS.Component {
944949
</FormGroup>
945950
<FormGroup row hidden={edgePrompts.type.hidden}>
946951
<Col sm={3} style={{hyphens: 'auto'}} className="pr-0">
947-
<Label for="relationship" className="tooltipAnchor small text-muted"><i className="fas fa-question-circle"></i>{edgePrompts.type.label}<span className="tooltiptext">{this.helpText(edgePrompts.type)}</span></Label>
952+
<Label for="relationship" className="tooltipAnchor small text-muted">
953+
<div className="badge">?</div>
954+
{edgePrompts.type.label}
955+
<span className="tooltiptext">{this.helpText(edgePrompts.type)}</span>
956+
</Label>
948957
</Col>
949958
<Col sm={9}>
950959
<Input type="select" name="relationship"
@@ -960,7 +969,11 @@ class EdgeEditor extends UNISYS.Component {
960969
</FormGroup>
961970
<FormGroup row>
962971
<Col sm={3} style={{hyphens: 'auto'}} className="pr-0">
963-
<Label for="nodeLabel" className="tooltipAnchor small text-muted"><i className="fas fa-question-circle"></i>{edgePrompts.target.label}<span className="tooltiptext">{this.helpText(edgePrompts.target)}</span></Label>
972+
<Label for="nodeLabel" className="tooltipAnchor small text-muted">
973+
<div className="badge">?</div>
974+
{edgePrompts.target.label}
975+
<span className="tooltiptext">{this.helpText(edgePrompts.target)}</span>
976+
</Label>
964977
</Col>
965978
<Col sm={9}>
966979
<AutoComplete
@@ -989,7 +1002,11 @@ class EdgeEditor extends UNISYS.Component {
9891002
</FormGroup>
9901003
<FormGroup row hidden={edgePrompts.category.hidden}>
9911004
<Col sm={3} style={{hyphens: 'auto'}} className="pr-0">
992-
<Label for="category" className="tooltipAnchor small text-muted"><i className="fas fa-question-circle"></i>{edgePrompts.category.label}<span className="tooltiptext">{this.helpText(edgePrompts.category)}</span></Label>
1005+
<Label for="category" className="tooltipAnchor small text-muted">
1006+
<div className="badge">?</div>
1007+
{edgePrompts.category.label}
1008+
<span className="tooltiptext">{this.helpText(edgePrompts.category)}</span>
1009+
</Label>
9931010
</Col>
9941011
<Col sm={9}>
9951012
<Input type="text" name="category"
@@ -1000,7 +1017,11 @@ class EdgeEditor extends UNISYS.Component {
10001017
</Col>
10011018
</FormGroup><FormGroup row hidden={edgePrompts.citation.hidden}>
10021019
<Col sm={3} style={{hyphens: 'auto'}} className="pr-0">
1003-
<Label for="citation" className="tooltipAnchor small text-muted"><i className="fas fa-question-circle"></i>{edgePrompts.citation.label}<span className="tooltiptext">{this.helpText(edgePrompts.citation)}</span></Label>
1020+
<Label for="citation" className="tooltipAnchor small text-muted">
1021+
<div className="badge">?</div>
1022+
{edgePrompts.citation.label}
1023+
<span className="tooltiptext">{this.helpText(edgePrompts.citation)}</span>
1024+
</Label>
10041025
</Col>
10051026
<Col sm={9}>
10061027
<Input type="text" name="citation"
@@ -1012,7 +1033,11 @@ class EdgeEditor extends UNISYS.Component {
10121033
</FormGroup>
10131034
<FormGroup row hidden={edgePrompts.notes.hidden}>
10141035
<Col sm={3} style={{hyphens: 'auto'}} className="pr-0">
1015-
<Label for="notes" className="tooltipAnchor small text-muted"><i className="fas fa-question-circle"></i>{edgePrompts.notes.label}<span className="tooltiptext">{this.helpText(edgePrompts.notes)}</span></Label>
1036+
<Label for="notes" className="tooltipAnchor small text-muted">
1037+
<div className="badge">?</div>
1038+
{edgePrompts.notes.label}
1039+
<span className="tooltiptext">{this.helpText(edgePrompts.notes)}</span>
1040+
</Label>
10161041
</Col>
10171042
<Col sm={9}>
10181043
<Input type="textarea" name="notes"
@@ -1026,7 +1051,11 @@ class EdgeEditor extends UNISYS.Component {
10261051
</FormGroup>
10271052
<FormGroup row hidden={edgePrompts.info.hidden}>
10281053
<Col sm={3} style={{hyphens: 'auto'}} className="pr-0">
1029-
<Label for="info" className="tooltipAnchor small text-muted"><i className="fas fa-question-circle"></i>{edgePrompts.info.label}<span className="tooltiptext">{this.helpText(edgePrompts.info)}</span></Label>
1054+
<Label for="info" className="tooltipAnchor small text-muted">
1055+
<div className="badge">?</div>
1056+
{edgePrompts.info.label}
1057+
<span className="tooltiptext">{this.helpText(edgePrompts.info)}</span>
1058+
</Label>
10301059
</Col>
10311060
<Col sm={9}>
10321061
<Input type="text" name="info"

0 commit comments

Comments
 (0)