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 CAE28B3983 for ; Wed, 29 Nov 2023 12:03:10 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id AE8214F13 for ; Wed, 29 Nov 2023 12:03:10 +0100 (CET) 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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 29 Nov 2023 12:03:10 +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 E03914047B for ; Wed, 29 Nov 2023 12:03:09 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Wed, 29 Nov 2023 12:03:08 +0100 Message-Id: <20231129110309.2524356-1-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.018 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pbs-devel] [PATCH proxmox-backup 1/2] ui: add 'show repository Information' button for datastores 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: Wed, 29 Nov 2023 11:03:10 -0000 this has a similar functionality as the 'show fingerprint' button, but for repository strings that are needed e.g. for the cli included with and without the current user for convenience Signed-off-by: Dominik Csapak --- www/Makefile | 1 + www/Utils.js | 8 +++ www/datastore/DataStoreListSummary.js | 15 +++++ www/datastore/Panel.js | 17 ++++- www/window/DatastoreRepoInfo.js | 97 +++++++++++++++++++++++++++ 5 files changed, 137 insertions(+), 1 deletion(-) create mode 100644 www/window/DatastoreRepoInfo.js diff --git a/www/Makefile b/www/Makefile index 04c12b31..be7e27ab 100644 --- a/www/Makefile +++ b/www/Makefile @@ -86,6 +86,7 @@ JSSRC= \ window/VerifyAll.js \ window/ZFSCreate.js \ window/InfluxDbEdit.js \ + window/DatastoreRepoInfo.js \ dashboard/DataStoreStatistics.js \ dashboard/LongestTasks.js \ dashboard/RunningTasks.js \ diff --git a/www/Utils.js b/www/Utils.js index 7592d1bd..439aadb1 100644 --- a/www/Utils.js +++ b/www/Utils.js @@ -752,4 +752,12 @@ Ext.define('PBS.Utils', { return options.join(', '); }, + copyInputContent: function(inputId) { + let el = document.getElementById(inputId); + if (!el) { + return; + } + el.select(); + document.execCommand("copy"); + }, }); diff --git a/www/datastore/DataStoreListSummary.js b/www/datastore/DataStoreListSummary.js index 968239b0..ae503496 100644 --- a/www/datastore/DataStoreListSummary.js +++ b/www/datastore/DataStoreListSummary.js @@ -89,6 +89,21 @@ Ext.define('PBS.datastore.DataStoreListSummary', { me.lookup('historychart').setData(data); }, + tools: [ + { + xtype: 'button', + text: gettext('Show Repository Information'), + handler: function() { + let me = this; + let datastore = me.up('panel').datastore; + Ext.create('PBS.window.DatastoreRepoInfo', { + datastore, + autoShow: true, + }); + }, + }, + ], + items: [ { xtype: 'container', diff --git a/www/datastore/Panel.js b/www/datastore/Panel.js index fd1b4611..248460d8 100644 --- a/www/datastore/Panel.js +++ b/www/datastore/Panel.js @@ -37,7 +37,22 @@ Ext.define('PBS.DataStorePanel', { border: false, }, - tools: [PBS.Utils.get_help_tool("datastore_intro")], + tools: [ + PBS.Utils.get_help_tool("datastore_intro"), + { + xtype: 'button', + margin: '0 0 0 10', + text: gettext('Show Repository Information'), + handler: function() { + let me = this; + let datastore = me.up('panel').datastore; + Ext.create('PBS.window.DatastoreRepoInfo', { + datastore, + autoShow: true, + }); + }, + }, + ], items: [ { diff --git a/www/window/DatastoreRepoInfo.js b/www/window/DatastoreRepoInfo.js new file mode 100644 index 00000000..9d2df9aa --- /dev/null +++ b/www/window/DatastoreRepoInfo.js @@ -0,0 +1,97 @@ +Ext.define('PBS.window.DatastoreRepoInfo', { + extend: 'Ext.window.Window', + alias: 'widget.pbsDatastoreRepoInfo', + mixins: ['Proxmox.Mixin.CBind'], + + title: gettext('Repository Information'), + + modal: true, + resizable: false, + width: 600, + layout: 'anchor', + bodyPadding: 10, + + cbindData: function() { + let me = this; + let host = window.location.hostname; + if (window.location.port.toString() !== "8007") { + host += `:${window.location.port}`; + } + let datastore = me.datastore; + let user = Proxmox.UserName; + let repository = `${host}:${datastore}`; + let repositoryWithUser = `${user}@${host}:${datastore}`; + + return { + datastore, + repository, + repositoryWithUser, + }; + }, + + defaults: { + xtype: 'fieldcontainer', + layout: 'hbox', + labelWidth: 120, + }, + + items: [ + { + xtype: 'displayfield', + fieldLabel: gettext('Datastore'), + cbind: { + value: '{datastore}', + }, + }, + { + fieldLabel: gettext('Repository'), + cbind: {}, + items: [ + { + xtype: 'textfield', + inputId: 'repository', + flex: 1, + editable: false, + cbind: { + value: '{repository}', + }, + }, + { + xtype: 'button', + iconCls: 'fa fa-clipboard', + handler: () => PBS.Utils.copyInputContent('repository'), + text: gettext('Copy'), + }, + ], + }, + { + fieldLabel: gettext('with current User'), + cbind: {}, + items: [ + { + xtype: 'textfield', + inputId: 'repositoryWithUser', + flex: 1, + editable: false, + cbind: { + value: '{repositoryWithUser}', + }, + }, + { + xtype: 'button', + iconCls: 'fa fa-clipboard', + handler: () => PBS.Utils.copyInputContent('repositoryWithUser'), + text: gettext('Copy'), + }, + ], + }, + ], + buttons: [ + { + text: gettext('Ok'), + handler: function() { + this.up('window').close(); + }, + }, + ], +}); -- 2.30.2