	Standortinformationen hinzugefügt (Wenn keine Pop ausgewählt)
	Umschaltbar Adresse/Koordinaten
	Adresse: Straße/Hausnummer/PLZ/Ort
	Huawei Backups Implementation
This commit is contained in:
Spitzer_Daniel
2023-04-06 15:53:33 +02:00
parent 214c0683e6
commit 73291d8ee0
6 changed files with 232 additions and 36 deletions

View File

@@ -2,7 +2,8 @@
?>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/header.php"); ?>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?=date('U')?>" rel="stylesheet" type="text/css"/>
<link href="<?= self::getResourcePath() ?>assets/css/datatables-std.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<style>
.card-border {
@@ -63,7 +64,7 @@ if ($devices->power != "0.0") {
<table class="table table-sm">
<tbody>
<tr>
<th>Device Name</th>
<th class="w-30">Device Name</th>
<td><?= $devices->name ?> </td>
</tr>
<tr>
@@ -104,29 +105,54 @@ if ($devices->power != "0.0") {
</div>
<?php
if ((trim($devices->pop->name))) {
$StdHeader = "Pop Informationen";
$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>';
} else if (trim($devices->addr_street)) {
if (trim($devices->addr_extended)) {
$addrExtended = ' / ' . $devices->addr_extended;
} else {
$addrExtended = "";
}
$StdHeader = "Standort Informationen";
$mapsHeader = "Adresse";
$mapsLink = '<a class="mapsLink"
href="http://maps.google.com/?q=' . $devices->addr_street . ' ' . $devices->addr_number . ' ' . $devices->addr_zip . ' ' . $devices->addr_city . '"
target="_blank"><div>' . $devices->addr_street . ' ' . $devices->addr_number . $addrExtended . '</div>
<div>' . $devices->addr_zip . ' ' . $devices->addr_city . '</div></a>';
} else if (trim($devices->gps_lat)) {
$StdHeader = "Standort Informationen";
$mapsHeader = "Koordinaten";
$mapsLink = '<a class="mapsLink"
href="http://maps.google.com/?q=' . $devices->gps_lat . ',' . $devices->gps_long . '"
target="_blank"><div>' . $devices->gps_lat . ' , ' . $devices->gps_long . '</div></a>';
}
?>
<div class="col-4 card-border">
<div>
<h4>Pop Informationen</h4>
<h4><?= $StdHeader ?></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>';
if ((trim($devices->pop->name))) {
?>
<div>
<table class="table table-sm">
<tbody>
<tr>
<th>Pop Name</th>
<th class="w-30">Pop Name</th>
<td>
<a href="<?= self::getUrl("Pop", "Detail", ["id" => $devices->pop->id]) ?>"><?= $devices->pop->name ?></a>
</td>
@@ -152,6 +178,24 @@ if ($devices->power != "0.0") {
</table>
</div>
<?php
} elseif (trim($devices->addr_street) || trim($devices->gps_lat)) {
?>
<div>
<table class="table table-sm">
<tbody>
<tr>
<th class="align-middle w-30"> <?= $mapsHeader ?></th>
<td>
<?= $mapsLink ?>
</td>
</tr>
<tr>
<td colspan="2"></td>
</tr>
</tbody>
</table>
</div>
<?php
} else {
?>
<h5 class="text-center">Keine Standort Informationen vorhanden</h5>
@@ -190,17 +234,23 @@ if ($devices->power != "0.0") {
</thead>
<tbody>
<?php foreach ($devicesconfig->data as $config) :
$configfileCleartext = $config->config_cleartext;
$configfileCompressed = $config->config_compressed;
$configfileCleartext = trim($config->config_cleartext);
$configfileCompressed = trim($config->config_compressed);
$configid = $config->id;
if ($configfileCleartext && $configfileCompressed) :
$configLinks = '<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>';
elseif ($configfileCleartext || $configfileCompressed) :
$configLinks = '<a href="https://' . $_SERVER['SERVER_NAME'] . '/Device/api?do=getconfig&id=<?= $configid; ?>&format=txt&filename=' . $configfileCleartext .$configfileCompressed . '">
TXT</a>';
endif;
?>
<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>
<td><?= $configLinks; ?></td>
</tr>
<?php endforeach; ?>

View File

@@ -21,7 +21,8 @@ if (isset($_GET['returnto']) && $_GET['returnto'] == "device-detail") {
$cancelUrl = self::getUrl("Device");
}
?>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?=date('U')?>" rel="stylesheet" type="text/css"/>
<link href="<?= self::getResourcePath() ?>assets/css/select2-cstm.css?<?= date('U') ?>" rel="stylesheet"
type="text/css"/>
<!-- start page title -->
<div class="row">
<div class="col-12">
@@ -47,7 +48,7 @@ if (isset($_GET['returnto']) && $_GET['returnto'] == "device-detail") {
<div class="card">
<div class="card-body">
<h4 class="header-title mb-2"><?= ($device->id) ? "Device bearbeiten" : "Neues Gerät" ?></h4>
<h4 class="header-title mb-2"><?= ($device->id) ? "Device bearbeiten" : "Neues Device" ?></h4>
<form class="form-horizontal" method="post"
action="<?= self::getUrl("Device", "save", ["returnto" => $_GET["returnto"]]) ?>">
<div class="card">
@@ -85,6 +86,63 @@ if (isset($_GET['returnto']) && $_GET['returnto'] == "device-detail") {
</select>
</div>
</div>
<div class="form-group row std-types">
<label class="col-lg-2 col-form-label">Adresse/Koordinaten</label>
<div class="col-lg-2">
<select class="select2 form-control " id="select-std-type">
<option value="0">Adresse</option>
<option
<?php if (trim($device->gps_lat)): ?>selected="selected"<?php endif; ?>
value="1">Koordinaten
</option>
</select>
</div>
</div>
<div class="form-group row addr-fields">
<label class="col-lg-2 col-form-label"
for="addr_street">Straße/Hausnummer/Stock-Tür</label>
<div class="col-lg-3">
<input type="text" class="form-control addr-fields" name="addr_street"
id="addr_street" placeholder="Dr. Auner Straße"
value="<?= $device->addr_street ?>">
</div>
<div class="col-lg-1">
<input type="text" class="form-control addr-fields" name="addr_number"
id="addr_number" placeholder="22"
value="<?= $device->addr_number ?>">
</div>
<div class="col-lg-1">
<input type="text" class="form-control addr-fields" name="addr_extended"
id="addr_extended" placeholder="OG5/1"
value="<?= $device->addr_extended ?>">
</div>
</div>
<div class="form-group row addr-fields">
<label class="col-lg-2 col-form-label" for="addr_zip">PLZ./Ort</label>
<div class="col-lg-1">
<input type="text" class="form-control" name="addr_zip"
id="addr_zip" placeholder="8074"
value="<?= $device->addr_zip ?>">
</div>
<div class="col-lg-4">
<input type="text" class="form-control" name="addr_city"
id="addr_city" placeholder="Raaba"
value="<?= $device->addr_city ?>">
</div>
</div>
<div class="form-group row gps-fields">
<label class="col-lg-2 col-form-label" for="gps_lat">GPS Breite/GPS Länge</label>
<div class="col-lg-2">
<input type="text" class="form-control " name="gps_lat"
id="gps_lat" placeholder="46.98........"
value="<?= $device->gps_lat ?>">
</div>
<div class="col-lg-2">
<input type="text" class="form-control" name="gps_long"
id="gps_long" placeholder="15.36........"
value="<?= $device->gps_long ?>">
</div>
</div>
<div class="form-group row">
<label class="col-lg-2 col-form-label" for="ip">IP-Adresse *</label>
<div class="col-lg-10">
@@ -169,6 +227,52 @@ if (isset($_GET['returnto']) && $_GET['returnto'] == "device-detail") {
$('form').on('blur', 'input[type=number]', function (e) {
$(this).off('wheel.disableScroll')
});
$(document).ready(function () {
if ($("#pop_id").val() != 0) {
$('#select-std-type').val('0');
$('#select-std-type').trigger('change');
$('.gps-fields').find('input').val('');
$('.gps-fields').hide();
$('.addr-fields').find('input').val('');
$('.addr-fields').hide();
$('.std-types').hide();
} else if ($("#select-std-type").val() == 0) {
$('.gps-fields').hide();
$('.addr-fields').show();
} else if ($("#select-std-type").val() == 1) {
$('.addr-fields').hide();
$('.gps-fields').show();
}
$("#pop_id").change(function () {
if ($(this).val() != 0) {
$('#select-std-type').val('0');
$('#select-std-type').trigger('change');
$('.gps-fields').find('input').val('');
$('.gps-fields').hide();
$('.addr-fields').find('input').val('');
$('.addr-fields').hide();
$('.std-types').hide();
} else {
$('.addr-fields').show();
$('.std-types').show();
}
});
$("#select-std-type").change(function () {
if ($(this).val() == 0) {
$('.gps-fields').find('input').val('');
$('.gps-fields').hide();
$('.addr-fields').show();
} else if ($(this).val() == 1) {
$('.addr-fields').find('input').val('');
$('.addr-fields').hide();
$('.gps-fields').show();
}
});
});
</script>
<?php include(realpath(dirname(__FILE__) . "/../../$mfLayoutPackage") . "/footer.php"); ?>

View File

@@ -17,6 +17,7 @@ class DeviceApicontroller extends mfBaseApicontroller
$deviceReturn[$key]['name'] = $device->name;
$deviceReturn[$key]['ip'] = $device->ip;
$deviceReturn[$key]['serial'] = $device->serial;
$deviceReturn[$key]['manufactor'] = $device->devicetype->devicemanufactor->name;
}
return mfResponse::Ok($deviceReturn);

View File

@@ -100,6 +100,26 @@ class DeviceController extends mfBaseController
} else {
$data['pop_id'] = $r->pop_id;
}
if (!(trim($r->addr_street))) {
$data['addr_street'] = NULL;
$data['addr_number'] = NULL;
$data['addr_extended'] = NULL;
$data['addr_zip'] = NULL;
$data['addr_city'] = NULL;
} else {
$data['addr_street'] = $r->addr_street;
$data['addr_number'] = $r->addr_number;
$data['addr_extended'] = $r->addr_extended;
$data['addr_zip'] = $r->addr_zip;
$data['addr_city'] = $r->addr_city;
}
if (!trim($r->gps_lat) || !trim($r->gps_long)) {
$data['gps_lat'] = NULL;
$data['gps_long'] = NULL;
} else {
$data['gps_lat'] = $r->gps_lat;
$data['gps_long'] = $r->gps_long;
}
$data['ip'] = $r->ip;
$data['mac'] = $r->mac;
$data['serial'] = $r->serial;
@@ -216,6 +236,19 @@ class DeviceController extends mfBaseController
}
protected function deleteAction()
{
$id = $this->request->id;
$device = new Device($id);
if (!$device->id || $device->id != $id) {
$this->layout()->setFlash("Gerätetyp nicht gefunden.", "error");
$this->redirect("Device");
}
$device->delete();
$this->redirect("Device");
}
private function getConfig($id, $format, $filename)
{
$configDownload = DeviceModel::getconifgdownload($id, $format);
@@ -234,13 +267,10 @@ class DeviceController extends mfBaseController
$r = $this->request;
$id = $r->id;
$createConfig = DeviceModel::configcreate($ip);
if ($createConfig->success==="true")
{
if ($createConfig->success === "true") {
$this->layout()->setFlash("Backup wurde erfolgreich erstellt", "success");
}
else
{
$this->layout()->setFlash("Backup konnte nicht erstellt werden. <b>Fehler</b>: ".$createConfig->error, "error");
} else {
$this->layout()->setFlash("Backup konnte nicht erstellt werden. <b>Fehler</b>: " . $createConfig->error, "error");
}
$returnUrl = "Device";
$returnAction = "Detail";

View File

@@ -9,8 +9,13 @@ class DeviceModel
public $comment = null;
public $devicetype_id = null;
public $pop_id = null;
public $addr_street = null;
public $addr_number = null;
public $addr_extended = null;
public $addr_zip = null;
public $gps_lat = null;
public $addr_city = null;
public $gps_long = null;
public $create_by = null;
public $edit_by = null;
public $create = null;
@@ -188,7 +193,7 @@ class DeviceModel
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://172.16.5.56/api/deviceconfigscreate/' . $ip ,
CURLOPT_URL => 'https://172.16.5.56/api/deviceconfigscreate/' . $ip,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,

View File

@@ -33,7 +33,7 @@
}
.edit-width-large {
width: 100px;
width: 128px;
}
.order-date-pill {
@@ -67,17 +67,23 @@
}
.filestore-history {
background-color: #33ff0021 !important;
}
.filestore-history-td {
padding: 0 0px 0 10px !important;
box-shadow: unset;
}
.filestore-history-td:hover {
box-shadow: unset !important;
}
.filestore-history-tr:hover{
.filestore-history-tr:hover {
color: unset !important;
background-color: #fff !important;
}
.w-30 {
width: 33% !important;
}