public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel
@ 2020-10-30 14:02 Dominik Csapak
  2020-10-30 14:02 ` [pbs-devel] [PATCH widget-toolkit 1/1] add form/TaskTypeSelector Dominik Csapak
                   ` (7 more replies)
  0 siblings, 8 replies; 10+ messages in thread
From: Dominik Csapak @ 2020-10-30 14:02 UTC (permalink / raw)
  To: pbs-devel

this series extends the node/tasks api call with several new filters,
and adds a new task panel to the ui that makes use of these filters

the type selector will show all tasks in the current Proxmox.Utils object,
so this will work best when [0] is applied

0: https://lists.proxmox.com/pipermail/pve-devel/2020-October/045730.html

proxmox-widget-toolkit:

Dominik Csapak (1):
  add form/TaskTypeSelector

 src/Makefile                 |  1 +
 src/form/TaskTypeSelector.js | 12 ++++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 src/form/TaskTypeSelector.js

proxmox-backup:

Dominik Csapak (6):
  server/worker_task: add tasktype to return the api type of a taskstate
  api2/node/tasks: change limit behaviour when it is 0
  api2/node/tasks: add optional since/typefilter/statusfilter
  api2/status: remove list_task api call
  api2/node/tasks: add optional until filter
  ui: add panel/Tasks and use it for the node tasks

 src/api2/node/tasks.rs       |  67 ++++++-
 src/api2/status.rs           |  99 ----------
 src/server/worker_task.rs    |  11 +-
 www/Dashboard.js             |   3 +-
 www/Makefile                 |   1 +
 www/ServerAdministration.js  |   2 +-
 www/dashboard/TaskSummary.js |   3 +-
 www/panel/Tasks.js           | 362 +++++++++++++++++++++++++++++++++++
 8 files changed, 438 insertions(+), 110 deletions(-)
 create mode 100644 www/panel/Tasks.js

-- 
2.20.1





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] [PATCH widget-toolkit 1/1] add form/TaskTypeSelector
  2020-10-30 14:02 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Dominik Csapak
@ 2020-10-30 14:02 ` 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
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 10+ messages in thread
From: Dominik Csapak @ 2020-10-30 14:02 UTC (permalink / raw)
  To: pbs-devel

for suggesting workery types when we want to filter by them

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/Makefile                 |  1 +
 src/form/TaskTypeSelector.js | 12 ++++++++++++
 2 files changed, 13 insertions(+)
 create mode 100644 src/form/TaskTypeSelector.js

diff --git a/src/Makefile b/src/Makefile
index f984ac7..2117da5 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -31,6 +31,7 @@ JSSRC=					\
 	form/RoleSelector.js		\
 	form/DiskSelector.js		\
 	form/MultiDiskSelector.js	\
+	form/TaskTypeSelector.js	\
 	button/Button.js		\
 	button/HelpButton.js		\
 	grid/ObjectGrid.js		\
diff --git a/src/form/TaskTypeSelector.js b/src/form/TaskTypeSelector.js
new file mode 100644
index 0000000..b370cb4
--- /dev/null
+++ b/src/form/TaskTypeSelector.js
@@ -0,0 +1,12 @@
+Ext.define('Proxmox.form.TaskTypeSelector', {
+    extend: 'Ext.form.field.ComboBox',
+    alias: 'widget.pmxTaskTypeSelector',
+
+    anyMatch: true,
+
+    initComponent: function() {
+	let me = this;
+	me.store = Object.keys(Proxmox.Utils.task_desc_table).sort();
+	me.callParent();
+    },
+});
-- 
2.20.1





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 1/6] server/worker_task: add tasktype to return the api type of a taskstate
  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 14:02 ` 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
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dominik Csapak @ 2020-10-30 14:02 UTC (permalink / raw)
  To: pbs-devel

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/server/worker_task.rs | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/src/server/worker_task.rs b/src/server/worker_task.rs
index 24cfab62..c2f4a7e2 100644
--- a/src/server/worker_task.rs
+++ b/src/server/worker_task.rs
@@ -21,7 +21,7 @@ use super::UPID;
 
 use crate::tools::logrotate::{LogRotate, LogRotateFiles};
 use crate::tools::{FileLogger, FileLogOptions};
-use crate::api2::types::Authid;
+use crate::api2::types::{Authid, TaskStateType};
 
 macro_rules! PROXMOX_BACKUP_VAR_RUN_DIR_M { () => ("/run/proxmox-backup") }
 macro_rules! PROXMOX_BACKUP_LOG_DIR_M { () => ("/var/log/proxmox-backup") }
@@ -273,6 +273,15 @@ impl TaskState {
         }
     }
 
+    pub fn tasktype(&self) -> TaskStateType {
+        match self {
+            TaskState::OK { .. } => TaskStateType::OK,
+            TaskState::Unknown { .. } => TaskStateType::Unknown,
+            TaskState::Error { .. } => TaskStateType::Error,
+            TaskState::Warning { .. } => TaskStateType::Warning,
+        }
+    }
+
     fn result_text(&self) -> String {
         match self {
             TaskState::Error { message, .. } => format!("TASK ERROR: {}", message),
-- 
2.20.1





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 2/6] api2/node/tasks: change limit behaviour when it is 0
  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 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 ` Dominik Csapak
  2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 3/6] api2/node/tasks: add optional since/typefilter/statusfilter Dominik Csapak
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dominik Csapak @ 2020-10-30 14:02 UTC (permalink / raw)
  To: pbs-devel

instead of returning 0 elements (which does not really make sense anyway),
change it so that there is no limit anymore (besides usize::MAX)

this is technically a breaking change for the api, but i guess
no one is using limit=0 for anything sensible anyway

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/node/tasks.rs | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs
index 9146d351..00516f3b 100644
--- a/src/api2/node/tasks.rs
+++ b/src/api2/node/tasks.rs
@@ -271,7 +271,7 @@ fn stop_task(
             },
             limit: {
                 type: u64,
-                description: "Only list this amount of tasks.",
+                description: "Only list this amount of tasks. (0 means no limit)",
                 default: 50,
                 optional: true,
             },
@@ -328,6 +328,7 @@ pub fn list_tasks(
     let store = param["store"].as_str();
 
     let list = TaskListInfoIterator::new(running)?;
+    let limit = if limit > 0 { limit as usize } else { usize::MAX };
 
     let result: Vec<TaskListItem> = list
         .take_while(|info| !info.is_err())
@@ -372,11 +373,11 @@ pub fn list_tasks(
 
         Some(info.into())
     }).skip(start as usize)
-        .take(limit as usize)
+        .take(limit)
         .collect();
 
     let mut count = result.len() + start as usize;
-    if result.len() > 0 && result.len() >= limit as usize { // we have a 'virtual' entry as long as we have any new
+    if result.len() > 0 && result.len() >= limit { // we have a 'virtual' entry as long as we have any new
         count += 1;
     }
 
-- 
2.20.1





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 3/6] api2/node/tasks: add optional since/typefilter/statusfilter
  2020-10-30 14:02 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Dominik Csapak
                   ` (2 preceding siblings ...)
  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
  2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 4/6] api2/status: remove list_task api call Dominik Csapak
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dominik Csapak @ 2020-10-30 14:02 UTC (permalink / raw)
  To: pbs-devel

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





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 4/6] api2/status: remove list_task api call
  2020-10-30 14:02 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Dominik Csapak
                   ` (3 preceding siblings ...)
  2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 3/6] api2/node/tasks: add optional since/typefilter/statusfilter Dominik Csapak
@ 2020-10-30 14:02 ` Dominik Csapak
  2020-10-30 14:02 ` [pbs-devel] [PATCH proxmox-backup 5/6] api2/node/tasks: add optional until filter Dominik Csapak
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 10+ messages in thread
From: Dominik Csapak @ 2020-10-30 14:02 UTC (permalink / raw)
  To: pbs-devel

we do not need it anymore, we can do everything with nodes/NODE/tasks
instead

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/status.rs | 99 ----------------------------------------------
 1 file changed, 99 deletions(-)

diff --git a/src/api2/status.rs b/src/api2/status.rs
index 02ba1a78..582d7f0f 100644
--- a/src/api2/status.rs
+++ b/src/api2/status.rs
@@ -17,17 +17,13 @@ use crate::api2::types::{
     RRDMode,
     RRDTimeFrameResolution,
     Authid,
-    TaskListItem,
-    TaskStateType,
 };
 
-use crate::server;
 use crate::backup::{DataStore};
 use crate::config::datastore;
 use crate::tools::statistics::{linear_regression};
 use crate::config::cached_user_info::CachedUserInfo;
 use crate::config::acl::{
-    PRIV_SYS_AUDIT,
     PRIV_DATASTORE_AUDIT,
     PRIV_DATASTORE_BACKUP,
 };
@@ -179,103 +175,8 @@ fn datastore_status(
     Ok(list.into())
 }
 
-#[api(
-    input: {
-        properties: {
-            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 string.",
-            },
-            statusfilter: {
-                optional: true,
-                type: Array,
-                description: "Only list tasks which have any one of the listed status.",
-                items: {
-                    type: TaskStateType,
-                },
-            },
-        },
-    },
-    returns: {
-        description: "A list of tasks.",
-        type: Array,
-        items: { type: TaskListItem },
-    },
-    access: {
-        description: "Users can only see there own tasks, unless the have Sys.Audit on /system/tasks.",
-        permission: &Permission::Anybody,
-    },
-)]
-/// List tasks.
-pub fn list_tasks(
-    since: Option<i64>,
-    typefilter: Option<String>,
-    statusfilter: Option<Vec<TaskStateType>>,
-    _param: Value,
-    rpcenv: &mut dyn RpcEnvironment,
-) -> Result<Vec<TaskListItem>, Error> {
-
-    let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
-    let user_info = CachedUserInfo::new()?;
-    let user_privs = user_info.lookup_privs(&auth_id, &["system", "tasks"]);
-
-    let list_all = (user_privs & PRIV_SYS_AUDIT) != 0;
-    let since = since.unwrap_or_else(|| 0);
-
-    let list: Vec<TaskListItem> = server::TaskListInfoIterator::new(false)?
-        .take_while(|info| {
-            match info {
-                Ok(info) => info.upid.starttime > since,
-                Err(_) => false
-            }
-        })
-        .filter_map(|info| {
-            match info {
-                Ok(info) => {
-                    if list_all || info.upid.auth_id == auth_id {
-                        if let Some(filter) = &typefilter {
-                            if !info.upid.worker_type.contains(filter) {
-                                return None;
-                            }
-                        }
-
-                        if let Some(filters) = &statusfilter {
-                            if let Some(state) = &info.state {
-                                let statetype = match state {
-                                    server::TaskState::OK { .. } => TaskStateType::OK,
-                                    server::TaskState::Unknown { .. } => TaskStateType::Unknown,
-                                    server::TaskState::Error { .. } => TaskStateType::Error,
-                                    server::TaskState::Warning { .. } => TaskStateType::Warning,
-                                };
-
-                                if !filters.contains(&statetype) {
-                                    return None;
-                                }
-                            }
-                        }
-
-                        Some(Ok(TaskListItem::from(info)))
-                    } else {
-                        None
-                    }
-                }
-                Err(err) => Some(Err(err))
-            }
-        })
-        .collect::<Result<Vec<TaskListItem>, Error>>()?;
-
-    Ok(list.into())
-}
-
 const SUBDIRS: SubdirMap = &[
     ("datastore-usage", &Router::new().get(&API_METHOD_DATASTORE_STATUS)),
-    ("tasks", &Router::new().get(&API_METHOD_LIST_TASKS)),
 ];
 
 pub const ROUTER: Router = Router::new()
-- 
2.20.1





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 5/6] api2/node/tasks: add optional until filter
  2020-10-30 14:02 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Dominik Csapak
                   ` (4 preceding siblings ...)
  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 ` 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
  7 siblings, 0 replies; 10+ messages in thread
From: Dominik Csapak @ 2020-10-30 14:02 UTC (permalink / raw)
  To: pbs-devel

so that users select specific time ranges with 'since' and 'until'
(e.g. a single day)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/api2/node/tasks.rs | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/api2/node/tasks.rs b/src/api2/node/tasks.rs
index 8fe2aac1..a638b04f 100644
--- a/src/api2/node/tasks.rs
+++ b/src/api2/node/tasks.rs
@@ -301,6 +301,11 @@ fn stop_task(
                 description: "Only list tasks since this UNIX epoch.",
                 optional: true,
             },
+            until: {
+                type: i64,
+                description: "Only list tasks until this UNIX epoch.",
+                optional: true,
+            },
             typefilter: {
                 optional: true,
                 type: String,
@@ -334,6 +339,7 @@ pub fn list_tasks(
     running: bool,
     userfilter: Option<String>,
     since: Option<i64>,
+    until: Option<i64>,
     typefilter: Option<String>,
     statusfilter: Option<Vec<TaskStateType>>,
     param: Value,
@@ -352,6 +358,13 @@ pub fn list_tasks(
     let limit = if limit > 0 { limit as usize } else { usize::MAX };
 
     let result: Vec<TaskListItem> = list
+        .skip_while(|info| {
+            match (info, until) {
+                (Ok(info), Some(until)) => info.upid.starttime > until,
+                (Ok(_), None) => false,
+                (Err(_), _) => false,
+            }
+        })
         .take_while(|info| {
             match (info, since) {
                 (Ok(info), Some(since)) => info.upid.starttime > since,
-- 
2.20.1





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] [PATCH proxmox-backup 6/6] ui: add panel/Tasks and use it for the node tasks
  2020-10-30 14:02 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Dominik Csapak
                   ` (5 preceding siblings ...)
  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 ` Dominik Csapak
  2020-11-03 13:52 ` [pbs-devel] applied-series: [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Thomas Lamprecht
  7 siblings, 0 replies; 10+ messages in thread
From: Dominik Csapak @ 2020-10-30 14:02 UTC (permalink / raw)
  To: pbs-devel

this is a panel that is heavily inspired from widget-toolkits
node/Tasks panel, but is adapted to use the extended api calls of
pbs (e.g. since/until filter)

has 'filter' panel (like pmgs log tracker gui), but it is collapsible

if we extend the api calls of the other projects, we can merge this
again into the widget-toolkit one and use that

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/Makefile                |   1 +
 www/ServerAdministration.js |   2 +-
 www/panel/Tasks.js          | 362 ++++++++++++++++++++++++++++++++++++
 3 files changed, 364 insertions(+), 1 deletion(-)
 create mode 100644 www/panel/Tasks.js

diff --git a/www/Makefile b/www/Makefile
index 99ea578e..affeb6a9 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -36,6 +36,7 @@ JSSRC=							\
 	dashboard/LongestTasks.js			\
 	dashboard/RunningTasks.js			\
 	dashboard/TaskSummary.js			\
+	panel/Tasks.js					\
 	Utils.js					\
 	AccessControlPanel.js				\
 	ZFSList.js					\
diff --git a/www/ServerAdministration.js b/www/ServerAdministration.js
index 936d8a07..aa963638 100644
--- a/www/ServerAdministration.js
+++ b/www/ServerAdministration.js
@@ -55,7 +55,7 @@ Ext.define('PBS.ServerAdministration', {
 	    url: "/api2/extjs/nodes/localhost/journal",
 	},
 	{
-	    xtype: 'proxmoxNodeTasks',
+	    xtype: 'pbsNodeTasks',
 	    itemId: 'tasks',
 	    title: gettext('Tasks'),
 	    height: 'auto',
diff --git a/www/panel/Tasks.js b/www/panel/Tasks.js
new file mode 100644
index 00000000..65f0b31c
--- /dev/null
+++ b/www/panel/Tasks.js
@@ -0,0 +1,362 @@
+Ext.define('PBS.node.Tasks', {
+    extend: 'Ext.grid.GridPanel',
+
+    alias: 'widget.pbsNodeTasks',
+
+    stateful: true,
+    stateId: 'pbs-grid-node-tasks',
+
+    loadMask: true,
+    sortableColumns: false,
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+
+	showTaskLog: function() {
+	    let me = this;
+	    let selection = me.getView().getSelection();
+	    if (selection.length < 1) {
+		return;
+	    }
+
+	    let rec = selection[0];
+
+	    Ext.create('Proxmox.window.TaskViewer', {
+		upid: rec.data.upid,
+		endtime: rec.data.endtime,
+	    }).show();
+	},
+
+	updateLayout: function() {
+	    let me = this;
+	    // we want to update the scrollbar on every store load
+	    // since the total count might be different
+	    // the buffered grid plugin does this only on scrolling itself
+	    // and even reduces the scrollheight again when scrolling up
+	    me.getView().updateLayout();
+	},
+
+	sinceChange: function(field, newval) {
+	    let me = this;
+	    let vm = me.getViewModel();
+
+	    vm.set('since', newval);
+	},
+
+	untilChange: function(field, newval, oldval) {
+	    let me = this;
+	    let vm = me.getViewModel();
+
+	    vm.set('until', newval);
+	},
+
+	reload: function() {
+	    let me = this;
+	    let view = me.getView();
+	    view.getStore().load();
+	},
+
+	showFilter: function(btn, pressed) {
+	    let me = this;
+	    let vm = me.getViewModel();
+	    vm.set('showFilter', pressed);
+	},
+
+	init: function(view) {
+	    let me = this;
+	    Proxmox.Utils.monStoreErrors(view, view.getStore(), true);
+	},
+    },
+
+
+    listeners: {
+	itemdblclick: 'showTaskLog',
+    },
+
+    viewModel: {
+	data: {
+	    typefilter: '',
+	    statusfilter: '',
+	    datastore: '',
+	    showFilter: false,
+	    since: null,
+	    until: null,
+	},
+
+	formulas: {
+	    extraParams: function(get) {
+		let me = this;
+		let params = {};
+		if (get('typefilter')) {
+		    params.typefilter = get('typefilter');
+		}
+		if (get('statusfilter')) {
+		    params.statusfilter = get('statusfilter');
+		}
+		if (get('datastore')) {
+		    params.store = get('datastore');
+		}
+
+		if (get('since')) {
+		    params.since = get('since').valueOf()/1000;
+		}
+
+		if (get('until')) {
+		    let until = new Date(get('until').getTime()); // copy object
+		    until.setDate(until.getDate() + 1); // end of the day
+		    params.until = until.valueOf()/1000;
+		}
+
+		me.getView().getStore().load();
+
+		return params;
+	    },
+	},
+
+	stores: {
+	    bufferedstore: {
+		type: 'buffered',
+		pageSize: 500,
+		autoLoad: true,
+		remoteFilter: true,
+		model: 'proxmox-tasks',
+		proxy: {
+		    type: 'proxmox',
+		    startParam: 'start',
+		    limitParam: 'limit',
+		    extraParams: '{extraParams}',
+		    url: "/api2/json/nodes/localhost/tasks",
+		},
+		listeners: {
+		    prefetch: 'updateLayout',
+		},
+	    },
+	},
+    },
+
+    bind: {
+	store: '{bufferedstore}',
+    },
+
+
+    dockedItems: [
+	{
+	    xtype: 'toolbar',
+	    items: [
+		{
+		    xtype: 'proxmoxButton',
+		    text: gettext('View'),
+		    disabled: true,
+		    handler: 'showTaskLog',
+		},
+		{
+		    xtype: 'button',
+		    text: gettext('Reload'),
+		    handler: 'reload',
+		},
+		'->',
+		{
+		    xtype: 'button',
+		    enableToggle: true,
+		    text: gettext('Filter'),
+		    stateful: true,
+		    stateId: 'task-showfilter',
+		    stateEvents: ['toggle'],
+		    applyState: function(state) {
+			if (state.pressed !== undefined) {
+			    this.setPressed(state.pressed);
+			}
+		    },
+		    getState: function() {
+			return {
+			    pressed: this.pressed,
+			};
+		    },
+		    listeners: {
+			toggle: 'showFilter',
+		    },
+		},
+	    ],
+	},
+	{
+	    xtype: 'toolbar',
+	    dock: 'top',
+	    layout: {
+		type: 'hbox',
+		align: 'top',
+	    },
+	    bind: {
+		hidden: '{!showFilter}',
+	    },
+	    items: [
+		{
+		    xtype: 'container',
+		    padding: 10,
+		    layout: {
+			type: 'vbox',
+			align: 'stretch',
+		    },
+		    items: [
+			{
+			    fieldLabel: gettext('Type'),
+			    bind: {
+				value: '{typefilter}',
+			    },
+			    xtype: 'pmxTaskTypeSelector',
+			},
+			{
+			    fieldLabel: gettext('Datastore'),
+			    xtype: 'pbsDataStoreSelector',
+			    emptyText: gettext('All'),
+			    bind: {
+				value: '{datastore}',
+			    },
+			    allowBlank: true,
+			},
+			{
+			    fieldLabel: gettext('States'),
+			    xtype: 'combobox',
+			    multiSelect: true,
+			    emptyText: gettext('All'),
+			    store: [
+				['ok', gettext('OK'), ],
+				['unknown', Proxmox.Utils.unknownText, ],
+				['warning', gettext('Warnings') ],
+				['error', gettext('Errors') ],
+			    ],
+			    bind: {
+				value: '{statusfilter}',
+			    },
+			},
+		    ]
+		},
+		{
+		    xtype: 'container',
+		    padding: 10,
+		    layout: {
+			type: 'vbox',
+			align: 'stretch',
+		    },
+		    items: [
+			// we cannot bind the values directly,
+			// since it then changes also on blur,
+			// causing wrong reloads of the store
+			{
+			    fieldLabel: gettext('Since'),
+			    xtype: 'datefield',
+			    format: 'Y-m-d',
+			    bind: {
+				maxValue: '{until}',
+			    },
+			    listeners: {
+				change: 'sinceChange',
+			    },
+			},
+			{
+			    fieldLabel: gettext('Until'),
+			    xtype: 'datefield',
+			    format: 'Y-m-d',
+			    bind: {
+				minValue: '{since}',
+			    },
+			    listeners: {
+				change: 'untilChange',
+			    },
+			},
+		    ],
+		},
+	    ]
+	},
+    ],
+
+    viewConfig: {
+	trackOver: false,
+	stripeRows: false, // does not work with getRowClass()
+	emptyText: gettext('No Tasks found'),
+
+	getRowClass: function(record, index) {
+	    let status = record.get('status');
+
+	    if (status) {
+		let parsed = Proxmox.Utils.parse_task_status(status);
+		if (parsed === 'error') {
+		    return "proxmox-invalid-row";
+		} else if (parsed === 'warning') {
+		    return "proxmox-warning-row";
+		}
+	    }
+	    return '';
+	},
+    },
+
+    columns: [
+	{
+	    header: gettext("Start Time"),
+	    dataIndex: 'starttime',
+	    width: 130,
+	    renderer: function(value) {
+		return Ext.Date.format(value, "M d H:i:s");
+	    },
+	},
+	{
+	    header: gettext("End Time"),
+	    dataIndex: 'endtime',
+	    width: 130,
+	    renderer: function(value, metaData, record) {
+		if (!value) {
+		    metaData.tdCls = "x-grid-row-loading";
+		    return '';
+		}
+		return Ext.Date.format(value, "M d H:i:s");
+	    },
+	},
+	{
+	    header: gettext("Duration"),
+	    hidden: true,
+	    width: 80,
+	    renderer: function(value, metaData, record) {
+		let start = record.data.starttime;
+		if (start) {
+		    let end = record.data.endtime || Date.now();
+		    let duration = end - start;
+		    if (duration > 0) {
+			duration /= 1000;
+		    }
+		    return Proxmox.Utils.format_duration_human(duration);
+		}
+		return Proxmox.Utils.unknownText;
+	    },
+	},
+	{
+	    header: gettext("User name"),
+	    dataIndex: 'user',
+	    width: 150,
+	},
+	{
+	    header: gettext("Description"),
+	    dataIndex: 'upid',
+	    flex: 1,
+	    renderer: Proxmox.Utils.render_upid,
+	},
+	{
+	    header: gettext("Status"),
+	    dataIndex: 'status',
+	    width: 200,
+	    renderer: function(value, metaData, record) {
+		if (value === undefined && !record.data.endtime) {
+		    metaData.tdCls = "x-grid-row-loading";
+		    return '';
+		}
+
+		let parsed = Proxmox.Utils.parse_task_status(value);
+		switch (parsed) {
+		    case 'unknown': return Proxmox.Utils.unknownText;
+		    case 'error': return Proxmox.Utils.errorText + ': ' + value;
+		    case 'ok': // fall-through
+		    case 'warning': // fall-through
+		    default: return value;
+		}
+	    },
+	},
+    ],
+});
-- 
2.20.1





^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] applied: [PATCH widget-toolkit 1/1] add form/TaskTypeSelector
  2020-10-30 14:02 ` [pbs-devel] [PATCH widget-toolkit 1/1] add form/TaskTypeSelector Dominik Csapak
@ 2020-10-30 17:19   ` Thomas Lamprecht
  0 siblings, 0 replies; 10+ messages in thread
From: Thomas Lamprecht @ 2020-10-30 17:19 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 30.10.20 15:02, Dominik Csapak wrote:
> for suggesting workery types when we want to filter by them
> 
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
>  src/Makefile                 |  1 +
>  src/form/TaskTypeSelector.js | 12 ++++++++++++
>  2 files changed, 13 insertions(+)
>  create mode 100644 src/form/TaskTypeSelector.js
> 
>

applied, thanks!




^ permalink raw reply	[flat|nested] 10+ messages in thread

* [pbs-devel] applied-series: [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel
  2020-10-30 14:02 [pbs-devel] [PATCH widget-toolkit/proxmox-backup] improve Administration/Task panel Dominik Csapak
                   ` (6 preceding siblings ...)
  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 ` Thomas Lamprecht
  7 siblings, 0 replies; 10+ messages in thread
From: Thomas Lamprecht @ 2020-11-03 13:52 UTC (permalink / raw)
  To: Proxmox Backup Server development discussion, Dominik Csapak

On 30.10.20 15:02, Dominik Csapak wrote:
> this series extends the node/tasks api call with several new filters,
> and adds a new task panel to the ui that makes use of these filters
> 
> the type selector will show all tasks in the current Proxmox.Utils object,
> so this will work best when [0] is applied
> 
> 0: https://lists.proxmox.com/pipermail/pve-devel/2020-October/045730.html
> 
> proxmox-widget-toolkit:
> 
> Dominik Csapak (1):
>   add form/TaskTypeSelector
> 
>  src/Makefile                 |  1 +
>  src/form/TaskTypeSelector.js | 12 ++++++++++++
>  2 files changed, 13 insertions(+)
>  create mode 100644 src/form/TaskTypeSelector.js
> 
> proxmox-backup:
> 
> Dominik Csapak (6):
>   server/worker_task: add tasktype to return the api type of a taskstate
>   api2/node/tasks: change limit behaviour when it is 0
>   api2/node/tasks: add optional since/typefilter/statusfilter
>   api2/status: remove list_task api call
>   api2/node/tasks: add optional until filter
>   ui: add panel/Tasks and use it for the node tasks
> 
>  src/api2/node/tasks.rs       |  67 ++++++-
>  src/api2/status.rs           |  99 ----------
>  src/server/worker_task.rs    |  11 +-
>  www/Dashboard.js             |   3 +-
>  www/Makefile                 |   1 +
>  www/ServerAdministration.js  |   2 +-
>  www/dashboard/TaskSummary.js |   3 +-
>  www/panel/Tasks.js           | 362 +++++++++++++++++++++++++++++++++++
>  8 files changed, 438 insertions(+), 110 deletions(-)
>  create mode 100644 www/panel/Tasks.js
> 



applied remaining series, thanks!

Did some field reordering to use more of the extra vertical space instead of
shrinking the task grid to much for the filters.

Also, button icons, a clear trigger for task type, fieldLabel fixes and a
emptyText for clarity - just for the record.





^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-11-03 13:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pbs-devel] [PATCH proxmox-backup 3/6] api2/node/tasks: add optional since/typefilter/statusfilter Dominik Csapak
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal