Show connected time and uptime

Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
This commit is contained in:
Jianhui Zhao
2021-01-14 21:32:27 +08:00
parent b681b8cfa4
commit dc56150510
5 changed files with 11 additions and 5 deletions
+1
View File
@@ -14,6 +14,7 @@
"device-count": "Online Device: {count}",
"No devices connected": "No devices connected",
"Device ID": "Device ID",
"Connected time": "Connected time",
"Uptime": "Uptime",
"Description": "Description",
"Please select the devices you want to operate": "Please select the devices you want to operate",
+2 -1
View File
@@ -14,7 +14,8 @@
"device-count": "在线设备数: {count}",
"No devices connected": "没有设备连接",
"Device ID": "设备ID",
"Uptime": "在线时长",
"Connected time": "已连接时长",
"Uptime": "运行时长",
"Description": "描述",
"Please select the devices you want to operate": "请选择您要操作的设备",
"Command": "命令",
+5 -2
View File
@@ -12,8 +12,11 @@
@selection-change='handleSelection'>
<el-table-column type="index" label="#" width="100"/>
<el-table-column type="selection"/>
<el-table-column prop="id" :label="$t('Device ID')" sortable width="300"/>
<el-table-column prop="uptime" :label="$t('Uptime')" sortable width="150">
<el-table-column prop="id" :label="$t('Device ID')" sortable width="200"/>
<el-table-column prop="connected" :label="$t('Connected time')" sortable width="200">
<template v-slot="{ row }">{{ row.connected | formatTime }}</template>
</el-table-column>
<el-table-column prop="uptime" :label="$t('Uptime')" sortable width="200">
<template v-slot="{ row }">{{ row.uptime | formatTime }}</template>
</el-table-column>
<el-table-column prop="description" :label="$t('Description')" show-overflow-tooltip/>
+2 -1
View File
@@ -109,6 +109,7 @@ func httpStart(br *broker) {
authorized.GET("/devs", func(c *gin.Context) {
type DeviceInfo struct {
ID string `json:"id"`
Connected uint32 `json:"connected"`
Uptime uint32 `json:"uptime"`
Description string `json:"description"`
}
@@ -116,7 +117,7 @@ func httpStart(br *broker) {
devs := make([]DeviceInfo, 0)
for id, dev := range br.devices {
dev := DeviceInfo{id, dev.uptime, dev.desc}
dev := DeviceInfo{id, uint32(time.Now().Unix() - dev.timestamp), dev.uptime, dev.desc}
devs = append(devs, dev)
}
+1 -1
View File
File diff suppressed because one or more lines are too long