增加清空节点同步任务、清空DNS同步任务功能

This commit is contained in:
GoEdgeLab
2023-07-02 17:29:00 +08:00
parent 198139446d
commit 99c930bde7
8 changed files with 81 additions and 7 deletions

View File

@@ -0,0 +1,25 @@
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package tasks
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAllAction struct {
actionutils.ParentAction
}
func (this *DeleteAllAction) RunPost(params struct{}) {
defer this.CreateLogInfo(codes.NodeTask_LogDeleteAllNodeTasks)
_, err := this.RPC().NodeTaskRPC().DeleteAllNodeTasks(this.AdminContext(), &pb.DeleteAllNodeTasksRequest{})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -17,6 +17,7 @@ func init() {
Post("/check", new(CheckAction)).
Post("/delete", new(DeleteAction)).
Post("/deleteBatch", new(DeleteBatchAction)).
Post("/deleteAll", new(DeleteAllAction)).
EndAll()
})

View File

@@ -0,0 +1,25 @@
// Copyright 2023 GoEdge CDN goedge.cdn@gmail.com. All rights reserved. Official site: https://goedge.cn .
package tasks
import (
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
"github.com/TeaOSLab/EdgeCommon/pkg/langs/codes"
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
)
type DeleteAllAction struct {
actionutils.ParentAction
}
func (this *DeleteAllAction) RunPost(params struct{}) {
defer this.CreateLogInfo(codes.DNSTask_LogDeleteAllDNSTasks)
_, err := this.RPC().DNSTaskRPC().DeleteAllDNSTasks(this.AdminContext(), &pb.DeleteAllDNSTasksRequest{})
if err != nil {
this.ErrorPage(err)
return
}
this.Success()
}

View File

@@ -16,7 +16,7 @@ func init() {
GetPost("/listPopup", new(ListPopupAction)).
Post("/check", new(CheckAction)).
Post("/delete", new(DeleteAction)).
Post("/deleteAll", new(DeleteAllAction)).
EndAll()
})
}

View File

@@ -1,10 +1,11 @@
{$layout "layout_popup"}
<h3>正在同步的节点任务<span v-if="countTasks > 0">(共{{countTasks}}个)</span>
<a href="" v-if="countCheckedTasks() > 0" @click.prevent="deleteBatch">批量删除{{countCheckedTasks()}}个任务</a>
</h3>
<p class="comment" v-if="clusters.length == 0">暂时没有同步的集群。</p>
<h3>正在同步的节点任务<span v-if="countTasks > 0">(共{{countTasks}}个)</span></h3>
<p class="comment" v-if="clusters.length == 0">暂时没有同步的任务</p>
<div v-if="clusters.length > 0">
<button class="ui button basic tiny" @click.prevent="deleteAllTasks">清空所有任务</button> &nbsp;
<button class="ui button basic tiny" v-if="countCheckedTasks() > 0" @click.prevent="deleteBatch">批量删除{{countCheckedTasks()}}个任务</button>
<table class="ui table selectable celled">
<thead>
<tr>

View File

@@ -65,7 +65,7 @@ Tea.context(function () {
}
this.deleteBatch = function () {
var taskIds = []
let taskIds = []
this.clusters.forEach(function (cluster) {
cluster.tasks.forEach(function (task) {
if (task.isChecked) {
@@ -85,4 +85,14 @@ Tea.context(function () {
})
})
}
this.deleteAllTasks = function () {
let that = this
teaweb.confirm("确定要清空所有的任务吗?", function () {
that.$post(".deleteAll")
.success(function () {
teaweb.reload()
})
})
}
})

View File

@@ -1,8 +1,10 @@
{$layout "layout_popup"}
<h3>正在同步的DNS任务<span v-if="tasks.length > 0">(共{{tasks.length}}个)</span></h3>
<p class="comment" v-if="tasks.length == 0">暂时没有同步的集群</p>
<p class="comment" v-if="tasks.length == 0">暂时没有同步的任务</p>
<div v-if="tasks.length > 0">
<button class="ui button tiny basic" @click.prevent="deleteAllTasks">清空所有任务</button>
<table class="ui table selectable celled">
<thead>
<tr>

View File

@@ -27,4 +27,14 @@ Tea.context(function () {
})
})
}
this.deleteAllTasks = function () {
let that = this
teaweb.confirm("确定要清空所有的任务吗?", function () {
that.$post(".deleteAll")
.success(function () {
teaweb.reload()
})
})
}
})