[pve-devel] [PATCH manager 1/4] move DiskSelector to its own file, for generic use

Dominik Csapak d.csapak at proxmox.com
Mon Jul 30 10:26:07 CEST 2018


also set the default diskType to undefined and
change the api endpoint to /nodes/NODE/disks/list

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 www/manager6/Makefile             |  1 +
 www/manager6/ceph/OSD.js          | 79 +--------------------------------------
 www/manager6/form/DiskSelector.js | 79 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 82 insertions(+), 77 deletions(-)
 create mode 100644 www/manager6/form/DiskSelector.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 3cc6990f..eb36800f 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -30,6 +30,7 @@ JSSRC= 				                 	\
 	form/MemoryField.js				\
 	form/NetworkCardSelector.js			\
 	form/DiskFormatSelector.js			\
+	form/DiskSelector.js				\
 	form/BusTypeSelector.js				\
 	form/ControllerSelector.js			\
 	form/EmailNotificationSelector.js		\
diff --git a/www/manager6/ceph/OSD.js b/www/manager6/ceph/OSD.js
index 684c7f30..8fe7e794 100644
--- a/www/manager6/ceph/OSD.js
+++ b/www/manager6/ceph/OSD.js
@@ -1,78 +1,3 @@
-Ext.define('PVE.form.CephDiskSelector', {
-    extend: 'Proxmox.form.ComboGrid',
-    alias: ['widget.pveCephDiskSelector'],
-
-    diskType: 'journal_disks',
-
-    valueField: 'devpath',
-    displayField: 'devpath',
-    emptyText: gettext('No Disks unused'),
-    listConfig: {
-	columns: [
-	    {
-		header: gettext('Device'),
-		width: 80,
-		sortable: true,
-		dataIndex: 'devpath'
-	    },
-	    {
-		header: gettext('Size'),
-		width: 60,
-		sortable: false,
-		renderer: Proxmox.Utils.format_size,
-		dataIndex: 'size'
-	    },
-	    {
-		header: gettext('Serial'),
-		flex: 1,
-		sortable: true,
-		dataIndex: 'serial'
-	    }
-	]
-    },
-    initComponent: function() {
-	var me = this;
-
-	var nodename = me.nodename;
-	if (!nodename) {
-	    throw "no node name specified";
-	}
-
-	var store = Ext.create('Ext.data.Store', {
-	    filterOnLoad: true,
-	    model: 'ceph-disk-list',
-	    proxy: {
-                type: 'proxmox',
-                url: "/api2/json/nodes/" + nodename + "/ceph/disks",
-		extraParams: { type: me.diskType }
-	    },
-	    sorters: [
-		{
-		    property : 'devpath',
-		    direction: 'ASC'
-		}
-	    ]
-	});
-
-	Ext.apply(me, {
-	    store: store
-	});
-
-        me.callParent();
-
-	store.load();
-    }
-}, function() {
-
-    Ext.define('ceph-disk-list', {
-	extend: 'Ext.data.Model',
-	fields: [ 'devpath', 'used', { name: 'size', type: 'number'},
-		  {name: 'osdid', type: 'number'},
-		  'vendor', 'model', 'serial'],
-	idProperty: 'devpath'
-    });
-});
-
 Ext.define('PVE.CephCreateOsd', {
     extend: 'Proxmox.window.Edit',
     alias: ['widget.pveCephCreateOsd'],
@@ -97,7 +22,7 @@ Ext.define('PVE.CephCreateOsd', {
 	    method: 'POST',
 	    items: [
 		{
-		    xtype: 'pveCephDiskSelector',
+		    xtype: 'pveDiskSelector',
 		    name: 'dev',
 		    nodename: me.nodename,
 		    diskType: 'unused',
@@ -105,7 +30,7 @@ Ext.define('PVE.CephCreateOsd', {
 		    allowBlank: false
 		},
 		{
-		    xtype: 'pveCephDiskSelector',
+		    xtype: 'pveDiskSelector',
 		    name: 'journal_dev',
 		    nodename: me.nodename,
 		    diskType: 'journal_disks',
diff --git a/www/manager6/form/DiskSelector.js b/www/manager6/form/DiskSelector.js
new file mode 100644
index 00000000..177b6c2f
--- /dev/null
+++ b/www/manager6/form/DiskSelector.js
@@ -0,0 +1,79 @@
+Ext.define('PVE.form.DiskSelector', {
+    extend: 'Proxmox.form.ComboGrid',
+    xtype: 'pveDiskSelector',
+
+    // can be
+    // undefined: all
+    // unused: only unused
+    // journal_disk: all disks with gpt
+    diskType: undefined,
+
+    valueField: 'devpath',
+    displayField: 'devpath',
+    emptyText: gettext('No Disks unused'),
+    listConfig: {
+	columns: [
+	    {
+		header: gettext('Device'),
+		width: 80,
+		sortable: true,
+		dataIndex: 'devpath'
+	    },
+	    {
+		header: gettext('Size'),
+		width: 60,
+		sortable: false,
+		renderer: Proxmox.Utils.format_size,
+		dataIndex: 'size'
+	    },
+	    {
+		header: gettext('Serial'),
+		flex: 1,
+		sortable: true,
+		dataIndex: 'serial'
+	    }
+	]
+    },
+
+    initComponent: function() {
+	var me = this;
+
+	var nodename = me.nodename;
+	if (!nodename) {
+	    throw "no node name specified";
+	}
+
+	var store = Ext.create('Ext.data.Store', {
+	    filterOnLoad: true,
+	    model: 'pve-disk-list',
+	    proxy: {
+                type: 'proxmox',
+                url: "/api2/json/nodes/" + nodename + "/disks/list",
+		extraParams: { type: me.diskType }
+	    },
+	    sorters: [
+		{
+		    property : 'devpath',
+		    direction: 'ASC'
+		}
+	    ]
+	});
+
+	Ext.apply(me, {
+	    store: store
+	});
+
+        me.callParent();
+
+	store.load();
+    }
+}, function() {
+
+    Ext.define('pve-disk-list', {
+	extend: 'Ext.data.Model',
+	fields: [ 'devpath', 'used', { name: 'size', type: 'number'},
+		  {name: 'osdid', type: 'number'},
+		  'vendor', 'model', 'serial'],
+	idProperty: 'devpath'
+    });
+});
-- 
2.11.0





More information about the pve-devel mailing list