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 8CA7474455 for ; Thu, 8 Jul 2021 16:45:37 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 8A9961A279 for ; Thu, 8 Jul 2021 16:45:37 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 B05061A264 for ; Thu, 8 Jul 2021 16:45:35 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 872F940F43 for ; Thu, 8 Jul 2021 16:45:35 +0200 (CEST) From: Stefan Reiter To: pbs-devel@lists.proxmox.com Date: Thu, 8 Jul 2021 16:45:28 +0200 Message-Id: <20210708144528.1405534-2-s.reiter@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210708144528.1405534-1-s.reiter@proxmox.com> References: <20210708144528.1405534-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.629 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment 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. [parentnode.id, rec.data] Subject: [pbs-devel] [PATCH proxmox-backup 2/2] ui: add support for notes on backup groups 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: Thu, 08 Jul 2021 14:45:37 -0000 Currently done a little bit hacky in a seperate API call following the initial list_snapshots, as we previously didn't call list_groups at all and instead calculated the groups from the snapshots. This calls it async and updates the view with group comments when data arrives. The editor is simply reused with the 'group-notes' API call, since the semantics are the same. Signed-off-by: Stefan Reiter --- www/datastore/Content.js | 59 ++++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/www/datastore/Content.js b/www/datastore/Content.js index 101763aa..29d58fc3 100644 --- a/www/datastore/Content.js +++ b/www/datastore/Content.js @@ -125,6 +125,29 @@ Ext.define('PBS.DataStoreContent', { return groups; }, + updateGroupNotes: function(view) { + Proxmox.Utils.API2Request({ + url: `/api2/extjs/admin/datastore/${view.datastore}/groups`, + method: 'GET', + success: function(response) { + let groups = response.result.data; + let map = {}; + for (const group of groups) { + map[`${group["backup-type"]}/${group["backup-id"]}`] = group["comment"]; + } + view.getRootNode().cascade(node => { + if (node.parentNode && node.parentNode.id === 'root') { + node.set( + 'comment', + map[`${node.data.backup_type}/${node.data.backup_id}`], + { dirty: false }, + ); + } + }); + }, + }); + }, + onLoad: function(store, records, success, operation) { let me = this; let view = this.getView(); @@ -242,6 +265,8 @@ Ext.define('PBS.DataStoreContent', { children: children, }); + this.updateGroupNotes(view); + if (selected !== undefined) { let selection = view.getRootNode().findChildBy(function(item) { let id = item.data.text; @@ -358,19 +383,31 @@ Ext.define('PBS.DataStoreContent', { }); }, - onNotesEdit: function(view, data) { + onNotesEdit: function(view, data, isGroup) { let me = this; - let url = `/admin/datastore/${view.datastore}/notes`; + let url = `/admin/datastore/${view.datastore}/`; + url += isGroup ? 'group-notes' : 'notes'; + + let params; + if (isGroup) { + params = { + "backup-type": data.backup_type, + "backup-id": data.backup_id, + }; + } else { + params = { + "backup-type": data["backup-type"], + "backup-id": data["backup-id"], + "backup-time": (data['backup-time'].getTime()/1000).toFixed(0), + }; + } + Ext.create('PBS.window.NotesEdit', { url: url, autoShow: true, apiCallDone: () => me.reload(), // FIXME: do something more efficient? - extraRequestParams: { - "backup-type": data["backup-type"], - "backup-id": data["backup-id"], - "backup-time": (data['backup-time'].getTime()/1000).toFixed(0), - }, + extraRequestParams: params, }); }, @@ -585,7 +622,7 @@ Ext.define('PBS.DataStoreContent', { flex: 1, renderer: (v, meta, record) => { let data = record.data; - if (!data || data.leaf || record.parentNode.id === 'root') { + if (!data || data.leaf) { return ''; } if (v === undefined || v === null) { @@ -608,17 +645,17 @@ Ext.define('PBS.DataStoreContent', { } let view = tree.up(); let controller = view.controller; - controller.onNotesEdit(view, rec.data); + controller.onNotesEdit(view, rec.data, rec.parentNode.id === 'root'); }); }, dblclick: function(tree, el, row, col, ev, rec) { let data = rec.data || {}; - if (data.leaf || rec.parentNode.id === 'root') { + if (data.leaf) { return; } let view = tree.up(); let controller = view.controller; - controller.onNotesEdit(view, rec.data); + controller.onNotesEdit(view, rec.data, rec.parentNode.id === 'root'); }, }, }, -- 2.30.2