From f14f98a263141d2f8ec0079866a758cc7a1c38d1 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期一, 22 八月 2022 03:20:29 +0800
Subject: [PATCH] 添加用户删除功能

---
 src/Pool/PollData.ts |  209 +++++++++++++++++++++++++---------------------------
 1 files changed, 101 insertions(+), 108 deletions(-)

diff --git a/src/Pool/PollData.ts b/src/Pool/PollData.ts
index 3ecfc8d..96db2a7 100644
--- a/src/Pool/PollData.ts
+++ b/src/Pool/PollData.ts
@@ -1,99 +1,97 @@
-import { getPollConfig, changeRunType, getCamerasByServer, statisticRunInfo, updateChannelCount } from "@/api/pollConfig";
-import { getSystemSummaryInfo, getSysThresholds } from "@/api/system"
+import { getPollConfig, changeRunType, getCamerasByServer, updateChannelCount } from "@/api/pollConfig"
+import { getSysThresholds } from "@/api/system"
+import { clusterStatisticRunInfo, deviceStatisticRunInfo, devicesSysInfo, clusterSysInfo } from "@/api/clusterManage"
 
 export default class PollData {
-  public Config: Object = {};
-  public SearchName: String = "";
-  public CameraList: Array<object> = [];
-  public Enabled: boolean = false;
+  public Config: Object = {}
+  public SearchName: String = ""
+  public CameraList: Array<object> = []
+  public Enabled: boolean = false
 
   //鎬荤畻鍔�
-  public channelTotal: number = 0;
+  public channelTotal: number = 0
 
-  public Running: number = 0;
-  public Idle: number = 0;
+  public Running: number = 0
+  public Idle: number = 0
   //瀹炴椂鍏ㄩ儴鎵撳紑
-  public RealTimeSum: number = 0;
+  public RealTimeSum: number = 0
   //瀹炴椂绠楀姏鎬绘暟
-  public RealTimeValidCount: number = 0;
+  public RealTimeValidCount: number = 0
   //瀹炴椂閰嶇疆涓嶅叏
-  public RealTimeInvalid: number = 0;
+  public RealTimeInvalid: number = 0
   //瀹炴椂姝e湪澶勭悊
-  public RealTimeRun: number = 0;
+  public RealTimeRun: number = 0
   //瀹炴椂鏁呴殰
-  public RealTimeNoDeal: number = 0;
-
+  public RealTimeNoDeal: number = 0
 
   //杞绠楀姏鎬绘暟
-  public PollValidCount: number = 0;
+  public PollValidCount: number = 0
   //杞鍏ㄩ儴鎵撳紑
-  public PollSum: number = 0;
+  public PollSum: number = 0
   //杞姝e湪鎵ц
-  public PollRun: number = 0;
+  public PollRun: number = 0
   //杞閰嶇疆涓嶅叏
-  public PollInvalid: number = 0;
+  public PollInvalid: number = 0
   //杞鏁呴殰
-  public PollNoDeal: number = 0;
-  public PollChannelTotal: number = 0;
-
+  public PollNoDeal: number = 0
+  public PollChannelTotal: number = 0
 
   //鏁版嵁鏍堢畻鍔涙�绘暟
-  public stackChannelCount: number = 0;
+  public stackChannelCount: number = 0
   //鏁版嵁鏍堟�绘暟
-  public stackTotal: number = 0;
+  public stackTotal: number = 0
   //鏁版嵁鏍堥厤缃笉鍏�
-  public stackInvalidCount: number = 0;
+  public stackInvalidCount: number = 0
   //鏁版嵁鏍堟鍦ㄦ墽琛�
-  public stackRunningCount: number = 0;
+  public stackRunningCount: number = 0
   //鏁版嵁鏍堟晠闅�
-  public stackNoDeal: number = 0;
-
+  public stackNoDeal: number = 0
 
   //鏈湴绠楀姏閫氶亾鏁�
-  public localVideo: number = 0;
+  public localVideo: number = 0
 
-  public CpuUsedPercent: number = 0;
-  public MemUsedPercent: number = 0;
-  public GpuUsedPercent: number = 0;
-  public DiskUsePercent: number = 0;
-  public barCharts: Array<any> = [];
-  public Thresholds: Array<object> = [];
+  public CpuUsedPercent: number = 0
+  public MemUsedPercent: number = 0
+  public GpuUsedPercent: number = 0
+  public DiskUsePercent: number = 0
+  public barCharts: Array<any> = []
+  public Thresholds: Array<object> = []
 
   //绠楀姏閰嶇疆涓粦鍧楁暟鎹�
-  public sliderList: Array<any> = [];
+  public sliderList: Array<any> = []
 
   public init() {
-    this.fetchPollConfig();
-    this.fetchPollList();
-    this.sysThresholds();
-    this.statisticTaskInfo();
+    this.fetchPollConfig()
+    this.fetchPollList()
+    this.sysThresholds()
+    this.statisticTaskInfo()
   }
 
   public async fetchPollConfig() {
-    const rsp: any = await getPollConfig();
+    const rsp: any = await getPollConfig()
     if (rsp && rsp.success) {
-      this.Config = rsp.data;
+      this.Config = rsp.data
       if (rsp.data.enable) {
-        this.Enabled = true;
+        this.Enabled = true
       }
     }
   }
 
   public async fetchPollList() {
     this.CameraList = []
-    let rsp: any = await getCamerasByServer({ cameraName: this.SearchName });
+    let rsp: any = await getCamerasByServer({ cameraName: this.SearchName })
     if (rsp && rsp.success) {
       if (rsp.data) {
-        this.CameraList = rsp.data.sort(function (obj1: any, obj2: any) {
-          var val1 = obj1.run_type;
-          var val2 = obj2.run_type;
-          return (val2 - val1)
-        });
+        this.CameraList = rsp.data.sort(function(obj1: any, obj2: any) {
+          var val1 = obj1.run_type
+          var val2 = obj2.run_type
+          return val2 - val1
+        })
       }
     }
 
     // 鏍规嵁rtsp 鎻愬彇ip鍦板潃
-    const ipReg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;
+    const ipReg = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/
     this.CameraList.forEach((cam: any) => {
       // 鍥芥爣鎽勫儚鏈轰笉鏄剧ずip
       if (cam.type === 1) {
@@ -108,80 +106,76 @@
   }
 
   public async switchType(id: string, type: number) {
-    let rsp: any = await changeRunType({ camera_ids: [id], run_type: type });
+    let rsp: any = await changeRunType({ camera_ids: [id], run_type: type })
   }
 
   public async sysThresholds() {
     let rsp: any = await getSysThresholds()
     if (rsp && rsp.success) {
-      this.Thresholds = rsp.data;
+      this.Thresholds = rsp.data
     }
   }
   public async statistics() {
-    let list = []
+    // let list = []
 
-    let rsp: any = await getCamerasByServer({ cameraName: "" });
-    if (rsp && rsp.success) {
-      list = list.concat(rsp.data);
-    }
+    // let rsp: any = await getCamerasByServer({ cameraName: "" });
+    // if (rsp && rsp.success) {
+    //   list = list.concat(rsp.data);
+    // }
 
-    let RealTimeSum = 0, RealTimeRun = 0, PollSum = 0, PollRun = 0;
+    // let RealTimeSum = 0, RealTimeRun = 0, PollSum = 0, PollRun = 0;
 
-    list.forEach((cam: any) => {
-      if (cam.run_type === 1) {
-        RealTimeSum++
-        if (cam.is_running) {
-          RealTimeRun++
-        }
-      }
+    // list.forEach((cam: any) => {
+    //   if (cam.run_type === 1) {
+    //     RealTimeSum++
+    //     if (cam.is_running) {
+    //       RealTimeRun++
+    //     }
+    //   }
 
-      if (cam.run_type === 0) {
-        PollSum++
-        if (cam.is_running) {
-          PollRun++
-        }
-      }
-    })
+    //   if (cam.run_type === 0) {
+    //     PollSum++
+    //     if (cam.is_running) {
+    //       PollRun++
+    //     }
+    //   }
+    // })
 
-    this.Running = RealTimeRun + PollRun
-    this.Idle = RealTimeSum + PollSum - this.Running
+    // this.Running = RealTimeRun + PollRun
+    // this.Idle = RealTimeSum + PollSum - this.Running
 
     // 璁$畻绯荤粺淇℃伅
-    rsp = await getSystemSummaryInfo()
-    if (rsp && rsp.success && rsp.data.cpu) {
-      let sysinfo = rsp.data
-
-      // cpu
-      if (sysinfo.cpu) {
-        let cpuLoad = sysinfo.cpu.reduce((pre, item) => {
-          return pre + item;
-        }, 0)
-
-        this.CpuUsedPercent = Number((cpuLoad / sysinfo.cpu.length).toFixed(2))
-      }
-
-      // 鍐呭瓨
-      this.MemUsedPercent = Number(sysinfo.mem.usedPercent.toFixed(2))
-      // 纭洏浣跨敤鎯呭喌
-      this.DiskUsePercent = Number(sysinfo.disk.usedPercent.toFixed(2))
-
-      if (sysinfo.gpu) {
-        let gpuLoad = 0, gpuTotal = 0;
-
-        for (let i = 0; i < sysinfo.gpu.length; i++) {
-          gpuLoad += sysinfo.gpu[i].used;
-          gpuTotal += sysinfo.gpu[i].memory;
-        }
-        this.GpuUsedPercent = Number((gpuLoad / gpuTotal * 100).toFixed(2))
-      }
-      this.barCharts = [this.DiskUsePercent,this.CpuUsedPercent,this.GpuUsedPercent,this.MemUsedPercent]
+    let res: any
+    if (sessionStorage.getItem("clusterId")) {
+      res = await clusterSysInfo({
+        clusterId: ""
+      })
+    } else {
+      res = await devicesSysInfo({
+        deviceId: [sessionStorage.getItem("devId")]
+      })
+    }
+    if (res && res.success) {
+      this.CpuUsedPercent = res.data.cpu.usedPercent.toFixed(2)
+      this.MemUsedPercent = res.data.mem.usedPercent.toFixed(2)
+      this.DiskUsePercent = res.data.disk.usedPercent.toFixed(2)
+      this.GpuUsedPercent = res.data.gpu.usedPercent.toFixed(2)
+      this.barCharts = [this.DiskUsePercent, this.CpuUsedPercent, this.GpuUsedPercent, this.MemUsedPercent]
     }
   }
 
   public async statisticTaskInfo() {
-    let res: any = await statisticRunInfo({});
+    let res: any
+    if (sessionStorage.getItem("clusterId")) {
+      res = await clusterStatisticRunInfo({})
+    } else {
+      res = await deviceStatisticRunInfo({
+        deviceId: [sessionStorage.getItem("devId")],
+        userId: ""
+      })
+    }
+
     if (res && res.success) {
-      // console.log(res,'缁熻瀹炴椂銆佽疆璇㈡暟閲�')
       this.RealTimeSum = res.data.realTotal
       this.RealTimeRun = res.data.realRunningCount
       this.RealTimeValidCount = res.data.realValidCount
@@ -210,21 +204,20 @@
       let totalCount = res.data.channelTotal
       let realCount = res.data.realValidCount
       let pollCount = res.data.pollChannelCount
-      this.sliderList = [0,realCount,realCount + pollCount]
+      this.sliderList = [0, realCount, realCount + pollCount]
       // if(realCount + pollCount == totalCount){
       //   this.sliderList = [0,realCount,realCount + pollCount]
       // }else{
       //   this.sliderList = [0,realCount,realCount + pollCount,totalCount]
       // }
-      
     }
   }
 
-  public async updateChannelCount(fileChannelCount,pollChannelCount){
+  public async updateChannelCount(fileChannelCount, pollChannelCount) {
     let res: any = await updateChannelCount({
       videoChannelCount: fileChannelCount,
       pollChannelCount: pollChannelCount
     })
     this.statisticTaskInfo()
   }
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0