public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v7 proxmox-widget-toolkit 2/2] add buttons for add/enable/disable
Date: Wed, 23 Jun 2021 15:39:00 +0200	[thread overview]
Message-ID: <20210623133904.174072-8-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210623133904.174072-1-f.ebner@proxmox.com>

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

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





  parent reply	other threads:[~2021-06-23 13:39 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-23 13:38 [pve-devel] [PATCH-SERIES v7] APT repositories API/UI Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 1/5] initial commit Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 2/5] add files for Debian packaging Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 3/5] add more functions to check repositories Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 4/5] add handling of Proxmox standard repositories Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-apt 5/5] bump version to 0.2.0-1 Fabian Ebner
2021-06-23 13:38 ` [pve-devel] [PATCH v7 proxmox-widget-toolkit 1/2] add UI for APT repositories Fabian Ebner
2021-06-23 13:39 ` Fabian Ebner [this message]
2021-06-23 13:39 ` [pve-devel] [PATCH v7 pve-rs 1/1] add bindings for proxmox-apt Fabian Ebner
2021-06-30 19:17   ` [pve-devel] applied: " Thomas Lamprecht
2021-06-23 13:39 ` [pve-devel] [PATCH v7 pve-manager 1/3] api: apt: add call for repository information Fabian Ebner
2021-06-23 13:39 ` [pve-devel] [PATCH v7 pve-manager 2/3] api: apt: add PUT and POST handler for repositories Fabian Ebner
2021-06-23 13:39 ` [pve-devel] [PATCH v7 pve-manager 3/3] ui: add panel for listing APT repositories Fabian Ebner
2021-06-23 18:02 ` [pve-devel] partially-applied: [PATCH-SERIES v7] APT repositories API/UI Thomas Lamprecht
2021-07-05  6:51 ` [pve-devel] applied-series: " Thomas Lamprecht

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=20210623133904.174072-8-f.ebner@proxmox.com \
    --to=f.ebner@proxmox.com \
    --cc=pve-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