|
@@ -1,3 +1,5 @@
|
|
|
|
|
+var SignalAbortFetch = null;
|
|
|
|
|
+
|
|
|
const fetchHeaders = {
|
|
const fetchHeaders = {
|
|
|
'Accept': 'text/html',
|
|
'Accept': 'text/html',
|
|
|
'Content-Type': 'text/html',
|
|
'Content-Type': 'text/html',
|
|
@@ -8,6 +10,12 @@ const fetchHeaders = {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
$(function () {
|
|
$(function () {
|
|
|
|
|
+ $.fn.dataTable.ext.order['dom-checkbox'] = function (settings, col) {
|
|
|
|
|
+ return this.api().column(col, {order: 'index'}).nodes().map(function (td, i) {
|
|
|
|
|
+ return $('input', td).prop('checked') ? '1' : '0';
|
|
|
|
|
+ });
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
// DataTable fix
|
|
// DataTable fix
|
|
|
$("#datatable").DataTable({
|
|
$("#datatable").DataTable({
|
|
|
paging: false,
|
|
paging: false,
|
|
@@ -21,13 +29,21 @@ $(function () {
|
|
|
railOpacity: .3,
|
|
railOpacity: .3,
|
|
|
height: "50vh"
|
|
height: "50vh"
|
|
|
})
|
|
})
|
|
|
- }
|
|
|
|
|
|
|
+ },
|
|
|
|
|
+ "columnDefs": [
|
|
|
|
|
+ {"orderDataType": "dom-checkbox", "targets": 0},
|
|
|
|
|
+ {'orderable': false, "targets": -1}
|
|
|
|
|
+ ]
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
$('.statusmodal').on('shown.bs.modal', function () {
|
|
$('.statusmodal').on('shown.bs.modal', function () {
|
|
|
labelID = $('.statusmodal #labelID').html();
|
|
labelID = $('.statusmodal #labelID').html();
|
|
|
refreshESLStatus(labelID);
|
|
refreshESLStatus(labelID);
|
|
|
});
|
|
});
|
|
|
|
|
+
|
|
|
|
|
+ $('.statusmodal').on('hide.bs.modal', function () {
|
|
|
|
|
+ SignalAbortFetch.abort();
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -42,7 +58,7 @@ $(function () {
|
|
|
* @returns {Promise<Response | never>}
|
|
* @returns {Promise<Response | never>}
|
|
|
*/
|
|
*/
|
|
|
function AjaxReq(url, options) {
|
|
function AjaxReq(url, options) {
|
|
|
- let defaults = {headers: fetchHeaders}
|
|
|
|
|
|
|
+ let defaults = {headers: fetchHeaders};
|
|
|
// Extend default options
|
|
// Extend default options
|
|
|
Object.assign(defaults, options);
|
|
Object.assign(defaults, options);
|
|
|
|
|
|
|
@@ -78,32 +94,60 @@ function LoadConfig() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function OpenESLDetails(labelID) {
|
|
function OpenESLDetails(labelID) {
|
|
|
|
|
+ SignalAbortFetch = new AbortController();
|
|
|
|
|
+
|
|
|
|
|
+ $('#esl_rssi_list').html('');
|
|
|
|
|
+ $('#svgpath').removeAttr('src');
|
|
|
|
|
+
|
|
|
$('.statusmodal #labelID').html(labelID);
|
|
$('.statusmodal #labelID').html(labelID);
|
|
|
$('.statusmodal').modal('show');
|
|
$('.statusmodal').modal('show');
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-function fillStatusApList(ESLstatus) {
|
|
|
|
|
|
|
+function fillESLDetails(ESLstatus) {
|
|
|
$('#esl_rssi_list').html('');
|
|
$('#esl_rssi_list').html('');
|
|
|
- for (let [ap, rssi] of Object.entries(ESLstatus)) {
|
|
|
|
|
- let ap_rssi = `<div class="ml-4"><span class="badge badge-primary">${ap}</span><span class="ml-2 badge text-inverse badge-warning">${rssi}</span></div>`;
|
|
|
|
|
|
|
+ $('#svgpath').removeAttr('src');
|
|
|
|
|
+
|
|
|
|
|
+ $('#esl_rssi').html(ESLstatus.value.status.rssi);
|
|
|
|
|
+ $('#hello').html(ESLstatus.value.status.hello_period);
|
|
|
|
|
+ $('#blink_count').html(ESLstatus.value.status.blink_count);
|
|
|
|
|
+ let hardver = `${ESLstatus.value.status.hard_major}.${ESLstatus.value.status.hard_minor}.${ESLstatus.value.status.hard_patch}`;
|
|
|
|
|
+ let softver = `${ESLstatus.value.status.soft_major}.${ESLstatus.value.status.soft_minor}.${ESLstatus.value.status.soft_patch}`;
|
|
|
|
|
+ $('#hardware_ver').html(hardver);
|
|
|
|
|
+ $('#software_ver').html(softver);
|
|
|
|
|
+
|
|
|
|
|
+ for (let [ap, rssi] of Object.entries(ESLstatus.value.rssi)) {
|
|
|
|
|
+ let ap_rssi = `<div><span class="badge badge-primary">${ap}</span><span class="badge text-inverse badge-warning">${rssi}</span></div>`;
|
|
|
$('#esl_rssi_list').append(ap_rssi);
|
|
$('#esl_rssi_list').append(ap_rssi);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ if (ESLstatus.svgPath != null)
|
|
|
|
|
+ $('#svgpath').prop('src', BASEURL + '/' + ESLstatus.svgPath);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function refreshESLStatus(labelID) {
|
|
function refreshESLStatus(labelID) {
|
|
|
|
|
+ $('#spinnerloader').removeClass('d-none');
|
|
|
|
|
+
|
|
|
AjaxReq(`${BASEURL}/admin/config`, {
|
|
AjaxReq(`${BASEURL}/admin/config`, {
|
|
|
method: 'POST',
|
|
method: 'POST',
|
|
|
- body: JSON.stringify({"method": "geteslstatus", "label_id": labelID})
|
|
|
|
|
|
|
+ body: JSON.stringify({"method": "geteslstatus", "label_id": labelID}),
|
|
|
|
|
+ signal: SignalAbortFetch.signal
|
|
|
})
|
|
})
|
|
|
.then(json => {
|
|
.then(json => {
|
|
|
- $('#esl_rssi').html(json.value.status.rssi);
|
|
|
|
|
- fillStatusApList(json.value.rssi);
|
|
|
|
|
|
|
+ fillESLDetails(json);
|
|
|
toastr.success(json.err);
|
|
toastr.success(json.err);
|
|
|
|
|
+ if ($('.statusmodal').is(':visible'))
|
|
|
|
|
+ setTimeout(function () {
|
|
|
|
|
+ refreshESLStatus(labelID);
|
|
|
|
|
+ }, 3000);
|
|
|
})
|
|
})
|
|
|
.catch(err => {
|
|
.catch(err => {
|
|
|
|
|
+ if (err.name == 'AbortError')
|
|
|
|
|
+ return;
|
|
|
if (err.url !== undefined)
|
|
if (err.url !== undefined)
|
|
|
toastr.error(err.url, `${err.status} (${err.statusText})`);
|
|
toastr.error(err.url, `${err.status} (${err.statusText})`);
|
|
|
else
|
|
else
|
|
|
toastr.error(err);
|
|
toastr.error(err);
|
|
|
- });
|
|
|
|
|
|
|
+ }).finally(function () {
|
|
|
|
|
+ $('#spinnerloader').addClass('d-none');
|
|
|
|
|
+ });
|
|
|
}
|
|
}
|