소스 검색

feat(dashboard): statistics are refreshed every 60 seconds

Casper Dai 2 년 전
부모
커밋
408f349d1d
2개의 변경된 파일10개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      src/views/dashboard/components/DeviceDashboard.vue
  2. 3 0
      src/views/dashboard/components/DeviceGroupAttention.vue

+ 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)
     }
   }
 }