From 6cac9defbdec8673af3cdbe7dbaa47d1f8789758 Mon Sep 17 00:00:00 2001 From: Oliver Gerlich Date: Mon, 16 Jul 2018 23:02:52 +0200 Subject: [PATCH] [test only] add "Create Heavy Load" button to node page This will set up a timer which updates the node hostname every 200 msec, to simulate high load for testing frontend performance in browsers. The notification box for successful updates has been disable for this test since it would fill the screen otherwise. --- webroot/js/socket.js | 4 ++-- webroot/js/view/node.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/webroot/js/socket.js b/webroot/js/socket.js index c7584a5..8b9f11d 100644 --- a/webroot/js/socket.js +++ b/webroot/js/socket.js @@ -159,10 +159,10 @@ export function delEvent (to, func) { export function sendnode(node, callback) { sendjson({'subject':'node-system','body': node}, (msg) => { if(msg.body){ - notify.send({ + /*notify.send({ 'header': 'Speichern', 'type': 'success', - }, `Einstellungen für '${node.node_id}' gespeichert.`); + }, `Einstellungen für '${node.node_id}' gespeichert.`);*/ }else{ notify.send({ 'header': 'Speichern', diff --git a/webroot/js/view/node.js b/webroot/js/view/node.js index 16c8828..d1d0f52 100644 --- a/webroot/js/view/node.js +++ b/webroot/js/view/node.js @@ -142,6 +142,34 @@ export class NodeView extends View { }); this.gpsStatusText = domlib.newAt(this.el, 'span'); this.gpsStatusText.classList.add('withTextMargins'); + + this.createLoadBtn = domlib.newAt(this.el, 'span'); + this.createLoadBtn.classList.add('btn'); + this.createLoadBtn.innerHTML = 'Create Heavy Load'; + this.loadIntervalId = null; + this.createLoadBtn.addEventListener('click', () => { + console.log("starting to create load for " + this.currentNodeID); + if (this.loadIntervalId == null) { + this.createLoadBtn.innerHTML = 'Creating Load...'; + this.loadIntervalId = setInterval(() => { + console.log("sending dummy data for node " + this.currentNodeID); + + const node = store.getNode(this.currentNodeID) || store.createNode(this.currentNodeID), + localNodeCopy = Object.assign({}, node), + nowTime = new Date(), + dummyData = "test_" + nowTime.toLocaleTimeString() + "." + nowTime.getMilliseconds(); + //localNodeCopy.owner = dummyData; + localNodeCopy.hostname = dummyData; + socket.sendnode(localNodeCopy); + + }, 200); + } + else { + clearInterval(this.loadIntervalId); + this.loadIntervalId = null; + this.createLoadBtn.innerHTML = 'Create Heavy Load'; + } + }); } updatePosition (lat, lng) {