View Issue Details

IDProjectCategoryView StatusLast Update
365RackTablesdefaultpublic2011-08-28 13:02
Reporteruser143Assigned Toandriyanov  
PrioritynormalSeverityfeatureReproducibilityalways
Status closedResolutionno change required 
Product Version0.18.4 
Fixed in Version0.19.6 
Summary365: Request for comments: ajax-support
DescriptionWe (more exactly: a student) have developed a patch to improve the input of ports.
It would be nice to get this included in the main branch. I'm willing to let the student develop this patch as you like. Please comment the first patch-version ;)
TagsNo tags attached.
Attached Files
RackTables-0.18.4-ajax.patch (20,723 bytes)   
diff -ruwp RackTables-0.18.4/inc/init.php RackTables-0.18.4-ajax/inc/init.php
--- RackTables-0.18.4/inc/init.php	2010-06-24 15:42:17.000000000 +0200
+++ RackTables-0.18.4-ajax/inc/init.php	2010-09-09 09:36:17.000000000 +0200
@@ -164,11 +164,13 @@ $user_given_tags = array();
 $pageheaders = array
 (
 	100 => "<link rel='STYLESHEET' type='text/css' href='pi.css' />",
+	101 => "<link rel='STYLESHEET' type='text/css' href='pix/jqueryui-theme/jquery-ui-1.8.4.custom.css' />",
 	102 => "<link rel='ICON' type='image/x-icon' href='pix/racktables.ico' />",
-	200 => "<script language='javascript' type='text/javascript' src='js/racktables.js'></script>",
-	201 => "<script language='javascript' type='text/javascript' src='js/jquery-1.3.1.min.js'></script>",
+	201 => "<script language='javascript' type='text/javascript' src='js/jquery-1.4.2.min.js'></script>",
 	202 => "<script language='javascript' type='text/javascript' src='js/live_validation.js'></script>",
 	203 => "<script language='javascript' type='text/javascript' src='js/codepress/codepress.js'></script>",
+	204 => "<script language='javascript' type='text/javascript' src='js/jquery-ui-1.8.4.custom.min.js'></script>",
+	205 => "<script language='javascript' type='text/javascript' src='js/racktables.js'></script>"
 );
 
 if (!isset ($script_mode) or $script_mode !== TRUE)
diff -ruwp RackTables-0.18.4/inc/interface.php RackTables-0.18.4-ajax/inc/interface.php
--- RackTables-0.18.4/inc/interface.php	2010-07-09 17:07:24.000000000 +0200
+++ RackTables-0.18.4-ajax/inc/interface.php	2010-09-09 09:36:17.000000000 +0200
@@ -1173,56 +1173,34 @@ function renderRackMultiSelect ($sname, 
 	echo "</select>\n";
 }
 
-// This function renders a form for port edition.
-function renderPortsForObject ($object_id)
+
+function renderSinglePortForObject($object_id, $port = NULL)
 {
-	$prefs = getPortListPrefs();
-	function printNewItemTR ($prefs)
+	if ($port == NULL)
 	{
-		printOpFormIntro ('addPort');
-		echo "<tr><td>";
-		printImageHREF ('add', 'add a port', TRUE);
-		echo "</td><td><input type=text size=8 name=port_name tabindex=100></td>\n";
-		echo "<td><input type=text name=port_label tabindex=101></td><td>";
-		printNiftySelect (getNewPortTypeOptions(), array ('name' => 'port_type_id', 'tabindex' => 102), $prefs['selected']);
-		echo "<td><input type=text name=port_l2address tabindex=103 size=18 maxlength=24></td>\n";
-		echo "<td colspan=3>&nbsp;</td><td>";
-		printImageHREF ('add', 'add a port', TRUE, 104);
-		echo "</td></tr></form>";
-	}
-	if (getConfigVar('ENABLE_MULTIPORT_FORM') == 'yes' || getConfigVar('ENABLE_BULKPORT_FORM') == 'yes' )
-		startPortlet ('Ports and interfaces');
-	else
-		echo '<br>';
+		if (isset ($_REQUEST['port_id']))
+		{
+			assertUIntArg ('port_id');
+			
 	$object = spotEntity ('object', $object_id);
 	amplifyCell ($object);
-	if (getConfigVar ('ADDNEW_AT_TOP') == 'yes' && getConfigVar('ENABLE_BULKPORT_FORM') == 'yes'){
-		echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n";
-		echo "<tr><th>&nbsp;</th><th class=tdleft>Local name</th><th class=tdleft>Visible label</th><th class=tdleft>Interface</th><th class=tdleft>Start Number</th>";
-		echo "<th class=tdleft>Count</th><th>&nbsp;</th></tr>\n";
-		printOpFormIntro ('addBulkPorts');
-		echo "<tr><td>";
-		printImageHREF ('add', 'add ports', TRUE);
-		echo "</td><td><input type=text size=8 name=port_name tabindex=105></td>\n";
-		echo "<td><input type=text name=port_label tabindex=106></td><td>";
-		printNiftySelect (getNewPortTypeOptions(), array ('name' => 'port_type_id', 'tabindex' => 107), $prefs['selected']);
-		echo "<td><input type=text name=port_numbering_start tabindex=108 size=3 maxlength=3></td>\n";
-		echo "<td><input type=text name=port_numbering_count tabindex=109 size=3 maxlength=3></td>\n";
-		echo "<td>&nbsp;</td><td>";
-		printImageHREF ('add', 'add ports', TRUE, 110);
-		echo "</td></tr></form>";
-		echo "</table><br>\n";
+			foreach ($object['ports'] as $port_)
+				if ($port_['id'] == $_REQUEST['port_id'])
+				{
+					$port = $port_;
+					break;
+				}
 	}
 	
-	echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n";
-	echo "<tr><th>&nbsp;</th><th class=tdleft>Local name</th><th class=tdleft>Visible label</th><th class=tdleft>Interface</th><th class=tdleft>L2 address</th>";
-	echo "<th class=tdcenter colspan=2>Remote object and port</th><th class=tdcenter>(Un)link or (un)reserve</th><th>&nbsp;</th></tr>\n";
-	if (getConfigVar ('ADDNEW_AT_TOP') == 'yes')
-		printNewItemTR ($prefs);
-	foreach ($object['ports'] as $port)
-	{
-		printOpFormIntro ('editPort', array ('port_id' => $port['id']));
-		echo "<tr><td><a href='".makeHrefProcess(array('op'=>'delPort', 'port_id'=>$port['id'], 'object_id'=>$object_id, 'port_name'=>$port['name']))."'>";
+		if ($port == NULL)
+			return;
+	}
+	
+	global $tabno;
+	if ($tabno == 'port')
+		$tabno = 'ports';
+
+	echo "<td><a href='".makeHrefProcess(array('op'=>'delPort', 'port_id'=>$port['id'], 'object_id'=>$object_id, 'port_name'=>$port['name']))."'>";
 		printImageHREF ('delete', 'Unlink and Delete this port');
 		echo "</a></td>\n";
 		echo "<td><input type=text name=name value='${port['name']}' size=8></td>";
@@ -1256,7 +1234,7 @@ function renderPortsForObject ($object_i
 					'port_id'=>$port['id'],
 					'remote_port_id' => $port['remote_id'],
 					'object_id'=>$object_id)).
-			"'>";
+		"' onclick='javascript:sendEditPortLinkAsync(this, ${port['id']}, ${object_id})'>";
 			printImageHREF ('cut', 'Unlink this port');
 			echo "</a></td>";
 		}
@@ -1269,7 +1247,7 @@ function renderPortsForObject ($object_i
 					'op'=>'useup',
 					'port_id'=>$port['id'], 
 					'object_id'=>$object_id)).
-			"'>";
+		"' onclick='javascript:sendEditPortLinkAsync(this, ${port['id']}, ${object_id})'>";
 			printImageHREF ('clear', 'Use up this port');
 			echo "</a></td>";
 		}
@@ -1288,7 +1266,9 @@ function renderPortsForObject ($object_i
 			echo "\",\"findlink\",\"${popup_args}\");'";
 			// end of onclick=
 			$helper_args['in_rack'] = 'y';
-			echo " onclick='window.open(\"" . makeHrefForHelper ('portlist', $helper_args);
+		//echo " onclick='window.open(\"";
+		echo " onclick='javascript:showPopupInJSDlg(\"";
+		echo makeHrefForHelper ('portlist', $helper_args);
 			echo "\",\"findlink\",\"${popup_args}\");'";
 			// end of onclick=
 			echo '>';
@@ -1299,7 +1279,61 @@ function renderPortsForObject ($object_i
 		}
 		echo "<td>";
 		printImageHREF ('save', 'Save changes', TRUE);
-		echo "</td></form></tr>\n";
+}
+
+// This function renders a form for port edition.
+function renderPortsForObject ($object_id)
+{
+	$prefs = getPortListPrefs();
+	function printNewItemTR ($prefs)
+	{
+		printOpFormIntro ('addPort');
+		echo "<tr><td>";
+		printImageHREF ('add', 'add a port', TRUE);
+		echo "</td><td><input type=text size=8 name=port_name tabindex=100></td>\n";
+		echo "<td><input type=text name=port_label tabindex=101></td><td>";
+		printNiftySelect (getNewPortTypeOptions(), array ('name' => 'port_type_id', 'tabindex' => 102), $prefs['selected']);
+		echo "<td><input type=text name=port_l2address tabindex=103 size=18 maxlength=24></td>\n";
+		echo "<td colspan=3>&nbsp;</td><td>";
+		printImageHREF ('add', 'add a port', TRUE, 104);
+		echo "</td></tr></form>";
+	}
+	if (getConfigVar('ENABLE_MULTIPORT_FORM') == 'yes' || getConfigVar('ENABLE_BULKPORT_FORM') == 'yes' )
+		startPortlet ('Ports and interfaces');
+	else
+		echo '<br>';
+	$object = spotEntity ('object', $object_id);
+	amplifyCell ($object);
+	if (getConfigVar ('ADDNEW_AT_TOP') == 'yes' && getConfigVar('ENABLE_BULKPORT_FORM') == 'yes'){
+		echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n";
+		echo "<tr><th>&nbsp;</th><th class=tdleft>Local name</th><th class=tdleft>Visible label</th><th class=tdleft>Interface</th><th class=tdleft>Start Number</th>";
+		echo "<th class=tdleft>Count</th><th>&nbsp;</th></tr>\n";
+		printOpFormIntro ('addBulkPorts');
+		echo "<tr><td>";
+		printImageHREF ('add', 'add ports', TRUE);
+		echo "</td><td><input type=text size=8 name=port_name tabindex=105></td>\n";
+		echo "<td><input type=text name=port_label tabindex=106></td><td>";
+		printNiftySelect (getNewPortTypeOptions(), array ('name' => 'port_type_id', 'tabindex' => 107), $prefs['selected']);
+		echo "<td><input type=text name=port_numbering_start tabindex=108 size=3 maxlength=3></td>\n";
+		echo "<td><input type=text name=port_numbering_count tabindex=109 size=3 maxlength=3></td>\n";
+		echo "<td>&nbsp;</td><td>";
+		printImageHREF ('add', 'add ports', TRUE, 110);
+		echo "</td></tr></form>";
+		echo "</table><br>\n";
+	}
+	
+	echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n";
+	echo "<tr><th>&nbsp;</th><th class=tdleft>Local name</th><th class=tdleft>Visible label</th><th class=tdleft>Interface</th><th class=tdleft>L2 address</th>";
+	echo "<th class=tdcenter colspan=2>Remote object and port</th><th class=tdcenter>(Un)link or (un)reserve</th><th>&nbsp;</th></tr>\n";
+	if (getConfigVar ('ADDNEW_AT_TOP') == 'yes')
+		printNewItemTR ($prefs);
+	foreach ($object['ports'] as $port)
+	{
+		printOpFormIntro ("editPort", array ('port_id' => $port['id']), false, "editPort_${port['id']}", "return sendEditPortFormAsync(this, ${port['id']}, ${object_id});");
+		echo "<tr id='tr_${port['id']}'>";
+		renderSinglePortForObject($object_id, $port);
+		echo "</tr>\n";
+		echo "</form>";
 	}
 	if (getConfigVar ('ADDNEW_AT_TOP') != 'yes')
 		printNewItemTR ($prefs);
@@ -5749,11 +5783,15 @@ function renderFilesForEntity ($entity_i
 // Print common operation form prologue, include bypass argument, if
 // appropriate, and some extra hidden inputs, if requested.
 // Use special encoding for upload forms
-function printOpFormIntro ($opname, $extra = array(), $upload = FALSE)
+function printOpFormIntro ($opname, $extra = array(), $upload = FALSE, $formid = NULL, $onsubmit = NULL)
 {
 	global $pageno, $tabno, $page;
 
-	echo "<form method=post id=${opname} name=${opname} action='process.php?page=${pageno}&tab=${tabno}&op=${opname}'";
+	if ($formid == NULL)
+		$formid = $opname;
+	echo "<form method=post id=${formid} name=${opname} action='process.php?page=${pageno}&tab=${tabno}&op=${opname}'";
+	if($onsubmit != NULL)
+		echo " onsubmit='${onsubmit}'";
 	if ($upload)
 		echo " enctype='multipart/form-data'";
 	echo ">";
diff -ruwp RackTables-0.18.4/inc/navigation.php RackTables-0.18.4-ajax/inc/navigation.php
--- RackTables-0.18.4/inc/navigation.php	2010-06-15 13:11:05.000000000 +0200
+++ RackTables-0.18.4-ajax/inc/navigation.php	2010-09-09 09:36:17.000000000 +0200
@@ -106,6 +106,7 @@ $tabhandler['object']['default'] = 'rend
 $tabhandler['object']['edit'] = 'renderEditObjectForm';
 $tabhandler['object']['rackspace'] = 'renderRackSpaceForObject';
 $tabhandler['object']['ports'] = 'renderPortsForObject';
+$tabhandler['object']['port'] = 'renderSinglePortForObject';
 $tabhandler['object']['ipv4'] = 'renderIPv4ForObject';
 $tabhandler['object']['nat4'] = 'renderNATv4ForObject';
 $tabhandler['object']['livevlans'] = 'renderVLANMembership';
diff -ruwp RackTables-0.18.4/index.php RackTables-0.18.4-ajax/index.php
--- RackTables-0.18.4/index.php	2010-06-24 15:42:17.000000000 +0200
+++ RackTables-0.18.4-ajax/index.php	2010-09-09 09:36:17.000000000 +0200
@@ -51,6 +51,9 @@ printPageHeaders();
  <tr>
   <td colspan=2>
 <?php
+if (isset ($_REQUEST['ajaxResponse']) && $_REQUEST['ajaxResponse'] == 1)
+	ob_clean();
+
 if (isset ($tabhandler[$pageno][$tabno]))
 {
 	if (isset ($page[$pageno]['bypass']) && isset ($page[$pageno]['bypass_type']))
@@ -88,6 +91,13 @@ elseif (isset ($page[$pageno]['handler']
 }
 else
 	throw new RackTablesError ("Failed to find handler for page '${pageno}', tab '${tabno}'", RackTablesError::INTERNAL);
+
+if (isset ($_REQUEST['ajaxResponse']) && $_REQUEST['ajaxResponse'] == 1)
+{
+	ob_end_flush();
+	ob_start();
+}
+
 ?>
 	</td>
 	</tr>
@@ -95,6 +105,9 @@ else
 </body>
 </html>
 <?php
+	if (isset ($_REQUEST['ajaxResponse']) && $_REQUEST['ajaxResponse'] == 1)
+		ob_end_clean();
+	else
 	ob_end_flush();
 } catch (Exception $e) {
 	ob_end_clean();
Only in RackTables-0.18.4-ajax/js: jquery-1.4.2.min.js
Only in RackTables-0.18.4-ajax/js: jquery-ui-1.8.4.custom.min.js
diff -ruwp RackTables-0.18.4/js/racktables.js RackTables-0.18.4-ajax/js/racktables.js
--- RackTables-0.18.4/js/racktables.js	2010-04-22 17:23:32.000000000 +0200
+++ RackTables-0.18.4-ajax/js/racktables.js	2010-09-09 09:36:17.000000000 +0200
@@ -62,3 +62,180 @@ function checkColumnOfRadios (prefix, nu
 		document.getElementById(elemId).checked = true;
 	}
 }
+
+function sendGetRequest(url, successfunc)
+{
+	$.ajax({
+		type: 'GET',
+		url: url,
+		success: successfunc
+	});
+}
+
+function reloadPortRow(portid, objid)
+{
+	var currentTR = $('tr[id|=tr_'+portid+']')[0];
+	/*sendGetRequest('index.php?page=object&tab=port&object_id=' + objid + '&port_id=' + portid + '&ajaxResponse=1', function(data) {
+			$(currentTR).html(data);
+			//handle further submits by js:
+			$('input[name|=submit]', currentTR).attr('onclick', 'javascript:sendEditPortFormAsync(this, ' + portid + ', ' + objid + ');');
+			//submit on return-key:
+			$('input', currentTR).attr('onKeyPress', 'javascript:{ if(event.keyCode == 13) sendEditPortFormAsync(this, ' + portid + ', ' + objid + '); }');
+	});*/
+	$(currentTR).load('index.php?page=object&tab=port&object_id=' + objid + '&port_id=' + portid + '&ajaxResponse=1',
+			{},
+			function(responseText, textStatus, XMLHttpRequest) {
+				//handle further submits by js:
+				$('input[name|=submit]', currentTR).bind('click', function () {
+					sendEditPortFormAsync(this, portid, objid);
+				});
+				//submit on return-key:
+				$('input', currentTR).bind('keypress', function(event) { 
+					if(event.keyCode == 13) 
+						sendEditPortFormAsync(this, portid, objid); 
+					}
+				);
+			}
+	);
+}
+
+function sendEditPortLinkAsync(obj, portid, objid)
+{
+	sendGetRequest(obj.href, function(data) {
+		reloadPortRow(portid, objid);
+	});
+
+	obj.href = 'javascript://'; //blocks reloading
+	return false;
+}
+
+function sendEditPortFormAsync(obj, portid, objid)
+{
+	if($.browser.msie) //msie is making trouble ...
+		return true;
+	
+	var postData = null;
+	var currentTR = $('tr[id|=tr_' + portid + ']')[0];
+	var form = $('form[id|=editPort_' + portid + ']')[0];
+	
+	/* There are problems with the form-integration into the table (html forbids
+	 * this kind of integration), so we have to handle the submits from the second
+	 * update of a row on seperatley. The first one works, whyever.
+	 * This is also the cause of the msie problems.
+	 */ 
+	if($(obj).is('form'))
+	{
+		postData = $(form).serialize();
+	}
+	else
+	{
+		if($(obj).is('input'))
+		{
+			postData = $(form).serialize();
+			$('input', currentTR).add('select', currentTR).each(function(index, element) { 
+				var s = $(element).serialize();
+				if(s != '')
+					postData += '&' + s;
+			});
+		}
+		else
+			return true;
+	}
+	
+	//Send the form
+	$.ajax({ 
+		type: 'POST',
+    	url: form.action + '&ajaxNoRedir=1', //ajaxNoRedir->just error/success message is loaded instead of the whole site
+		data: postData,
+		success: function(data){
+			//Interpret the message returned
+			if($(data).hasClass('msg_success'))
+			{ 
+				$(currentTR).addClass('ajax_update_success');
+				$(currentTR).html('<td colspan="8"><center><p>Reloading ... please wait!</p></center></td>');
+				
+				reloadPortRow(portid, objid);
+				
+				setTimeout(function(){ $(currentTR).removeClass('ajax_update_success'); }, 5000);
+			}
+			else
+			{
+				$(currentTR).addClass('ajax_update_error');
+				alert('Error: ' + $(data).text());
+				setTimeout(function(){ $(currentTR).removeClass('ajax_update_error'); }, 5000);
+			}
+		} 
+	});
+	//JavaScript is on so don't send the form the old way (for a second time)
+	return false;
+}
+
+function makeDlgLinksAsync(dlg)
+{
+	$('a[href]', dlg).each(function(index, element) { 
+		$(element).bind('click', function() {
+			dlg.dialog('disable');
+			dlg.load(element.href + '&ajaxResponse=1',
+					{},
+					function (responseText, textStatus, XMLHttpRequest) {
+						makeDlgLinksAsync(dlg);
+						dlg.dialog('enable');
+					});
+			element.href = 'javascript://';
+			return false;
+		});
+	});
+}
+
+function showPopupInJSDlg(url, wndname, params)
+{
+	var dlg = $('div[id|=jsDlg]')[0];
+	if(dlg == null)
+		dlg = $('<div id="jsDlg" style="display:hidden"></div>').appendTo('body');
+	else
+		dlg = $(dlg);
+	
+	dlg.dialog({
+		autoOpen: false,
+		modal: true,
+		title: wndname,
+		width: 'auto',
+		close: function(event, ui) { dlg.dialog('destroy'); }
+	});
+	
+	opener = window; //so the "popup" can reference the window that it created
+	
+	dlg.load(
+			url + '&ajaxResponse=1', 
+			{},
+			function (responseText, textStatus, XMLHttpRequest) {
+				//overwrites the close-function declared as global variable in the popup code
+				dlgCloseFunc = function() { dlg.dialog('close'); };
+				
+				makeDlgLinksAsync(dlg);
+				
+				dlg.dialog('open');
+			}
+		);
+}
+
+function popupSubmitLinkPorts(portid, objid)
+{
+	var elem = document.getElementById("ports");
+	if((elem != null) && (elem.value != "")) {
+		if($.browser.msie) //msie is making trouble ...
+		{
+			window.opener.location="process.php?page=object&tab=ports&op=linkPort&object_id=" + objid + "&port_id=" + portid + "&remote_port_id=" + elem.value;
+			window.close();
+		}
+		else
+			opener.sendGetRequest("process.php?page=object&tab=ports&op=linkPort&object_id=" + objid + "&port_id=" + portid + "&remote_port_id=" + elem.value,
+				function(data) {
+					window.opener.reloadPortRow(portid, objid);
+					dlgCloseFunc(); //registered in the popupwindow-code
+				}
+			);
+	}
+	else
+		alert('You did not select a port!');
+}
diff -ruwp RackTables-0.18.4/pi.css RackTables-0.18.4-ajax/pi.css
--- RackTables-0.18.4/pi.css	2010-06-12 20:05:37.000000000 +0200
+++ RackTables-0.18.4-ajax/pi.css	2010-09-09 09:36:17.000000000 +0200
@@ -512,3 +512,12 @@ div.tagselector td {
 .rsvtext {
 	font-style: italic;
 }
+
+
+.ajax_update_success {
+	background-color: #a0ffa0;
+}
+
+.ajax_update_error {
+	background-color: #ffa0a0;
+}
Only in RackTables-0.18.4-ajax/pix: jqueryui-theme
diff -ruwp RackTables-0.18.4/popup.php RackTables-0.18.4-ajax/popup.php
--- RackTables-0.18.4/popup.php	2010-06-25 12:54:06.000000000 +0200
+++ RackTables-0.18.4-ajax/popup.php	2010-09-09 09:36:17.000000000 +0200
@@ -87,6 +87,13 @@ header ('Content-Type: text/html; charse
 	echo "<title>RackTables pop-up</title>\n";
 	printPageHeaders();
 	echo '</head><body style="height: 100%;">';
+	
+	//This helps closing the window as a popup and as a jqueryui dialog
+	echo "<script language='javascript'>var dlgCloseFunc = function() { window.close(); };</script>";
+	
+	if (isset ($_REQUEST['ajaxResponse']) && $_REQUEST['ajaxResponse'] == 1)
+		ob_clean();
+		
 	assertStringArg ('helper');
 	switch ($_REQUEST['helper'])
 	{
@@ -118,10 +125,7 @@ header ('Content-Type: text/html; charse
 
 			printSelect ($spare_ports, array ('name' => 'ports', 'size' => getConfigVar ('MAXSELSIZE')));
 			echo '<br><br>';
-			echo "<input type='submit' value='Link' onclick='".
-			"if (getElementById(\"ports\").value != \"\") {".
-			"	opener.location=\"process.php?page=object&tab=ports&op=linkPort&object_id=${port_info['object_id']}&port_id=$port_id&remote_port_id=\"+getElementById(\"ports\").value; ".
-			"	window.close();}'>";
+			echo "<input type='submit' value='Link' onclick='javascript:popupSubmitLinkPorts(${port_id}, ${port_info['object_id']});'>";
 			echo '</form></div>';
 			break;
 		case 'inet4list':
@@ -150,10 +154,19 @@ header ('Content-Type: text/html; charse
 		default:
 			throw new InvalidRequestArgException ('helper', $_REQUEST['helper']);
 	}
+	
+	if (isset ($_REQUEST['ajaxResponse']) && $_REQUEST['ajaxResponse'] == 1)
+	{
+		ob_end_flush();
+		ob_start();
+	}
 ?>
 </body>
 </html>
 <?php
+	if (isset ($_REQUEST['ajaxResponse']) && $_REQUEST['ajaxResponse'] == 1)
+		ob_end_clean();
+	else
 ob_end_flush();
 }
 catch (Exception $e)
diff -ruwp RackTables-0.18.4/process.php RackTables-0.18.4-ajax/process.php
--- RackTables-0.18.4/process.php	2010-06-30 18:42:19.000000000 +0200
+++ RackTables-0.18.4-ajax/process.php	2010-09-09 09:36:17.000000000 +0200
@@ -27,6 +27,12 @@ else
 	if (!strlen ($location))
 		throw new RackTablesError ('Operation handler failed to return its status', RackTablesError::INTERNAL);
 }
+if(isset($_REQUEST['ajaxNoRedir']) && $_REQUEST['ajaxNoRedir'] == 1)
+{
+	require_once 'inc/interface.php';
+	showMessageOrError();
+}
+else
 header ("Location: " . $location);
 ob_end_flush();
 }
RackTables-0.18.4-ajax.patch (20,723 bytes)   
ajax-ports.rar (82,890 bytes)

Activities

andriyanov

andriyanov

2010-09-14 09:46

reporter   ~0000131

Denis asked me to review your patch.

This patch adds pretty much code but does not provide new functionality or solve any problems.

All operations with device ports linking/unlinking can be done witout ajax as quickly as with it and more reliably.

Also the patch causes problems, for example when you link two ports of
a single device together, both ports will be shown linked only after page reload.

This ajax functionality does not work in MSIE, although there is no
fundamental problem with displaying jquery.ui dialogs with MSIE.

Instead of using ajax.php you've modified plenty of other files (
 index.php,
 navigation.php,
 popup.php,
 process.php
)
infrastation

infrastation

2010-09-14 10:35

administrator   ~0000132

The biggest problem about port selector is that it becomes barely usable with tens of thousands of OPTIONs. Ryan tried to solve that with DHTMLX Combo element earlier, but it didn't work.

If you could implement a good mean to choose from such large amount of port records, that would be demanded a lot.

user143

2010-11-19 12:45

  ~0000176

I've attached a new version of the patch.

The footprint (modified files) is reduced.
If you link two ports of a single device both ports are now updated and the port selector has a nice filter textbox.

The most important functionality: usability.
Furthermore: speed (page-reload with a 48-port switch takes a while).

Yet: no MSIE-Support

user143

2011-05-13 05:59

  ~0000329

anything new on this bug?
We have now "in-place AJAX editing of reservation comments on object ports and IP addresses" but this is still much more important for me..
andriyanov

andriyanov

2011-08-28 13:02

reporter   ~0000413

Port linker was pretty much improved in 0.19.6 and I believe, no AJAX functionality is needed in this place.

Issue History

Date Modified Username Field Change
2010-09-09 07:55 user143 New Issue
2010-09-09 07:55 user143 File Added: RackTables-0.18.4-ajax.patch
2010-09-09 07:55 user143 File Added: RackTables-0.18.4-ajax.patch-files.tar.gz
2010-09-14 09:46 andriyanov Note Added: 0000131
2010-09-14 10:35 infrastation Note Added: 0000132
2010-11-19 12:45 user143 Note Added: 0000176
2010-11-19 12:46 user143 File Added: ajax-ports.rar
2010-11-19 16:09 infrastation Status new => assigned
2010-11-19 16:09 infrastation Assigned To => andriyanov
2011-05-13 05:59 user143 Note Added: 0000329
2011-08-28 13:02 andriyanov Note Added: 0000413
2011-08-28 13:02 andriyanov Status assigned => closed
2011-08-28 13:02 andriyanov Fixed in Version => 0.19.6
2011-08-28 13:02 andriyanov Resolution open => no change required