Devices:
• Übersicht Pop/Adressen/Koordinaten Verlinkungen Pop: • Fontsize in Übersicht auf 13px geändert für bessere Übersicht • Neue Features: o Poprackverwaltung v1 CRUD o Poprackmodulverwaltung V1 CRUD
This commit is contained in:
@@ -6,6 +6,11 @@ $pagination_entity_name = "Device";
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
|
||||
type="text/css"/>
|
||||
<style>
|
||||
table.dataTable.table-sm > thead > tr > th:not(.sorting_disabled) {
|
||||
padding-right: 1.5rem;
|
||||
}
|
||||
</style>
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
@@ -37,22 +42,18 @@ $pagination_entity_name = "Device";
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
|
||||
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table id="datatable" class="table table-striped table-hover table-sm font-13">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="min-width: 250px;">Device Name</th>
|
||||
<th class="text-center">Geräte Typ</th>
|
||||
<th class="text-center">Hersteller</th>
|
||||
<th class="text-center">Pop</th>
|
||||
<th class="text-center">Pop/Adresse</th>
|
||||
<th class="text-center">IP-Adresse</th>
|
||||
<th class="text-center">Mac-Adresse</th>
|
||||
<th class="text-center">Seriennummer</th>
|
||||
<th class="text-center">Preis</th>
|
||||
<th class="text-center">max. Leistung</th>
|
||||
<th class="text-center text-nowrap ml-2 mr-2">max. Leistung</th>
|
||||
<th class="text-center">Backup</th>
|
||||
<th class="edit-width"></th>
|
||||
</tr>
|
||||
@@ -97,7 +98,17 @@ $pagination_entity_name = "Device";
|
||||
$backup = '<i class="fa-regular fa-ban" title="Kein Configbackup"><span style="display: none">N/A</span></i>';
|
||||
}
|
||||
|
||||
|
||||
if ($device->pop->id) {
|
||||
$destination = '<a href="' . self::getUrl("Pop", "Detail", ["id" => $device->pop->id]) . '">' . $device->pop->name . '</a>';
|
||||
} else if ($device->addr_street) {
|
||||
$address = $device->addr_street . " " . $device->addr_number . ", " . $device->addr_zip . " " . $device->addr_city;
|
||||
$destination = '<a title="Google-Maps: ' . $address . '" class="mapsLink" href="http://maps.google.com/?q=' . $address . '" target="_blank">' . $address . '</a>';
|
||||
} else if ($device->gps_lat) {
|
||||
$address = $device->gps_lat . " , " . $device->gps_long;
|
||||
$destination = '<a title="Google-Maps: ' . $address . '" class="mapsLink" href="http://maps.google.com/?q=' . $address . '" target="_blank">' . $address . '</a>';
|
||||
} else {
|
||||
$destination = '';
|
||||
}
|
||||
?>
|
||||
|
||||
<tr>
|
||||
@@ -106,14 +117,14 @@ $pagination_entity_name = "Device";
|
||||
</td>
|
||||
<td class="text-center"><?= $device->devicetype->name ?></td>
|
||||
<td class="text-center"><?= $device->devicetype->devicemanufactor->name ?></td>
|
||||
<td class="text-center"><?= $device->pop->name ?></td>
|
||||
<td class="text-center text-nowrap"><?= $destination ?></td>
|
||||
|
||||
|
||||
<td class="text-center"><?= $device->ip ?></td>
|
||||
<td class="text-center"><?= $device->mac ?></td>
|
||||
<td class="text-center"><?= $device->serial ?></td>
|
||||
<td class="text-right"><?= $price ?> €</td>
|
||||
<td class="text-right"><?= $power ?> Watt</td>
|
||||
<td class="text-right text-nowrap"><?= $price ?> €</td>
|
||||
<td class="text-right text-nowrap"><?= $power ?> Watt</td>
|
||||
<td class="text-center"><?= $backup ?></td>
|
||||
|
||||
|
||||
@@ -129,11 +140,6 @@ $pagination_entity_name = "Device";
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
|
||||
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
|
||||
<!---->
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -142,11 +148,11 @@ $pagination_entity_name = "Device";
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
var hidesearch = [10];
|
||||
var hidesearch = [7, 8, 10];
|
||||
var columndefs = {type: 'ip-address', targets: 4};
|
||||
|
||||
var columnfilter = [9];
|
||||
var columnoptions='<option value=""></option><option value="OK">OK</option><option value="AGED">AGED</option><option value="N/A">N/A</option>';
|
||||
var columnoptions = '<option value=""></option><option value="OK">OK</option><option value="AGED">AGED</option><option value="N/A">N/A</option>';
|
||||
$(document).ready(function () {
|
||||
|
||||
});
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,4 +1,17 @@
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
|
||||
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php");
|
||||
|
||||
if (isset($_GET['returnto']) && $_GET['returnto'] == "pop-detail") {
|
||||
$cancelUrl = self::getUrl("Pop", "Detail", ["id" => $pop->id]);
|
||||
$cancelText="Pop Detail";
|
||||
} else if (isset($_GET['returnto'])) {
|
||||
$cancelUrl = self::getUrl("Pop");
|
||||
$cancelText="Pops";
|
||||
} else
|
||||
{
|
||||
$cancelUrl = self::getUrl("Network");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!-- start page title -->
|
||||
<div class="row">
|
||||
@@ -11,14 +24,14 @@
|
||||
<?php if (empty($_GET["returnto"])) {
|
||||
?>
|
||||
<li class="breadcrumb-item"><a href="<?= self::getUrl("Network") ?>">Netzgebiete</a></li>
|
||||
<li class="breadcrumb-item">POP</li>
|
||||
<li class="breadcrumb-item">Pop</li>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
|
||||
<li class="breadcrumb-item"><a
|
||||
href="<?= self::getUrl(ucfirst($_GET["returnto"])) ?>"><?= strtoupper($_GET["returnto"]) ?>
|
||||
></a></li>
|
||||
href="<?= $cancelUrl ?>"><?= ucfirst($cancelText) ?>
|
||||
</a></li>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
@@ -140,6 +153,9 @@
|
||||
<label class="col-lg-2"></label>
|
||||
<div class="col-lg-10">
|
||||
<button type="submit" class="btn btn-primary">Speichern</button>
|
||||
<a href="<?= $cancelUrl ?>">
|
||||
<button type="button" class="btn btn-secondary">Abbrechen</button>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -37,10 +37,11 @@ $pagination_entity_name = "Pops";
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination.php"); ?>
|
||||
<!-- --><?php //include(realpath(dirname(__FILE__) . "/../") . "/tpl/pagination-summary.php"); ?>
|
||||
|
||||
<table id="datatable" class="table table-striped table-hover table-sm">
|
||||
<table id="datatable" class="table table-striped table-hover table-sm font-13">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
||||
@@ -43,6 +43,7 @@ class PopController extends mfBaseController
|
||||
|
||||
$this->layout()->setTemplate("Pop/Detail");
|
||||
$filter['pop_id'] = $id;
|
||||
$this->layout()->set("popracks", PoprackModel::getAllbyPop($id));
|
||||
$this->layout()->set("devices", DeviceModel::search($filter));
|
||||
$pops = PopModel::getOne($id);
|
||||
$this->layout()->set("pops", $pops);
|
||||
@@ -151,7 +152,6 @@ class PopController extends mfBaseController
|
||||
$returnAction = "";
|
||||
$returnVariables['id'] = $id;
|
||||
$this->returUrl = $returnUrl;
|
||||
var_dump($returnUrl);
|
||||
} else {
|
||||
$this->returUrl = ucfirst($this->request->returnto);
|
||||
|
||||
|
||||
25
application/Poprack/Poprack.php
Normal file
25
application/Poprack/Poprack.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
class Poprack extends mfBaseModel
|
||||
{
|
||||
|
||||
private $pop;
|
||||
|
||||
public function getProperty($name)
|
||||
{
|
||||
if ($this->$name == null) {
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name . "_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if ($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
}
|
||||
229
application/Poprack/PoprackController.php
Normal file
229
application/Poprack/PoprackController.php
Normal file
@@ -0,0 +1,229 @@
|
||||
<?php
|
||||
|
||||
class PoprackController extends mfBaseController
|
||||
{
|
||||
protected function apiAction()
|
||||
{
|
||||
$do = $this->request->do;
|
||||
|
||||
$data = [];
|
||||
|
||||
switch ($do) {
|
||||
case "addRack":
|
||||
$return = $this->addRack();
|
||||
break;
|
||||
case "editRack":
|
||||
$return = $this->editRack();
|
||||
break;
|
||||
case "removeRack":
|
||||
$return = $this->removeRack();
|
||||
break;
|
||||
case "sortRack":
|
||||
$return = $this->sortRack();
|
||||
break;
|
||||
case "generateRack";
|
||||
$return = $this->generateRack();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
|
||||
if (!is_array($return) || !count($return)) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
$data['status'] = "OK";
|
||||
$data['result'] = $return;
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
private function addRack()
|
||||
{
|
||||
$r = $this->request;
|
||||
$pop_id = $r->pop_id;
|
||||
$data = [];
|
||||
$data['name'] = trim($r->name);
|
||||
$data['he'] = trim($r->he);
|
||||
$data['pop_id'] = trim($pop_id);
|
||||
$poprack = PoprackModel::create($data);
|
||||
|
||||
$new_id = $poprack->save();
|
||||
// var_dump($r);die();
|
||||
if (!$new_id) {
|
||||
$response['success'] = false;
|
||||
} else {
|
||||
$response['success'] = true;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function editRack()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->poprack_id;
|
||||
$poprack = new Poprack($id);
|
||||
$response['success'] = false;
|
||||
if ($poprack->id) {
|
||||
$data = [];
|
||||
$data['name'] = $r->name;
|
||||
$data['he'] = $r->he;
|
||||
$poprack->update($data);
|
||||
if ($poprack->save()) {
|
||||
$response['success'] = true;
|
||||
}
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function sortRack()
|
||||
{
|
||||
$r = $this->request;
|
||||
$racksortids = $r->racksortids;
|
||||
// var_dump($racksortids);
|
||||
// die();
|
||||
|
||||
foreach ($racksortids as $sort => $id) {
|
||||
$poprack = new Poprack($id);
|
||||
$response['success'] = false;
|
||||
if ($poprack->id) {
|
||||
$data = [];
|
||||
$data['sort'] = $sort;
|
||||
$poprack->update($data);
|
||||
if ($poprack->save()) {
|
||||
$response['success'] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
private function removeRack()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$poprack = new Poprack($id);
|
||||
if (!$poprack->id || $poprack->id != $id) {
|
||||
$response['success'] = false;
|
||||
} else {
|
||||
$poprack->delete();
|
||||
$response['success'] = true;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
private function generateRack()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$cellwidth = 227;
|
||||
$blocktd = 0;
|
||||
$poprack = PoprackModel::getAllbyRack($id);
|
||||
$plugs[1] = "LC";
|
||||
$plugs[2] = "SC";
|
||||
$plugs[3] = "E2000";
|
||||
for ($i = 1; $i <= $poprack[0]['rack']['he']; $i++) :
|
||||
echo '<tr>
|
||||
<td class="border-right w-15 p-0 pl-1 pr-1 border-bottom font-13 rack-he user-select-none"
|
||||
data-toggle="modal" data-target="#rackModuleModal"
|
||||
style="cursor: pointer" data-he="' . $i . '">He' . $i . '</td>';
|
||||
foreach ($poprack[0]['modules'] as $module) {
|
||||
|
||||
if ($module['start_he'] == $i) {
|
||||
$modulestart = 1;
|
||||
|
||||
$modulelenght = $module['end_he'] - $module['start_he'] + 1;
|
||||
$position = 1;
|
||||
$slotcounter = 0;
|
||||
$calcwidth = 0;
|
||||
$extText = "";
|
||||
$extTextspan="";
|
||||
foreach ($module['slots'] as $slots) {
|
||||
$extText = "";
|
||||
if ($slots['type'] == '0') {
|
||||
$color = '#9fff6e';
|
||||
$colorclass = "rack-color-lwl";
|
||||
if ($slots['plug']) {
|
||||
|
||||
$extText = " (" . $plugs[$slots['plug']] . "/" . $slots['ports'] . "P)";
|
||||
$extTextspan = "<span style='font-size: 12px;font-weight: 400'>".$extText."</span>";
|
||||
}
|
||||
} else if ($slots['type'] == '1') {
|
||||
|
||||
$color = '#b6c6ff';
|
||||
$colorclass = "rack-color-device";
|
||||
} else if ($slots['type'] == '2') {
|
||||
|
||||
$color = '#ff8100';
|
||||
$colorclass = "rack-color-rpanel";
|
||||
} else if ($slots['type'] == '3') {
|
||||
$color = '#ffad59';
|
||||
$colorclass = "rack-color-infra";
|
||||
} else if ($slots['type'] == '4') {
|
||||
$color = '#96f3de';
|
||||
$colorclass = "rack-color-panel";
|
||||
} else if ($slots['type'] == '5') {
|
||||
$color = '#96f3de';
|
||||
$colorclass = "rack-color-blocked";
|
||||
}
|
||||
if ($slots['width'] == "12") {
|
||||
$width = "85%";
|
||||
$maxwidth = $cellwidth;
|
||||
} else if ($slots['width'] == "6") {
|
||||
$width = "42%";
|
||||
$maxwidth = intval($cellwidth / 2);
|
||||
} else if ($slots['width'] == "4") {
|
||||
$width = "28%";
|
||||
$maxwidth = intval($cellwidth / 3);
|
||||
} else if ($slots['width'] == "3") {
|
||||
$width = "21%";
|
||||
$maxwidth = intval($cellwidth / 4);
|
||||
}
|
||||
if ($slots['width'] < 12 && $position != $slots['position']) {
|
||||
echo '<td colspan="' . $slots['width'] . '" style="width: ' . $width . ';" class="text-center border-top border-bottom border-right text-nowrap text-truncate pl-1 pr-1" rowspan="' . $modulelenght . '">frei</td>';
|
||||
$position++;
|
||||
$calcwidth = $calcwidth + $slots['width'];
|
||||
|
||||
}
|
||||
if ($slots['width'] < 12 && $position != $slots['position']) {
|
||||
echo '<td colspan="' . $slots['width'] . '" style="width: ' . $width . ';" class="text-center border-top border-bottom border-righttext-nowrap text-truncate pl-1 pr-1" rowspan="' . $modulelenght . '">frei</td>';
|
||||
$position++;
|
||||
$calcwidth = $calcwidth + $slots['width'];
|
||||
}
|
||||
if ($slots['width'] < 12 && $position != $slots['position']) {
|
||||
echo '<td colspan="' . $slots['width'] . '" style="width: ' . $width . ';" class="text-center border-top border-bottom border-right text-nowrap text-truncate pl-1 pr-1" rowspan="' . $modulelenght . '">frei</td>';
|
||||
$position++;
|
||||
$calcwidth = $calcwidth + $slots['width'];
|
||||
}
|
||||
echo '<td title="' . $slots['modulname'] . $extText . '" colspan="' . $slots['width'] . '" class="text-center border-top border-bottom border-right text-nowrap text-truncate pl-1 pr-1 ' . $colorclass . '" data-id="' . $slots['moduleid'] . '" data-type="' . $slots['type'] . '" data-name="' . $slots['modulname'] . '" data-starthe="' . $module['start_he'] . '" data-ports="' . $slots['ports'] . '" data-plug="' . $slots['plug'] . '" rowspan="' . $modulelenght . '" style="width: ' . $width . '; background-color: ' . $color . ';border-color: #797979 !important; white-space: nowrap; text-overflow: ellipsis;max-width: ' . $maxwidth . 'px;"><span></span> ' . $slots['modulname'] . $extTextspan . '</td>';
|
||||
$position++;
|
||||
$calcwidth = $calcwidth + $slots['width'];
|
||||
}
|
||||
if ($calcwidth != 12) {
|
||||
echo '<td colspan="' . $slots['width'] . '" style="width: ' . $width . ';" class="text-center border-top border-bottom border-right text-nowrap text-truncate pl-1 pr-1" rowspan="' . $modulelenght . '">frei</td>';
|
||||
$calcwidth = $calcwidth + $slots['width'];
|
||||
}
|
||||
if ($calcwidth != 12) {
|
||||
echo '<td colspan="' . $slots['width'] . '" style="width: ' . $width . ';" class="text-center border-top border-bottom border-right text-nowrap text-truncate pl-1 pr-1" rowspan="' . $modulelenght . '">frei</td>';
|
||||
$calcwidth = $calcwidth + $slots['width'];
|
||||
}
|
||||
if ($calcwidth != 12) {
|
||||
echo '<td colspan="' . $slots['width'] . '" style="width: ' . $width . ';" class="text-center border-top border-bottom border-right text-nowrap text-truncate pl-1 pr-1" rowspan="' . $modulelenght . '">frei</td>';
|
||||
$calcwidth = $calcwidth + $slots['width'];
|
||||
}
|
||||
|
||||
$blocktd = $modulelenght + $i;
|
||||
|
||||
}
|
||||
}
|
||||
if ($i >= $blocktd) {
|
||||
echo '<td colspan="12" style="background-color: #fff;" class="text-center he-free" ><span></span> frei</td>';
|
||||
}
|
||||
echo '</tr>';
|
||||
endfor;
|
||||
die();
|
||||
}
|
||||
}
|
||||
183
application/Poprack/PoprackModel.php
Normal file
183
application/Poprack/PoprackModel.php
Normal file
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
class PoprackModel
|
||||
{
|
||||
public $pop_id = null;
|
||||
public $name = null;
|
||||
public $he = null;
|
||||
public $sort = null;
|
||||
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
public static function create(array $data)
|
||||
{
|
||||
$model = new Poprack();
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if (property_exists(get_called_class(), $field)) {
|
||||
if (substr($field, 0, 5) == "vlan_" && !$value) {
|
||||
$model->$field = null;
|
||||
continue;
|
||||
}
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = mfValuecache::singleton()->get("me");
|
||||
if (!$me) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
mfValuecache::singleton()->set("me", $me);
|
||||
}
|
||||
|
||||
if ($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if ($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
public static function getAllbyPop($pop_id)
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "(SELECT `Poprackmodule`.`type`,`Poprack`.`id`,`Poprack`.`sort`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Poprackmodule`.`name` as `modulname`,device_id ,`Poprackmodule`.`id` as moduleid,`Poprackmodule`.`width` as modulewidth,`Poprackmodule`.`position` as moduleposition,`Poprackmodule`.`ports` as moduleports,`Poprackmodule`.`plug` as moduleplug FROM `Poprack`
|
||||
LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id` AND `Poprackmodule`.`type`!=1)
|
||||
WHERE `Poprack`.`pop_id`='" . $pop_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.start_he,`Poprackmodule`.position)
|
||||
UNION
|
||||
(SELECT `Poprackmodule`.`type`,`Poprack`.`id`,`Poprack`.`sort`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Device`.`name` as `modulname`,device_id,`Poprackmodule`.`id` as moduleid,`Poprackmodule`.`width` as modulewidth,`Poprackmodule`.`position` as moduleposition,`Poprackmodule`.`ports` as moduleports,`Poprackmodule`.`plug` as moduleplug FROM `Poprack`
|
||||
LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id` AND `Poprackmodule`.`type`=1)
|
||||
LEFT JOIN `Device` ON (`Device`.`id`=`Poprackmodule`.`device_id`)
|
||||
WHERE `Poprack`.`pop_id`='" . $pop_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.start_he,`Poprackmodule`.position)
|
||||
ORDER BY sort,name,start_he,moduleposition
|
||||
";
|
||||
|
||||
//
|
||||
// $sql = "SELECT `Poprack`.`id`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Poprackmodule`.`name` as `modulname` FROM `Poprack`
|
||||
// LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id`)
|
||||
// WHERE `Poprack`.`pop_id`='" . $pop_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.`start_he`";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
$oldrackid = "";
|
||||
$counter = -1;
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
|
||||
if ($oldrackid != $data['id']) {
|
||||
$counter++;
|
||||
$items[$counter]['rack']['id'] = $data['id'];
|
||||
$items[$counter]['rack']['name'] = $data['name'];
|
||||
$items[$counter]['rack']['he'] = $data['he'];
|
||||
$modulecounter = 0;
|
||||
}
|
||||
if ($data['modulname']) {
|
||||
if ($data['device_id']) {
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['device_id'] = $data['device_id'];
|
||||
}
|
||||
$items[$counter]['modules'][$data['start_he']]['start_he'] = $data['start_he'];
|
||||
$items[$counter]['modules'][$data['start_he']]['end_he'] = $data['end_he'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['modulname'] = $data['modulname'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['moduleid'] = $data['moduleid'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['type'] = $data['type'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['width'] = $data['modulewidth'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['position'] = $data['moduleposition'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['ports'] = $data['moduleports'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['plug'] = $data['moduleplug'];
|
||||
$modulecounter++;
|
||||
}
|
||||
$oldrackid = $data['id'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getAllbyRack($rack_id)
|
||||
{
|
||||
$items = [];
|
||||
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "(SELECT `Poprackmodule`.`type`,`Poprack`.`id`,`Poprack`.`sort`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Poprackmodule`.`name` as `modulname`,device_id ,`Poprackmodule`.`id` as moduleid,`Poprackmodule`.`width` as modulewidth,`Poprackmodule`.`position` as moduleposition,`Poprackmodule`.`ports` as moduleports,`Poprackmodule`.`plug` as moduleplug FROM `Poprack`
|
||||
LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id` AND `Poprackmodule`.`type`!=1)
|
||||
WHERE `Poprack`.`id`='" . $rack_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.start_he,`Poprackmodule`.position)
|
||||
UNION
|
||||
(SELECT `Poprackmodule`.`type`,`Poprack`.`id`,`Poprack`.`sort`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Device`.`name` as `modulname`,device_id,`Poprackmodule`.`id` as moduleid,`Poprackmodule`.`width` as modulewidth,`Poprackmodule`.`position` as moduleposition,`Poprackmodule`.`ports` as moduleports,`Poprackmodule`.`plug` as moduleplug FROM `Poprack`
|
||||
LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id` AND `Poprackmodule`.`type`=1)
|
||||
LEFT JOIN `Device` ON (`Device`.`id`=`Poprackmodule`.`device_id`)
|
||||
WHERE `Poprack`.`id`='" . $rack_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.start_he,`Poprackmodule`.position)
|
||||
ORDER BY sort,name,start_he,moduleposition
|
||||
";
|
||||
|
||||
//
|
||||
// $sql = "SELECT `Poprack`.`id`, `Poprack`.`name`, `Poprack`.`he`,`Poprackmodule`.start_he,`Poprackmodule`.end_he,`Poprackmodule`.`name` as `modulname` FROM `Poprack`
|
||||
// LEFT JOIN `Poprackmodule` ON (`Poprackmodule`.`poprack_id`=`Poprack`.`id`)
|
||||
// WHERE `Poprack`.`pop_id`='" . $pop_id . "' ORDER by `Poprack`.`sort`,`Poprack`.`name`,`Poprackmodule`.`start_he`";
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
$oldrackid = "";
|
||||
$counter = -1;
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
|
||||
if ($oldrackid != $data['id']) {
|
||||
$counter++;
|
||||
$items[$counter]['rack']['id'] = $data['id'];
|
||||
$items[$counter]['rack']['name'] = $data['name'];
|
||||
$items[$counter]['rack']['he'] = $data['he'];
|
||||
$modulecounter = 0;
|
||||
}
|
||||
if ($data['modulname']) {
|
||||
if ($data['device_id']) {
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['device_id'] = $data['device_id'];
|
||||
}
|
||||
$items[$counter]['modules'][$data['start_he']]['start_he'] = $data['start_he'];
|
||||
$items[$counter]['modules'][$data['start_he']]['end_he'] = $data['end_he'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['modulname'] = $data['modulname'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['moduleid'] = $data['moduleid'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['type'] = $data['type'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['width'] = $data['modulewidth'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['position'] = $data['moduleposition'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['ports'] = $data['moduleports'];
|
||||
$items[$counter]['modules'][$data['start_he']]['slots'][$data['moduleid']]['plug'] = $data['moduleplug'];
|
||||
$modulecounter++;
|
||||
}
|
||||
$oldrackid = $data['id'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $items;
|
||||
|
||||
}
|
||||
|
||||
public static function getpoprack($pop_id)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT `id`, `name`, `he` FROM `Poprack` WHERE pop_id='" . $pop_id . "' ";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$items[] = $data;
|
||||
}
|
||||
|
||||
$response['data'] = $items;
|
||||
$response['success'] = true;
|
||||
|
||||
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
25
application/Poprackmodule/Poprackmodule.php
Normal file
25
application/Poprackmodule/Poprackmodule.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
class Poprackmodule extends mfBaseModel
|
||||
{
|
||||
private $poprack;
|
||||
|
||||
public function getProperty($name)
|
||||
{
|
||||
if ($this->$name == null) {
|
||||
|
||||
$classname = ucfirst($name);
|
||||
$idfield = $name . "_id";
|
||||
$this->$name = new $classname($this->$idfield);
|
||||
|
||||
if ($this->$name->id) {
|
||||
return $this->$name;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return $this->$name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
116
application/Poprackmodule/PoprackmoduleController.php
Normal file
116
application/Poprackmodule/PoprackmoduleController.php
Normal file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
class PoprackmoduleController extends mfBaseController
|
||||
{
|
||||
protected function apiAction()
|
||||
{
|
||||
$do = $this->request->do;
|
||||
|
||||
$data = [];
|
||||
|
||||
switch ($do) {
|
||||
case "addModule":
|
||||
$return = $this->addModule();
|
||||
break;
|
||||
case "removeModule":
|
||||
$return = $this->removeModule();
|
||||
break;
|
||||
case "updateModule":
|
||||
$return = $this->updateModule();
|
||||
break;
|
||||
default:
|
||||
$return = false;
|
||||
}
|
||||
|
||||
if (!is_array($return) || !count($return)) {
|
||||
$data = ["status" => "error"];
|
||||
$this->returnJson($data);
|
||||
}
|
||||
$data['status'] = "OK";
|
||||
$data['result'] = $return;
|
||||
$this->returnJson($data);
|
||||
}
|
||||
|
||||
private function addModule()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
$data = [];
|
||||
$data['poprack_id'] = $r->poprack_id;
|
||||
$data['type'] = $r->type;
|
||||
if ($data['type'] == 0) {
|
||||
$data['ports'] = ($r->ports) ? $r->ports : null;
|
||||
$data['plug'] = ($r->plug) ? $r->plug : null;
|
||||
}
|
||||
if ($data['type'] == 1) {
|
||||
$data['device_id'] = ($r->device_id) ? $r->device_id : null;
|
||||
}
|
||||
$data['name'] = ($r->name) ? $r->name : null;
|
||||
$data['start_he'] = $r->start_he;
|
||||
$data['end_he'] = $r->end_he;
|
||||
$data['width'] = $r->width;
|
||||
$data['position'] = ($r->position) ? $r->position : null;
|
||||
|
||||
$poprackmodule = PoprackmoduleModel::create($data);
|
||||
|
||||
$new_id = $poprackmodule->save();
|
||||
// var_dump($r);die();
|
||||
if (!$new_id) {
|
||||
$response['success'] = false;
|
||||
} else {
|
||||
$response['success'] = true;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function updateModule()
|
||||
{
|
||||
$r = $this->request;
|
||||
$id = $r->id;
|
||||
if (is_numeric($id) && $id > 0) {
|
||||
$poprackmodule = new Poprackmodule($id);
|
||||
if (!$poprackmodule->id) {
|
||||
$response['success'] = false;
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
die();
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
|
||||
if ($r->type == 0) {
|
||||
$data['ports'] = ($r->ports) ? $r->ports : null;
|
||||
$data['plug'] = ($r->plug) ? $r->plug : null;
|
||||
}
|
||||
$data['name'] = ($r->name);
|
||||
$poprackmodule->update($data);
|
||||
|
||||
$new_id = $poprackmodule->save();
|
||||
// var_dump($r);die();
|
||||
if (!$new_id) {
|
||||
$response['success'] = false;
|
||||
} else {
|
||||
$response['success'] = true;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
private function removeModule()
|
||||
{
|
||||
$id = $this->request->id;
|
||||
$poprackmodule = new Poprackmodule($id);
|
||||
if (!$poprackmodule->id || $poprackmodule->id != $id) {
|
||||
$response['success'] = false;
|
||||
} else {
|
||||
$poprackmodule->delete();
|
||||
$response['success'] = true;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
77
application/Poprackmodule/PoprackmoduleModel.php
Normal file
77
application/Poprackmodule/PoprackmoduleModel.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php
|
||||
|
||||
class PoprackmoduleModel
|
||||
{
|
||||
|
||||
public $poprack_id = null;
|
||||
public $type = null;
|
||||
public $device_id = null;
|
||||
public $name = null;
|
||||
public $start_he = null;
|
||||
public $end_he = null;
|
||||
public $width = null;
|
||||
public $ports = null;
|
||||
public $plug = null;
|
||||
public $position = null;
|
||||
public $create_by = null;
|
||||
public $edit_by = null;
|
||||
public $create = null;
|
||||
public $edit = null;
|
||||
|
||||
public static function create(array $data)
|
||||
{
|
||||
$model = new Poprackmodule();
|
||||
|
||||
foreach ($data as $field => $value) {
|
||||
if (property_exists(get_called_class(), $field)) {
|
||||
if (substr($field, 0, 5) == "vlan_" && !$value) {
|
||||
$model->$field = null;
|
||||
continue;
|
||||
}
|
||||
$model->$field = $value;
|
||||
}
|
||||
}
|
||||
|
||||
$me = mfValuecache::singleton()->get("me");
|
||||
if (!$me) {
|
||||
$me = new User();
|
||||
$me->loadMe();
|
||||
mfValuecache::singleton()->set("me", $me);
|
||||
}
|
||||
|
||||
if ($model->create_by === null) {
|
||||
$model->create_by = $me->id;
|
||||
}
|
||||
if ($model->edit_by === null) {
|
||||
$model->edit_by = $me->id;
|
||||
}
|
||||
|
||||
return $model;
|
||||
}
|
||||
|
||||
|
||||
public static function getpoprackmodule($poprack_id)
|
||||
{
|
||||
$items = [];
|
||||
$db = FronkDB::singleton();
|
||||
$sql = "SELECT `id`, `name`, `start_he`,`end_he` FROM `Poprackmodule` WHERE `poprack_id`='" . $poprack_id . "' AND type ='0' ORDER by name";
|
||||
|
||||
$res = $db->query($sql);
|
||||
if ($db->num_rows($res)) {
|
||||
while ($data = $db->fetch_array($res)) {
|
||||
$items[] = $data;
|
||||
}
|
||||
|
||||
$response['data'] = $items;
|
||||
$response['success'] = true;
|
||||
|
||||
|
||||
} else {
|
||||
$response['success'] = false;
|
||||
}
|
||||
echo json_encode($response);
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@ let table;
|
||||
if (typeof hidesearch === "undefined") {
|
||||
var hidesearch;
|
||||
hidesearch = [100];
|
||||
console.log(hidesearch);
|
||||
}
|
||||
|
||||
if (typeof cstmdom === "undefined") {
|
||||
|
||||
Reference in New Issue
Block a user