Skip to content

Commit

Permalink
Indicator of missing template '(T)' and/or '(O)' was missing in the l…
Browse files Browse the repository at this point in the history
…egend 'Markup Key' and on zero devices.

The display is slightly re-factored and the blink attribute not any more applied since most modern browsers don't display it anyway. In case it is required for some browsers it can be added by defining a CSS class 'blink'.
  • Loading branch information
AndHam89 committed Feb 18, 2014
1 parent 2f10358 commit 0d22fbb
Show file tree
Hide file tree
Showing 3 changed files with 1,758 additions and 37 deletions.
97 changes: 60 additions & 37 deletions cabnavigator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

/**
* Determines ownership of the cabinet and returns the CSS class in case a
* color unequal white is assigned to the owner
* color unequal white is assigned to the owner.
*
* @param Cabinet $cabinet
* @param array $deptswithcolor
Expand Down Expand Up @@ -105,6 +105,31 @@ function renderCabinetProps($cab, $audit, $AuditorName)
return $renderedHTML;
}

/**
* Render the indicator that a device has no ownership or template assigned.
*
* @param Device $device
* @return (boolean|boolean|string)[] CSS class or empty stringtype
*/
function renderUnassignedTemplateOwnership($device) {
$retstr = '';
if ($device->TemplateID == 0) {
$noTemplate = '(T)';
$template_unassigned = true;
}
if ($device->Owner == 0) {
$noOwnership = '(O)';
$ownership_unassigned = true;
}
if ($template_unassigned or $ownership_unassigned) {
// most modern browsers don't display anymore the blinking text therefore
// it is dropped.
# $retstr = '<span class="hlight blink">' . $noTemplate . $noOwnership . '</span>';
$retstr = '<span class="hlight">' . $noTemplate . $noOwnership . '</span>';
}
return array($template_unassigned, $ownership_unassigned, $retstr);
}

$cab=new Cabinet();
$cab->CabinetID=$_REQUEST["cabinetid"];
$cab->GetCabinet();
Expand Down Expand Up @@ -172,15 +197,15 @@ function renderCabinetProps($cab, $audit, $AuditorName)
list($cab_color, $deptswithcolor) = getColorofCabinetOwner($cab, $deptswithcolor);

if($config->ParameterArray["ReservedColor"] != "#FFFFFF" || $config->ParameterArray["FreeSpaceColor"] != "#FFFFFF"){
$head.=" <style type=\"text/css\">
.reserved{background-color: {$config->ParameterArray['ReservedColor']};}
.freespace{background-color: {$config->ParameterArray['FreeSpaceColor']};}\n";
$head .= " <style type=\"text/css\">
.reserved {background-color: {$config->ParameterArray['ReservedColor']};}
.freespace {background-color: {$config->ParameterArray['FreeSpaceColor']};}\n";

if($config->ParameterArray["ReservedColor"] != "#FFFFFF"){
$legend.='<p><span class="reserved border">&nbsp;&nbsp;&nbsp;&nbsp;</span> - '.__("Reservation").'</p>';
$legend.='<p><span class="reserved colorbox border"></span> - '.__("Reservation").'</p>';
}
if($config->ParameterArray["FreeSpaceColor"] != "#FFFFFF"){
$legend.='<p><span class="freespace border">&nbsp;&nbsp;&nbsp;&nbsp;</span> - '.__("Free Space").'</p>';
$legend.='<p><span class="freespace color border"></span> - '.__("Free Space").'</p>';
}
}

Expand All @@ -194,7 +219,8 @@ function BuildCabinet($rear=false){
// This is fucking horrible, there has to be a better way to accomplish this.
global $cab_color, $cab, $device, $body, $highlight, $currentHeight, $heighterr,
$devList, $templ, $tempDept, $backside, $deptswithcolor, $tempDept,
$totalWeight, $totalWatts, $totalMoment, $zeroheight;
$totalWeight, $totalWatts, $totalMoment, $zeroheight,
$template_unassigned, $ownership_unassigned;

$currentHeight=$cab->CabinetHeight;

Expand All @@ -205,6 +231,8 @@ function BuildCabinet($rear=false){
$heighterr="";
while(list($dev_index,$device)=each($devList)){
if($device->Height<1 && !$rear){
list($template_unassigned, $ownership_unassigned, $highlight) =
renderUnassignedTemplateOwnership($device);
if($device->Rights!="None"){
$zeroheight.="\t\t\t<a href=\"devices.php?deviceid=$device->DeviceID\" data-deviceid=$device->DeviceID>$highlight $device->Label</a>\n";
}else{
Expand All @@ -229,17 +257,8 @@ function BuildCabinet($rear=false){
$deptswithcolor[$device->Owner]["color"]=$tempDept->DeptColor;
$deptswithcolor[$device->Owner]["name"]=$tempDept->Name;
}

$highlight="<blink><font color=red>";
if($device->TemplateID==0){
$highlight.="(T)";
$template_unassigned = true;
}
if($device->Owner==0){
$highlight.="(O)";
$ownership_unassigned = true;
}
$highlight.= "</font></blink>";
list($template_unassigned, $ownership_unassigned, $highlight) =
renderUnassignedTemplateOwnership($device);

$totalWatts+=$device->GetDeviceTotalPower();
$DeviceTotalWeight=$device->GetDeviceTotalWeight();
Expand Down Expand Up @@ -331,27 +350,31 @@ function BuildCabinet($rear=false){
if(isset($deptswithcolor[""])){unset($deptswithcolor[""]);}

// We're done processing devices so build the legend and style blocks
if(!empty($deptswithcolor)){
foreach($deptswithcolor as $deptid => $row){
// If head is empty then we don't have any custom colors defined above so add a style container for these
if($head==""){$head.=" <style type=\"text/css\">\n";}
$head.=" .dept$deptid{background-color: {$row['color']};}\n";
$legend.="<p><span class=\"border dept$deptid\">&nbsp;&nbsp;&nbsp;&nbsp;</span> - <span>{$row['name']}</span></p>\n";
}
}
if (!empty($deptswithcolor)) {
foreach ($deptswithcolor as $deptid => $row) {
// If head is empty then we don't have any custom colors defined above so add a style container for these
if ($head == "") {
$head .= " <style type=\"text/css\">\n";
}
$head .= " .dept$deptid {background-color: {$row['color']};}\n";
$legend .= "<div class=\"legenditem\"><span class=\"border colorbox dept$deptid\"></span> - <span>{$row['name']}</span></div>\n";
}
}

// This will add an item to the legend for a white box. If we ever get a good name for it.
if($legend!=""){
// This will add an item to the legend for a white box. If we ever get a good name for it.
if ($legend != "") {
// $legend.='<p><span class="border">&nbsp;&nbsp;&nbsp;&nbsp;</span> - Custom Color Not Assigned</p>';
}
// add legend for the flags which actually used in the cabinet
$legend_flags = '';
if ($ownership_unassigned) {
$legend_flags.= ' <p><font color=red>(O)</font> - '.__("Owner Unassigned").'</p>';
}
if ($template_unassigned) {
$legend_flags .= ' <p><font color=red>(T)</font> - '.__("Template Unassigned").'</p>';
}
}
// add legend for the flags which actually are used in the cabinet
$legend_flags = '';
if ($ownership_unassigned) {
$legend_flags .= ' <div class="legenditem"><span class="hlight">(O)</span> - '
. __("Owner Unassigned") . '</div>';
}
if ($template_unassigned) {
$legend_flags .= ' <div class="legenditem"><span class="hlight"> - '
. __("Template Unassigned") . '</div>';
}


$body.='<div id="infopanel">
Expand Down
6 changes: 6 additions & 0 deletions css/inventory.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,12 @@
}
.request legend {border: 1px <?php echo $config->ParameterArray['HeaderColor']; ?> solid;background-color: white; padding: .15em;}
.errmsg {display:block;font-style:italic;margin-left:2em;}
.hlight {color: red;}
.legenditem { }
.colorbox {width: 1em; display: inline-block; height: 1.2em; margin: 0px;
padding: 0px; }
}


/* Datacenter Stats */
.dcstats .heading > div{width: 89%;display: inline-block;vertical-align: middle;}
Expand Down
Loading

0 comments on commit 0d22fbb

Please sign in to comment.