]> git.proxmox.com Git - proxmox-widget-toolkit.git/commitdiff
add window/ZFSDetail
authorDominik Csapak <d.csapak@proxmox.com>
Thu, 25 Jun 2020 11:59:32 +0000 (13:59 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 25 Jun 2020 13:58:18 +0000 (15:58 +0200)
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@proxmox.com>
src/Makefile
src/window/ZFSDetail.js [new file with mode: 0644]

index f4f8bf5f3ea3a8d9ba46c36575e1801305daba61..12dda3062480069f5123e5206267866a3311e08d 100644 (file)
@@ -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 (file)
index 0000000..8eb6a87
--- /dev/null
@@ -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',
+               },
+           ],
+       },
+    ],
+});