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 widget-toolkit 07/11] disk list: factor out renderers for type and usage
Date: Fri, 23 Apr 2021 12:14:57 +0200	[thread overview]
Message-ID: <20210423101501.27300-8-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210423101501.27300-1-f.ebner@proxmox.com>

to be re-used later.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
 src/panel/DiskList.js | 64 +++++++++++++++++++++++++------------------
 1 file changed, 37 insertions(+), 27 deletions(-)

diff --git a/src/panel/DiskList.js b/src/panel/DiskList.js
index ad965c8..10cf840 100644
--- a/src/panel/DiskList.js
+++ b/src/panel/DiskList.js
@@ -173,6 +173,39 @@ Ext.define('Proxmox.DiskList', {
 	},
     },
 
+    renderDiskType: function(v) {
+	if (v === undefined) return Proxmox.Utils.unknownText;
+	switch (v) {
+	    case 'ssd': return 'SSD';
+	    case 'hdd': return 'Hard Disk';
+	    case 'usb': return 'USB';
+	    default: return v;
+	}
+    },
+
+    renderDiskUsage: function(v, metaData, rec) {
+	let extendedInfo = '';
+	if (rec) {
+	    let types = [];
+	    if (rec.data.osdid !== undefined && rec.data.osdid >= 0) {
+		types.push(`OSD.${rec.data.osdid.toString()}`);
+	    }
+	    if (rec.data.journals > 0) {
+		types.push('Journal');
+	    }
+	    if (rec.data.db > 0) {
+		types.push('DB');
+	    }
+	    if (rec.data.wal > 0) {
+		types.push('WAL');
+	    }
+	    if (types.length > 0) {
+		extendedInfo = `, Ceph (${types.join(', ')})`;
+	    }
+	}
+	return v ? `${v}${extendedInfo}` : Proxmox.Utils.noText;
+    },
+
     tbar: [
 	{
 	    text: gettext('Reload'),
@@ -223,13 +256,8 @@ Ext.define('Proxmox.DiskList', {
 	    sortable: true,
 	    dataIndex: 'disk-type',
 	    renderer: function(v) {
-		if (v === undefined) return Proxmox.Utils.unknownText;
-		switch (v) {
-		    case 'ssd': return 'SSD';
-		    case 'hdd': return 'Hard Disk';
-		    case 'usb': return 'USB';
-		    default: return v;
-		}
+		let me = this;
+		return me.renderDiskType(v);
 	    },
 	},
 	{
@@ -237,26 +265,8 @@ Ext.define('Proxmox.DiskList', {
 	    width: 150,
 	    sortable: false,
 	    renderer: function(v, metaData, rec) {
-		let extendedInfo = '';
-		if (rec) {
-		    let types = [];
-		    if (rec.data.osdid !== undefined && rec.data.osdid >= 0) {
-			types.push(`OSD.${rec.data.osdid.toString()}`);
-		    }
-		    if (rec.data.journals > 0) {
-			types.push('Journal');
-		    }
-		    if (rec.data.db > 0) {
-			types.push('DB');
-		    }
-		    if (rec.data.wal > 0) {
-			types.push('WAL');
-		    }
-		    if (types.length > 0) {
-			extendedInfo = `, Ceph (${types.join(', ')})`;
-		    }
-		}
-		return v ? `${v}${extendedInfo}` : Proxmox.Utils.noText;
+		let me = this;
+		return me.renderDiskUsage(v, metaData, rec);
 	    },
 	    dataIndex: 'used',
 	},
-- 
2.20.1





  parent reply	other threads:[~2021-04-23 10:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-23 10:14 [pve-devel] [PATCH-SERIES storage/widget-toolkit/manager] Add wipe disk api call and button Fabian Ebner
2021-04-23 10:14 ` [pve-devel] [PATCH storage 01/11] diskmanage: add wipe_blockdev method Fabian Ebner
2021-04-23 10:14 ` [pve-devel] [PATCH storage 02/11] diskmanage: factor out mounted_blockdevs helper Fabian Ebner
2021-04-23 10:14 ` [pve-devel] [PATCH storage 03/11] diskmanage: add is_mounted method Fabian Ebner
2021-04-23 10:14 ` [pve-devel] [PATCH storage 04/11] diskmanage: add has_holder method Fabian Ebner
2021-04-23 10:14 ` [pve-devel] [PATCH storage 05/11] api: add wipedisk call Fabian Ebner
2021-04-23 10:14 ` [pve-devel] [PATCH widget-toolkit 06/11] disk list: fix minor usage renderer issue Fabian Ebner
2021-05-07 15:59   ` [pve-devel] applied: " Thomas Lamprecht
2021-04-23 10:14 ` Fabian Ebner [this message]
2021-05-07 15:59   ` [pve-devel] applied: [PATCH widget-toolkit 07/11] disk list: factor out renderers for type and usage Thomas Lamprecht
2021-04-23 10:14 ` [pve-devel] [PATCH widget-toolkit 08/11] disk list: move title bar initialization to initComponent Fabian Ebner
2021-04-23 10:14 ` [pve-devel] [PATCH widget-toolkit 09/11] disk list: add wipe disk button Fabian Ebner
2021-04-23 10:15 ` [pve-devel] [PATCH manager 10/11] ui: add task description for wipe disk Fabian Ebner
2021-04-23 10:15 ` [pve-devel] [PATCH manager 11/11] ui: disk list: enable wipe disk button Fabian Ebner
2021-06-02 12:17 ` [pve-devel] applied-partially: [PATCH-SERIES storage/widget-toolkit/manager] Add wipe disk api call and button Thomas Lamprecht
2021-06-02 14:43 ` [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=20210423101501.27300-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