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 18EDC76810 for ; Tue, 19 Oct 2021 11:34:05 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 77CCC2B2A9 for ; Tue, 19 Oct 2021 11:34:04 +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 709592AF37 for ; Tue, 19 Oct 2021 11:33:56 +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 17993468D0 for ; Tue, 19 Oct 2021 11:33:56 +0200 (CEST) From: Dominik Csapak To: pve-devel@lists.proxmox.com Date: Tue, 19 Oct 2021 11:33:47 +0200 Message-Id: <20211019093353.2451987-7-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211019093353.2451987-1-d.csapak@proxmox.com> References: <20211019093353.2451987-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.287 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 manager 05/11] ui: ceph/ServiceList: refactor controller out 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: Tue, 19 Oct 2021 09:34:05 -0000 we want to reuse that controller type by overriding some functionality in the future, so factor it out. Signed-off-by: Dominik Csapak --- www/manager6/ceph/ServiceList.js | 302 ++++++++++++++++--------------- 1 file changed, 153 insertions(+), 149 deletions(-) diff --git a/www/manager6/ceph/ServiceList.js b/www/manager6/ceph/ServiceList.js index 86cdcc8f..d5ba2efa 100644 --- a/www/manager6/ceph/ServiceList.js +++ b/www/manager6/ceph/ServiceList.js @@ -44,172 +44,176 @@ Ext.define('PVE.CephCreateService', { }, }); -Ext.define('PVE.node.CephServiceList', { - extend: 'Ext.grid.GridPanel', - xtype: 'pveNodeCephServiceList', - - onlineHelp: 'chapter_pveceph', - emptyText: gettext('No such service configured.'), - - stateful: true, +Ext.define('PVE.node.CephServiceController', { + extend: 'Ext.app.ViewController', + alias: 'controller.CephServiceList', - // will be called when the store loads - storeLoadCallback: Ext.emptyFn, - // if set to true, does shows the ceph install mask if needed - showCephInstallMask: false, + render_version: function(value, metadata, rec) { + if (value === undefined) { + return ''; + } + let view = this.getView(); + let host = rec.data.host, nodev = [0]; + if (view.nodeversions[host] !== undefined) { + nodev = view.nodeversions[host].version.parts; + } - controller: { - xclass: 'Ext.app.ViewController', + let icon = ''; + if (PVE.Utils.compare_ceph_versions(view.maxversion, nodev) > 0) { + icon = PVE.Utils.get_ceph_icon_html('HEALTH_UPGRADE'); + } else if (PVE.Utils.compare_ceph_versions(nodev, value) > 0) { + icon = PVE.Utils.get_ceph_icon_html('HEALTH_OLD'); + } else if (view.mixedversions) { + icon = PVE.Utils.get_ceph_icon_html('HEALTH_OK'); + } + return icon + value; + }, - render_version: function(value, metadata, rec) { - if (value === undefined) { - return ''; + getMaxVersions: function(store, records, success) { + if (!success || records.length < 1) { + return; + } + let me = this; + let view = me.getView(); + + view.nodeversions = records[0].data.node; + view.maxversion = []; + view.mixedversions = false; + for (const [_nodename, data] of Object.entries(view.nodeversions)) { + let res = PVE.Utils.compare_ceph_versions(data.version.parts, view.maxversion); + if (res !== 0 && view.maxversion.length > 0) { + view.mixedversions = true; } - let view = this.getView(); - let host = rec.data.host, nodev = [0]; - if (view.nodeversions[host] !== undefined) { - nodev = view.nodeversions[host].version.parts; + if (res > 0) { + view.maxversion = data.version.parts; } + } + }, - let icon = ''; - if (PVE.Utils.compare_ceph_versions(view.maxversion, nodev) > 0) { - icon = PVE.Utils.get_ceph_icon_html('HEALTH_UPGRADE'); - } else if (PVE.Utils.compare_ceph_versions(nodev, value) > 0) { - icon = PVE.Utils.get_ceph_icon_html('HEALTH_OLD'); - } else if (view.mixedversions) { - icon = PVE.Utils.get_ceph_icon_html('HEALTH_OK'); - } - return icon + value; - }, + init: function(view) { + if (view.pveSelNode) { + view.nodename = view.pveSelNode.data.node; + } + if (!view.nodename) { + throw "no node name specified"; + } - getMaxVersions: function(store, records, success) { - if (!success || records.length < 1) { - return; - } - let me = this; - let view = me.getView(); - - view.nodeversions = records[0].data.node; - view.maxversion = []; - view.mixedversions = false; - for (const [_nodename, data] of Object.entries(view.nodeversions)) { - let res = PVE.Utils.compare_ceph_versions(data.version.parts, view.maxversion); - if (res !== 0 && view.maxversion.length > 0) { - view.mixedversions = true; - } - if (res > 0) { - view.maxversion = data.version.parts; - } - } - }, + if (!view.type) { + throw "no type specified"; + } - init: function(view) { - if (view.pveSelNode) { - view.nodename = view.pveSelNode.data.node; - } - if (!view.nodename) { - throw "no node name specified"; - } + view.versionsstore = Ext.create('Proxmox.data.UpdateStore', { + autoStart: true, + interval: 10000, + storeid: `ceph-versions-${view.type}-list${view.nodename}`, + proxy: { + type: 'proxmox', + url: "/api2/json/cluster/ceph/metadata?scope=versions", + }, + }); + view.versionsstore.on('load', this.getMaxVersions, this); + view.on('destroy', view.versionsstore.stopUpdate); + + view.rstore = Ext.create('Proxmox.data.UpdateStore', { + autoStart: true, + interval: 3000, + storeid: `ceph-${view.type}-list${view.nodename}`, + model: 'ceph-service-list', + proxy: { + type: 'proxmox', + url: `/api2/json/nodes/${view.nodename}/ceph/${view.type}`, + }, + }); - if (!view.type) { - throw "no type specified"; - } + view.setStore(Ext.create('Proxmox.data.DiffStore', { + rstore: view.rstore, + sorters: [{ property: 'name' }], + })); - view.versionsstore = Ext.create('Proxmox.data.UpdateStore', { - autoStart: true, - interval: 10000, - storeid: `ceph-versions-${view.type}-list${view.nodename}`, - proxy: { - type: 'proxmox', - url: "/api2/json/cluster/ceph/metadata?scope=versions", - }, - }); - view.versionsstore.on('load', this.getMaxVersions, this); - view.on('destroy', view.versionsstore.stopUpdate); - - view.rstore = Ext.create('Proxmox.data.UpdateStore', { - autoStart: true, - interval: 3000, - storeid: `ceph-${view.type}-list${view.nodename}`, - model: 'ceph-service-list', - proxy: { - type: 'proxmox', - url: `/api2/json/nodes/${view.nodename}/ceph/${view.type}`, - }, - }); + if (view.storeLoadCallback) { + view.rstore.on('load', view.storeLoadCallback, this); + } + view.on('destroy', view.rstore.stopUpdate); - view.setStore(Ext.create('Proxmox.data.DiffStore', { - rstore: view.rstore, - sorters: [{ property: 'name' }], - })); + if (view.showCephInstallMask) { + PVE.Utils.monitor_ceph_installed(view, view.rstore, view.nodename, true); + } + }, - if (view.storeLoadCallback) { - view.rstore.on('load', view.storeLoadCallback, this); - } - view.on('destroy', view.rstore.stopUpdate); + service_cmd: function(rec, cmd) { + let view = this.getView(); + if (!rec.data.host) { + Ext.Msg.alert(gettext('Error'), "entry has no host"); + return; + } + Proxmox.Utils.API2Request({ + url: `/nodes/${rec.data.host}/ceph/${cmd}`, + method: 'POST', + params: { service: view.type + '.' + rec.data.name }, + success: function(response, options) { + Ext.create('Proxmox.window.TaskProgress', { + autoShow: true, + upid: response.result.data, + taskDone: () => view.rstore.load(), + }); + }, + failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus), + }); + }, + onChangeService: function(button) { + let me = this; + let record = me.getView().getSelection()[0]; + me.service_cmd(record, button.action); + }, - if (view.showCephInstallMask) { - PVE.Utils.monitor_ceph_installed(view, view.rstore, view.nodename, true); - } - }, + showSyslog: function() { + let view = this.getView(); + let rec = view.getSelection()[0]; + let service = `ceph-${view.type}@${rec.data.name}`; + Ext.create('Ext.window.Window', { + title: `${gettext('Syslog')}: ${service}`, + autoShow: true, + modal: true, + width: 800, + height: 400, + layout: 'fit', + items: [{ + xtype: 'proxmoxLogView', + url: `/api2/extjs/nodes/${rec.data.host}/syslog?service=${encodeURIComponent(service)}`, + log_select_timespan: 1, + }], + }); + }, - service_cmd: function(rec, cmd) { - let view = this.getView(); - if (!rec.data.host) { - Ext.Msg.alert(gettext('Error'), "entry has no host"); - return; - } - Proxmox.Utils.API2Request({ - url: `/nodes/${rec.data.host}/ceph/${cmd}`, - method: 'POST', - params: { service: view.type + '.' + rec.data.name }, - success: function(response, options) { - Ext.create('Proxmox.window.TaskProgress', { - autoShow: true, - upid: response.result.data, - taskDone: () => view.rstore.load(), - }); - }, - failure: (response, _opts) => Ext.Msg.alert(gettext('Error'), response.htmlStatus), - }); - }, - onChangeService: function(button) { - let me = this; - let record = me.getView().getSelection()[0]; - me.service_cmd(record, button.action); - }, + onCreate: function() { + let view = this.getView(); + Ext.create('PVE.CephCreateService', { + autoShow: true, + nodename: view.nodename, + subject: view.getTitle(), + type: view.type, + taskDone: () => view.rstore.load(), + }); + }, +}); - showSyslog: function() { - let view = this.getView(); - let rec = view.getSelection()[0]; - let service = `ceph-${view.type}@${rec.data.name}`; - Ext.create('Ext.window.Window', { - title: `${gettext('Syslog')}: ${service}`, - autoShow: true, - modal: true, - width: 800, - height: 400, - layout: 'fit', - items: [{ - xtype: 'proxmoxLogView', - url: `/api2/extjs/nodes/${rec.data.host}/syslog?service=${encodeURIComponent(service)}`, - log_select_timespan: 1, - }], - }); - }, +Ext.define('PVE.node.CephServiceList', { + extend: 'Ext.grid.GridPanel', + xtype: 'pveNodeCephServiceList', - onCreate: function() { - let view = this.getView(); - Ext.create('PVE.CephCreateService', { - autoShow: true, - nodename: view.nodename, - subject: view.getTitle(), - type: view.type, - taskDone: () => view.rstore.load(), - }); - }, - }, + onlineHelp: 'chapter_pveceph', + emptyText: gettext('No such service configured.'), + + stateful: true, + + // will be called when the store loads + storeLoadCallback: Ext.emptyFn, + + // if set to true, does shows the ceph install mask if needed + showCephInstallMask: false, + + controller: 'CephServiceList', tbar: [ { -- 2.30.2