Ajax Requests auf getUrl umgebaut

This commit is contained in:
Spitzer_Daniel
2023-08-29 09:14:06 +02:00
parent 56f5666cb3
commit 0c9c7ffc43
+15 -12
View File
@@ -334,7 +334,7 @@ if ($devices->power != "0.0") {
<?php endif; ?> <?php endif; ?>
<div class="float-right"> <div class="float-right">
<a id="create-backup-href" <a id="create-backup-href"
href="https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=createconfig&ip=<?= $devices->ip; ?>&id=<?= $devices->id; ?>"> href="<?= self::getUrl("Device", "api", ['do' => 'createconfig', 'ip' => $devices->ip, 'id' => $devices->id]) ?>"
<button class="btn btn-primary "><span id="create-backup-button-text">Backup erstellen</span> <button class="btn btn-primary "><span id="create-backup-button-text">Backup erstellen</span>
<span id="create-backup-load"></i></span></button> <span id="create-backup-load"></i></span></button>
</a></div> </a></div>
@@ -356,11 +356,12 @@ if ($devices->power != "0.0") {
$configfileCompressed = trim($config->config_compressed); $configfileCompressed = trim($config->config_compressed);
$configid = $config->id; $configid = $config->id;
if ($configfileCleartext && $configfileCompressed) : 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 . '"> $configLinks = '<a href="' . self::getUrl("Device", "api", ['do' => 'getconfig', 'id' => $configid, 'format' => 'txt', 'filename' => $configfileCleartext]) . '">
TXT</a> / <a href="' . self::getUrl("Device", "api", ['do' => 'getconfig', 'id' => $configid, 'format' => 'xml', 'filename' => $configfileCompressed]) . '">
XML</a>'; XML</a>';
elseif ($configfileCleartext || $configfileCompressed) : elseif ($configfileCleartext || $configfileCompressed) :
$configLinks = '<a href="https://' . $_SERVER['SERVER_NAME'] . '/Device/api?do=getconfig&id=' . $configid . '&format=txt&filename=' . $configfileCleartext . $configfileCompressed . '"> $configLinks = '<a href="' . self::getUrl("Device", "api", ['do' => 'getconfig', 'id' => $configid, 'format' => 'txt', 'filename' => $configfileCleartext . $configfileCompressed]) . '">
TXT</a>'; TXT</a>';
endif; endif;
@@ -674,7 +675,7 @@ if ($devices->power != "0.0") {
$('#olt-info-button').remove(); $('#olt-info-button').remove();
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getoltinfo&ip=<?= $devices->ip; ?>", {}) $.getJSON("<?= self::getUrl("Device", "api", ['do' => 'getoltinfo', 'ip' => $devices->ip]) ?>", {})
.done(function (data) { .done(function (data) {
if (data.success == false) { if (data.success == false) {
$('#olt-body').text('Keine OLT/ONT Daten verfügbar'); $('#olt-body').text('Keine OLT/ONT Daten verfügbar');
@@ -867,7 +868,8 @@ if ($devices->power != "0.0") {
$("body").on("blur", "#change-splitter-ports", function () { $("body").on("blur", "#change-splitter-ports", function () {
var portid = $(this).closest('span').data('portid'); var portid = $(this).closest('span').data('portid');
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=changeoltsplitter&id=<?= $devices->id; ?>&portid=" + portid + "&ports=" + $(this).val(), {})
$.getJSON("<?= self::getUrl("Device", "api", ['do' => 'changeoltsplitter', 'id' => $devices->id]) ?>&portid=" + portid + "&ports=" + $(this).val(), {})
.done(function (data) { .done(function (data) {
}); });
@@ -919,7 +921,7 @@ if ($devices->power != "0.0") {
</tr> </tr>
</tbody></table>`); </tbody></table>`);
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getoltinfo&ip=<?= $devices->ip; ?>&portid=" + thisspan.data('portid'), {}) $.getJSON("<?= self::getUrl("Device", "api", ['do' => 'getoltinfo', 'ip' => $devices->ip]) ?>&portid=" + thisspan.data('portid'), {})
.done(function (data) { .done(function (data) {
if (typeof data.success === 'undefined') { if (typeof data.success === 'undefined') {
console.log('logged out'); console.log('logged out');
@@ -963,7 +965,7 @@ if ($devices->power != "0.0") {
$('.sp-splitter-count-show').removeClass('noclick'); $('.sp-splitter-count-show').removeClass('noclick');
}).done(function (data) { }).done(function (data) {
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getoltinfo&ip=<?= $devices->ip; ?>&portid=" + thisspan.data('portid') + "&adv=ext", {}).done(function (data) { $.getJSON("<?= self::getUrl("Device", "api", ['do' => 'getoltinfo', 'ip' => $devices->ip]) ?>&portid=" + thisspan.data('portid') + "&adv=ext", {}).done(function (data) {
if (typeof data.success === 'undefined') { if (typeof data.success === 'undefined') {
console.log('logged out'); console.log('logged out');
// window.location.href = "/"; // window.location.href = "/";
@@ -1010,7 +1012,8 @@ if ($devices->power != "0.0") {
var thisspan = $(this).closest('table'); var thisspan = $(this).closest('table');
$('.ont-refresh-span').html('<i class="fas fa-spinner fa-spin spinner-ico text-info"></i>'); $('.ont-refresh-span').html('<i class="fas fa-spinner fa-spin spinner-ico text-info"></i>');
$('.sp-splitter-count-show').addClass('noclick'); $('.sp-splitter-count-show').addClass('noclick');
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getoltinfo&ip=<?= $devices->ip; ?>&portid=" + thisspan.data('portid') + "&adv=ext", {}).done(function (data) {
$.getJSON("<?= self::getUrl("Device", "api", ['do' => 'getoltinfo', 'ip' => $devices->ip]) ?>&ip=<?= $devices->ip; ?>&portid=" + thisspan.data('portid') + "&adv=ext", {}).done(function (data) {
if (thisspan.data('portid') == $('#ont-table').data('portid')) { if (thisspan.data('portid') == $('#ont-table').data('portid')) {
@@ -1085,7 +1088,7 @@ if ($devices->power != "0.0") {
$('#ont-detail-mac-refresh').data('ontid', button.data('ontid')); $('#ont-detail-mac-refresh').data('ontid', button.data('ontid'));
$('#ont-detail-mac-refresh').data('snr', button.data('snr')); $('#ont-detail-mac-refresh').data('snr', button.data('snr'));
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getontinfo&ip=<?= $devices->ip; ?>&portid=" + button.data('portid') + "&ont=" + button.data('port') + '-' + button.data('ontid'), {}).done(function (data) { $.getJSON("<?= self::getUrl("Device", "api", ['do' => 'getontinfo', 'ip' => $devices->ip]) ?>&portid=" + button.data('portid') + "&ont=" + button.data('port') + '-' + button.data('ontid'), {}).done(function (data) {
$.each(data.data.linestat, function (o, ont) { $.each(data.data.linestat, function (o, ont) {
if (o == "lastofflinecausetitle") { if (o == "lastofflinecausetitle") {
$('#ont-detail-lastofflinecause').attr('data-original-title', ont); $('#ont-detail-lastofflinecause').attr('data-original-title', ont);
@@ -1138,7 +1141,7 @@ if ($devices->power != "0.0") {
var button = $('#ont-detail-mac-refresh'); var button = $('#ont-detail-mac-refresh');
$('#ont-macadresses').empty(); $('#ont-macadresses').empty();
$('#ont-macadresses-nomac').remove(); $('#ont-macadresses-nomac').remove();
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getontinfomac&ip=<?= $devices->ip; ?>&portid=" + button.data('portid') + "&ont=" + button.data('port') + '-' + button.data('ontid'), {}).done(function (data) { $.getJSON("<?= self::getUrl("Device", "api", ['do' => 'getontinfomac', 'ip' => $devices->ip]) ?>&portid=" + button.data('portid') + "&ont=" + button.data('port') + '-' + button.data('ontid'), {}).done(function (data) {
if (typeof data.data !== 'undefined' && data.data.length > 0) { if (typeof data.data !== 'undefined' && data.data.length > 0) {
$('#ont-macadresses').html(` $('#ont-macadresses').html(`
<tr> <tr>
@@ -1194,7 +1197,7 @@ if ($devices->power != "0.0") {
$('#ont-detail-refresh').data('portid', button.data('portid')); $('#ont-detail-refresh').data('portid', button.data('portid'));
$('#ont-detail-refresh').data('port', button.data('port')); $('#ont-detail-refresh').data('port', button.data('port'));
$('#ont-detail-refresh').data('ontid', button.data('ontid')); $('#ont-detail-refresh').data('ontid', button.data('ontid'));
$.getJSON("https://<?= $_SERVER['SERVER_NAME']; ?>/Device/api?do=getontinfo&ip=<?= $devices->ip; ?>&portid=" + button.data('portid') + "&ont=" + button.data('port') + '-' + button.data('ontid'), {}).done(function (data) { $.getJSON("<?= self::getUrl("Device", "api", ['do' => 'getontinfo', 'ip' => $devices->ip]) ?>&portid=" + button.data('portid') + "&ont=" + button.data('port') + '-' + button.data('ontid'), {}).done(function (data) {
$.each(data.data.linestat, function (o, ont) { $.each(data.data.linestat, function (o, ont) {
if (o == "lastofflinecausetitle") { if (o == "lastofflinecausetitle") {
$('#ont-detail-lastofflinecause').attr('data-original-title', ont); $('#ont-detail-lastofflinecause').attr('data-original-title', ont);