mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-15 09:04:39 +00:00
Diagnostics - refactor bootgrid usage . for https://github.com/opnsense/core/issues/4683
This commit is contained in:
parent
3dcc9f512e
commit
7bdcc97e3c
@ -32,31 +32,19 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
* fetch system arp table
|
||||
*/
|
||||
function updateARP() {
|
||||
var gridopt = {
|
||||
ajax: false,
|
||||
selection: false,
|
||||
multiSelect: false
|
||||
};
|
||||
$("#grid-arp").bootgrid('destroy');
|
||||
if ($("#grid-arp").hasClass('bootgrid-table')) {
|
||||
$("#grid-arp").bootgrid('clear');
|
||||
} else {
|
||||
$("#grid-arp").bootgrid({
|
||||
ajax: false,
|
||||
selection: false,
|
||||
multiSelect: false
|
||||
});
|
||||
}
|
||||
ajaxGet("/api/diagnostics/interface/getArp", {}, function (data, status) {
|
||||
if (status == "success") {
|
||||
var html = [];
|
||||
$.each(data, function (key, value) {
|
||||
var fields = ["ip", "mac", "manufacturer", "intf", "intf_description", "hostname"];
|
||||
let tr_str = '<tr>';
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
if (value[fields[i]] != null) {
|
||||
tr_str += '<td>' + value[fields[i]] + '</td>';
|
||||
} else {
|
||||
tr_str += '<td></td>';
|
||||
}
|
||||
}
|
||||
tr_str += '</tr>';
|
||||
html.push(tr_str);
|
||||
});
|
||||
$("#grid-arp > tbody").html(html.join(''));
|
||||
$("#grid-arp").bootgrid('append', data);
|
||||
}
|
||||
$("#grid-arp").bootgrid(gridopt);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -32,31 +32,19 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
* fetch system NDP table
|
||||
*/
|
||||
function updateNDP() {
|
||||
var gridopt = {
|
||||
ajax: false,
|
||||
selection: false,
|
||||
multiSelect: false
|
||||
};
|
||||
$("#grid-ndp").bootgrid('destroy');
|
||||
if ($("#grid-ndp").hasClass('bootgrid-table')) {
|
||||
$("#grid-ndp").bootgrid('clear');
|
||||
} else {
|
||||
$("#grid-ndp").bootgrid({
|
||||
ajax: false,
|
||||
selection: false,
|
||||
multiSelect: false
|
||||
});
|
||||
}
|
||||
ajaxGet("/api/diagnostics/interface/getNdp", {}, function (data, status) {
|
||||
if (status == "success") {
|
||||
var html = [];
|
||||
$.each(data, function (key, value) {
|
||||
var fields = ["ip", "mac", "manufacturer", "intf", "intf_description"];
|
||||
let tr_str = '<tr>';
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
if (value[fields[i]] != null) {
|
||||
tr_str += '<td>' + value[fields[i]] + '</td>';
|
||||
} else {
|
||||
tr_str += '<td></td>';
|
||||
}
|
||||
}
|
||||
tr_str += '</tr>';
|
||||
html.push(tr_str);
|
||||
});
|
||||
$("#grid-ndp > tbody").html(html.join(''));
|
||||
$("#grid-ndp").bootgrid('append', data);
|
||||
}
|
||||
$("#grid-ndp").bootgrid(gridopt);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
<script>
|
||||
$( document ).ready(function() {
|
||||
var gridopt = {
|
||||
let grid = $("#grid-routes").bootgrid({
|
||||
ajax: false,
|
||||
selection: false,
|
||||
multiSelect: false,
|
||||
@ -39,55 +39,35 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
data-row-id=\"" + row.destination + "," + row.gateway +"\"><span class=\"fa fa-trash-o\"></span></button>";
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$("#grid-routes").bootgrid('destroy');
|
||||
$("#grid-routes").bootgrid(gridopt);
|
||||
|
||||
}).on("loaded.rs.jquery.bootgrid", function(){
|
||||
grid.find(".command-delete").on("click", function(e){
|
||||
let route=$(this).data("row-id").split(',');
|
||||
stdDialogConfirm('{{ lang._('Remove static route') }}' + ' ('+$(this).data("row-id")+')',
|
||||
'{{ lang._('Are you sure you want to remove this route? Caution, this could potentially lead to loss of connectivity') }}',
|
||||
'{{ lang._('Yes') }}',
|
||||
'{{ lang._('No') }}',
|
||||
function() {
|
||||
ajaxCall('/api/diagnostics/interface/delRoute/', {'destination': route[0], 'gateway': route[1]},function(data,status){
|
||||
// reload grid after delete
|
||||
$("#update").click();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
// update routes
|
||||
$("#update").click(function() {
|
||||
$("#grid-routes").bootgrid('clear');
|
||||
$('#processing-dialog').modal('show');
|
||||
let resolve = '';
|
||||
if ($("#resolve").prop("checked")) {
|
||||
resolve = "yes";
|
||||
}
|
||||
ajaxGet("/api/diagnostics/interface/getRoutes/", {resolve:resolve}, function (data, status) {
|
||||
if (status == "success") {
|
||||
$("#grid-routes").bootgrid('destroy');
|
||||
var html = [];
|
||||
$.each(data, function (key, value) {
|
||||
var fields = ["proto", "destination", "gateway", "flags", "use", "mtu", "netif","intf_description", "expire"];
|
||||
let tr_str = '<tr>';
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
if (value[fields[i]] != null) {
|
||||
tr_str += '<td>' + value[fields[i]] + '</td>';
|
||||
} else {
|
||||
tr_str += '<td></td>';
|
||||
}
|
||||
}
|
||||
tr_str += '</tr>';
|
||||
html.push(tr_str);
|
||||
});
|
||||
$("#grid-routes > tbody").html(html.join(''));
|
||||
var grid = $("#grid-routes").bootgrid(gridopt).on("loaded.rs.jquery.bootgrid", function(){
|
||||
grid.find(".command-delete").on("click", function(e){
|
||||
let route=$(this).data("row-id").split(',');
|
||||
stdDialogConfirm('{{ lang._('Remove static route') }}' + ' ('+$(this).data("row-id")+')',
|
||||
'{{ lang._('Are you sure you want to remove this route? Caution, this could potentially lead to loss of connectivity') }}',
|
||||
'{{ lang._('Yes') }}',
|
||||
'{{ lang._('No') }}',
|
||||
function() {
|
||||
ajaxCall('/api/diagnostics/interface/delRoute/', {'destination': route[0], 'gateway': route[1]},function(data,status){
|
||||
// reload grid after delete
|
||||
$("#update").click();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
$('#processing-dialog').modal('hide');
|
||||
}
|
||||
);
|
||||
if (status == "success") {
|
||||
$("#grid-routes").bootgrid('append', data);
|
||||
}
|
||||
$('#processing-dialog').modal('hide');
|
||||
});
|
||||
});
|
||||
|
||||
// initial load
|
||||
@ -112,7 +92,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||
<th data-column-id="netif" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Netif') }}</th>
|
||||
<th data-column-id="intf_description" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Netif (name)') }}</th>
|
||||
<th data-column-id="expire" data-type="string" data-css-class="hidden-xs hidden-sm" data-header-css-class="hidden-xs hidden-sm">{{ lang._('Expire') }}</th>
|
||||
<th data-column-id="commands" data-width="2em" data-formatter="commands" data-sortable="false">{{ lang._('Action') }}</th>
|
||||
<th data-column-id="commands" data-searchable="false" data-width="2em" data-formatter="commands" data-sortable="false">{{ lang._('Action') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user