[pve-devel] r6278 - pve-manager/pve2/www/manager/qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Jul 8 14:41:12 CEST 2011


Author: dietmar
Date: 2011-07-08 14:41:12 +0200 (Fri, 08 Jul 2011)
New Revision: 6278

Modified:
   pve-manager/pve2/www/manager/qemu/HardwareView.js
   pve-manager/pve2/www/manager/qemu/StatusView.js
   pve-manager/pve2/www/manager/qemu/Summary.js
Log:
make lint happy


Modified: pve-manager/pve2/www/manager/qemu/HardwareView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-08 12:22:09 UTC (rev 6277)
+++ pve-manager/pve2/www/manager/qemu/HardwareView.js	2011-07-08 12:41:12 UTC (rev 6278)
@@ -1,3 +1,5 @@
+// fixme: howto avoid jslint type confusion?
+/*jslint confusion: true */
 Ext.define('PVE.qemu.CDEdit', {
     extend: 'PVE.window.Edit',
 
@@ -23,12 +25,14 @@
 	var me = this;
 
 	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
+	if (!nodename) {
 	    throw "no node name specified";
+	}
 
-	if (!me.confid)
+	if (!me.confid) {
 	    throw "create not implemented";
-	    
+	}
+
 	var cdfilesel = Ext.create('PVE.form.FileSelector', {
 	    name: 'cdimage',
 	    nodename: nodename,
@@ -48,8 +52,9 @@
 	    autoSelect: false,
 	    listeners: {
 		change: function(f, value) {
-		    if (!value)
+		    if (!value) {
 			return;
+		    }
 		    cdfilesel.setStorage(value);
 		}
 	    }
@@ -64,8 +69,9 @@
 		checked: true,
 		listeners: {
 		    change: function(f, value) {
-			if (!me.rendered)
+			if (!me.rendered) {
 			    return;
+			}
 			me.down('field[name=storage]').setDisabled(!value);
 			me.down('field[name=cdimage]').setDisabled(!value);
 			me.down('field[name=cdimage]').validate();
@@ -90,7 +96,7 @@
 
 	Ext.applyIf(me, {
 	    title: "Change CD/DVD settings (" + me.confid + ")"
- 	});
+	});
 
 	me.callParent();
 
@@ -115,7 +121,7 @@
 		    if (match) {
 			values.storage = match[1];
 			values.cdimage = me.drive.file;
-		    };
+		    }
 		}
 
 		form.setValues(values);
@@ -149,15 +155,16 @@
 	var me = this;
 
 	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
+	if (!nodename) { 
 	    throw "no node name specified";	    
+	}
 
 	me.create = me.confid ? false : true;
 
 	Ext.applyIf(me, {
 	    title: me.create ? "Add network device" : 
 		"Edit network device settings"
- 	});
+	});
 
 	me.column1 = [
 	    {
@@ -169,8 +176,9 @@
 		checked: true,
 		listeners: {
 		    change: function(f, value) {
-			if (!me.rendered)
+			if (!me.rendered) {
 			    return;
+			}
 			me.down('field[name=bridge]').setDisabled(!value);
 			me.down('field[name=bridge]').validate();
 		    }
@@ -254,7 +262,7 @@
     getParams: function(values) {
 	var me = this;
 
-	me.drive.cache = values.cache ? values.cache : undefined;	
+	me.drive.cache = values.cache || undefined;	
 	me.drive.backup = values.nobackup ? 'no' : undefined;
 
 	var params = {};
@@ -268,18 +276,20 @@
 	var me = this;
 
 	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
+	if (!nodename) { 
 	    throw "no node name specified";
+	}
 
-	if (!me.confid)
+	if (!me.confid) {
 	    throw "create not implemented";
-	    
+	}
+
 	me.column1 = [
 	    {
 		xtype: 'displayfield',
                 fieldLabel: 'Image',
                 name: 'file'
- 	    }
+	    }
 	];
 
 	me.column2 = [
@@ -287,13 +297,13 @@
 		xtype: 'CacheTypeSelector',
 		name: 'cache',
 		value: '',
-		fieldLabel: 'Cache',
+		fieldLabel: 'Cache'
 	    },
 	    {
 		xtype: 'pvecheckbox',
                 fieldLabel: 'No backup',
                 name: 'nobackup'
- 	    }
+	    }
 	];
 
 	Ext.applyIf(me, {
@@ -301,7 +311,7 @@
 	    fieldDefaults: {
 		labelWidth: 70
 	    }
- 	});
+	});
 
 	me.callParent();
 
@@ -341,7 +351,7 @@
 
 	var drive = {};
 
-	var confid = '' + values.controller + values.deviceid;
+	var confid = values.controller + values.deviceid;
 	
 	if (me.cdrom) {
 	    drive.media = 'cdrom';
@@ -360,11 +370,13 @@
 		drive.format = values.diskformat;
 	    }
 
-	    if (values.cache)
+	    if (values.cache) {
 		drive.cache = values.cache;
-	    
-	    if (values.nobackup)
+	    }
+
+	    if (values.nobackup) {
 		drive.backup = 'no';
+	    }
 	}
 
 	var params = {};
@@ -378,11 +390,13 @@
 	var me = this;
 
 	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
+	if (!nodename) { 
 	    throw "no node name specified";	    
+	}
 
-	if (!me.cdrom && me.confid && me.confid.match(/^unused\d+$/))
+	if (!me.cdrom && me.confid && me.confid.match(/^unused\d+$/)) {
 	    me.unused = true;
+	}
 
 	var maxIds = {
 	    ide: 3,
@@ -409,8 +423,9 @@
 		    allowBlank: false,
 		    listeners: {
 			change: function(t, value) {
-			    if (!me.rendered || !value)
+			    if (!me.rendered || !value) {
 				return;
+			    }
 			    var field = me.down('field[name=deviceid]');
 			    field.setMaxValue(maxIds[value]);
 			    field.validate();
@@ -421,16 +436,18 @@
 		    xtype: 'numberfield',
 		    name: 'deviceid',
 		    minValue: 0,
-		    maxValue: maxIds['ide'],
+		    maxValue: maxIds.ide,
 		    value: 0,
 		    validator: function(value) {
-			if (!me.rendered)
+			if (!me.rendered) {
 			    return;
+			}
 			var field = me.down('field[name=controller]');
 			var controller = field.getValue();
-			var confid = '' + controller + value;
-			if (Ext.isDefined(me.vmconfig[confid]))
+			var confid = controller + value;
+			if (Ext.isDefined(me.vmconfig[confid])) {
 			    return "This device is already in use.";
+			}
 			return true;
 		    }
 		}
@@ -472,8 +489,9 @@
 		    checked: true,
 		    listeners: {
 			change: function(f, value) {
-			    if (!me.rendered)
+			    if (!me.rendered) {
 				return;
+			    }
 			    me.down('field[name=storage]').setDisabled(!value);
 			    me.down('field[name=cdimage]').setDisabled(!value);
 			    me.down('field[name=cdimage]').validate();
@@ -539,13 +557,13 @@
 		    xtype: 'CacheTypeSelector',
 		    name: 'cache',
 		    value: '',
-		    fieldLabel: 'Cache',
+		    fieldLabel: 'Cache'
 		},
 		{
 		    xtype: 'pvecheckbox',
                     fieldLabel: 'No backup',
                     name: 'nobackup'
- 		}
+		}
 	    ];
 
 	    if (!me.unused) {
@@ -556,8 +574,7 @@
 		    value: 'raw',
 		    allowBlank: false
 		});
-	    };
-
+	    }
 	}
 
 	if (me.cdrom) {
@@ -575,7 +592,7 @@
 		var confid;
 		me.vmconfig = action.result.data;
 
-		if (me.cdrom && !Ext.isDefined(me.vmconfig['ide2'])) {
+		if (me.cdrom && !Ext.isDefined(me.vmconfig.ide2)) {
 
 		    me.down('field[name=controller]').setValue('ide');
 		    me.down('field[name=deviceid]').setValue(2);
@@ -586,8 +603,9 @@
 		    var disklist = [];
 		    
 		    Ext.Object.each(me.vmconfig, function(key, value) {
-			if (key.match(/^unused\d+$/))
+			if (key.match(/^unused\d+$/)) {
 			    disklist.push([key, value]);
+			}
 		    });
 		    unused_disks.store.loadData(disklist);
 		    unused_disks.setValue(me.confid);
@@ -600,7 +618,7 @@
 
 		var i;
 		for (i = 0; i <= maxIds[controller]; i++) {
-		    confid = '' + controller + i;
+		    confid = controller + i;
 		    if (!Ext.isDefined(me.vmconfig[confid])) {
 			me.down('field[name=deviceid]').setValue(i);
 			break;
@@ -650,7 +668,7 @@
 		xtype: 'DisplaySelector',
 		name: 'vga',
 		value: '',
-		fieldLabel: 'Graphic card',
+		fieldLabel: 'Graphic card'
 	    }
 	});
 
@@ -672,7 +690,7 @@
 		xtype: 'VNCKeyboardSelector',
 		name: 'keyboard',
 		value: '',
-		fieldLabel: 'Keyboard Layout',
+		fieldLabel: 'Keyboard Layout'
 	    }
 	});
 
@@ -735,7 +753,7 @@
 		xtype: 'CPUModelSelector',
 		name: 'cpu',
 		value: '',
-		fieldLabel: 'CPU type',
+		fieldLabel: 'CPU type'
 	    }
 	];
 
@@ -775,12 +793,14 @@
 	var i, confid;
 
 	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
+	if (!nodename) { 
 	    throw "no node name specified";
+	}
 
 	var vmid = me.pveSelNode.data.vmid;
-	if (!vmid) 
+	if (!vmid) {
 	    throw "no VM ID specified";
+	}
 
 	var rows = {
 	    memory: {
@@ -801,13 +821,13 @@
 		renderer: function(value, metaData, record, rowIndex, colIndex, store) {
 		    var model = me.getObjectValue('cpu');
 		    var cores = me.getObjectValue('cores');
-		    if (!cores || (cores <= 1))
+		    if (!cores || (cores <= 1)) {
 			return value;
-
+		    }
 		    var res = (value*cores) + ' (' + value + ' x ' + cores + ' cores)';
-		    if (model)
+		    if (model) {
 			res += ' [' + model + ']';
-
+		    }
 		    return res;
 		}
 	    },
@@ -885,10 +905,9 @@
 	    var v2 = rec2.data.key;
 	    var g1 = rows[v1].group || 0;
 	    var g2 = rows[v2].group || 0;
-	    if (g1 !== g2)
-		return g1 > g2 ? 1 : -1;
-
-            return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
+	    
+	    return (g1 !== g2) ? 
+		(g1 > g2 ? 1 : -1) : (v1 > v2 ? 1 : (v1 < v2 ? -1 : 0));
 	};
 
 	var reload = function() {
@@ -900,12 +919,14 @@
 	var run_editor = function() {
 	    var sm = me.getSelectionModel();
 	    var rec = sm.getSelection()[0];
-	    if (!rec)
+	    if (!rec) {
 		return;
+	    }
 
 	    var rowdef = rows[rec.data.key];
-	    if (!rowdef.editor)
+	    if (!rowdef.editor) {
 		return;
+	    }
 
 	    var editor = rowdef.editor;
 	    if (rowdef.tdCls == 'pve-itype-icon-storage') { 
@@ -937,8 +958,9 @@
 		var sm = me.getSelectionModel();
 		var rec = sm.getSelection()[0];
 
-		if (!rec)
+		if (!rec) {
 		    return;
+		}
 
 		var msg = 'Are you sure you want to remove: ' + 
 		    me.renderKey(rec.data.key, {}, rec);
@@ -949,14 +971,15 @@
 		}
 
 		Ext.Msg.confirm('Deletion Confirmation', msg, function(btn) {
-		    if (btn !== 'yes')
+		    if (btn !== 'yes') {
 			return;
+		    }
 		    me.setLoading(true, true);
 		    PVE.Utils.API2Request({
 			url: '/api2/extjs/' + baseurl,
 			method: 'PUT',
 			params: {
-			    delete: rec.data.key
+			    'delete': rec.data.key
 			},
 			callback: function() {
 			    me.setLoading(false);
@@ -985,12 +1008,12 @@
 	    edit_btn.setDisabled(!rowdef.editor);
 
 	    remove_btn.setDisabled(rowdef.never_delete === true);
-	}
+	};
 
 	Ext.applyIf(me, {
 	    url: '/api2/json/' + baseurl,
 	    cwidth1: 170,
- 	    tbar: [ 
+	    tbar: [ 
 		{
 		    text: 'Add',
 		    menu: new Ext.menu.Menu({

Modified: pve-manager/pve2/www/manager/qemu/StatusView.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/StatusView.js	2011-07-08 12:22:09 UTC (rev 6277)
+++ pve-manager/pve2/www/manager/qemu/StatusView.js	2011-07-08 12:41:12 UTC (rev 6278)
@@ -6,26 +6,30 @@
 	var me = this;
 
 	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
+	if (!nodename) {
 	    throw "no node name specified";
+	}
 
 	var vmid = me.pveSelNode.data.vmid;
-	if (!vmid) 
+	if (!vmid) {
 	    throw "no VM ID specified";
+	}
 
 	var render_cpu = function(value, metaData, record, rowIndex, colIndex, store) {
-	    if (!me.getObjectValue('uptime'))
+	    if (!me.getObjectValue('uptime')) {
 		return '-';
+	    }
 
 	    var maxcpu = me.getObjectValue('cpus', 1);
 
-	    if (!(Ext.isNumeric(value) && Ext.isNumeric(maxcpu) && (maxcpu >= 1)))
-		return '-'
+	    if (!(Ext.isNumeric(value) && Ext.isNumeric(maxcpu) && (maxcpu >= 1))) {
+		return '-';
+	    }
 
 	    var per = (value * 100) / maxcpu;
 
-	    return per.toFixed(1) + '% of ' + maxcpu + (maxcpu > 1 ? 'CPUs' : 'CPU');
- 	};
+	    return per.toFixed(1) + '% of ' + maxcpu.toString() + (maxcpu > 1 ? 'CPUs' : 'CPU');
+	};
 
 	var render_mem = function(value, metaData, record, rowIndex, colIndex, store) {
 	    var maxmem = me.getObjectValue('maxmem', 0);

Modified: pve-manager/pve2/www/manager/qemu/Summary.js
===================================================================
--- pve-manager/pve2/www/manager/qemu/Summary.js	2011-07-08 12:22:09 UTC (rev 6277)
+++ pve-manager/pve2/www/manager/qemu/Summary.js	2011-07-08 12:41:12 UTC (rev 6278)
@@ -6,12 +6,14 @@
         var me = this;
 
 	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
+	if (!nodename) {
 	    throw "no node name specified";
+	}
 
 	var vmid = me.pveSelNode.data.vmid;
-	if (!vmid) 
+	if (!vmid) {
 	    throw "no VM ID specified";
+	}
 
 	var statusview = Ext.create('PVE.qemu.StatusView', {
 	    title: 'Status',
@@ -53,8 +55,9 @@
 		    handler: function() {
 			var msg = "Do you really want to stop the VM?";
 			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
+			    if (btn !== 'yes') {
 				return;
+			    }
 			    vm_command("stop");
 			}); 
 		    }
@@ -65,8 +68,9 @@
 		    handler: function() { 
 			var msg = "Do you really want to reset the VM?";
 			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
+			    if (btn !== 'yes') {
 				return;
+			    }
 			    vm_command("reset");
 			});
 		    }
@@ -77,8 +81,9 @@
 		    handler: function() {
 			var msg = "Do you really want to shutdown the VM?";
 			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
+			    if (btn !== 'yes') {
 				return;
+			    }
 			    vm_command('shutdown');
 			});
 		    }			    
@@ -90,9 +95,9 @@
 			var msg = 'Are you sure you want to remove VM ' + 
 			    vmid + '? This will permanently erase all VM data.';
 			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
+			    if (btn !== 'yes') {
 				return;
-			    
+			    }
 			    me.setLoading(true, true);
 			    PVE.Utils.API2Request({
 				url: '/nodes/' + nodename + '/qemu/' + vmid,
@@ -203,6 +208,6 @@
 	me.on('hide', rstore.stopUpdate);
 	me.on('destroy', rstore.stopUpdate);	
 
- 	me.callParent();
+	me.callParent();
     }
 });




More information about the pve-devel mailing list