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 9D2EA6B748
 for <pbs-devel@lists.proxmox.com>; Wed, 17 Mar 2021 13:19:13 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 88C162D34B
 for <pbs-devel@lists.proxmox.com>; Wed, 17 Mar 2021 13:18:43 +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) server-digest SHA256)
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id 9E4292D340
 for <pbs-devel@lists.proxmox.com>; Wed, 17 Mar 2021 13:18:41 +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 6426142774
 for <pbs-devel@lists.proxmox.com>; Wed, 17 Mar 2021 13:18:41 +0100 (CET)
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Wed, 17 Mar 2021 13:18:40 +0100
Message-Id: <20210317121840.18844-1-d.csapak@proxmox.com>
X-Mailer: git-send-email 2.20.1
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.185 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: [pbs-devel] [PATCH proxmox-backup] ui: tape/BackupOverview: insert
 a datastore level
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 17 Mar 2021 12:19:13 -0000

since we can now backup multiple datastores in the same media-set,
we show the datastores as first level below that

the final tree structucture looks like this:

tapepool A
- media set 1
 - datastore I
  - tape x
   - ct/100
    - ct/100/2020-01-01T00:00:00Z

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
maybe we want to omit the 'tape' level in the future since IMHO it
does not really add valuable information for the user there
instead i would probably add it as a seperate column instead of the
'seq-nr' column. any thoughts on that ?

 www/tape/BackupOverview.js | 36 +++++++++++++++++++++++++++++-------
 1 file changed, 29 insertions(+), 7 deletions(-)

diff --git a/www/tape/BackupOverview.js b/www/tape/BackupOverview.js
index a53475c2..0f9a35af 100644
--- a/www/tape/BackupOverview.js
+++ b/www/tape/BackupOverview.js
@@ -127,9 +127,16 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
 		    },
 		});
 
-		list.result.data.sort((a, b) => a.snapshot.localeCompare(b.snapshot));
+		list.result.data.sort(function(a, b) {
+		    let storeRes = a.store.localeCompare(b.store);
+		    if (storeRes === 0) {
+			return a.snapshot.localeCompare(b.snapshot);
+		    } else {
+			return storeRes;
+		    }
+		});
 
-		let tapes = {};
+		let stores = {};
 
 		for (let entry of list.result.data) {
 		    entry.text = entry.snapshot;
@@ -140,9 +147,19 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
 			entry.iconCls = `fa ${iconCls}`;
 		    }
 
+		    let store = entry.store;
 		    let tape = entry['label-text'];
-		    if (tapes[tape] === undefined) {
-			tapes[tape] = {
+		    if (stores[store] === undefined) {
+			stores[store] = {
+			    text: store,
+			    'media-set-uuid': entry['media-set-uuid'],
+			    iconCls: 'fa fa-database',
+			    tapes: {},
+			};
+		    }
+
+		    if (stores[store].tapes[tape] === undefined) {
+			stores[store].tapes[tape] = {
 			    text: tape,
 			    'media-set-uuid': entry['media-set-uuid'],
 			    'seq-nr': entry['seq-nr'],
@@ -153,7 +170,7 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
 		    }
 		    let [type, group, _id] = PBS.Utils.parse_snapshot_id(entry.snapshot);
 
-		    let children = tapes[tape].children;
+		    let children = stores[store].tapes[tape].children;
 		    let text = `${type}/${group}`;
 		    if (children.length < 1 || children[children.length - 1].text !== text) {
 			children.push({
@@ -167,8 +184,13 @@ Ext.define('PBS.TapeManagement.BackupOverview', {
 		    children[children.length - 1].children.push(entry);
 		}
 
-		for (const tape of Object.values(tapes)) {
-		    node.appendChild(tape);
+		let storeList = Object.values(stores);
+		let expand = storeList.length === 1;
+		for (const store of storeList) {
+		    store.children = Object.values(store.tapes);
+		    store.expanded = expand;
+		    delete store.tapes;
+		    node.appendChild(store);
 		}
 
 		if (list.result.data.length === 0) {
-- 
2.20.1