From 35c4f4edfd250c20f635b06d89f3c1a65ad77768 Mon Sep 17 00:00:00 2001 From: zhengkunwang <31820853+zhengkunwang223@users.noreply.github.com> Date: Fri, 17 May 2024 17:54:38 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E7=9B=91=E6=8E=A7=E9=A1=B5=E9=9D=A2=20(#5038)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/dto/setting.go | 9 +++++++ backend/init/migration/migrate.go | 1 + backend/init/migration/migrations/v_1_10.go | 28 +++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/backend/app/dto/setting.go b/backend/app/dto/setting.go index e7f66d2a2..ee0897b73 100644 --- a/backend/app/dto/setting.go +++ b/backend/app/dto/setting.go @@ -186,3 +186,12 @@ type Clean struct { Name string `json:"name"` Size uint64 `json:"size"` } + +type XpackHideMenu struct { + ID string `json:"id"` + Label string `json:"label"` + IsCheck bool `json:"isCheck"` + Title string `json:"title"` + Path string `json:"path,omitempty"` + Children []XpackHideMenu `json:"children,omitempty"` +} diff --git a/backend/init/migration/migrate.go b/backend/init/migration/migrate.go index 1eedb99d1..5f8b6b2ef 100644 --- a/backend/init/migration/migrate.go +++ b/backend/init/migration/migrate.go @@ -85,6 +85,7 @@ func Init() { migrations.AddWebsiteSSLColumn, migrations.AddRedisCommand, + migrations.AddMonitorMenu, }) if err := m.Migrate(); err != nil { global.LOG.Error(err) diff --git a/backend/init/migration/migrations/v_1_10.go b/backend/init/migration/migrations/v_1_10.go index 9bc525f64..b245144ed 100644 --- a/backend/init/migration/migrations/v_1_10.go +++ b/backend/init/migration/migrations/v_1_10.go @@ -1,6 +1,8 @@ package migrations import ( + "encoding/json" + "github.com/1Panel-dev/1Panel/backend/app/dto" "github.com/1Panel-dev/1Panel/backend/app/model" "github.com/1Panel-dev/1Panel/backend/global" "github.com/go-gormigrate/gormigrate/v2" @@ -174,3 +176,29 @@ var AddRedisCommand = &gormigrate.Migration{ return nil }, } + +var AddMonitorMenu = &gormigrate.Migration{ + ID: "20240517-update-xpack-hide-menu", + Migrate: func(tx *gorm.DB) error { + var ( + setting model.Setting + menu dto.XpackHideMenu + ) + tx.Model(&model.Setting{}).Where("key", "XpackHideMenu").First(&setting) + if err := json.Unmarshal([]byte(setting.Value), &menu); err != nil { + return err + } + menu.Children = append(menu.Children, dto.XpackHideMenu{ + ID: "6", + Title: "xpack.monitor.name", + Path: "/xpack/monitor/dashboard", + Label: "MonitorDashboard", + IsCheck: true, + }) + data, err := json.Marshal(menu) + if err != nil { + return err + } + return tx.Model(&model.Setting{}).Where("key", "XpackHideMenu").Updates(map[string]interface{}{"value": string(data)}).Error + }, +}