[pve-devel] [PATCH manager v2 1/3] Turn the qemu StartupEdit widget into a generic component

Emmanuel Kasper e.kasper at proxmox.com
Mon Dec 5 14:48:06 CET 2016


and use this component for Qemu.
---
 www/manager6/Makefile              |  2 +-
 www/manager6/qemu/Options.js       |  5 ++-
 www/manager6/qemu/StartupEdit.js   | 85 -------------------------------------
 www/manager6/window/StartupEdit.js | 87 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 92 insertions(+), 87 deletions(-)
 delete mode 100644 www/manager6/qemu/StartupEdit.js
 create mode 100644 www/manager6/window/StartupEdit.js

diff --git a/www/manager6/Makefile b/www/manager6/Makefile
index 11e71be..ea21c5d 100644
--- a/www/manager6/Makefile
+++ b/www/manager6/Makefile
@@ -91,6 +91,7 @@ JSSRC= 				                 	\
 	window/SafeDestroy.js				\
 	window/BackupConfig.js				\
 	window/Settings.js				\
+	window/StartupEdit.js				\
 	panel/NotesView.js				\
 	grid/SelectFeature.js				\
 	grid/ObjectGrid.js				\
@@ -147,7 +148,6 @@ JSSRC= 				                 	\
 	qemu/DisplayEdit.js				\
 	qemu/KeyboardEdit.js				\
 	qemu/HardwareView.js				\
-	qemu/StartupEdit.js				\
 	qemu/ScsiHwEdit.js				\
 	qemu/QemuBiosEdit.js				\
 	qemu/Options.js					\
diff --git a/www/manager6/qemu/Options.js b/www/manager6/qemu/Options.js
index 7c6721d..cc9512a 100644
--- a/www/manager6/qemu/Options.js
+++ b/www/manager6/qemu/Options.js
@@ -73,7 +73,10 @@ Ext.define('PVE.qemu.Options', {
 		defaultValue: '',
 		renderer: PVE.Utils.render_kvm_startup,
 		editor: caps.vms['VM.Config.Options'] && caps.nodes['Sys.Modify'] ? 
-		    'PVE.qemu.StartupEdit' : undefined
+		    {
+			xtype: 'pveWindowStartupEdit',
+			onlineHelp: 'qm_startup_and_shutdown'
+		    } : undefined
 	    },
 	    ostype: {
 		header: gettext('OS Type'),
diff --git a/www/manager6/qemu/StartupEdit.js b/www/manager6/qemu/StartupEdit.js
deleted file mode 100644
index 3c832c5..0000000
--- a/www/manager6/qemu/StartupEdit.js
+++ /dev/null
@@ -1,85 +0,0 @@
-Ext.define('PVE.qemu.StartupInputPanel', {
-    extend: 'PVE.panel.InputPanel',
-    onlineHelp: 'qm_startup_and_shutdown',
-
-    onGetValues: function(values) {
-	var me = this;
-
-	var res = PVE.Parser.printStartup(values);
-
-	if (res === undefined || res === '') {
-	    return { 'delete': 'startup' };
-	}
-
-	return { startup: res };
-    },
-
-    setStartup: function(value) {
-	var me = this;
-
-	var startup = PVE.Parser.parseStartup(value);
-	if (startup) {
-	    me.setValues(startup);
-	}
-    },
-
-    initComponent : function() {
-	var me = this;
-
-	me.items = [
-	    {
-		xtype: 'textfield',
-		name: 'order',
-		defaultValue: '',
-		emptyText: 'any',
-		fieldLabel: gettext('Start/Shutdown order')
-	    },
-	    {
-		xtype: 'textfield',
-		name: 'up',
-		defaultValue: '',
-		emptyText: 'default',
-		fieldLabel: gettext('Startup delay')
-	    },
-	    {
-		xtype: 'textfield',
-		name: 'down',
-		defaultValue: '',
-		emptyText: 'default',
-		fieldLabel: gettext('Shutdown timeout')
-	    }
-	];
-
-	me.callParent();
-    }
-});
-
-Ext.define('PVE.qemu.StartupEdit', {
-    extend: 'PVE.window.Edit',
-
-    initComponent : function() {
-	/*jslint confusion: true */
-
-	var me = this;
-
-	var ipanel = Ext.create('PVE.qemu.StartupInputPanel', {});
-
-	Ext.applyIf(me, {
-	    subject: gettext('Start/Shutdown order'),
-	    fieldDefaults: {
-		labelWidth: 120
-	    },
-	    items: ipanel
-	});
-
-	me.callParent();
-
-	me.load({
-	    success: function(response, options) {
-		var i, confid;
-		me.vmconfig = response.result.data;
-		ipanel.setStartup(me.vmconfig.startup);		    
-	    }
-	});
-    }
-});
diff --git a/www/manager6/window/StartupEdit.js b/www/manager6/window/StartupEdit.js
new file mode 100644
index 0000000..7874794
--- /dev/null
+++ b/www/manager6/window/StartupEdit.js
@@ -0,0 +1,87 @@
+Ext.define('PVE.panel.StartupInputPanel', {
+    extend: 'PVE.panel.InputPanel',
+    onlineHelp: 'qm_startup_and_shutdown',
+
+    onGetValues: function(values) {
+	var me = this;
+
+	var res = PVE.Parser.printStartup(values);
+
+	if (res === undefined || res === '') {
+	    return { 'delete': 'startup' };
+	}
+
+	return { startup: res };
+    },
+
+    setStartup: function(value) {
+	var me = this;
+
+	var startup = PVE.Parser.parseStartup(value);
+	if (startup) {
+	    me.setValues(startup);
+	}
+    },
+
+    initComponent : function() {
+	var me = this;
+
+	me.items = [
+	    {
+		xtype: 'textfield',
+		name: 'order',
+		defaultValue: '',
+		emptyText: 'any',
+		fieldLabel: gettext('Start/Shutdown order')
+	    },
+	    {
+		xtype: 'textfield',
+		name: 'up',
+		defaultValue: '',
+		emptyText: 'default',
+		fieldLabel: gettext('Startup delay')
+	    },
+	    {
+		xtype: 'textfield',
+		name: 'down',
+		defaultValue: '',
+		emptyText: 'default',
+		fieldLabel: gettext('Shutdown timeout')
+	    }
+	];
+
+	me.callParent();
+    }
+});
+
+Ext.define('PVE.window.StartupEdit', {
+    extend: 'PVE.window.Edit',
+    alias: 'widget.pveWindowStartupEdit',
+    onlineHelp: undefined,
+
+    initComponent : function() {
+	/*jslint confusion: true */
+
+	var me = this;
+	var ipanelConfig = me.onlineHelp ? {onlineHelp: me.onlineHelp} : {};
+	var ipanel = Ext.create('PVE.panel.StartupInputPanel', ipanelConfig);
+
+	Ext.applyIf(me, {
+	    subject: gettext('Start/Shutdown order'),
+	    fieldDefaults: {
+		labelWidth: 120
+	    },
+	    items: ipanel
+	});
+
+	me.callParent();
+
+	me.load({
+	    success: function(response, options) {
+		var i, confid;
+		me.vmconfig = response.result.data;
+		ipanel.setStartup(me.vmconfig.startup);		    
+	    }
+	});
+    }
+});
-- 
2.1.4





More information about the pve-devel mailing list