[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.
This commit is contained in:
Oliver Gerlich 2018-07-16 23:02:52 +02:00
parent d999559fa5
commit 6cac9defbd
2 changed files with 30 additions and 2 deletions

View File

@ -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',

View File

@ -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) {