Don't reload browser view on reconnect unless controller has reloaded.
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 16 Oct 2018 23:40:26 +0000 (16:40 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Tue, 16 Oct 2018 23:40:26 +0000 (16:40 -0700)
CHANGELOG.md
src/js/app.js
src/py/bbctrl/State.py

index 03d705b88d969c03a1137c1f4d82dd05f3c82e21..ca2b519ff5c5e8fe2c255c2a37cd829c48ed2606 100644 (file)
@@ -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.
index 25edc0a84278da72093bd051e5114d03efeab6b1..913145e8906f81f2cedb643b0cb09a88f0a8a57c 100644 (file)
@@ -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');
 
index b724c2a36e19350af70c5a7f2cb2ad8b1ee2add9..6d8a3a5e3993f4bd7586f03465b5a89350737456 100644 (file)
@@ -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()