From c927132aa6a8c91240cf215158c263c9f9ef172e Mon Sep 17 00:00:00 2001 From: ssongliu Date: Wed, 29 Mar 2023 21:50:08 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96=E4=BA=86=E6=A6=82?= =?UTF-8?q?=E8=A7=88=E9=A1=B5=E3=80=81=E7=9B=91=E6=8E=A7=E9=A1=B5=E9=80=89?= =?UTF-8?q?=E9=A1=B9=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/v1/monitor.go | 3 + backend/app/dto/dashboard.go | 7 --- backend/app/service/dashboard.go | 33 ++--------- cmd/server/docs/docs.go | 70 ++++++++++++------------ cmd/server/docs/swagger.json | 70 ++++++++++++------------ cmd/server/docs/swagger.yaml | 49 +++++++++-------- frontend/src/api/interface/dashboard.ts | 7 --- frontend/src/views/home/app/index.vue | 19 +------ frontend/src/views/home/index.vue | 9 +-- frontend/src/views/home/status/index.vue | 25 ++++----- 10 files changed, 118 insertions(+), 174 deletions(-) diff --git a/backend/app/api/v1/monitor.go b/backend/app/api/v1/monitor.go index 1eb5a6d7f..b1d12e11c 100644 --- a/backend/app/api/v1/monitor.go +++ b/backend/app/api/v1/monitor.go @@ -1,6 +1,7 @@ package v1 import ( + "sort" "time" "github.com/1Panel-dev/1Panel/backend/app/api/v1/helper" @@ -88,6 +89,7 @@ func (b *BaseApi) GetNetworkOptions(c *gin.Context) { for _, net := range netStat { options = append(options, net.Name) } + sort.Strings(options) helper.SuccessWithData(c, options) } @@ -98,5 +100,6 @@ func (b *BaseApi) GetIOOptions(c *gin.Context) { for _, net := range diskStat { options = append(options, net.Name) } + sort.Strings(options) helper.SuccessWithData(c, options) } diff --git a/backend/app/dto/dashboard.go b/backend/app/dto/dashboard.go index f55ddd7ba..1efcd72a0 100644 --- a/backend/app/dto/dashboard.go +++ b/backend/app/dto/dashboard.go @@ -3,13 +3,6 @@ package dto import "time" type DashboardBase struct { - HaloID uint `json:"haloID"` - DateeaseID uint `json:"dateeaseID"` - JumpServerID uint `json:"jumpserverID"` - MeterSphereID uint `json:"metersphereID"` - KubeoperatorID uint `json:"kubeoperatorID"` - KubepiID uint `json:"kubepiID"` - WebsiteNumber int `json:"websiteNumber"` DatabaseNumber int `json:"databaseNumber"` CronjobNumber int `json:"cronjobNumber"` diff --git a/backend/app/service/dashboard.go b/backend/app/service/dashboard.go index 0d3c80524..e2bc21d58 100644 --- a/backend/app/service/dashboard.go +++ b/backend/app/service/dashboard.go @@ -39,27 +39,6 @@ func (u *DashboardService) LoadBaseInfo(ioOption string, netOption string) (*dto ss, _ := json.Marshal(hostInfo) baseInfo.VirtualizationSystem = string(ss) - apps, err := appRepo.GetBy() - if err != nil { - return nil, err - } - for _, app := range apps { - switch app.Key { - case "dateease": - baseInfo.DateeaseID = app.ID - case "halo": - baseInfo.HaloID = app.ID - case "metersphere": - baseInfo.MeterSphereID = app.ID - case "jumpserver": - baseInfo.JumpServerID = app.ID - case "kubeoperator": - baseInfo.KubeoperatorID = app.ID - case "kubepi": - baseInfo.KubepiID = app.ID - } - } - appInstall, err := appInstallRepo.ListBy() if err != nil { return nil, err @@ -169,10 +148,10 @@ func loadDiskInfo() []dto.DiskInfo { return datas } var excludes = []string{"/mnt/cdrom", "/boot", "/boot/efi", "/dev", "/dev/shm", "/run/lock", "/run", "/run/shm", "/run/user"} - for _, part := range parts { + for i := 0; i < len(parts); i++ { isExclude := false for _, exclude := range excludes { - if part.Mountpoint == exclude { + if parts[i].Mountpoint == exclude { isExclude = true break } @@ -180,11 +159,11 @@ func loadDiskInfo() []dto.DiskInfo { if isExclude { continue } - state, _ := disk.Usage("/") + state, _ := disk.Usage(parts[i].Mountpoint) var itemData dto.DiskInfo - itemData.Path = part.Mountpoint - itemData.Type = part.Fstype - itemData.Device = part.Device + itemData.Path = parts[i].Mountpoint + itemData.Type = parts[i].Fstype + itemData.Device = parts[i].Device itemData.Total = state.Total itemData.Free = state.Free itemData.Used = state.Used diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 65f94535c..a1d06bfe2 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -9171,33 +9171,15 @@ var doc = `{ "databaseNumber": { "type": "integer" }, - "dateeaseID": { - "type": "integer" - }, - "haloID": { - "type": "integer" - }, "hostname": { "type": "string" }, - "jumpserverID": { - "type": "integer" - }, "kernelArch": { "type": "string" }, "kernelVersion": { "type": "string" }, - "kubeoperatorID": { - "type": "integer" - }, - "kubepiID": { - "type": "integer" - }, - "metersphereID": { - "type": "integer" - }, "os": { "type": "string" }, @@ -9239,20 +9221,11 @@ var doc = `{ "cpuUsedPercent": { "type": "number" }, - "free": { - "type": "integer" - }, - "inodesFree": { - "type": "integer" - }, - "inodesTotal": { - "type": "integer" - }, - "inodesUsed": { - "type": "integer" - }, - "inodesUsedPercent": { - "type": "number" + "diskData": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.DiskInfo" + } }, "ioCount": { "type": "integer" @@ -9305,11 +9278,40 @@ var doc = `{ "timeSinceUptime": { "type": "string" }, + "uptime": { + "type": "integer" + } + } + }, + "dto.DiskInfo": { + "type": "object", + "properties": { + "device": { + "type": "string" + }, + "free": { + "type": "integer" + }, + "inodesFree": { + "type": "integer" + }, + "inodesTotal": { + "type": "integer" + }, + "inodesUsed": { + "type": "integer" + }, + "inodesUsedPercent": { + "type": "number" + }, + "path": { + "type": "string" + }, "total": { "type": "integer" }, - "uptime": { - "type": "integer" + "type": { + "type": "string" }, "used": { "type": "integer" diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index 6ca3aca43..5445b3c13 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -9157,33 +9157,15 @@ "databaseNumber": { "type": "integer" }, - "dateeaseID": { - "type": "integer" - }, - "haloID": { - "type": "integer" - }, "hostname": { "type": "string" }, - "jumpserverID": { - "type": "integer" - }, "kernelArch": { "type": "string" }, "kernelVersion": { "type": "string" }, - "kubeoperatorID": { - "type": "integer" - }, - "kubepiID": { - "type": "integer" - }, - "metersphereID": { - "type": "integer" - }, "os": { "type": "string" }, @@ -9225,20 +9207,11 @@ "cpuUsedPercent": { "type": "number" }, - "free": { - "type": "integer" - }, - "inodesFree": { - "type": "integer" - }, - "inodesTotal": { - "type": "integer" - }, - "inodesUsed": { - "type": "integer" - }, - "inodesUsedPercent": { - "type": "number" + "diskData": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.DiskInfo" + } }, "ioCount": { "type": "integer" @@ -9291,11 +9264,40 @@ "timeSinceUptime": { "type": "string" }, + "uptime": { + "type": "integer" + } + } + }, + "dto.DiskInfo": { + "type": "object", + "properties": { + "device": { + "type": "string" + }, + "free": { + "type": "integer" + }, + "inodesFree": { + "type": "integer" + }, + "inodesTotal": { + "type": "integer" + }, + "inodesUsed": { + "type": "integer" + }, + "inodesUsedPercent": { + "type": "number" + }, + "path": { + "type": "string" + }, "total": { "type": "integer" }, - "uptime": { - "type": "integer" + "type": { + "type": "string" }, "used": { "type": "integer" diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 49d223355..0600d462a 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -443,24 +443,12 @@ definitions: $ref: '#/definitions/dto.DashboardCurrent' databaseNumber: type: integer - dateeaseID: - type: integer - haloID: - type: integer hostname: type: string - jumpserverID: - type: integer kernelArch: type: string kernelVersion: type: string - kubeoperatorID: - type: integer - kubepiID: - type: integer - metersphereID: - type: integer os: type: string platform: @@ -488,16 +476,10 @@ definitions: type: number cpuUsedPercent: type: number - free: - type: integer - inodesFree: - type: integer - inodesTotal: - type: integer - inodesUsed: - type: integer - inodesUsedPercent: - type: number + diskData: + items: + $ref: '#/definitions/dto.DiskInfo' + type: array ioCount: type: integer ioReadBytes: @@ -532,10 +514,29 @@ definitions: type: string timeSinceUptime: type: string - total: - type: integer uptime: type: integer + type: object + dto.DiskInfo: + properties: + device: + type: string + free: + type: integer + inodesFree: + type: integer + inodesTotal: + type: integer + inodesUsed: + type: integer + inodesUsedPercent: + type: number + path: + type: string + total: + type: integer + type: + type: string used: type: integer usedPercent: diff --git a/frontend/src/api/interface/dashboard.ts b/frontend/src/api/interface/dashboard.ts index ef2fee0e7..f750ad1c2 100644 --- a/frontend/src/api/interface/dashboard.ts +++ b/frontend/src/api/interface/dashboard.ts @@ -1,12 +1,5 @@ export namespace Dashboard { export interface BaseInfo { - haloID: number; - dateeaseID: number; - jumpserverID: number; - metersphereID: number; - kubeoperatorID: number; - kubepiID: number; - websiteNumber: number; databaseNumber: number; cronjobNumber: number; diff --git a/frontend/src/views/home/app/index.vue b/frontend/src/views/home/app/index.vue index 2e712266c..1ec8d918a 100644 --- a/frontend/src/views/home/app/index.vue +++ b/frontend/src/views/home/app/index.vue @@ -41,7 +41,6 @@