From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 8F451648C8 for ; Fri, 30 Oct 2020 15:02:49 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 147AF14989 for ; Fri, 30 Oct 2020 15:02:19 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id CBBEF14627 for ; Fri, 30 Oct 2020 15:02:16 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 989B645E94 for ; Fri, 30 Oct 2020 15:02:16 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Fri, 30 Oct 2020 15:02:12 +0100 Message-Id: <20201030140215.13329-5-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201030140215.13329-1-d.csapak@proxmox.com> References: <20201030140215.13329-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.430 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [tasks.rs] Subject: [pbs-devel] [PATCH proxmox-backup 3/6] api2/node/tasks: add optional since/typefilter/statusfilter X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Oct 2020 14:02:49 -0000 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 --- 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, + since: Option, + typefilter: Option, + statusfilter: Option>, param: Value, mut rpcenv: &mut dyn RpcEnvironment, ) -> Result, Error> { @@ -331,7 +352,13 @@ pub fn list_tasks( let limit = if limit > 0 { limit as usize } else { usize::MAX }; let result: Vec = 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