From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 87F6F6917F
 for <pve-devel@lists.proxmox.com>; Thu, 12 Nov 2020 16:26:09 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 8631612644
 for <pve-devel@lists.proxmox.com>; Thu, 12 Nov 2020 16:26:09 +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 EC86B1261F
 for <pve-devel@lists.proxmox.com>; Thu, 12 Nov 2020 16:26:04 +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 B76F1424BD
 for <pve-devel@lists.proxmox.com>; Thu, 12 Nov 2020 16:26:04 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Thu, 12 Nov 2020 16:26:03 +0100
Message-Id: <20201112152603.8106-4-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
In-Reply-To: <20201112152603.8106-1-d.csapak@proxmox.com>
References: <20201112152603.8106-1-d.csapak@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.368 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
Subject: [pve-devel] [PATCH manager 1/1] ui: add comment/verification
 columns to backup/content grid
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 12 Nov 2020 15:26:09 -0000

verification column only shows in the backup grid and for
pbs storages

(renderer is mostly copied from proxmox-backup)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 www/manager6/grid/BackupView.js     | 39 +++++++++++++++++++++++++++++
 www/manager6/storage/ContentView.js |  8 +++++-
 2 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/www/manager6/grid/BackupView.js b/www/manager6/grid/BackupView.js
index ff8d69ec..a9c6be5e 100644
--- a/www/manager6/grid/BackupView.js
+++ b/www/manager6/grid/BackupView.js
@@ -99,6 +99,15 @@ Ext.define('PVE.grid.BackupView', {
 	    allowBlank: false,
 	    listeners: {
 		change: function(f, value) {
+		    let storage = f.getStore().findRecord('storage', value);
+		    if (storage) {
+			let isPbs = storage.data.type === 'pbs';
+			me.getColumns().forEach((column) => {
+			    if (column.dataIndex === 'verification') {
+				column.setHidden(!isPbs);
+			    }
+			});
+		    }
 		    setStorage(value);
 		}
 	    }
@@ -251,6 +260,36 @@ Ext.define('PVE.grid.BackupView', {
 		    dataIndex: 'vmid',
 		    hidden: true,
 		},
+		{
+		    header: gettext('Comment'),
+		    dataIndex: 'comment',
+		    width: 100,
+		    renderer: Ext.htmlEncode,
+		},
+		{
+		    header: gettext('Verify State'),
+		    dataIndex: 'verification',
+		    renderer: function(v) {
+			let i = (cls, txt) => `<i class="fa fa-fw fa-${cls}"></i> ${txt}`;
+			if (v === undefined || v === null) {
+			    return i('question-circle-o warning', gettext('None'));
+			}
+			let tip = ""
+			let txt = gettext('Failed');
+			let iconCls = 'times critical';
+			if (v.state === 'ok') {
+			    txt = gettext('OK');
+			    iconCls = 'check good';
+			    let now = Date.now() / 1000;
+			    let task = Proxmox.Utils.parse_task_upid(v.upid);
+			    if (now - v.starttime > 30 * 24 * 60 * 60) {
+				tip = `Last verify task over 30 days ago: ${verify_time}`;
+				iconCls = 'check warning';
+			    }
+			}
+			return `<span data-qtip="${tip}"> ${i(iconCls, txt)} </span>`;
+		    }
+		}
 	    ]
 	});
 
diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js
index 194ad42e..6b30167a 100644
--- a/www/manager6/storage/ContentView.js
+++ b/www/manager6/storage/ContentView.js
@@ -609,6 +609,12 @@ Ext.define('PVE.storage.ContentView', {
 		    width: 100,
 		    renderer: Proxmox.Utils.format_size,
 		    dataIndex: 'size'
+		},
+		{
+		    header: gettext('Comment'),
+		    width: 100,
+		    renderer: Ext.htmlEncode,
+		    dataIndex: 'comment',
 		}
 	    ],
 	    listeners: {
@@ -655,7 +661,7 @@ Ext.define('PVE.storage.ContentView', {
 	extend: 'Ext.data.Model',
 	fields: [
 	    'volid', 'content', 'format', 'size', 'used', 'vmid',
-	    'channel', 'id', 'lun',
+	    'channel', 'id', 'lun', 'comment', 'verification',
 	    {
 		name: 'text',
 		convert: function(value, record) {
-- 
2.20.1