Files
thetool/Layout/default/Device/Detail.php
Frank Schubert 95a452bba7 Merge branch 'master' into 'devbyspi'
# Conflicts:
#   Layout/default/Device/Detail.php
#   Layout/default/Device/Form.php
#   Layout/default/Device/Index.php
#   application/Device/DeviceController.php
#   application/Device/DeviceModel.php
#   public/assets/css/datatables-std.css
2023-03-22 14:36:13 +00:00

274 lines
13 KiB
PHP

<?php
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css" rel="stylesheet" type="text/css"/>
<style>
.card-border {
border-left: 1px solid #428bca;
border-left-width: 5px;
border-radius: 3px;
}
</style>
<!-- start page title -->
<div class="row">
<div class="col-12">
<div class="page-title-box">
<div class="page-title-right">
<ol class="breadcrumb m-0">
<li class="breadcrumb-item"><a href="<?= self::getUrl("Dashboard") ?>"><?= MFAPPNAME_SLUG ?></a>
</li>
<li class="breadcrumb-item"><a href="<?= self::getUrl("Device") ?>">Devices</a>
</li>
<li class="breadcrumb-item active">Device Detail</li>
</ol>
</div>
<h4 class="page-title">Device: <span class="font-weight-normal ml-1"><?= $devices->data->name ?></span> <span class="ml-2">
<a href="<?= self::getUrl("Device", "edit", ["id" => $devices->id, 'returnto' => "device-detail"]) ?>">
<button class="btn btn-primary">Bearbeiten</button>
</a>
</span></h4>
</div>
</div>
</div>
<!-- end page title -->
<?php
if ($devices->price != "0.00") {
$price = $devices->price;
} else {
$price = $devices->devicetype->price;
}
if ($devices->power != "0.0") {
$power = $devices->power;
} else {
$power = $devices->devicetype->power;
}
?>
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-5 card-border">
<div>
<h4>Allgemeine Informationen </h4>
</div>
<div>
<table class="table table-sm">
<tbody>
<tr>
<th>Device Name</th>
<td><?= $devices->name ?> </td>
</tr>
<tr>
<th>IP-Adresse</th>
<td><?= $devices->ip ?> </td>
</tr>
<tr>
<th>Geräte Typ</th>
<td><?= $devices->devicetype->name ?> </td>
</tr>
<tr>
<th>Geräte Hersteller</th>
<td><?= $devices->devicetype->devicemanufactor->name ?> </td>
</tr>
<tr>
<th>Mac Adresse</th>
<td><?= $devices->mac ?> </td>
</tr>
<tr>
<th>Seriennummer</th>
<td><?= $devices->serial ?> </td>
</tr>
<tr>
<th>Preis</th>
<td><?= $price ?> €</td>
</tr>
<tr>
<th>Leistung</th>
<td><?= $power ?> Watt</td>
</tr>
<tr>
<th>Bemerkung</th>
<td><?= nl2br($devices->comment) ?> </td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="col-4 card-border">
<div>
<h4>Pop Informationen</h4>
</div>
<?php
if (!empty(trim($devices->pop->name))) {
$vlans = "";
if (!empty(trim($devices->pop->vlan_public)))
$vlans .= '<span class="order-date-pill active mb-0">Public: <span class="font-weight-500">' . $devices->pop->vlan_public . '</span class="font-weight-500"></span>';
if (!empty(trim($devices->pop->vlan_nat)))
$vlans .= '<span class="order-date-pill active mb-0">Nat: <span class="font-weight-500">' . $devices->pop->vlan_nat . '</span></span>';
if (!empty(trim($devices->pop->vlan_ipv6)))
$vlans .= '<span class="order-date-pill active mb-0">IPv6: <span class="font-weight-500">' . $devices->pop->vlan_ipv6 . '</span></span>';
?>
<div>
<table class="table table-sm">
<tbody>
<tr>
<th>Pop Name</th>
<td>
<a href="<?= self::getUrl("Pop", "Detail", ["id" => $devices->pop->id]) ?>"><?= $devices->pop->name ?></a>
</td>
</tr>
<tr>
<th>Adresse</th>
<td>
<a title="Google-Maps: <?= rtrim($devices->pop->gps_lat, '0') ?> , <?= $devices->pop->gps_long ?>"
class="mapsLink"
href="http://maps.google.com/?q=<?= $devices->pop->gps_lat ?> , <?= $devices->pop->gps_long ?>"
target="_blank"><?= rtrim($devices->pop->gps_lat, '0') ?>
, <?= rtrim($devices->pop->gps_long, 0) ?></a></td>
</tr>
<tr>
<th>Standort Info</th>
<td><?= nl2br($devices->pop->location) ?> </td>
</tr>
<tr>
<th>Access VLANs</th>
<td><?= $vlans ?> </td>
</tr>
</tbody>
</table>
</div>
<?php
} else {
?>
<h5 class="text-center">Keine Standort Informationen vorhanden</h5>
<?php
}
?>
</div>
<div class="col-3 card-border">
<div class="overflow-auto">
<h4 class="float-left">Config Backups</h4>
<?php if ($devices->devicetype->devicemanufactor->config_backup > count()): ?>
<span><i title="Switch config" class="fa-light fa-rectangle-code code-ico"
data-toggle="modal" data-target="#configCode"></i></span>
<?php endif; ?>
<div class="float-right">
<a id="create-backup-href"
href="https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=createconfig&ip=<?= $devices->ip; ?>&id=<?= $devices->id; ?>">
<button class="btn btn-primary "><span id="create-backup-button-text">Backup erstellen</span>
<span id="create-backup-load"></i></span></button>
</a></div>
</div>
<?php
if ($devicesconfig->success == "true" && $devicesconfig->data > count()) {
?>
<div>
<table class="table table-sm">
<thead>
<tr>
<th>Datum/Uhrzeit</th>
<th></th>
</tr>
</thead>
<tbody>
<?php foreach ($devicesconfig->data as $config) :
$configfileCleartext = $config->config_cleartext;
$configfileCompressed = $config->config_compressed;
$configid = $config->id;
?>
<tr>
<td><?= date("d.m.Y/H:i", $config->config_timestamp); ?></td>
<td>
<a href="https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getconfig&id=<?= $configid; ?>&format=txt&filename=<?= $configfileCleartext; ?>">
TXT</a> / <a
href="https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getconfig&id=<?= $configid; ?>&format=xml&filename=<?= $configfileCompressed; ?>">
XML</a></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
} else {
?>
<div class="mt-1">
<h5 class="text-center">Keine Configs vorhanden</h5>
</div>
<?php
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php if ($devices->devicetype->devicemanufactor->config_backup > count()):
$year = date("Y", time());
$month = date("n", time());
$day = date("d", time());
$config = $devices->devicetype->devicemanufactor->config_backup;
$config = str_replace("&&YEAR&&", $year, $config);
$config = str_replace("&&MONTH&&", $month, $config);
$config = str_replace("&&DAY&&", $day, $config);
?>
<div class="modal fade" id="configCode" tabindex="-1" role="dialog" aria-labelledby="configCodeLabel"
aria-hidden="true">
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="configCodeLabel">SwitchConfig Autobackup</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<?= nl2br($config) ?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Schließen</button>
</div>
</div>
</div>
</div>
<?php endif; ?>
<script type="text/javascript">
$(document).ready(function () {
$('#create-backup-href').click(function () {
$('#create-backup-load').html('<i class="fas fa-spinner fa-spin spinner-ico"></i>');
$('#create-backup-button-text').text('Backup wird erstellt.')
});
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>