From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 3/6] api2/node/tasks: add optional since/typefilter/statusfilter
Date: Fri, 30 Oct 2020 15:02:12 +0100 [thread overview]
Message-ID: <20201030140215.13329-5-d.csapak@proxmox.com> (raw)
In-Reply-To: <20201030140215.13329-1-d.csapak@proxmox.com>
and change all users of the /status/tasks api call to this
with this change we can now delete the /status/tasks api call
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/api2/node/tasks.rs | 47 +++++++++++++++++++++++++++++++++---
www/Dashboard.js | 3 ++-
www/dashboard/TaskSummary.js | 3 ++-
3 files changed, 47 insertions(+), 6 deletions(-)
diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs
index 00516f3b..8fe2aac1 100644
--- a/src/api2/node/tasks.rs
+++ b/src/api2/node/tasks.rs
@@ -296,6 +296,24 @@ fn stop_task(
type: String,
description: "Only list tasks from this user.",
},
+ since: {
+ type: i64,
+ description: "Only list tasks since this UNIX epoch.",
+ optional: true,
+ },
+ typefilter: {
+ optional: true,
+ type: String,
+ description: "Only list tasks whose type contains this.",
+ },
+ statusfilter: {
+ optional: true,
+ type: Array,
+ description: "Only list tasks which have any one of the listed status.",
+ items: {
+ type: TaskStateType,
+ },
+ },
},
},
returns: {
@@ -315,6 +333,9 @@ pub fn list_tasks(
errors: bool,
running: bool,
userfilter: Option<String>,
+ since: Option<i64>,
+ typefilter: Option<String>,
+ statusfilter: Option<Vec<TaskStateType>>,
param: Value,
mut rpcenv: &mut dyn RpcEnvironment,
) -> Result<Vec<TaskListItem>, Error> {
@@ -331,7 +352,13 @@ pub fn list_tasks(
let limit = if limit > 0 { limit as usize } else { usize::MAX };
let result: Vec<TaskListItem> = list
- .take_while(|info| !info.is_err())
+ .take_while(|info| {
+ match (info, since) {
+ (Ok(info), Some(since)) => info.upid.starttime > since,
+ (Ok(_), None) => true,
+ (Err(_), _) => false,
+ }
+ })
.filter_map(|info| {
let info = match info {
Ok(info) => info,
@@ -365,9 +392,21 @@ pub fn list_tasks(
}
}
- match info.state {
- Some(_) if running => return None,
- Some(crate::server::TaskState::OK { .. }) if errors => return None,
+ if let Some(typefilter) = &typefilter {
+ if !info.upid.worker_type.contains(typefilter) {
+ return None;
+ }
+ }
+
+ match (&info.state, &statusfilter) {
+ (Some(_), _) if running => return None,
+ (Some(crate::server::TaskState::OK { .. }), _) if errors => return None,
+ (Some(state), Some(filters)) => {
+ if !filters.contains(&state.tasktype()) {
+ return None;
+ }
+ },
+ (None, Some(_)) => return None,
_ => {},
}
diff --git a/www/Dashboard.js b/www/Dashboard.js
index 122aa559..4f60efff 100644
--- a/www/Dashboard.js
+++ b/www/Dashboard.js
@@ -230,8 +230,9 @@ Ext.define('PBS.Dashboard', {
model: 'proxmox-tasks',
proxy: {
type: 'proxmox',
- url: '/api2/json/status/tasks',
+ url: '/api2/json/nodes/localhost/tasks',
extraParams: {
+ limit: 0,
since: '{sinceEpoch}',
},
},
diff --git a/www/dashboard/TaskSummary.js b/www/dashboard/TaskSummary.js
index 6a503979..a9ebec07 100644
--- a/www/dashboard/TaskSummary.js
+++ b/www/dashboard/TaskSummary.js
@@ -39,6 +39,7 @@ Ext.define('PBS.TaskSummary', {
let state = me.states[cellindex];
let type = me.types[rowindex];
let filterParam = {
+ limit: 0,
'statusfilter': state,
'typefilter': type,
};
@@ -111,7 +112,7 @@ Ext.define('PBS.TaskSummary', {
model: 'proxmox-tasks',
proxy: {
type: 'proxmox',
- url: "/api2/json/status/tasks",
+ url: "/api2/json/nodes/localhost/tasks",
},
},
});
--
2.20.1
next prev parent reply other threads:[~2020-10-30 14:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-30 14:02 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Dominik Csapak
2020-10-30 14:02 ` [pbs-devel] [PATCH widget-toolkit 1/1] add form/TaskTypeSelector Dominik Csapak
2020-10-30 17:19 ` [pbs-devel] applied: " Thomas Lamprecht
2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 1/6] server/worker_task: add tasktype to return the api type of a taskstate Dominik Csapak
2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 2/6] api2/node/tasks: change limit behaviour when it is 0 Dominik Csapak
2020-10-30 14:02 ` Dominik Csapak [this message]
2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 4/6] api2/status: remove list_task api call Dominik Csapak
2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 5/6] api2/node/tasks: add optional until filter Dominik Csapak
2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 6/6] ui: add panel/Tasks and use it for the node tasks Dominik Csapak
2020-11-03 13:52 ` [pbs-devel] applied-series: [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201030140215.13329-5-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox