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 57930712EB for ; Wed, 8 Jun 2022 14:22:46 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 88A707DCA for ; Wed, 8 Jun 2022 14:22:45 +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 5FBB37CE9 for ; Wed, 8 Jun 2022 14:22:40 +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 3778E42FB8 for ; Wed, 8 Jun 2022 14:22:40 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Wed, 8 Jun 2022 14:22:38 +0200 Message-Id: <20220608122238.3490889-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220608122238.3490889-1-d.csapak@proxmox.com> References: <20220608122238.3490889-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.104 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 T_SCC_BODY_TEXT_LINE -0.01 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [data.name] Subject: [pbs-devel] [PATCH proxmox-backup v8 7/7] ui: add MetricServerView and use it 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: Wed, 08 Jun 2022 12:22:46 -0000 simple CRUD interface to show/add/edit/delete metric servers it's a bit different from PVE's so that it's harder to reuse that to copy it. If we need it again, we can still refactor and combine them. introduce 'PBS.Schema' class to hold the server type/xtype mappings Signed-off-by: Dominik Csapak --- www/Makefile | 2 + www/Schema.js | 15 ++++ www/SystemConfiguration.js | 6 ++ www/config/MetricServerView.js | 128 +++++++++++++++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 www/Schema.js create mode 100644 www/config/MetricServerView.js diff --git a/www/Makefile b/www/Makefile index 3a36daba..4aa2b026 100644 --- a/www/Makefile +++ b/www/Makefile @@ -36,6 +36,7 @@ TAPE_UI_FILES= \ JSSRC= \ Utils.js \ + Schema.js \ form/TokenSelector.js \ form/AuthidSelector.js \ form/RemoteSelector.js \ @@ -62,6 +63,7 @@ JSSRC= \ config/WebauthnView.js \ config/CertificateView.js \ config/NodeOptionView.js \ + config/MetricServerView.js \ window/ACLEdit.js \ window/BackupFileDownloader.js \ window/BackupGroupChangeOwner.js \ diff --git a/www/Schema.js b/www/Schema.js new file mode 100644 index 00000000..dcd47a4a --- /dev/null +++ b/www/Schema.js @@ -0,0 +1,15 @@ +Ext.define('PBS.Schema', { + + singleton: true, + + metricServer: { + 'influxdb-http': { + type: 'InfluxDB (HTTP)', + xtype: 'InfluxDbHttp', + }, + 'influxdb-udp': { + type: 'InfluxDB (UDP)', + xtype: 'InfluxDbUdp', + }, + }, +}); diff --git a/www/SystemConfiguration.js b/www/SystemConfiguration.js index cdc9de35..ddb6ece5 100644 --- a/www/SystemConfiguration.js +++ b/www/SystemConfiguration.js @@ -45,6 +45,12 @@ Ext.define('PBS.SystemConfiguration', { }, ], }, + { + title: gettext('Metric Server'), + iconCls: 'fa fa-bar-chart', + xtype: 'pbsMetricServerView', + itemId: 'metrics', + }, { xtype: 'panel', title: gettext('Other'), diff --git a/www/config/MetricServerView.js b/www/config/MetricServerView.js new file mode 100644 index 00000000..11ae16d7 --- /dev/null +++ b/www/config/MetricServerView.js @@ -0,0 +1,128 @@ +Ext.define('PBS.config.MetricServerView', { + extend: 'Ext.grid.Panel', + alias: ['widget.pbsMetricServerView'], + + stateful: true, + stateId: 'grid-metricserver', + + controller: { + xclass: 'Ext.app.ViewController', + + editWindow: function(xtype, id) { + let me = this; + Ext.create(`PBS.window.${xtype}Edit`, { + serverid: id, + autoShow: true, + autoLoad: true, + listeners: { + destroy: () => me.reload(), + }, + }); + }, + + addServer: function(button) { + this.editWindow(PBS.Schema.metricServer[button.type]?.xtype); + }, + + editServer: function() { + let me = this; + let view = me.getView(); + let selection = view.getSelection(); + if (!selection || selection.length < 1) { + return; + } + + let cfg = selection[0].data; + + me.editWindow(PBS.Schema.metricServer[cfg.type]?.xtype, cfg.name); + }, + + reload: function() { + this.getView().getStore().load(); + }, + }, + + store: { + autoLoad: true, + id: 'metricservers', + proxy: { + type: 'proxmox', + url: '/api2/json/admin/metrics', + }, + }, + + columns: [ + { + text: gettext('Name'), + flex: 2, + dataIndex: 'name', + }, + { + text: gettext('Type'), + width: 150, + dataIndex: 'type', + renderer: (v) => PBS.Schema.metricServer[v]?.type ?? v, + }, + { + text: gettext('Enabled'), + dataIndex: 'disable', + width: 100, + renderer: Proxmox.Utils.format_neg_boolean, + }, + { + text: gettext('Target Server'), + width: 200, + dataIndex: 'server', + }, + { + text: gettext('Comment'), + flex: 3, + dataIndex: 'comment', + renderer: Ext.htmlEncode, + }, + ], + + tbar: [ + { + text: gettext('Add'), + menu: [ + { + text: 'InfluxDB (HTTP)', + type: 'influxdb-http', + iconCls: 'fa fa-fw fa-bar-chart', + handler: 'addServer', + }, + { + text: 'InfluxDB (UDP)', + type: 'influxdb-udp', + iconCls: 'fa fa-fw fa-bar-chart', + handler: 'addServer', + }, + ], + }, + { + text: gettext('Edit'), + xtype: 'proxmoxButton', + handler: 'editServer', + disabled: true, + }, + { + xtype: 'proxmoxStdRemoveButton', + getUrl: (rec) => `/api2/extjs/config/metrics/${rec.data.type}/${rec.data.name}`, + getRecordName: (rec) => rec.data.name, + callback: 'reload', + }, + ], + + listeners: { + itemdblclick: 'editServer', + }, + + initComponent: function() { + var me = this; + + me.callParent(); + + Proxmox.Utils.monStoreErrors(me, me.getStore()); + }, +}); -- 2.30.2