You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@vcl.apache.org by jf...@apache.org on 2014/09/23 22:06:38 UTC

svn commit: r1627142 - in /vcl/trunk/web: .ht-inc/computer.php .ht-inc/managementnode.php .ht-inc/resource.php .ht-inc/utils.php js/resources/computer.js

Author: jfthomps
Date: Tue Sep 23 20:06:37 2014
New Revision: 1627142

URL: http://svn.apache.org/r1627142
Log:
VCL-776 - rework resource code to have a base class for all resources and inheriting classes for each resource type

added code to handle widths of resource tables better

computer.php:
- added fieldWidth
- modified extraResourceFilters: set autoComplete to false for reloadimageid select object; having it on caused problems when typing in the box to filter the results

managementnode.php: added fieldWidth

resource.php:
- modified viewResources: added extra check for user agent including 'trident' to catch IE11 so that grid widths are specified in px instead of em; removed unused values from $w array; make a call to $this->fieldWidth to get the width for grid cells after name and owner
- added fieldWidth

utils.php: modified getComputers: return image.prettyname for nextimg instead of image.name

computer.js:
- modified buldExtraFilters: added formatter function for comboboxes so that bool fields can show the right values to select from; there is still a problem in that once selected, the 0 or 1 gets displayed in the box instead of false/true; updated how width of comboboxes is set to handle widths specified in px differently from those specified in em
- added cbformatter

Modified:
    vcl/trunk/web/.ht-inc/computer.php
    vcl/trunk/web/.ht-inc/managementnode.php
    vcl/trunk/web/.ht-inc/resource.php
    vcl/trunk/web/.ht-inc/utils.php
    vcl/trunk/web/js/resources/computer.js

Modified: vcl/trunk/web/.ht-inc/computer.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/computer.php?rev=1627142&r1=1627141&r2=1627142&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/computer.php (original)
+++ vcl/trunk/web/.ht-inc/computer.php Tue Sep 23 20:06:37 2014
@@ -65,6 +65,56 @@ class Computer extends Resource {
 
 	/////////////////////////////////////////////////////////////////////////////
 	///
+	/// \fn fieldWidth($field)
+	///
+	/// \param $field - name of a resource field
+	///
+	/// \return string for setting width of field (includes width= part)
+	///
+	/// \brief generates the required width for the field; can return an empty
+	/// string if field should default to auto width
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function fieldWidth($field) {
+		switch($field) {
+			case 'currentimg':
+			case 'nextimg':
+				$w = 17;
+				break;
+			case 'notes':
+				$w = 14;
+				break;
+			case 'IPaddress':
+			case 'privateIPaddress':
+				$w = 8;
+				break;
+			case 'eth0macaddress':
+			case 'eth1macaddress':
+				$w = 8.5;
+				break;
+			case 'vmhost':
+				$w = 8;
+				break;
+			case 'location':
+				$w = 9;
+				break;
+			case 'provisioning':
+				$w = 11;
+				break;
+			default:
+				return '';
+		}
+		if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']) ||
+		   preg_match('/Trident/i', $_SERVER['HTTP_USER_AGENT']))
+			$w = round($w * 11.5) . 'px';
+		else
+			$w = "{$w}em";
+		error_log($w);
+		return "width=\"$w\"";
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
 	/// \fn fieldDisplayName($field)
 	///
 	/// \param $field - name of a resource field
@@ -130,7 +180,8 @@ class Computer extends Resource {
 			$h .= "    <div dojoType=\"dijit.layout.ContentPane\"\n";
 			$h .= "         style=\"background-color: white; padding: 5px; border: 1px solid black;\">\n";
 			$h .= "      Reload computers with the following image:<br>\n";
-			$h .= selectInputAutoDijitHTML('', $resources['image'], 'reloadimageid');
+			$extra = 'autoComplete="false"';
+			$h .= selectInputAutoDijitHTML('', $resources['image'], 'reloadimageid', $extra);
 			$cont = addContinuationsEntry('AJreloadComputers', $this->basecdata);
 			$h .= "      <input type=\"hidden\" id=\"reloadcont\" value=\"$cont\"><br>\n";
 			$h .= dijitButton('', 'Confirm Reload Computers', 'confirmReload();', 0);

Modified: vcl/trunk/web/.ht-inc/managementnode.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/managementnode.php?rev=1627142&r1=1627141&r2=1627142&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/managementnode.php (original)
+++ vcl/trunk/web/.ht-inc/managementnode.php Tue Sep 23 20:06:37 2014
@@ -71,6 +71,57 @@ class ManagementNode extends Resource {
 
 	/////////////////////////////////////////////////////////////////////////////
 	///
+	/// \fn fieldWidth($field)
+	///
+	/// \param $field - name of a resource field
+	///
+	/// \return string for setting width of field (includes width= part)
+	///
+	/// \brief generates the required width for the field; can return an empty
+	/// string if field should default to auto width
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function fieldWidth($field) {
+		switch($field) {
+			case 'IPaddress':
+			case 'publicIPconfig':
+			case 'publicnetmask':
+			case 'publicgateway':
+				$w = 8;
+				break;
+			case 'installpath':
+			case 'publicdnsserver':
+				$w = 11;
+				break;
+			case 'imagelibgroup':
+			case 'imagelibkey':
+			case 'predictivemodule':
+			case 'federatedauth':
+				$w = 9.5;
+				break;
+			case 'keys':
+			case 'sharedmailbox':
+				$w = 12;
+				break;
+			case 'keys':
+			case 'sysadminemail':
+			case 'timeservers':
+				$w = 18;
+				break;
+			default:
+				return '';
+		}
+		if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']) ||
+		   preg_match('/Trident/i', $_SERVER['HTTP_USER_AGENT']))
+			$w = round($w * 11.5) . 'px';
+		else
+			$w = "{$w}em";
+		error_log($w);
+		return "width=\"$w\"";
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
 	/// \fn fieldDisplayName($field)
 	///
 	/// \param $field - name of a resource field

Modified: vcl/trunk/web/.ht-inc/resource.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/resource.php?rev=1627142&r1=1627141&r2=1627142&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/resource.php (original)
+++ vcl/trunk/web/.ht-inc/resource.php Tue Sep 23 20:06:37 2014
@@ -291,10 +291,11 @@ class Resource {
 			$h .= "height: 580px;\">\n";
 		$h .= "<thead>\n";
 		$h .= "<tr>\n";
-		if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']))
-			$w = array('64px', '38px', '200px', '142px', '65px', '142px', '59px', '58px', '63px', '73px');
+		if(preg_match('/MSIE/i', $_SERVER['HTTP_USER_AGENT']) ||
+		   preg_match('/Trident/i', $_SERVER['HTTP_USER_AGENT']))
+			$w = array('64px', '38px', '200px', '142px');
 		else
-			$w = array('5em', '3em', '17em', '12em', '5em', '12em', '5em', '5em', '5.6em', '6.3em');
+			$w = array('5em', '3em', '17em', '12em');
 		$h .= "<th field=\"id\" id=\"delcolth\" width=\"{$w[0]}\" formatter=\"resource.DeleteBtn\" styles=\"text-align: center;\">&nbsp;</th>\n";
 		$h .= "<th field=\"id\" width=\"{$w[1]}\" formatter=\"resource.EditBtn\" styles=\"text-align: center;\">&nbsp;</th>\n";
 		$h .= "<th field=\"name\" width=\"{$w[2]}\">Name</th>\n";
@@ -306,7 +307,8 @@ class Resource {
 			   is_array($resdata[$testid][$field]) ||
 			   preg_match('/id$/', $field))
 				continue;
-			$h .= "<th field=\"$field\" hidden=\"true\" formatter=\"resource.colformatter\">";
+			$w = $this->fieldWidth($field);
+			$h .= "<th field=\"$field\" $w hidden=\"true\" formatter=\"resource.colformatter\">";
 			$h .= $this->fieldDisplayName($field);
 			$h .= "</th>\n";
 		}
@@ -398,6 +400,22 @@ class Resource {
 
 	/////////////////////////////////////////////////////////////////////////////
 	///
+	/// \fn fieldWidth($field)
+	///
+	/// \param $field - name of a resource field
+	///
+	/// \return string for setting width of field (includes width= part)
+	///
+	/// \brief generates the required width for the field; can return an empty
+	/// string if field should default to auto width
+	///
+	/////////////////////////////////////////////////////////////////////////////
+	function fieldWidth($field) {
+		return '';
+	}
+
+	/////////////////////////////////////////////////////////////////////////////
+	///
 	/// \fn fieldDisplayName($field)
 	///
 	/// \param $field - name of a resource field

Modified: vcl/trunk/web/.ht-inc/utils.php
URL: http://svn.apache.org/viewvc/vcl/trunk/web/.ht-inc/utils.php?rev=1627142&r1=1627141&r2=1627142&view=diff
==============================================================================
--- vcl/trunk/web/.ht-inc/utils.php (original)
+++ vcl/trunk/web/.ht-inc/utils.php Tue Sep 23 20:06:37 2014
@@ -8132,7 +8132,7 @@ function getComputers($sort=0, $included
 	       .        "cur.prettyname AS currentimg, "
 	       .        "c.currentimageid AS currentimgid, "
 	       .        "c.imagerevisionid, "
-	       .        "next.name AS nextimg, "
+	       .        "next.prettyname AS nextimg, "
 	       .        "c.nextimageid AS nextimgid, "
 	       .        "c.RAM AS ram, "
 	       .        "c.procnumber AS procnumber, "

Modified: vcl/trunk/web/js/resources/computer.js
URL: http://svn.apache.org/viewvc/vcl/trunk/web/js/resources/computer.js?rev=1627142&r1=1627141&r2=1627142&view=diff
==============================================================================
--- vcl/trunk/web/js/resources/computer.js (original)
+++ vcl/trunk/web/js/resources/computer.js Tue Sep 23 20:06:37 2014
@@ -186,7 +186,6 @@ Computer.prototype.Selection = function(
 				dijit.byId('chkb' + comp.id).set('checked', true);
 		}
 	}
-	//console.log(resource.selids.length + ":" + resourcegrid.rowCount);
 	if(resource.selids.length != resourcegrid.rowCount)
 		dijit.byId('selectallchkb').set('checked', false);
 	else
@@ -388,15 +387,23 @@ function buildExtraFilters() {
 					field: item.field,
 					queryExpr: '*${0}*',
 					autoComplete: false,
+					labelFunc: cbformatter,
+					labelType: 'html',
 					searchAttr: 'value'
 				});
 				if(typeof item.width != 'undefined') {
-					var newwidth = parseInt(item.width) - 0.6;
-					cb.set('style', {width: newwidth + "em"});
+					if(item.width.match(/px/))
+						var newwidth = (parseInt(item.width) - 11) + 'px';
+					else
+						var newwidth = (parseInt(item.width) - 0.6) + 'em';
+					cb.set('style', {width: newwidth});
 				}
 				else if(typeof item.unitWidth != 'undefined') {
-					var newwidth = parseInt(item.unitWidth) - 0.6;
-					cb.set('style', {width: newwidth + "em"});
+					if(item.unitWidth.match(/px/))
+						var newwidth = (parseInt(item.unitWidth) - 11) + 'px';
+					else
+						var newwidth = (parseInt(item.unitWidth) - 0.6) + 'em';
+					cb.set('style', {width: newwidth});
 				}
 				return cb;
 			};
@@ -452,6 +459,11 @@ function buildExtraFilters() {
 	});
 }
 
+function cbformatter(item, store) {
+	var comp = new Computer();
+	return comp.colformatter(store.getValue(item, 'value'), '', this);
+}
+
 function combofocus(obj) {
 	if(dijit.byId(obj.cell.field + "cb"))
 		dijit.byId(obj.cell.field + "cb").focus();