瀏覽代碼

feat(dashboard): statistics are refreshed every 60 seconds

Casper Dai 2 年之前
父節點
當前提交
408f349d1d

+ 7 - 2
src/views/dashboard/components/DeviceDashboard.vue

@@ -156,6 +156,7 @@ export default {
           options.offline = offLineTotal + notConnectedTotal
           options.loaded = true
           this.$emit('loaded', options.total)
+          this.$timer = setTimeout(this.getDeviceStatisticsByPath, 60000)
         },
         ({ isCancel }) => {
           if (!isCancel || options.ignore) {
@@ -168,8 +169,12 @@ export default {
     },
     onDeviceStatusChanged (val) {
       if (this.options.loaded) {
-        this.options.online += val
-        this.options.offline -= val
+        if (val === 0) {
+          this.getDeviceStatisticsByPath()
+        } else {
+          this.options.online += val
+          this.options.offline -= val
+        }
       }
     }
   }

+ 3 - 0
src/views/dashboard/components/DeviceGroupAttention.vue

@@ -80,6 +80,9 @@ export default {
       this.$emit('change', [{
         children: [...this.groupOptions.list]
       }])
+    },
+    onStatusChanged () {
+      this.dashboard?.onDeviceStatusChanged(0)
     }
   }
 }