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 735C875249 for ; Wed, 23 Jun 2021 15:39:44 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 69A3EB6B1 for ; Wed, 23 Jun 2021 15:39:14 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C2264B65A for ; Wed, 23 Jun 2021 15:39:11 +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 8DC5F4672E for ; Wed, 23 Jun 2021 15:39:11 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 23 Jun 2021 15:39:00 +0200 Message-Id: <20210623133904.174072-8-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210623133904.174072-1-f.ebner@proxmox.com> References: <20210623133904.174072-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.681 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 Subject: [pve-devel] [PATCH v7 proxmox-widget-toolkit 2/2] add buttons for add/enable/disable X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jun 2021 13:39:44 -0000 Signed-off-by: Fabian Ebner --- New in v7. src/node/APTRepositories.js | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js index 30c31ec..2121a0f 100644 --- a/src/node/APTRepositories.js +++ b/src/node/APTRepositories.js @@ -63,6 +63,46 @@ Ext.define('Proxmox.node.APTRepositoriesGrid', { me.up('proxmoxNodeAPTRepositories').reload(); }, }, + { + text: gettext('Add'), + menu: { + plain: true, + itemId: "addMenu", + items: [], + }, + }, + { + xtype: 'proxmoxButton', + text: gettext('Enable') + '/' + gettext('Disable'), + disabled: true, + handler: function(button, event, record) { + let me = this; + let panel = me.up('proxmoxNodeAPTRepositories'); + + let params = { + path: record.data.Path, + index: record.data.Index, + enabled: record.data.Enabled ? 0 : 1, // invert + }; + + if (panel.digest !== undefined) { + params.digest = panel.digest; + } + + Proxmox.Utils.API2Request({ + url: `/nodes/${panel.nodename}/apt/repositories`, + method: 'POST', + params: params, + failure: function(response, opts) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + panel.reload(); + }, + success: function(response, opts) { + panel.reload(); + }, + }); + }, + }, ], sortableColumns: false, @@ -340,6 +380,9 @@ Ext.define('Proxmox.node.APTRepositories', { let me = this; let vm = me.getViewModel(); + let menu = me.down('#addMenu'); + menu.removeAll(); + for (const standardRepo of standardRepos) { const handle = standardRepo.handle; const status = standardRepo.status; @@ -349,6 +392,43 @@ Ext.define('Proxmox.node.APTRepositories', { } else if (handle === "no-subscription") { vm.set('noSubscriptionRepo', status); } + + let status_text = ''; + if (status !== undefined && status !== null) { + status_text = Ext.String.format( + ' ({0}, {1})', + gettext('configured'), + status ? gettext('enabled') : gettext('disabled'), + ); + } + + menu.add({ + text: standardRepo.name + status_text, + disabled: status !== undefined && status !== null, + repoHandle: handle, + handler: function(menuItem) { + let params = { + handle: menuItem.repoHandle, + }; + + if (me.digest !== undefined) { + params.digest = me.digest; + } + + Proxmox.Utils.API2Request({ + url: `/nodes/${me.nodename}/apt/repositories`, + method: 'PUT', + params: params, + failure: function(response, opts) { + Ext.Msg.alert(gettext('Error'), response.htmlStatus); + me.reload(); + }, + success: function(response, opts) { + me.reload(); + }, + }); + }, + }); } }, -- 2.30.2