From 4a7bdc5d6403c8e8284042c4fadfc16a0a80bbdf Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Thu, 7 Apr 2022 21:37:13 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A4=E6=96=AD=E4=BF=AE=E6=94=B9=E8=8A=82?= =?UTF-8?q?=E7=82=B9=E7=BA=A7=E5=88=AB=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/actions/default/clusters/cluster/node/update.go | 7 +++++++ .../actions/default/clusters/cluster/node/update_hook.go | 9 +++++++++ web/views/@default/clusters/cluster/node/update.html | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 internal/web/actions/default/clusters/cluster/node/update_hook.go diff --git a/internal/web/actions/default/clusters/cluster/node/update.go b/internal/web/actions/default/clusters/cluster/node/update.go index 60ca4f18..7c2722a6 100644 --- a/internal/web/actions/default/clusters/cluster/node/update.go +++ b/internal/web/actions/default/clusters/cluster/node/update.go @@ -10,6 +10,7 @@ import ( "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" "github.com/iwind/TeaGo/actions" "github.com/iwind/TeaGo/maps" + "github.com/iwind/TeaGo/types" ) type UpdateAction struct { @@ -132,6 +133,8 @@ func (this *UpdateAction) RunGet(params struct { this.Data["node"] = nodeMap + this.Data["canUpdateLevel"] = this.CanUpdateLevel(2) + this.Show() } @@ -188,6 +191,10 @@ func (this *UpdateAction) RunPost(params struct { } // 保存 + if !this.CanUpdateLevel(params.Level) { + this.Fail("没有权限修改节点级别:" + types.String(params.Level)) + } + _, err := this.RPC().NodeRPC().UpdateNode(this.AdminContext(), &pb.UpdateNodeRequest{ NodeId: params.NodeId, NodeGroupId: params.GroupId, diff --git a/internal/web/actions/default/clusters/cluster/node/update_hook.go b/internal/web/actions/default/clusters/cluster/node/update_hook.go new file mode 100644 index 00000000..a4d16e3e --- /dev/null +++ b/internal/web/actions/default/clusters/cluster/node/update_hook.go @@ -0,0 +1,9 @@ +// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. +//go:build !plus +// +build !plus + +package node + +func (this *UpdateAction) CanUpdateLevel(level int32) bool { + return level <= 1 +} diff --git a/web/views/@default/clusters/cluster/node/update.html b/web/views/@default/clusters/cluster/node/update.html index a8cae1fc..95dfbdd5 100644 --- a/web/views/@default/clusters/cluster/node/update.html +++ b/web/views/@default/clusters/cluster/node/update.html @@ -48,7 +48,7 @@ - + 级别