From bcb2610f0a0ae5d6e9c987ba5582addfe7801fe1 Mon Sep 17 00:00:00 2001 From: MikoyChinese Date: Fri, 14 Jan 2022 17:34:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=AE=A1=E7=90=86=E5=90=8E?= =?UTF-8?q?=E5=8F=B0=E9=A1=B5=E9=9D=A2=E6=96=B0=E6=B7=BB=E5=8A=A0CoverIgno?= =?UTF-8?q?reAll=E7=B1=BB=E5=9E=8B=E6=9C=8D=E5=8A=A1=E9=9C=80=E8=A6=81?= =?UTF-8?q?=E9=87=8D=E5=90=AFdocker=E9=95=9C=E5=83=8F=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/dashboard/controller/member_api.go | 1 + model/monitor.go | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/cmd/dashboard/controller/member_api.go b/cmd/dashboard/controller/member_api.go index 195e369..c3e5564 100644 --- a/cmd/dashboard/controller/member_api.go +++ b/cmd/dashboard/controller/member_api.go @@ -235,6 +235,7 @@ func (ma *memberAPI) addOrEditMonitor(c *gin.Context) { m.Cover = mf.Cover m.Notify = mf.Notify == "on" m.Duration = mf.Duration + err = m.InitSkipServers() } if err == nil { if m.ID == 0 { diff --git a/model/monitor.go b/model/monitor.go index 39b2a7c..cb8dd19 100644 --- a/model/monitor.go +++ b/model/monitor.go @@ -79,3 +79,15 @@ func (m *Monitor) AfterFind(tx *gorm.DB) error { func IsServiceSentinelNeeded(t uint64) bool { return t != TaskTypeCommand && t != TaskTypeTerminal && t != TaskTypeUpgrade } + +func (m *Monitor) InitSkipServers() error { + var skipServers []uint64 + if err := json.Unmarshal([]byte(m.SkipServersRaw), &skipServers); err != nil { + return err + } + m.SkipServers = make(map[uint64]bool) + for i := 0; i < len(skipServers); i++ { + m.SkipServers[skipServers[i]] = true + } + return nil +}