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 31B546A52D for ; Fri, 26 Feb 2021 16:10:41 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 929E2188E4 for ; Fri, 26 Feb 2021 16:10:10 +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)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id BCF8018878 for ; Fri, 26 Feb 2021 16:10:07 +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 886BA45DDF for ; Fri, 26 Feb 2021 16:10:07 +0100 (CET) From: Fabian Ebner To: pbs-devel@lists.proxmox.com Date: Fri, 26 Feb 2021 16:09:56 +0100 Message-Id: <20210226150959.9518-8-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210226150959.9518-1-f.ebner@proxmox.com> References: <20210226150959.9518-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.000 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. [values.name] Subject: [pbs-devel] [PATCH v2 widget-toolkit 07/10] add UI for APT repositories 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: Fri, 26 Feb 2021 15:10:41 -0000 Signed-off-by: Fabian Ebner --- Changes from v1: * Make sure grid reloads when the tab is switched back and to the window, which is relevant for PBS. * Avoid extracting file type from path, now it's returned by the API. * Adapt to options being an array of key+values pairs. src/Makefile | 1 + src/node/APTRepositories.js | 145 ++++++++++++++++++++++++++++++++++++ 2 files changed, 146 insertions(+) create mode 100644 src/node/APTRepositories.js diff --git a/src/Makefile b/src/Makefile index 46b90ae..f172d55 100644 --- a/src/Makefile +++ b/src/Makefile @@ -54,6 +54,7 @@ JSSRC= \ window/DiskSmart.js \ window/ZFSDetail.js \ node/APT.js \ + node/APTRepositories.js \ node/NetworkEdit.js \ node/NetworkView.js \ node/DNSEdit.js \ diff --git a/src/node/APTRepositories.js b/src/node/APTRepositories.js new file mode 100644 index 0000000..0b21a8a --- /dev/null +++ b/src/node/APTRepositories.js @@ -0,0 +1,145 @@ +Ext.define('apt-repolist', { + extend: 'Ext.data.Model', + fields: [ + 'Path', + 'Number', + 'FileType', + 'Enabled', + 'Comment', + 'Types', + 'URIs', + 'Suites', + 'Components', + 'Options', + ], +}); + +Ext.define('Proxmox.node.APTRepositories', { + extend: 'Ext.grid.GridPanel', + + xtype: 'proxmoxNodeAPTRepositories', + + sortableColumns: false, + + columns: [ + { + header: gettext('Enabled'), + dataIndex: 'Enabled', + renderer: Proxmox.Utils.format_enabled_toggle, + width: 90, + }, + { + header: gettext('Types'), + dataIndex: 'Types', + renderer: function(options, cell, record) { + return record.data.Types.join(' '); + }, + width: 100, + }, + { + header: gettext('URIs'), + dataIndex: 'URIs', + renderer: function(options, cell, record) { + return record.data.URIs.join(' '); + }, + width: 350, + }, + { + header: gettext('Suites'), + dataIndex: 'Suites', + renderer: function(options, cell, record) { + return record.data.Suites.join(' '); + }, + width: 130, + }, + { + header: gettext('Components'), + dataIndex: 'Components', + renderer: function(options, cell, record) { + return record.data.Components.join(' '); + }, + width: 170, + }, + { + header: gettext('Options'), + dataIndex: 'Options', + renderer: function(options, cell, record) { + if (!options) { + return ''; + } + + let filetype = record.data.FileType; + let text = ''; + + options.forEach(function(option) { + let key = option.Key; + if (filetype === 'list') { + let values = option.Values.join(','); + text += `${key}=${values} `; + } else if (filetype === 'sources') { + let values = option.Values.join(' '); + text += `${key}: ${values}\n`; + } else { + throw "unkown file type"; + } + }); + return text; + }, + flex: 1, + }, + { + header: gettext('Comment'), + dataIndex: 'Comment', + flex: 1, + }, + ], + + initComponent: function() { + let me = this; + + if (!me.nodename) { + throw "no node name specified"; + } + + let store = Ext.create('Ext.data.Store', { + model: 'apt-repolist', + groupField: 'Path', + proxy: { + type: 'proxmox', + url: `/api2/json/nodes/${me.nodename}/apt/repositories`, + }, + sorters: [ + { + property: 'Number', + direction: 'ASC', + }, + ], + }); + + let groupingFeature = Ext.create('Ext.grid.feature.Grouping', { + groupHeaderTpl: '{[ "File: " + values.name ]} ({rows.length} ' + + 'repositor{[values.rows.length > 1 ? "ies" : "y"]})', + enableGroupingMenu: false, + }); + + let reload = function() { + store.load(); + }; + + let sm = Ext.create('Ext.selection.RowModel', {}); + + Ext.apply(me, { + store: store, + selModel: sm, + features: [groupingFeature], + listeners: { + activate: reload, + }, + }); + + Proxmox.Utils.monStoreErrors(me, store, true); + reload(); + + me.callParent(); + }, +}); -- 2.20.1