[pve-devel] r6333 - in pve-manager/pve2: . www/manager www/manager/dc www/manager/form www/manager/qemu www/manager/storage

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jul 20 12:40:23 CEST 2011


Author: dietmar
Date: 2011-07-20 12:40:23 +0200 (Wed, 20 Jul 2011)
New Revision: 6333

Added:
   pve-manager/pve2/www/manager/form/ContentTypeSelector.js
   pve-manager/pve2/www/manager/storage/DirEdit.js
Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/www/manager/Makefile.am
   pve-manager/pve2/www/manager/dc/StorageView.js
   pve-manager/pve2/www/manager/form/Checkbox.js
   pve-manager/pve2/www/manager/qemu/HardwareView.js
Log:
	* www/manager/storage/DirEdit.js: impl.

	* www/manager/form/ContentTypeSelector.js: impl.

	* www/manager/dc/StorageView.js: impl. Add/Remove/Edit buttons



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-07-20 10:28:38 UTC (rev 6332)
+++ pve-manager/pve2/ChangeLog	2011-07-20 10:40:23 UTC (rev 6333)
@@ -1,5 +1,11 @@
 2011-07-20  Proxmox Support Team  <support at proxmox.com>
 
+	* www/manager/storage/DirEdit.js: impl.
+
+	* www/manager/form/ContentTypeSelector.js: impl.
+
+	* www/manager/dc/StorageView.js: impl. Add/Remove/Edit buttons
+
 	* www/manager/grid/ResourceGrid.js (gather_child_nodes): only
 	include real children.
 

Modified: pve-manager/pve2/www/manager/Makefile.am
===================================================================
--- pve-manager/pve2/www/manager/Makefile.am	2011-07-20 10:28:38 UTC (rev 6332)
+++ pve-manager/pve2/www/manager/Makefile.am	2011-07-20 10:40:23 UTC (rev 6333)
@@ -18,7 +18,7 @@
 	form/RRDTypeSelector.js				\
 	form/ComboGrid.js				\
 	form/KVComboBox.js				\
-	form/Boolean.js				\
+	form/Boolean.js					\
 	form/NetworkCardSelector.js			\
 	form/DiskFormatSelector.js			\
 	form/BusTypeSelector.js				\
@@ -34,6 +34,7 @@
 	form/VNCKeyboardSelector.js			\
 	form/DisplaySelector.js				\
 	form/CacheTypeSelector.js			\
+	form/ContentTypeSelector.js			\
 	dc/Tasks.js					\
 	dc/Log.js					\
 	panel/StatusPanel.js				\
@@ -82,6 +83,7 @@
 	storage/StatusView.js				\
 	storage/Summary.js				\
 	storage/Browser.js				\
+	storage/DirEdit.js				\
 	dc/StorageView.js				\
 	dc/UserEdit.js					\
 	dc/UserView.js					\

Modified: pve-manager/pve2/www/manager/dc/StorageView.js
===================================================================
--- pve-manager/pve2/www/manager/dc/StorageView.js	2011-07-20 10:28:38 UTC (rev 6332)
+++ pve-manager/pve2/www/manager/dc/StorageView.js	2011-07-20 10:40:23 UTC (rev 6333)
@@ -18,13 +18,125 @@
 	    }
 	});
 
+	var reload = function() {
+	    store.load();
+	}
 
+	var run_editor = function() {
+	    var sm = me.getSelectionModel();
+	    var rec = sm.getSelection()[0];
+	    if (!rec) {
+		return;
+	    }
+	    var type = rec.data.type;
+	    
+	    var editor;
+	    if (type === 'dir') {
+		editor = 'PVE.storage.DirEdit';
+	    } else {
+		return;
+	    }
+	    var win = Ext.create(editor, {
+		storageId: rec.data.storage,
+	    });
+
+	    win.show();
+	    win.on('destroy', reload);
+	};
+	
+	var edit_btn = new Ext.Button({
+	    text: 'Edit',
+	    disabled: true,
+	    handler: run_editor
+	});
+
+	var remove_btn = new Ext.Button({
+	    text: 'Remove',
+	    disabled: true,
+	    handler: function(){
+		var sm = me.getSelectionModel();
+		var rec = sm.getSelection()[0];
+
+		if (!rec) {
+		    return;
+		}
+
+		var msg = "Are you sure you want to remove storage: '" + 
+		    rec.data.storage + "'";
+
+		Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
+		    if (btn !== 'yes') {
+			return;
+		    }
+		    me.setLoading(true, true);
+		    PVE.Utils.API2Request({
+			url: '/storage/' + rec.data.storage,
+			method: 'DELETE',
+			callback: function() {
+			    me.setLoading(false);
+			    reload();
+			},
+			failure: function (response, opts) {
+			    Ext.Msg.alert('Error', response.htmlStatus);
+			}
+		    });
+		});
+	    }
+	});
+
+	var set_button_status = function() {
+	    var sm = me.getSelectionModel();
+	    var rec = sm.getSelection()[0];
+
+	    if (!rec) {
+		remove_btn.disable();
+		edit_btn.disable();
+		return;
+	    }
+
+	    edit_btn.setDisabled(false);
+
+	    remove_btn.setDisabled(rec.data.storage === 'local');
+	};
+
 	Ext.apply(me, {
 	    store: store,
 	    stateful: false,
 	    viewConfig: {
 		trackOver: false
 	    },
+	    tbar: [ 
+		{
+		    text: 'Add',
+		    menu: new Ext.menu.Menu({
+			items: [
+			    {
+				text: 'Directory',
+				iconCls: 'pve-itype-icon-itype',
+				handler: function() {
+				    var win = Ext.create('PVE.storage.DirEdit', {});
+				    win.on('destroy', reload);
+				    win.show();
+				}
+
+			    },
+			    {
+				text: 'LVM group'
+			    },
+			    {
+				text: 'NFS share',
+				iconCls: 'pve-itype-icon-node'
+			    },
+			    {
+				text: 'iSCSI target',
+				iconCls: 'pve-itype-icon-node'
+			    }
+			]
+		    })
+		},
+		remove_btn,
+		edit_btn
+	    ],
 	    columns: [
 		{
 		    header: 'Storage ID',
@@ -34,33 +146,43 @@
 		},
 		{
 		    header: 'Type',
-		    width: 100,
+		    width: 60,
 		    sortable: true,
-		    dataIndex: 'type'
+		    dataIndex: 'type',
+		    renderer: PVE.Utils.format_storage_type
 		},
 		{
-		    header: 'Path',
+		    header: 'Content',
 		    width: 150,
 		    sortable: true,
+		    dataIndex: 'content',
+		    renderer: PVE.Utils.format_content_types
+		},
+		{
+		    header: 'Path',
+		    width: 200,
+		    sortable: true,
 		    dataIndex: 'path'
 		},
 		{
 		    header: 'Shared',
 		    width: 80,
 		    sortable: true,
-		    dataIndex: 'shared'
+		    dataIndex: 'shared',
+		    renderer: PVE.Utils.format_boolean
 		},
 		{
 		    header: 'Disable',
 		    width: 80,
 		    sortable: true,
-		    dataIndex: 'disable'
+		    dataIndex: 'disable',
+		    renderer: PVE.Utils.format_boolean
 		}
 	    ],
 	    listeners: {
-		show: function() {
-		    store.load();
-		}
+		show: reload,
+		itemdblclick: run_editor,
+		selectionchange: set_button_status
 	    }
 	});
 

Modified: pve-manager/pve2/www/manager/form/Checkbox.js
===================================================================
--- pve-manager/pve2/www/manager/form/Checkbox.js	2011-07-20 10:28:38 UTC (rev 6332)
+++ pve-manager/pve2/www/manager/form/Checkbox.js	2011-07-20 10:40:23 UTC (rev 6333)
@@ -9,6 +9,8 @@
  
     inputValue: '1',
 
+    height: 22, // hack: set same height as text fields
+
     getSubmitData: function() {
         var me = this,
             data = null,

Added: pve-manager/pve2/www/manager/form/ContentTypeSelector.js
===================================================================
--- pve-manager/pve2/www/manager/form/ContentTypeSelector.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/form/ContentTypeSelector.js	2011-07-20 10:40:23 UTC (rev 6333)
@@ -0,0 +1,17 @@
+Ext.define('PVE.form.ContentTypeSelector', {
+    extend: 'PVE.form.KVComboBox',
+    alias: ['widget.pveContentTypeSelector'],
+  
+    initComponent: function() {
+	var me = this;
+
+	me.data = [
+	    ['images', 'Images'],
+	    ['iso', 'ISO'],
+	    ['vztmpl', 'Templates'],
+	    ['backup', 'Backups']
+	];
+
+	me.callParent();
+    }
+});

Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-20 10:28:38 UTC (rev 6332)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-20 10:40:23 UTC (rev 6333)
@@ -296,13 +296,12 @@
 	    rows: rows,
 	    sorterFn: sorterFn,
 	    listeners: {
+		show: reload,
 		itemdblclick: run_editor,
 		selectionchange: set_button_status
 	    }
 	});
 
 	me.callParent();
-
-	me.on('show', reload);
     }
 });

Added: pve-manager/pve2/www/manager/storage/DirEdit.js
===================================================================
--- pve-manager/pve2/www/manager/storage/DirEdit.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/storage/DirEdit.js	2011-07-20 10:40:23 UTC (rev 6333)
@@ -0,0 +1,111 @@
+Ext.define('PVE.storage.DirInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+
+    onGetValues: function(values) {
+	var me = this;
+
+	values.type = 'dir';
+
+	if (!me.create) {
+	    delete values.type;
+	    delete values.storage;
+	}
+	
+	return values;
+    },
+
+    initComponent : function() {
+	var me = this;
+
+
+	me.column1 = [
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		name: 'storage',
+		height: 22, // hack: set same height as text fields
+		value: me.storageId || '',
+		fieldLabel: 'Storage name',
+		allowBlank: false
+	    },
+	    {
+		xtype: me.create ? 'textfield' : 'displayfield',
+		height: 22, // hack: set same height as text fields
+		name: 'path',
+		value: '',
+		fieldLabel: 'Directory',
+		allowBlank: false
+	    },
+	    {
+		xtype: 'pveContentTypeSelector',
+		name: 'content',
+		value: 'images',
+		multiSelect: me.storageId === 'local',
+		fieldLabel: 'Content',
+		allowBlank: false
+	    }
+	];
+
+	me.column2 = [
+	    {
+		xtype: 'pvecheckbox',
+		name: 'disable',
+		uncheckedValue: 0,
+		fieldLabel: 'Disable'
+	    },
+	    {
+		xtype: 'pvecheckbox',
+		name: 'shared',
+		uncheckedValue: 0,
+		fieldLabel: 'Shared'
+	    }
+	];
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.storage.DirEdit', {
+    extend: 'PVE.window.Edit',
+
+    initComponent : function() {
+	var me = this;
+ 
+	me.create = !me.storageId;
+
+	if (me.create) {
+            me.url = '/api2/extjs/storage';
+            me.method = 'POST';
+        } else {
+            me.url = '/api2/extjs/storage/' + me.storageId;
+            me.method = 'PUT';
+        }
+
+	var ipanel = Ext.create('PVE.storage.DirInputPanel', {
+	    create: me.create,
+	    storageId: me.storageId
+	});
+	
+	Ext.apply(me, {
+	    title: me.create ? "Create directory storage" :
+		"Edit directory storage '" + me.storageId + "'",
+	    items: [ ipanel ]
+	});
+
+	me.callParent();
+
+	if (!me.create) {
+	    me.load({
+		success:  function(response, options) {
+		    var values = response.result.data;
+		    var ctypes = values.content || '';
+
+		    if (values.storage === 'local') {
+			values.content = ctypes.split(',');
+		    }
+
+		    ipanel.setValues(values);
+		}
+	    });
+	}
+    }
+});




More information about the pve-devel mailing list