Device OLT Anpassungen

- Service Ports können nun Live gesynct werden
This commit is contained in:
Daniel Spitzer
2025-06-23 22:25:22 +02:00
parent bfbf9a1c12
commit 5ef2f39582
3 changed files with 129 additions and 4 deletions

View File

@@ -365,7 +365,8 @@ foreach ($devicesall as $deviceall) {
<div class="col-12 col-lg-3 card-border">
<div class="overflow-auto">
<h4 class="float-left">Config Backups</h4>
<span><i class="fa-sharp fa-solid fa-arrows-spin fa-backup-check <?= ($devices->backup_check) ? '' : 'fa-backup-check-uncheck' ?>" title=" <?= ($devices->backup_check) ? 'Backup Check aktiv' : 'Backup Check inaktiv' ?>"></i></span>
<span><i class="fa-sharp fa-solid fa-arrows-spin fa-backup-check <?= ($devices->backup_check) ? '' : 'fa-backup-check-uncheck' ?>"
title=" <?= ($devices->backup_check) ? 'Backup Check aktiv' : 'Backup Check inaktiv' ?>"></i></span>
<?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>
@@ -471,9 +472,19 @@ foreach ($devicesall as $deviceall) {
</div>
<div id="olt-info" class="row pt-1 mt-1" style="border-top:1px dotted #428bca7d;display: none">
<div class="col-7 card-border">
<div>
<h4>OLT/ONT Informationen </h4>
<h5><span id="olt-uptime"></span></h5>
<div class="row">
<div class="col-lg-4">
<h4>OLT/ONT Informationen </h4>
<h5><span id="olt-uptime"></span></h5>
</div>
<div class="col-lg-6">
<h4>Serviceports von <span style="width: 20px;"
class="mr-4 ont-serviceport-refresh-span "><i
title="Refresh"
class="fa-solid fa-rotate-right ont-serviceport-refresh"></i></span>
</h4>
<h5><span id="olt-serviceports"></span></h5>
</div>
</div>
<div id="olt-body"></div>
</div>
@@ -992,6 +1003,26 @@ foreach ($devicesall as $deviceall) {
table.draw();
}
const apiUrl = "<?= self::getUrl('Device', 'api', ['do' => 'deviceoltserviceporttimestamp', 'ip' => $devices->ip]) ?>";
// Funktion, die die Daten holt und ins DOM schreibt
function updateTimestamp() {
$.getJSON(apiUrl)
.done(function(data) {
$('#olt-serviceports').text('(' + data.data.timestamp + ')');
})
.fail(function(jqxhr, textStatus, error) {
console.error('Error fetching timestamp:', textStatus, error);
});
}
// Erstaufruf direkt beim Laden der Seite
updateTimestamp();
// Dann alle 30 000 ms (30 Sekunden) wiederholen
setInterval(updateTimestamp, 10000);
}).fail(function (jqxhr, textStatus, error) {
window.location.href = "Dashboard";
console.log("Request Failed: " + err);
@@ -1037,6 +1068,25 @@ foreach ($devicesall as $deviceall) {
});
$("body").on("click", ".ont-serviceport-refresh", function () {
if ($(this).hasClass('noclick')) {
return;
}
$('.ont-serviceport-refresh').addClass('noclick');
$('.ont-serviceport-refresh-span').html('<i class="fas fa-spinner fa-spin spinner-ico text-info"></i>');
$.getJSON("<?= self::getUrl("Device", "api", ['do' => 'deviceoltserviceportrefresh', 'ip' => $devices->ip]) ?>", {})
.done(function (data) {
setTimeout(function () {
$('.spinner-border').remove();
$('.ont-serviceport-refresh').removeClass('noclick');
$('.ont-serviceport-refresh-span').html(
'<i title="Refresh" class="fa-solid fa-rotate-right ont-serviceport-refresh"></i>'
);
}, 8000);
});
});
$("body").on("click", ".sp-splitter-count-show", function () {
if ($(this).hasClass('noclick')) {
return;

View File

@@ -337,6 +337,12 @@ class DeviceController extends mfBaseController
case "changeoltsplitter":
$this->changeoltSplitter($id, $portid, $ports);
break;
case "deviceoltserviceporttimestamp":
$this->deviceoltserviceporttimestamp($ip);
break;
case "deviceoltserviceportrefresh":
$this->deviceoltserviceportrefresh($ip);
break;
default:
$return = false;
}
@@ -423,6 +429,21 @@ class DeviceController extends mfBaseController
exit;
}
private function deviceoltserviceporttimestamp($ip)
{
$deviceoltserviceporttimestamp = DeviceModel::deviceoltserviceporttimestamp($ip);
echo json_encode($deviceoltserviceporttimestamp);
exit;
}
private function deviceoltserviceportrefresh($ip)
{
$deviceoltserviceportrefresh = DeviceModel::deviceoltserviceportrefresh($ip);
echo json_encode($deviceoltserviceportrefresh);
exit;
}
private function getontInfoMac($ip, $portid, $ont)
{
$r = $this->request;

View File

@@ -337,6 +337,60 @@ class DeviceModel
endif;
return json_decode($response);
}
public static function deviceoltserviceporttimestamp($ip)
{
$url = TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceoltserviceporttimestamp/' . $ip;
$response = "";
if (TT_MBI_API_ENABLE) :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . TT_MBI_API_KEY),
));
$response = curl_exec($curl);
curl_close($curl);
endif;
return json_decode($response);
}
public static function deviceoltserviceportrefresh($ip)
{
$url = TT_MBI_API_URL . TT_MBI_API_VERSION . '/deviceoltserviceportrefresh/' . $ip;
$response = "";
if (TT_MBI_API_ENABLE) :
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_SSL_VERIFYHOST => false,
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'Authorization: Bearer ' . TT_MBI_API_KEY),
));
$response = curl_exec($curl);
curl_close($curl);
endif;
return json_decode($response);
}
public static function changeoltSplitter($id, $portid, $ports)
{