diff --git a/internal/web/actions/default/clusters/cluster/init.go b/internal/web/actions/default/clusters/cluster/init.go index afff1282..5d2f288b 100644 --- a/internal/web/actions/default/clusters/cluster/init.go +++ b/internal/web/actions/default/clusters/cluster/init.go @@ -48,6 +48,7 @@ func init() { Get("/logs", new(node.LogsAction)). Post("/start", new(node.StartAction)). Post("/stop", new(node.StopAction)). + Post("/uninstall", new(node.UninstallAction)). Post("/up", new(node.UpAction)). Post("/updateIsOn", new(node.UpdateIsOnAction)). Get("/detail", new(node.DetailAction)). diff --git a/internal/web/actions/default/clusters/cluster/node/uninstall.go b/internal/web/actions/default/clusters/cluster/node/uninstall.go new file mode 100644 index 00000000..0bd23fc3 --- /dev/null +++ b/internal/web/actions/default/clusters/cluster/node/uninstall.go @@ -0,0 +1,32 @@ +// Copyright 2024 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn . + +package node + +import ( + "github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils" + "github.com/TeaOSLab/EdgeCommon/pkg/langs/codes" + "github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb" +) + +type UninstallAction struct { + actionutils.ParentAction +} + +func (this *UninstallAction) RunPost(params struct { + NodeId int64 +}) { + resp, err := this.RPC().NodeRPC().UninstallNode(this.AdminContext(), &pb.UninstallNodeRequest{NodeId: params.NodeId}) + if err != nil { + this.ErrorPage(err) + return + } + + // 创建日志 + defer this.CreateLogInfo(codes.Node_LogUninstallNodeRemotely, params.NodeId) + + if resp.IsOk { + this.Success() + } + + this.Fail("执行失败:" + resp.Error) +} diff --git a/web/views/@default/clusters/cluster/node/detail.html b/web/views/@default/clusters/cluster/node/detail.html index 46ca29ab..cd3bb12b 100644 --- a/web/views/@default/clusters/cluster/node/detail.html +++ b/web/views/@default/clusters/cluster/node/detail.html @@ -321,8 +321,12 @@ 已安装 - 已安装 + 已安装   [操作] 未安装 + + 操作 + [卸载] + \ No newline at end of file diff --git a/web/views/@default/clusters/cluster/node/detail.js b/web/views/@default/clusters/cluster/node/detail.js index a1b48f95..718d8473 100644 --- a/web/views/@default/clusters/cluster/node/detail.js +++ b/web/views/@default/clusters/cluster/node/detail.js @@ -36,4 +36,24 @@ Tea.context(function () { this.round = function (f) { return Math.round(f * 100) / 100 } + + this.moreOpsVisible = false + this.showMoreOps = function () { + this.moreOpsVisible = !this.moreOpsVisible + } + + this.uninstallNode = function () { + let that = this + teaweb.confirm("html:确定要卸载当前节点吗?
此操作将会删除节点上除缓存以外的相关文件。", function () { + that.$post("/clusters/cluster/node/uninstall") + .params({ + nodeId: that.node.id + }) + .success(function () { + teaweb.success("执行成功", function () { + teaweb.reload() + }) + }) + }) + } }) \ No newline at end of file