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) server-digest SHA256) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 2C9B3653DC for ; Tue, 3 Nov 2020 09:31:02 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 20C82296C8 for ; Tue, 3 Nov 2020 09:31:02 +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 51E22296BF for ; Tue, 3 Nov 2020 09:31:01 +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 1EB5C45FEA for ; Tue, 3 Nov 2020 09:31:01 +0100 (CET) From: Dylan Whyte To: pbs-devel@lists.proxmox.com Date: Tue, 3 Nov 2020 09:30:54 +0100 Message-Id: <20201103083054.30654-1-d.whyte@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.020 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [rec.data, parentnode.id, win.show] Subject: [pbs-devel] [PATCH v3 proxmox-backup] gui: Add button for changing backup group owner 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: Tue, 03 Nov 2020 08:31:02 -0000 Extension of fix #2847 Adds an action button to the datastore content view, to change the owner of a backup. Signed-off-by: Dylan Whyte --- v3: - Declare input panel inline in the edit window - use of gettext for string fields - remove unnecessary win.show call - use gitTip property for tool tip v2: - Fix whitespace - BackupGroupChangeOwner: remove unnecessary reload function - Use let insread of var in "onGetValues" - Use template literals for URL - Set autoShow true when creating the window www/BackupGroupChangeOwner.js | 46 +++++++++++++++++++++++++++++++++++ www/DataStoreContent.js | 26 +++++++++++++++++++- www/Makefile | 1 + 3 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 www/BackupGroupChangeOwner.js diff --git a/www/BackupGroupChangeOwner.js b/www/BackupGroupChangeOwner.js new file mode 100644 index 00000000..0a7a7563 --- /dev/null +++ b/www/BackupGroupChangeOwner.js @@ -0,0 +1,46 @@ +Ext.define('PBS.BackupGroupChangeOwner', { + extend: 'Proxmox.window.Edit', + alias: 'widget.pbsBackupGroupChangeOwner', + + submitText: gettext("Change Owner"), + subject: gettext("Change Owner"), + + initComponent: function() { + let me = this; + + if (!me.datastore) { + throw "no datastore specified"; + } + if (!me.backup_type) { + throw "no backup_type specified"; + } + if (!me.backup_id) { + throw "no backup_id specified"; + } + + Ext.apply(me, { + url: `/api2/extjs/admin/datastore/${me.datastore}/change-owner`, + method: 'POST', + items: { + xtype: 'inputpanel', + onGetValues: function(values) { + values["backup-type"] = me.backup_type; + values["backup-id"] = me.backup_id; + return values; + }, + + column1: [ + { + xtype: 'textfield', + name: 'new-owner', + fieldLabel: gettext('Userid'), + minLength: 8, + allowBlank: false, + }, + ], + }, + }); + + me.callParent(); + }, +}); diff --git a/www/DataStoreContent.js b/www/DataStoreContent.js index db912a83..7c6395c2 100644 --- a/www/DataStoreContent.js +++ b/www/DataStoreContent.js @@ -268,6 +268,24 @@ Ext.define('PBS.DataStoreContent', { } }, + onChangeOwner: function(view, rI, cI, item, e, rec) { + view = this.getView(); + + if (!rec || !rec.data || rec.parentNode.id !== 'root' || !view.datastore) { + return; + } + + let data = rec.data; + + let win = Ext.create('PBS.BackupGroupChangeOwner', { + datastore: view.datastore, + backup_type: data.backup_type, + backup_id: data.backup_id, + autoShow: true, + }); + win.on('destroy', this.reload, this); + }, + onPrune: function(view, rI, cI, item, e, rec) { view = this.getView(); @@ -582,7 +600,13 @@ Ext.define('PBS.DataStoreContent', { getTip: (v, m, rec) => Ext.String.format(gettext("Verify '{0}'"), v), getClass: (v, m, rec) => rec.data.leaf ? 'pmx-hidden' : 'pve-icon-verify-lettering', isDisabled: (v, r, c, i, rec) => !!rec.data.leaf, - }, + }, + { + handler: 'onChangeOwner', + getClass: (v, m, rec) => rec.parentNode.id ==='root' ? 'fa fa-user' : 'pmx-hidden', + getTip: (v, m, rec) => Ext.String.format(gettext("Change owner of '{0}'"), v), + isDisabled: (v, r, c, i, rec) => rec.parentNode.id !=='root', + }, { handler: 'onPrune', getTip: (v, m, rec) => Ext.String.format(gettext("Prune '{0}'"), v), diff --git a/www/Makefile b/www/Makefile index 99ea578e..0288b604 100644 --- a/www/Makefile +++ b/www/Makefile @@ -50,6 +50,7 @@ JSSRC= \ DataStorePrune.js \ DataStoreContent.js \ DataStorePanel.js \ + BackupGroupChangeOwner.js \ ServerStatus.js \ ServerAdministration.js \ Dashboard.js \ -- 2.20.1