Skip to content

Commit 2b6d1c7

Browse files
committed
集群节点列表页增加停用/启用操作
1 parent faaef3b commit 2b6d1c7

File tree

4 files changed

+58
-2
lines changed

4 files changed

+58
-2
lines changed

internal/web/actions/default/clusters/cluster/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ func init() {
4949
Post("/start", new(node.StartAction)).
5050
Post("/stop", new(node.StopAction)).
5151
Post("/up", new(node.UpAction)).
52+
Post("/updateIsOn", new(node.UpdateIsOnAction)).
5253
Get("/detail", new(node.DetailAction)).
5354
GetPost("/updateDNSPopup", new(node.UpdateDNSPopupAction)).
5455
Post("/syncDomain", new(node.SyncDomainAction)).
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright 2024 GoEdge CDN [email protected]. All rights reserved. Official site: https://goedge.cn .
2+
3+
package node
4+
5+
import (
6+
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
7+
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
8+
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
9+
)
10+
11+
type UpdateIsOnAction struct {
12+
actionutils.ParentAction
13+
}
14+
15+
func (this *UpdateIsOnAction) RunPost(params struct {
16+
NodeId int64
17+
IsOn bool
18+
}) {
19+
if params.IsOn {
20+
defer this.CreateLogInfo(codes.Node_LogUpdateNodeOn, params.NodeId)
21+
} else {
22+
defer this.CreateLogInfo(codes.Node_LogUpdateNodeOff, params.NodeId)
23+
}
24+
25+
_, err := this.RPC().NodeRPC().UpdateNodeIsOn(this.AdminContext(), &pb.UpdateNodeIsOnRequest{
26+
NodeId: params.NodeId,
27+
IsOn: params.IsOn,
28+
})
29+
if err != nil {
30+
this.ErrorPage(err)
31+
return
32+
}
33+
34+
this.Success()
35+
}

web/views/@default/clusters/cluster/nodes.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
<th class="value-column center" v-if="windowWidth < miniWidth || windowWidth > columnWidth4">连接数<sort-arrow name="connectionsOrder"></sort-arrow></th>
7171
<th class="value-column center" v-if="windowWidth < miniWidth || windowWidth > columnWidth5">负载<sort-arrow name="loadOrder"></sort-arrow></th>
7272
<th class="width6 center">状态</th>
73-
<th class="two op">操作</th>
73+
<th class="three op">操作</th>
7474
</tr>
7575
</thead>
7676
<tr v-for="(node, nodeIndex) in nodes">
@@ -172,7 +172,7 @@
172172
</div>
173173
</td>
174174
<td>
175-
<a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">详情</a> &nbsp; <a href="" @click.prevent="deleteNode(node.id)">删除</a>
175+
<a :href="'/clusters/cluster/node?clusterId=' + clusterId + '&nodeId=' + node.id">详情</a> &nbsp; <a href="" @click.prevent="updateNodeOn(node.id, !node.isOn)"><span v-if="node.isOn">停用</span><span v-else class="red">启用</span></a> &nbsp; <a href="" @click.prevent="deleteNode(node.id)">删除</a>
176176
</td>
177177
</tr>
178178
</table>

web/views/@default/clusters/cluster/nodes.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,26 @@ Tea.context(function () {
4949
})
5050
}
5151

52+
this.updateNodeOn = function (nodeId, isOn) {
53+
let that = this
54+
let op
55+
if (isOn) {
56+
op = "启用"
57+
} else {
58+
op = "停用"
59+
}
60+
teaweb.confirm("确定要" + op + "此节点吗?", function () {
61+
that.$post(".node.updateIsOn")
62+
.params({
63+
nodeId: nodeId,
64+
isOn: isOn
65+
})
66+
.success(function () {
67+
teaweb.successRefresh(op + "成功")
68+
})
69+
})
70+
}
71+
5272
/**
5373
* 显示和隐藏IP
5474
*/

0 commit comments

Comments
 (0)