mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-05 20:00:25 +08:00
可以批量删除同步任务
This commit is contained in:
24
internal/web/actions/default/clusters/tasks/deleteBatch.go
Normal file
24
internal/web/actions/default/clusters/tasks/deleteBatch.go
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
package tasks
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||||
|
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||||
|
)
|
||||||
|
|
||||||
|
type DeleteBatchAction struct {
|
||||||
|
actionutils.ParentAction
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *DeleteBatchAction) RunPost(params struct {
|
||||||
|
TaskIds []int64
|
||||||
|
}) {
|
||||||
|
defer this.CreateLogInfo("批量删除节点同步任务")
|
||||||
|
|
||||||
|
_, err := this.RPC().NodeTaskRPC().DeleteNodeTasks(this.AdminContext(), &pb.DeleteNodeTasksRequest{NodeTaskIds: params.TaskIds})
|
||||||
|
if err != nil {
|
||||||
|
this.ErrorPage(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.Success()
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ func init() {
|
|||||||
GetPost("/listPopup", new(ListPopupAction)).
|
GetPost("/listPopup", new(ListPopupAction)).
|
||||||
Post("/check", new(CheckAction)).
|
Post("/check", new(CheckAction)).
|
||||||
Post("/delete", new(DeleteAction)).
|
Post("/delete", new(DeleteAction)).
|
||||||
|
Post("/deleteBatch", new(DeleteBatchAction)).
|
||||||
|
|
||||||
EndAll()
|
EndAll()
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
{$layout "layout_popup"}
|
{$layout "layout_popup"}
|
||||||
|
|
||||||
<h3>正在同步的节点任务<span v-if="countTasks > 0">(共{{countTasks}}个)</span></h3>
|
<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>
|
<p class="comment" v-if="clusters.length == 0">暂时没有同步的集群。</p>
|
||||||
<div v-if="clusters.length > 0">
|
<div v-if="clusters.length > 0">
|
||||||
<table class="ui table selectable">
|
<table class="ui table selectable celled">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
<th style="width:3em"><checkbox @input="checkAll"></checkbox></th>
|
||||||
<th>集群</th>
|
<th>集群</th>
|
||||||
<th>节点</th>
|
<th>节点</th>
|
||||||
<th>任务</th>
|
<th>任务</th>
|
||||||
@@ -16,6 +19,9 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody v-for="cluster in clusters">
|
<tbody v-for="cluster in clusters">
|
||||||
<tr v-for="task in cluster.tasks">
|
<tr v-for="task in cluster.tasks">
|
||||||
|
<td>
|
||||||
|
<checkbox v-model="task.isChecked" @input="checkTask"></checkbox>
|
||||||
|
</td>
|
||||||
<td>{{cluster.name}}</td>
|
<td>{{cluster.name}}</td>
|
||||||
<td>
|
<td>
|
||||||
{{task.node.name}} <a :href="'/clusters/cluster/node?clusterId=' + cluster.id + '&nodeId=' + task.node.id" target="_blank"><i class="icon linkify small grey"></i></a>
|
{{task.node.name}} <a :href="'/clusters/cluster/node?clusterId=' + cluster.id + '&nodeId=' + task.node.id" target="_blank"><i class="icon linkify small grey"></i></a>
|
||||||
|
|||||||
@@ -1,8 +1,40 @@
|
|||||||
Tea.context(function () {
|
Tea.context(function () {
|
||||||
|
let checkedAll = false
|
||||||
|
|
||||||
this.$delay(function () {
|
this.$delay(function () {
|
||||||
this.reload()
|
this.reload()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.checkAll = function (b) {
|
||||||
|
checkedAll = b
|
||||||
|
let that = this
|
||||||
|
this.clusters.forEach(function (cluster, index) {
|
||||||
|
cluster.tasks.forEach(function (task) {
|
||||||
|
task.isChecked = checkedAll
|
||||||
|
})
|
||||||
|
Vue.set(that.clusters, index, cluster)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
this.checkTask = function (b) {
|
||||||
|
this.clusters.forEach(function (cluster, index) {
|
||||||
|
Vue.set(that.clusters, index, cluster)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
let that = this
|
||||||
|
this.countCheckedTasks = function () {
|
||||||
|
let count = 0
|
||||||
|
that.clusters.forEach(function (cluster) {
|
||||||
|
cluster.tasks.forEach(function (task) {
|
||||||
|
if (task.isChecked) {
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
return count
|
||||||
|
}
|
||||||
|
|
||||||
this.reload = function () {
|
this.reload = function () {
|
||||||
this.$post("$")
|
this.$post("$")
|
||||||
.success(function (resp) {
|
.success(function (resp) {
|
||||||
@@ -11,7 +43,10 @@ Tea.context(function () {
|
|||||||
})
|
})
|
||||||
.done(function () {
|
.done(function () {
|
||||||
this.$delay(function () {
|
this.$delay(function () {
|
||||||
|
// 没有选中任务的时候才重新刷新
|
||||||
|
if (this.countCheckedTasks() == 0) {
|
||||||
this.reload()
|
this.reload()
|
||||||
|
}
|
||||||
}, 3000)
|
}, 3000)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -28,4 +63,26 @@ Tea.context(function () {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.deleteBatch = function () {
|
||||||
|
var taskIds = []
|
||||||
|
this.clusters.forEach(function (cluster) {
|
||||||
|
cluster.tasks.forEach(function (task) {
|
||||||
|
if (task.isChecked) {
|
||||||
|
taskIds.push(task.id)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
let that = this
|
||||||
|
teaweb.confirm("确定要批量删除选中的任务吗?", function () {
|
||||||
|
that.$post(".deleteBatch")
|
||||||
|
.params({
|
||||||
|
taskIds: taskIds
|
||||||
|
})
|
||||||
|
.success(function () {
|
||||||
|
teaweb.reload()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<h3>正在同步的DNS任务<span v-if="tasks.length > 0">(共{{tasks.length}}个)</span></h3>
|
<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">
|
<div v-if="tasks.length > 0">
|
||||||
<table class="ui table selectable">
|
<table class="ui table selectable celled">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>对象</th>
|
<th>对象</th>
|
||||||
|
|||||||
Reference in New Issue
Block a user