From f6475e7c7fc56ca23fcba29b136c3a7b53825e12 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:48:15 +0800 Subject: [PATCH] style(website): Update Nginx Status Page Styling (#7423) --- agent/app/dto/response/nginx.go | 14 +-- agent/app/service/nginx.go | 36 ++++++-- frontend/src/api/interface/nginx.ts | 14 +-- frontend/src/components/app-status/index.vue | 2 +- frontend/src/components/back-button/index.vue | 19 +--- .../src/components/layout-content/index.vue | 52 +++++------ .../website/website/nginx/status/index.vue | 91 ++++++++----------- 7 files changed, 108 insertions(+), 120 deletions(-) diff --git a/agent/app/dto/response/nginx.go b/agent/app/dto/response/nginx.go index 4a48e654a..f848c83f2 100644 --- a/agent/app/dto/response/nginx.go +++ b/agent/app/dto/response/nginx.go @@ -3,13 +3,13 @@ package response import "github.com/1Panel-dev/1Panel/agent/app/dto" type NginxStatus struct { - Active string `json:"active"` - Accepts string `json:"accepts"` - Handled string `json:"handled"` - Requests string `json:"requests"` - Reading string `json:"reading"` - Writing string `json:"writing"` - Waiting string `json:"waiting"` + Active int `json:"active"` + Accepts int `json:"accepts"` + Handled int `json:"handled"` + Requests int `json:"requests"` + Reading int `json:"reading"` + Writing int `json:"writing"` + Waiting int `json:"waiting"` } type NginxParam struct { diff --git a/agent/app/service/nginx.go b/agent/app/service/nginx.go index bc07e31e4..5bbc56fc4 100644 --- a/agent/app/service/nginx.go +++ b/agent/app/service/nginx.go @@ -12,6 +12,7 @@ import ( "net/http" "os" "path" + "strconv" "strings" "time" @@ -94,13 +95,34 @@ func (n NginxService) GetStatus() (response.NginxStatus, error) { } var status response.NginxStatus resArray := strings.Split(string(content), " ") - status.Active = resArray[2] - status.Accepts = resArray[7] - status.Handled = resArray[8] - status.Requests = resArray[9] - status.Reading = resArray[11] - status.Writing = resArray[13] - status.Waiting = resArray[15] + active, err := strconv.Atoi(resArray[2]) + if err == nil { + status.Active = active + } + accepts, err := strconv.Atoi(resArray[7]) + if err == nil { + status.Accepts = accepts + } + handled, err := strconv.Atoi(resArray[8]) + if err == nil { + status.Handled = handled + } + requests, err := strconv.Atoi(resArray[9]) + if err == nil { + status.Requests = requests + } + reading, err := strconv.Atoi(resArray[11]) + if err == nil { + status.Reading = reading + } + writing, err := strconv.Atoi(resArray[13]) + if err == nil { + status.Writing = writing + } + waiting, err := strconv.Atoi(resArray[15]) + if err == nil { + status.Waiting = waiting + } return status, nil } diff --git a/frontend/src/api/interface/nginx.ts b/frontend/src/api/interface/nginx.ts index aba13b71e..e4edf06b2 100644 --- a/frontend/src/api/interface/nginx.ts +++ b/frontend/src/api/interface/nginx.ts @@ -15,13 +15,13 @@ export namespace Nginx { } export interface NginxStatus { - accepts: string; - handled: string; - active: string; - requests: string; - reading: string; - writing: string; - waiting: string; + accepts: number; + handled: number; + active: number; + requests: number; + reading: number; + writing: number; + waiting: number; } export interface NginxFileUpdate { diff --git a/frontend/src/components/app-status/index.vue b/frontend/src/components/app-status/index.vue index 465595738..3c1f9777f 100644 --- a/frontend/src/components/app-status/index.vue +++ b/frontend/src/components/app-status/index.vue @@ -5,7 +5,7 @@