View Issue Details

IDProjectCategoryView StatusLast Update
905RackTablesdefaultpublic2013-08-03 19:22
Reportersbrown@saskpower.com Assigned Toadoom42  
PrioritynormalSeveritytextReproducibilityalways
Status closedResolutionfixed 
Product Version0.20.5 
Target Version0.20.6Fixed in Version0.20.6 
Summary905: Show location of Rack or Object in blue title bar
DescriptionI noticed you have added the location break down of the racks to the rackspace page.

I tried to find the bug report I had put in a few months ago about a feature request similar to this but was unable to find it.

Would it be possible to put the location in the breadcrumb bar as well?

When I click on a rack from the rackspace page I get a bar that looks like this:

Main page : Rackspace : 1 : 01



This could be any number of racks within our organization since we have many locations to manage.


Ideally it would look something like this:

Main page : Rackspace : Location : Sub-Location (as deep as it needs to go) : Rack x : Row y


Also the same issue exists with naming when viewing the contents of a rack or an object.

The name above the rack shows 1 : 01 with no indication of where it actually resides. Currently I use both tags and the locations feature to display the physical location of my assets.


I work for a power utility that has multiple data centers across our province so having a clear indication of where a rack / object is located is important to us.
Steps To ReproduceGo to the RackSpace page.
Additional InformationIf a SQL dump or testing is required, please contact me.
TagsNo tags attached.

Activities

blaza-pl

blaza-pl

2013-08-01 08:37

reporter  

location-trail_functions.php.patch (1,392 bytes)   
--- ../../racktables-prod/inc/functions.php	2013-07-02 15:17:42.000000000 +0200
+++ ./functions.php	2013-07-31 14:45:12.557187967 +0200
@@ -6116,4 +6116,49 @@
 	return FALSE;
 }
 
+
+
+// function getLocationTrail requires location id 
+// and optional: spacer/delimiter 
+// and optional: link - if href link should be create to each location
+// it returns html string with parent location names 
+function getLocationTrail($loc_id, $link = true, $spacer = " : ")
+{
+
+	//build location lookup table:
+        $loc_tree = listCells('location');
+        
+        global $loc_name_tbl;
+        global $loc_parents;
+        
+	//lets do it once and then use it again in next function calls
+        if(count($loc_name_tbl) == 0)
+	{
+	        $loc_name_tbl = array();
+		$loc_parents = array();
+		//populate tables
+		foreach($loc_tree as $loc)
+	        {
+            		$loc_parents[$loc['id']] = $loc['parent_id'];
+		        $loc_name_tbl[$loc['id']] = $loc['name'];
+		}
+	}
+
+	//generate parent location to given location string
+        $name = "";
+        $id=$loc_id;
+        while(isset($id))
+        {
+		if($link)
+			$name = mkA($loc_name_tbl[$id],'location',$id) . $spacer . $name;
+		else
+			$name = $loc_name_tbl[$id] . $spacer . $name;
+                $id = $loc_parents[$id];
+        }
+	$name = substr($name,0,0 - strlen($spacer));
+
+	return $name;
+}
+
+
 ?>
blaza-pl

blaza-pl

2013-08-01 08:38

reporter  

location-trail_interface.php.patch (3,650 bytes)   
--- ../../racktables-prod/inc/interface.php	2013-07-17 13:29:48.021322333 +0200
+++ ./interface.php	2013-08-01 08:19:32.433190996 +0200
@@ -912,14 +912,18 @@
 		highlightObject ($rackData, $hl_obj_id);
 	$prev_id = getPrevIDforRack ($rackData['row_id'], $rack_id);
 	$next_id = getNextIDforRack ($rackData['row_id'], $rack_id);
-	echo "<center><table border=0><tr valign=middle>";
-	echo '<td><h2>' . mkA ($rackData['row_name'], 'row', $rackData['row_id']) . ' :</h2></td>';
+	echo "<center>";
+	$trail = getLocationTrail($rackData['location_id']);
+	if(!empty($trail))
+		echo "<h2>" . $trail   . " :</h2>";
+	echo "<h2>" .  mkA ($rackData['row_name'], 'row', $rackData['row_id']) . " :</h2><h2>";
 	if ($prev_id != NULL)
-		echo '<td>' . mkA (getImageHREF ('prev', 'previous rack'), 'rack', $prev_id) . '</td>';
-	echo '<td><h2>' . mkA ($rackData['name'], 'rack', $rackData['id']) . '</h2></td>';
+		echo mkA (getImageHREF ('prev', 'previous rack'), 'rack', $prev_id);
+	echo mkA ($rackData['name'], 'rack', $rackData['id']);
 	if ($next_id != NULL)
-		echo '<td>' . mkA (getImageHREF ('next', 'next rack'), 'rack', $next_id) . '</td>';
-	echo "</h2></td></tr></table>\n";
+		echo mkA (getImageHREF ('next', 'next rack'), 'rack', $next_id);
+	echo "</h2>";
+	
 	echo "<table class=rack border=0 cellspacing=0 cellpadding=1>\n";
 	echo "<tr><th width='10%'>&nbsp;</th><th width='20%'>Front</th>";
 	echo "<th width='50%'>Interior</th><th width='20%'>Back</th></tr>\n";
@@ -1592,30 +1596,15 @@
 function renderRackMultiSelect ($sname, $racks, $selected)
 {
 
-	$loc_tree = listCells('location');
-	$loc_name_tbl = array();
-	$loc_parents = array();
-	foreach($loc_tree as $loc)
-	{
-		$loc_parents[$loc['id']] = $loc['parent_id'];
-		$loc_name_tbl[$loc['id']] = $loc['name'];
-	}
-	
-
-
 	// Transform the given flat list into a list of groups, each representing a rack row.
 	$rdata = array();
 	foreach ($racks as $rack)
 	{
-		$name = "";
-		$id=$rack['location_id'];
-		while(isset($id))
-		{
-			$name = $loc_name_tbl[$id] . " / " . $name;
-			$id = $loc_parents[$id];
-		}
-
-		$row_name = $name . $rack['row_name'];
+		$trail = getLocationTrail($rack['location_id'],false);
+		if(!empty($trail))
+			$row_name = $trail . " : "  . $rack['row_name'];
+		else
+			$row_name =  $rack['row_name'];
 		$rdata[$row_name][$rack['id']] = $rack['name'];
 	}
 	echo "<select name=${sname} multiple size=" . getConfigVar ('MAXSELSIZE') . " onchange='getElementsByName(\"updateObjectAllocation\")[0].submit()'>\n";
@@ -6269,6 +6264,22 @@
 		$item .= $ancor_tail;
 		$item .= "'>" . $title['name'] . "</a>";
 		$items[] = $item;
+
+		//location bread crumbs insert for Rows and Racks
+		if($no == "row")
+		{
+			//print_r($title);
+			$trail = getLocationTrail($title['params']['location_id']);
+			if(!empty($trail))
+				$items[] = $trail;
+		}
+		
+		if($no == "location")
+		{
+			//we overwrite the bread crumb for current location with whole path
+			$items[count($items)-1] = getLocationTrail($title['params']['location_id']);
+		}
+
 	}
 	// Search form.
 	echo "<div class='searchbox' style='float:right'>";
@@ -6399,14 +6410,14 @@
 			return array
 			(
 				'name' => $rack['row_name'],
-				'params' => array ('row_id' => $rack['row_id'])
+				'params' => array ('row_id' => $rack['row_id'], 'location_id' => $rack['location_id'])
 			);
 		case 'row':
 			$row_info = getRowInfo (assertUIntArg ('row_id'));
 			return array
 			(
 				'name' => $row_info['name'],
-				'params' => array ('row_id' => $row_info['id'])
+				'params' => array ('row_id' => $row_info['id'], 'location_id' => $row_info['location_id'])
 			);
 		default:
 			break;
blaza-pl

blaza-pl

2013-08-01 08:47

reporter   ~0001663

I have created a patch that show the whole Location path in bread crumbs (for Location, Row and Rack), in Rackspace tab of Object and over the Rack on multiple pages (Object, Rack).

This overwrites the changes made in bug 925.
adoom42

adoom42

2013-08-03 19:22

administrator   ~0001693

blaza-pl, thanks for the patch.

Issue History

Date Modified Username Field Change
2013-06-24 19:27 sbrown@saskpower.com New Issue
2013-08-01 08:37 blaza-pl File Added: location-trail_functions.php.patch
2013-08-01 08:38 blaza-pl File Added: location-trail_interface.php.patch
2013-08-01 08:47 blaza-pl Note Added: 0001663
2013-08-03 19:22 adoom42 Note Added: 0001693
2013-08-03 19:22 adoom42 Assigned To => adoom42
2013-08-03 19:22 adoom42 Status new => closed
2013-08-03 19:22 adoom42 Resolution open => fixed
2013-08-03 19:22 adoom42 Fixed in Version => 0.20.6
2013-08-03 19:22 adoom42 Target Version => 0.20.6