Skip to content

Commit

Permalink
Graphical cabnavigator opendcim#342
Browse files Browse the repository at this point in the history
  • Loading branch information
jomigom committed Jan 24, 2014
1 parent 7cb7700 commit 3726ca7
Show file tree
Hide file tree
Showing 10 changed files with 957 additions and 55 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Changes in 3.0
* Auto path making - will find the least weight connection between two points utilizing patch panels
* Half-depth support and front/rear cabinet views
* New email report on switch capacity, configured as either OptIn or OptOut
* Support multi-level containers for data centers grouping
* Support for defining zones and rows within data center
* Tooltips for CDUs with user defined data to display
* Enhanced search functions
Expand Down
134 changes: 130 additions & 4 deletions assets.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,9 @@ function CabinetOccupancy($CabinetID){

$CabinetID=intval($CabinetID);

$sql="SELECT SUM(Height) AS Occupancy FROM fac_Device WHERE Cabinet=$CabinetID;";
//$sql="SELECT SUM(Height) AS Occupancy FROM fac_Device WHERE Cabinet=$CabinetID;";
//JMGA halfdepth height calculation
$sql = "select sum(if(HalfDepth,Height/2,Height)) as Occupancy from fac_Device where Cabinet=$CabinetID";

if(!$row=$dbh->query($sql)->fetch()){
$info=$dbh->errorInfo();
Expand Down Expand Up @@ -1508,7 +1510,10 @@ function GetDeviceChildren() {

$this->MakeSafe();

$sql="SELECT * FROM fac_Device WHERE ParentDevice=$this->DeviceID ORDER BY ChassisSlots, Position ASC;";

// $sql="SELECT * FROM fac_Device WHERE ParentDevice=$this->DeviceID ORDER BY ChassisSlots, Position ASC;";
// JMGA
$sql="SELECT * FROM fac_Device WHERE ParentDevice=$this->DeviceID ORDER BY BackSide, Position ASC;";

$childList = array();

Expand All @@ -1522,8 +1527,10 @@ function GetDeviceChildren() {
function GetParentDevices(){
global $dbh;

$sql="SELECT * FROM fac_Device WHERE ChassisSlots>0 AND ParentDevice=0 ORDER BY Label ASC;";

// $sql="SELECT * FROM fac_Device WHERE ChassisSlots>0 AND ParentDevice=0 ORDER BY Label ASC;";
// JMGA multichassis
$sql="SELECT * FROM fac_Device WHERE ChassisSlots>0 ORDER BY Label ASC;";

$parentList=array();
foreach($dbh->query($sql) as $row){
// Assigning here will trigger the FilterRights method and check the cabinet rights
Expand Down Expand Up @@ -2089,6 +2096,125 @@ function GetDeviceTotalWeight(){
}
return $TotalWeight;
}
function GetChildDevicePicture($zoom){
global $dbh;

$resp="";

$templ=new DeviceTemplate();
$templ->TemplateID=$this->TemplateID;
$templ->GetTemplateByID();

$parentDev=new Device();
$parentDev->DeviceID=$this->ParentDevice;
$parentDev->GetDevice();

if ($templ->FrontPictureFile<>""){
$picturefile="pictures/".$templ->FrontPictureFile;
list($width, $height, $type, $attr)=getimagesize($picturefile);
$hor_blade=($width>$height);
$slot=new Slot();
$slot->TemplateID=$parentDev->TemplateID;
$slot->Position=$this->Position;
$slot->BackSide=$this->BackSide;
if ($slot->GetSlot()){
$hor_slot=($slot->W>$slot->H);
$rotar="";
if($hor_slot){
if(!$hor_blade)
$rotar=" rotar_i";
}else{
if($hor_blade)
$rotar=" rotar_d";
}
if($this->Rights!="None")
$resp.="<a href=\"devices.php?deviceid=$this->DeviceID\">";
if ($rotar==""){
$resp.="<div style='position:absolute; left:".$slot->X*$zoom."px; top:".$slot->Y*$zoom."px;'>";
$resp.="<img class='bladepict' data-deviceid=$this->DeviceID width='".$slot->W*$zoom."px' height='".$slot->H*$zoom."px' data-deviceid=$this->DeviceID src='pictures/".$templ->FrontPictureFile."' alt='".$this->Label."'>";
}
else {
//como la rotaci�n es desde el centro del div, lo posiciono en el centro del slot
$resp.="<div style='position:absolute; left:".(($slot->X-abs($slot->W-$slot->H)/2)*$zoom)."px; top:".(($slot->Y+abs($slot->W-$slot->H)/2)*$zoom)."px;'>";
$resp.="<img class='picturerot$rotar' data-deviceid=$this->DeviceID width='".$slot->H*$zoom."px' height='".$slot->W*$zoom."px' src='pictures/".$templ->FrontPictureFile."' alt='".$this->Label."'>";
}
//$resp.="</div>";
if ( $this->ChassisSlots > 0 ) {
//multichassis
$childList = $this->GetDeviceChildren();
foreach ( $childList as $tmpDev ) {
if (!$tmpDev->BackSide){
$resp.=$tmpDev->GetChildDevicePicture($zoom);
}
}
}
$resp.="</div>";
if($this->Rights!="None")
$resp.="</a>";
}
}
return $resp;
}
function GetDeviceFrontPicture(){
global $dbh;

$templ=new DeviceTemplate();
$templ->TemplateID=$this->TemplateID;
$templ->GetTemplateByID();
if ($templ->FrontPictureFile=="")
$resp="";
else {
//Device (front)
$picturefile="pictures/".$templ->FrontPictureFile;
list($width, $height, $type, $attr)=getimagesize($picturefile);
$ancho=220;
$zoom=$ancho/$width;

$resp="<div class='picture'>";
$resp.="<img class='picture' data-deviceid=$this->DeviceID width='".$ancho."px' src='".$picturefile."' alt='".$this->Label."'>";
//Front childs
if ( $this->ChassisSlots > 0 ) {
$childList = $this->GetDeviceChildren();
foreach ( $childList as $tmpDev ) {
if (!$tmpDev->BackSide){
$resp.=$tmpDev->GetChildDevicePicture($zoom);
} //if (!$tmpdev->BackSide){
} //foreach
}
$resp.="</div>";
}
return $resp;
}
function GetDeviceRearPicture(){
global $dbh;

$templ=new DeviceTemplate();
$templ->TemplateID=$this->TemplateID;
$templ->GetTemplateByID();
if ($templ->RearPictureFile=="")
$resp="";
else {
//Device (rear)
$picturefile="pictures/".$templ->RearPictureFile;
list($width, $height, $type, $attr)=getimagesize($picturefile);
$ancho=220;
$zoom=$ancho/$width;

$resp="<div class='picture'>";
$resp.="<img class='picture' data-deviceid=$this->DeviceID width='".$ancho."px' src='".$picturefile."' alt='".$this->Label."'>";
//Rear childs
if ( $this->RearChassisSlots > 0 ) {
$childList = $this->GetDeviceChildren();
foreach ( $childList as $tmpDev ) {
if ($tmpDev->BackSide){
$resp.=$tmpDev->GetChildDevicePicture($zoom);
} //if (!$tmpdev->BackSide){
} //foreach
}
$resp.="</div>";
}
return $resp;
}
}

class DevicePorts {
Expand Down
Loading

0 comments on commit 3726ca7

Please sign in to comment.