[pve-devel] [PATCH manager] ui: add date column for backups in storage content view

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Dec 3 09:27:19 CET 2019


main use case is to sort by date, e.g., I just re-created a cluster,
did some VM/CT backups on a NFS dump of mine which already had quite
some backups. Now, on restore I knew that only the backups made
yesterday were interesting, so a sort by date would allow me to find
them all easily, thus this patch was born.

Simple frontend extraction of information from the volid, for now
only for backups as there's the only case were we have the info at
all. Called the model entry "vdate" for "virtual date".

Mayb adding the creation date to all entries could be a nice addition
for the API someday.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/storage/ContentView.js | 28 +++++++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js
index b72fc88d..df6aba16 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -588,6 +588,11 @@ Ext.define('PVE.storage.ContentView', {
 		    renderer: PVE.Utils.render_storage_content,
 		    dataIndex: 'text'
 		},
+		{
+		    header: gettext('Date'),
+		    width: 150,
+		    dataIndex: 'vdate'
+		},
 		{
 		    header: gettext('Format'),
 		    width: 100,
@@ -661,7 +666,28 @@ Ext.define('PVE.storage.ContentView', {
 		    }
 		    return PVE.Utils.render_storage_content(value, {}, record);
 		}
-	    }
+	    },
+	    {
+		name: 'vdate',
+		convert: function(value, record) {
+		    // check for volid, because if you click on a grouping header,
+		    // it calls convert (but with an empty volid)
+		    if (value || record.data.volid === null) {
+			return value;
+		    }
+		    let t = record.data.content;
+		    if (t === "backup") {
+			let v = record.data.volid;
+			let match = v.match(/(\d{4}_\d{2}_\d{2})-(\d{2}_\d{2}_\d{2})/);
+			if (match) {
+			    let date = match[1].replace(/_/g, '.');
+			    let time = match[2].replace(/_/g, ':');
+			    return date + " " + time;
+			}
+		    }
+		    return '';
+		}
+	    },
 	],
 	idProperty: 'volid'
     });
-- 
2.20.1





More information about the pve-devel mailing list