From d6cfcca42bd63abd9c18d208f2c8096aab9e6f58 Mon Sep 17 00:00:00 2001 From: Joseph Coffland Date: Tue, 16 Oct 2018 16:40:26 -0700 Subject: [PATCH] Don't reload browser view on reconnect unless controller has reloaded. --- CHANGELOG.md | 1 + src/js/app.js | 25 +++++++++++++------------ src/py/bbctrl/State.py | 3 +++ 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03d705b..ca2b519 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ Buildbotics CNC Controller Firmware Changelog - Show IO status indicators on configuration pages. - Check that axis dimensions fit path plan dimensions. - Show machine working envelope in path plan viewer. + - Don't reload browser view on reconnect unless controller has reloaded. ## v0.3.28 - Show step rate on motor configuration page. diff --git a/src/js/app.js b/src/js/app.js index 25edc0a..913145e 100644 --- a/src/js/app.js +++ b/src/js/app.js @@ -98,7 +98,6 @@ module.exports = new Vue({ errorTimeoutStart: 0, errorShow: false, errorMessage: '', - reloadOnConnect: false, confirmUpgrade: false, confirmUpload: false, firmwareUpgrading: false, @@ -142,17 +141,7 @@ module.exports = new Vue({ }, - connected: function () { - if (this.reloadOnConnect) { - if (typeof this.hostname != 'undefined' && - String(location.hostname) != 'localhost') - location.hostname = this.hostname; - location.reload(true); - } else this.update(); - }, - - - disconnected: function () {this.reloadOnConnect = true}, + connected: function () {this.update()}, update: function () {this.update()}, @@ -303,6 +292,18 @@ module.exports = new Vue({ delete e.data.message; } + // Check for session ID change on controller + if ('sid' in e.data) { + if (typeof this.sid == 'undefined') this.sid = e.data.sid; + + else if (this.sid != e.data.sid) { + if (typeof this.hostname != 'undefined' && + String(location.hostname) != 'localhost') + location.hostname = this.hostname; + location.reload(true); + } + } + update_object(this.state, e.data, false); this.$broadcast('update'); diff --git a/src/py/bbctrl/State.py b/src/py/bbctrl/State.py index b724c2a..6d8a3a5 100644 --- a/src/py/bbctrl/State.py +++ b/src/py/bbctrl/State.py @@ -28,6 +28,7 @@ import logging import traceback import copy +import uuid import bbctrl @@ -106,6 +107,8 @@ class State(object): self.set_callback('metric', lambda name: 1 if self.is_metric() else 0) self.set_callback('imperial', lambda name: 0 if self.is_metric() else 1) + self.set('sid', str(uuid.uuid4())) + self.reset() -- 2.27.0