mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-20 16:20:27 +08:00
实现删除集群
This commit is contained in:
33
internal/web/actions/default/clusters/delete.go
Normal file
33
internal/web/actions/default/clusters/delete.go
Normal file
@@ -0,0 +1,33 @@
|
||||
package clusters
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
)
|
||||
|
||||
type DeleteAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *DeleteAction) RunPost(params struct {
|
||||
ClusterId int64
|
||||
}) {
|
||||
// 检查有无服务正在使用
|
||||
countResp, err := this.RPC().ServerRPC().CountAllEnabledServersWithNodeClusterId(this.AdminContext(), &pb.CountAllEnabledServersWithNodeClusterIdRequest{NodeClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
if countResp.Count > 0 {
|
||||
this.Fail("有代理服务正在使用此集群,请修改这些代理服务后再删除")
|
||||
}
|
||||
|
||||
// 删除
|
||||
_, err = this.RPC().NodeClusterRPC().DeleteNodeCluster(this.AdminContext(), &pb.DeleteNodeClusterRequest{ClusterId: params.ClusterId})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Success()
|
||||
}
|
||||
@@ -15,6 +15,7 @@ func init() {
|
||||
GetPost("/create", new(CreateAction)).
|
||||
Post("/sync", new(SyncAction)).
|
||||
Post("/checkChange", new(CheckChangeAction)).
|
||||
Post("/delete", new(DeleteAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
|
||||
@@ -7,6 +7,11 @@ Vue.component("csrf-token", {
|
||||
this.$refs.token.form.addEventListener("submit", function () {
|
||||
that.refreshToken()
|
||||
})
|
||||
|
||||
// 自动刷新
|
||||
setInterval(function () {
|
||||
that.refreshToken()
|
||||
}, 10 * 60 * 1000)
|
||||
},
|
||||
data: function () {
|
||||
return {
|
||||
|
||||
@@ -5,6 +5,6 @@
|
||||
<form class="ui form" data-tea-action="$" data-tea-success="success">
|
||||
<input type="hidden" name="clusterId" :value="clusterId"/>
|
||||
<health-check-config-box :v-health-check-config="healthCheckConfig"></health-check-config-box>
|
||||
<submit-btn></submit-btn> <a href="" @click.prevent="run()">立即检查</a>
|
||||
<submit-btn></submit-btn> <a href="" @click.prevent="run()" v-if="healthCheckConfig != null && healthCheckConfig.isOn">立即检查</a>
|
||||
</form>
|
||||
</div>
|
||||
@@ -28,7 +28,8 @@
|
||||
<span v-else class="disabled">N</span>
|
||||
</td>
|
||||
<td>
|
||||
<a :href="'/clusters/cluster?clusterId=' + cluster.id">详情</a>
|
||||
<a :href="'/clusters/cluster?clusterId=' + cluster.id">详情</a>
|
||||
<a href="" @click.prevent="deleteCluster(cluster.id)">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
12
web/views/@default/clusters/index.js
Normal file
12
web/views/@default/clusters/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
Tea.context(function () {
|
||||
this.deleteCluster = function (clusterId) {
|
||||
let that = this
|
||||
teaweb.confirm("确定要删除此集群吗?", function () {
|
||||
that.$post("/clusters/delete")
|
||||
.params({
|
||||
clusterId: clusterId
|
||||
})
|
||||
.refresh()
|
||||
})
|
||||
}
|
||||
})
|
||||
@@ -1,8 +1,8 @@
|
||||
{$layout}
|
||||
|
||||
<first-menu v-if="messages.length > 0">
|
||||
<a href="" class="item" @click.prevent="updatePageRead()">[设置当前页为已读]</a>
|
||||
<a href="" class="item" @click.prevent="updateAllRead()">[设置全部为已读]</a>
|
||||
<a href="" class="item" @click.prevent="updatePageRead()">[当前页已读]</a>
|
||||
<a href="" class="item" @click.prevent="updateAllRead()">[全部已读]</a>
|
||||
</first-menu>
|
||||
<div class="margin"></div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user