Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
29 changes: 0 additions & 29 deletions app/assets/index.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -56,35 +56,6 @@
</script>
<script src="/scripts/netc-lib.js"></script>
<script src="/scripts/netc-app.js"></script>
<!-- Google Analytics -->
<script>
let googlea = NC_CONFIG.googlea;
if (googlea != '0') {
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
(i[r] =
i[r] ||
function () {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(
window,
document,
'script',
'https://www.google-analytics.com/analytics.js',
'ga'
);

ga('create', 'UA-132368455-3', 'auto');
ga('send', 'pageview');
}
</script>
<!-- End Google Analytics -->
<script>
document.title += ` ${window.NC_CONFIG.dataset} @ ${window.NC_UNISYS.server.ip}`;
require('init');
Expand Down
31 changes: 0 additions & 31 deletions app/assets/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,6 @@
<script src="config/netcreate-config.js">
// auto generated netcreate config script
</script>
<!-- Google Analytics -->
<script>
(function (i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
(i[r] =
i[r] ||
function () {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = 1 * new Date());
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m);
})(
window,
document,
'script',
'https://www.google-analytics.com/analytics.js',
'ga'
);

// added by Joshua to allow google analytics to be driven by a flag on run
//const NC_CONFIG = require("../../../config/netcreate-config");
let googlea = NC_CONFIG.googlea;
if (googlea != '0') {
ga('create', googlea, 'auto');
ga('send', 'pageview');
}
</script>
<!-- End Google Analytics -->
<script>
// index.html is loaded only by standalone mode without a server
// server-based operation uses index.ejs
Expand Down
23 changes: 14 additions & 9 deletions app/unisys/component/SessionShell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const INVALID = {
class SessionShell extends UNISYS.Component {
constructor() {
super();
this.getDecodedToken = this.getDecodedToken.bind(this);
this.renderLogin = this.renderLogin.bind(this);
this.renderLoggedIn = this.renderLoggedIn.bind(this);
this.handleChange = this.handleChange.bind(this);
Expand All @@ -136,8 +137,7 @@ class SessionShell extends UNISYS.Component {
hashedId: null,
subId: null,
groupId: null,
isValid: false,
templateSalt: undefined // this is set in componentDidMount()
isValid: false
};
this.previousIsValid = false; // to track changes in loggedIn status

Expand All @@ -153,6 +153,14 @@ class SessionShell extends UNISYS.Component {
// });
}

/// PRIVATE FUNCTIONS //////////////////////////////////////////////////////////
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
getDecodedToken(token) {
const TEMPLATE = this.AppState('TEMPLATE');
const templateSalt = TEMPLATE && TEMPLATE.secretKey;
return SESSION.DecodeToken(token, templateSalt);
}

/// ROUTE RENDER FUNCTIONS ////////////////////////////////////////////////////
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/** render successful logged-in
Expand Down Expand Up @@ -347,10 +355,7 @@ class SessionShell extends UNISYS.Component {

const { routeProps } = SETTINGS.GetRouteInfoFromURL();
let { token } = routeProps;
const TEMPLATE = this.AppState('TEMPLATE');
const templateSalt = TEMPLATE && TEMPLATE.secretKey;
this.setState({ templateSalt });
const decoded = SESSION.DecodeToken(token, templateSalt) || {};
const decoded = this.getDecodedToken(token) || {};
this.SetAppState('SESSION', decoded);
this.previousIsValid = decoded.isValid;
}
Expand All @@ -363,7 +368,7 @@ class SessionShell extends UNISYS.Component {
let { token } = routeProps;

if (!token) return; // don't bother to check if this was a result of changes from the form
let decoded = SESSION.DecodeToken(token, this.state.templateSalt);
const decoded = this.getDecodedToken(token) || {};
if (decoded.isValid !== this.previousIsValid) {
this.SetAppState('SESSION', decoded);
this.previousIsValid = decoded.isValid;
Expand All @@ -374,7 +379,7 @@ class SessionShell extends UNISYS.Component {
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
handleChange(event) {
let token = event.target.value;
let decoded = SESSION.DecodeToken(token, this.state.templateSalt);
const decoded = this.getDecodedToken(token) || {};
let { classId, projId, hashedId, subId, groupId } = decoded;
this.setState(decoded);
}
Expand Down Expand Up @@ -413,7 +418,7 @@ class SessionShell extends UNISYS.Component {
if (!token) return this.renderLogin();

// try to decode token
let decoded = SESSION.DecodeToken(token, this.state.templateSalt);
const decoded = this.getDecodedToken(token) || {};
if (decoded.isValid) {
return this.renderLoggedIn(decoded);
} else {
Expand Down
2 changes: 1 addition & 1 deletion app/view/netcreate/components/MURColorGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ function ColorGroup(props) {
const renderColorItems = () => {
let items = [];
const colorItems = sourceData.map((item, index) => {
const itemHash = btoa(`${item.color}-${item.label}`);
const itemHash = btoa(encodeURIComponent(`${item.color}-${item.label}`));
const itemKey = `${index}-${itemHash}`;
const itemPropDef = `${propDef}[${index}]`;
items.push(item);
Expand Down
8 changes: 7 additions & 1 deletion app/view/netcreate/components/NCEdgeTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const UDATAOwner = { name: 'NCEdgeTable' };
const UDATA = UNISYS.NewDataLink(UDATAOwner);

const DBG = false;
const PR = 'NCEdgeTable';

/// REACT FUNCTIONAL COMPONENT ////////////////////////////////////////////////
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -95,6 +96,7 @@ function NCEdgeTable({ isOpen }) {
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/// FILTEREDNCDATA is the reduced list of nodes, not ALL edges
function urstate_FILTEREDNCDATA(data) {
if (DBG) console.log(PR, 'urstate_FILTEREDNCDATA', data);
// skip update if not open
if (!isOpenRef.current) return;

Expand All @@ -113,6 +115,7 @@ function NCEdgeTable({ isOpen }) {
}
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function urstate_SESSION(decoded) {
if (DBG) console.log(PR, 'urstate_SESSION', decoded);
const isLocked = !decoded.isValid;
if (isLocked === state.isLocked) {
return;
Expand All @@ -121,21 +124,24 @@ function NCEdgeTable({ isOpen }) {
}
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function urstate_TEMPLATE(data) {
if (DBG) console.log(PR, 'urstate_TEMPLATE', data);
setState(prevState => ({
...prevState,
columnDefs: DeriveColumnDefs(data.edgeDefs), // re-derive column defs after template changes
edgeDefs: data.edgeDefs,
selectedEdgeColor: data.sourceColor
}));
}
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function urstate_TBLCOLSTATE(TBLCOLSTATE) {
if (DBG) console.log(PR, 'urstate_TBLCOLSTATE', TBLCOLSTATE);
forceUpdate();
}

/// COLUMN DEFINTION GENERATION /////////////////////////////////////////////
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function DeriveColumnDefs(incomingEdgeDefs) {
const { edges, edgeDefs, disableEdit, isLocked } = state;
const { edgeDefs, disableEdit, isLocked } = state;
const defs = incomingEdgeDefs || edgeDefs;

// Only include built in fields
Expand Down
6 changes: 6 additions & 0 deletions app/view/netcreate/components/NCNodeTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const UDATAOwner = { name: 'NCNodeTable' };
const UDATA = UNISYS.NewDataLink(UDATAOwner);

const DBG = false;
const PR = 'NCNodeTable';

/// REACT FUNCTIONAL COMPONENT ////////////////////////////////////////////////
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Expand Down Expand Up @@ -94,6 +95,7 @@ function NCNodeTable({ isOpen }) {
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/// FILTEREDNCDATA is the reduced list of nodes, not ALL nodes
function urstate_FILTEREDNCDATA(data) {
if (DBG) console.log(PR, 'urstate_FILTEREDNCDATA', data);
// skip update if not open
if (!isOpenRef.current) return;

Expand All @@ -113,6 +115,7 @@ function NCNodeTable({ isOpen }) {
}
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function urstate_SESSION(decoded) {
if (DBG) console.log(PR, 'urstate_SESSION', decoded);
const isLocked = !decoded.isValid;
if (isLocked === state.isLocked) {
return;
Expand All @@ -121,15 +124,18 @@ function NCNodeTable({ isOpen }) {
}
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function urstate_TEMPLATE(data) {
if (DBG) console.log(PR, 'urstate_TEMPLATE', data);
setState(prevState => ({
...prevState,
columnDefs: DeriveColumnDefs(data.nodeDefs), // re-derive column defs after template changes
nodeDefs: data.nodeDefs,
selectedNodeColor: data.sourceColor,
hilitedNodeColor: data.searchColor
}));
}
/// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function urstate_TBLCOLSTATE(TBLCOLSTATE) {
if (DBG) console.log(PR, 'urstate_TBLCOLSTATE', TBLCOLSTATE);
forceUpdate();
}

Expand Down
Loading