[pve-devel] [PATCH widget-toolkit 3/3] add window/ZFSDetail

Dominik Csapak d.csapak at proxmox.com
Thu Jun 25 13:59:32 CEST 2020


inspired by pve's detail window, which used two sub components
(ZFSStatus, ZFSDevices; which were never used elsewhere)
combined into one self-contained window

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 src/Makefile            |   1 +
 src/window/ZFSDetail.js | 152 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 153 insertions(+)
 create mode 100644 src/window/ZFSDetail.js

diff --git a/src/Makefile b/src/Makefile
index f4f8bf5..12dda30 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -46,6 +46,7 @@ JSSRC=					\
 	window/TaskViewer.js		\
 	window/LanguageEdit.js		\
 	window/DiskSmart.js		\
+	window/ZFSDetail.js		\
 	node/APT.js			\
 	node/NetworkEdit.js		\
 	node/NetworkView.js		\
diff --git a/src/window/ZFSDetail.js b/src/window/ZFSDetail.js
new file mode 100644
index 0000000..8eb6a87
--- /dev/null
+++ b/src/window/ZFSDetail.js
@@ -0,0 +1,152 @@
+Ext.define('Proxmox.window.ZFSDetail', {
+    extend: 'Ext.window.Window',
+    alias: 'widget.pmxZFSDetail',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    cbindData: function(initialConfig) {
+	let me = this;
+	me.url = `/nodes/${me.nodename}/disks/zfs/${encodeURIComponent(me.zpool)}`;
+	return {
+	    zpoolUri: `/api2/json/${me.url}`,
+	    title: `${gettext('Status')}: ${me.zpool}`,
+	};
+    },
+
+    controller: {
+	xclass: 'Ext.app.ViewController',
+
+	reload: function() {
+	    let me = this;
+	    let view = me.getView();
+	    me.lookup('status').reload();
+
+	    Proxmox.Utils.API2Request({
+		url: `/api2/extjs/${view.url}`,
+		waitMsgTarget: view,
+		method: 'GET',
+		failure: function(response, opts) {
+		    Proxmox.Utils.setErrorMask(view, response.htmlStatus);
+		},
+		success: function(response, opts) {
+		    let devices = me.lookup('devices');
+		    devices.getSelectionModel().deselectAll();
+		    devices.setRootNode(response.result.data);
+		    devices.expandAll();
+		},
+	    });
+	},
+
+	init: function(view) {
+	    let me = this;
+	    Proxmox.Utils.monStoreErrors(me, me.lookup('status').getStore().rstore);
+	    me.reload();
+	},
+    },
+
+    modal: true,
+    width: 800,
+    height: 400,
+    resizable: true,
+    cbind: {
+	title: '{title}',
+    },
+
+    layout: {
+	type: 'vbox',
+	align: 'stretch',
+    },
+    defaults: {
+	layout: 'fit',
+	border: false,
+    },
+
+    tbar: [
+	{
+	    text: gettext('Reload'),
+	    iconCls: 'fa fa-refresh',
+	    handler: 'reload',
+	},
+    ],
+
+    items: [
+	{
+	    xtype: 'proxmoxObjectGrid',
+	    reference: 'status',
+	    flex: 0,
+	    cbind: {
+		url: '{zpoolUri}',
+		nodename: '{nodename}',
+	    },
+	    rows: {
+		scan: {
+		    header: gettext('Scan'),
+		},
+		status: {
+		    header: gettext('Status'),
+		},
+		action: {
+		    header: gettext('Action'),
+		},
+		errors: {
+		    header: gettext('Errors'),
+		},
+	    },
+	},
+	{
+	    xtype: 'treepanel',
+	    reference: 'devices',
+	    title: gettext('Devices'),
+	    stateful: true,
+	    stateId: 'grid-node-zfsstatus',
+	    rootVisible: true,
+	    fields: ['name', 'status',
+		{
+		    type: 'string',
+		    name: 'iconCls',
+		    calculate: function(data) {
+			var txt = 'fa x-fa-tree fa-';
+			if (data.leaf) {
+			    return txt + 'hdd-o';
+			}
+			return undefined;
+		    },
+		},
+	    ],
+	    sorters: 'name',
+	    flex: 1,
+	    cbind: {
+		zpool: '{zpoolUri}',
+		nodename: '{nodename}',
+	    },
+	    columns: [
+		{
+		    xtype: 'treecolumn',
+		    text: gettext('Name'),
+		    dataIndex: 'name',
+		    flex: 1,
+		},
+		{
+		    text: gettext('Health'),
+		    renderer: Proxmox.Utils.render_zfs_health,
+		    dataIndex: 'state',
+		},
+		{
+		    text: 'READ',
+		    dataIndex: 'read',
+		},
+		{
+		    text: 'WRITE',
+		    dataIndex: 'write',
+		},
+		{
+		    text: 'CKSUM',
+		    dataIndex: 'cksum',
+		},
+		{
+		    text: gettext('Message'),
+		    dataIndex: 'msg',
+		},
+	    ],
+	},
+    ],
+});
-- 
2.20.1





More information about the pve-devel mailing list