From b2feb452e05774fcab088f8008c1eb63e4e000e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E7=A5=A5=E8=B6=85?= Date: Tue, 2 Feb 2021 20:52:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E4=BB=A5=E6=89=B9=E9=87=8F=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E5=90=8C=E6=AD=A5=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../default/clusters/tasks/deleteBatch.go | 24 ++++++++ .../actions/default/clusters/tasks/init.go | 1 + .../@default/clusters/tasks/listPopup.html | 10 +++- .../@default/clusters/tasks/listPopup.js | 59 ++++++++++++++++++- web/views/@default/dns/tasks/listPopup.html | 2 +- 5 files changed, 92 insertions(+), 4 deletions(-) create mode 100644 internal/web/actions/default/clusters/tasks/deleteBatch.go diff --git a/internal/web/actions/default/clusters/tasks/deleteBatch.go b/internal/web/actions/default/clusters/tasks/deleteBatch.go new file mode 100644 index 00000000..db72e2c1 --- /dev/null +++ b/internal/web/actions/default/clusters/tasks/deleteBatch.go @@ -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() +} diff --git a/internal/web/actions/default/clusters/tasks/init.go b/internal/web/actions/default/clusters/tasks/init.go index bc9a45e8..e20acb31 100644 --- a/internal/web/actions/default/clusters/tasks/init.go +++ b/internal/web/actions/default/clusters/tasks/init.go @@ -16,6 +16,7 @@ func init() { GetPost("/listPopup", new(ListPopupAction)). Post("/check", new(CheckAction)). Post("/delete", new(DeleteAction)). + Post("/deleteBatch", new(DeleteBatchAction)). EndAll() }) diff --git a/web/views/@default/clusters/tasks/listPopup.html b/web/views/@default/clusters/tasks/listPopup.html index 8abd1106..72f84d51 100644 --- a/web/views/@default/clusters/tasks/listPopup.html +++ b/web/views/@default/clusters/tasks/listPopup.html @@ -1,11 +1,14 @@ {$layout "layout_popup"} -

正在同步的节点任务(共{{countTasks}}个)

+

正在同步的节点任务(共{{countTasks}}个) + 批量删除{{countCheckedTasks()}}个任务 +

暂时没有同步的集群。

- +
+ @@ -16,6 +19,9 @@ +
集群 节点 任务
+ + {{cluster.name}} {{task.node.name}}   diff --git a/web/views/@default/clusters/tasks/listPopup.js b/web/views/@default/clusters/tasks/listPopup.js index 2b6db9f9..fe5fe642 100644 --- a/web/views/@default/clusters/tasks/listPopup.js +++ b/web/views/@default/clusters/tasks/listPopup.js @@ -1,8 +1,40 @@ Tea.context(function () { + let checkedAll = false + this.$delay(function () { 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.$post("$") .success(function (resp) { @@ -11,7 +43,10 @@ Tea.context(function () { }) .done(function () { this.$delay(function () { - this.reload() + // 没有选中任务的时候才重新刷新 + if (this.countCheckedTasks() == 0) { + this.reload() + } }, 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() + }) + }) + } }) \ No newline at end of file diff --git a/web/views/@default/dns/tasks/listPopup.html b/web/views/@default/dns/tasks/listPopup.html index 030f7375..bebb939e 100644 --- a/web/views/@default/dns/tasks/listPopup.html +++ b/web/views/@default/dns/tasks/listPopup.html @@ -3,7 +3,7 @@

正在同步的DNS任务(共{{tasks.length}}个)

暂时没有同步的集群。

- +
对象