public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 2/2] ui: add fingerprint also to the 'show repository information' window
Date: Wed, 29 Nov 2023 12:03:09 +0100	[thread overview]
Message-ID: <20231129110309.2524356-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20231129110309.2524356-1-d.csapak@proxmox.com>

by globally calling the 'status' api once and saving the fingerprint
into the global Proxmox variable.

since not all users might have that permission, ignore errors for that,
and don't show the fingerprint in this case

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
sending this seperately because i'm not sure if we want to have the
fingerprint here too, and if i handled the permission in an ok way

sadly there is no way to get that info from the browser itself
(at least i could not find it..)

 www/MainView.js                 | 11 +++++++++++
 www/window/DatastoreRepoInfo.js | 25 +++++++++++++++++++++++++
 2 files changed, 36 insertions(+)

diff --git a/www/MainView.js b/www/MainView.js
index d35162e4..4dbfe9bf 100644
--- a/www/MainView.js
+++ b/www/MainView.js
@@ -184,6 +184,17 @@ Ext.define('PBS.MainView', {
 		interval: 15*60*1000,
 	    });
 
+	    Proxmox.Utils.API2Request({
+		url: `/api2/extjs/nodes/localhost/status`,
+		success: function({ result }) {
+		    if (result?.data?.info?.fingerprint) {
+			Proxmox.Fingerprint = result.data.info.fingerprint;
+		    }
+		},
+		failure: function() {
+		    // silently ignore errors
+		},
+	    });
 
 	    // select treeitem and load page from url fragment, if set
 	    let token = Ext.util.History.getToken() || 'pbsDashboard';
diff --git a/www/window/DatastoreRepoInfo.js b/www/window/DatastoreRepoInfo.js
index 9d2df9aa..eb704f81 100644
--- a/www/window/DatastoreRepoInfo.js
+++ b/www/window/DatastoreRepoInfo.js
@@ -13,6 +13,7 @@ Ext.define('PBS.window.DatastoreRepoInfo', {
 
     cbindData: function() {
 	let me = this;
+	let fingerprint = Proxmox.Fingerprint;
 	let host = window.location.hostname;
 	if (window.location.port.toString() !== "8007") {
 	    host += `:${window.location.port}`;
@@ -24,6 +25,7 @@ Ext.define('PBS.window.DatastoreRepoInfo', {
 
 	return {
 	    datastore,
+	    fingerprint,
 	    repository,
 	    repositoryWithUser,
 	};
@@ -43,6 +45,29 @@ Ext.define('PBS.window.DatastoreRepoInfo', {
 		value: '{datastore}',
 	    },
 	},
+	{
+	    fieldLabel: gettext('Fingerprint'),
+	    cbind: {
+		hidden: '{!fingerprint}',
+	    },
+	    items: [
+		{
+		    xtype: 'textfield',
+		    inputId: 'fingerprintField',
+		    editable: false,
+		    flex: 1,
+		    cbind: {
+			value: '{fingerprint}',
+		    },
+		},
+		{
+		    xtype: 'button',
+		    iconCls: 'fa fa-clipboard',
+		    handler: () => PBS.Utils.copyInputContent('fingerprintField'),
+		    text: gettext('Copy'),
+		},
+	    ],
+	},
 	{
 	    fieldLabel: gettext('Repository'),
 	    cbind: {},
-- 
2.30.2





  reply	other threads:[~2023-11-29 11:03 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-29 11:03 [pbs-devel] [PATCH proxmox-backup 1/2] ui: add 'show repository Information' button for datastores Dominik Csapak
2023-11-29 11:03 ` Dominik Csapak [this message]
2023-11-29 14:14 ` Fabian Grünbichler
2023-11-29 14:53 ` Thomas Lamprecht
2023-11-29 14:59   ` Dominik Csapak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231129110309.2524356-2-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal