Skip to content

Commit

Permalink
Fix up bootgrid tables, they inserted a div before the first div brea…
Browse files Browse the repository at this point in the history
…king event propagation

switch to regular js function to scope variables instead of jquery
  • Loading branch information
murrant committed May 22, 2024
1 parent 879aa33 commit 0e4803a
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 98 deletions.
37 changes: 16 additions & 21 deletions resources/views/widgets/alertlog.blade.php
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
<div id="alertlog_container-{{ $id }}" class="table-responsive" data-reload="false">
<table id="alertlog_{{ $id }}" class="table table-hover table-condensed alerts">
<thead>
<tr>
<th data-column-id="status" data-sortable="false"></th>
<th data-column-id="time_logged" data-order="desc">{{ __('Timestamp') }}</th>
<th data-column-id="details" data-sortable="false">&nbsp;</th>
<th data-column-id="hostname">{{ __('Device') }}</th>
<th data-column-id="alert">{{ __('Alert') }}</th>
</tr>
</thead>
</table>
<div id="alertlog_container-{{ $id }}" data-reload="false">
<div class="table-responsive">
<table id="alertlog_{{ $id }}" class="table table-hover table-condensed alerts">
<thead>
<tr>
<th data-column-id="status" data-sortable="false"></th>
<th data-column-id="time_logged" data-order="desc">{{ __('Timestamp') }}</th>
<th data-column-id="details" data-sortable="false">&nbsp;</th>
<th data-column-id="hostname">{{ __('Device') }}</th>
<th data-column-id="alert">{{ __('Alert') }}</th>
</tr>
</thead>
</table>
</div>
</div>
<script>
$(function () {
(function () {
var grid = $("#alertlog_{{ $id }}").bootgrid({
ajax: true,
rowCount: [50, 100, 250, -1],
Expand All @@ -28,13 +30,6 @@
},
url: "ajax_table.php"
}).on("loaded.rs.jquery.bootgrid", function () {
var results = $("div.infos").text().split(" ");
low = results[1] - 1;
high = results[3];
max = high - low;
search = $('.search-field').val();
grid.find(".incident-toggle").each(function () {
$(this).parent().addClass('incident-toggle-td');
}).on("click", function (e) {
Expand Down Expand Up @@ -65,5 +60,5 @@
grid.bootgrid('destroy');
delete grid;
});
});
})();
</script>
26 changes: 14 additions & 12 deletions resources/views/widgets/alertlog_stats.blade.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<div id="alertlog_stats_container-{{ $id }}" class="table-responsive" data-reload="false">
<table id="alertlog_stats-{{ $id }}" class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th data-column-id="count">{{ __('Count') }}</th>
<th data-column-id="hostname">{{ __('Device') }}</th>
<th data-column-id="alert_rule">{{ __('Alert rule') }}</th>
</tr>
</thead>
</table>
<div id="alertlog_stats_container-{{ $id }}" data-reload="false">
<div class="table-responsive">
<table id="alertlog_stats-{{ $id }}" class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th data-column-id="count">{{ __('Count') }}</th>
<th data-column-id="hostname">{{ __('Device') }}</th>
<th data-column-id="alert_rule">{{ __('Alert rule') }}</th>
</tr>
</thead>
</table>
</div>
</div>
<script>
$(function () {
(function () {
var grid = $("#alertlog_stats-{{ $id }}").bootgrid({
ajax: true,
rowCount: [50, 100, 250, -1],
Expand All @@ -33,5 +35,5 @@
grid.bootgrid('destroy');
delete grid;
});
});
})();
</script>
44 changes: 23 additions & 21 deletions resources/views/widgets/alerts.blade.php
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<div id="alerts_container-{{ $id }}" class="table-responsive" data-reload="false">
<table id="alerts-{{ $id }}" class="table table-hover table-condensed alerts">
<thead>
<tr>
<th data-column-id="severity"></th>
<th data-column-id="timestamp">{{ __('Timestamp') }}</th>
<th data-column-id="rule">{{ __('Rule') }}</th>
<th data-column-id="details" data-sortable="false"></th>
<th data-column-id="hostname">{{ __('Hostname') }}</th>
<th data-column-id="location" data-visible="{{ $location ? 'true' : 'false' }}">{{ __('Location') }}</th>
<th data-column-id="ack_ico" data-sortable="false">{{ __('ACK') }}</th>
<th data-column-id="notes" data-sortable="false">{{ __('Notes') }}</th>
<th data-column-id="proc" data-sortable="false" data-visible="{{ $proc ? 'true' : 'false' }}">URL</th>
</tr>
</thead>
</table>
<div id="alerts_container-{{ $id }}" data-reload="false">
<div class="table-responsive">
<table id="alerts-{{ $id }}" class="table table-hover table-condensed alerts">
<thead>
<tr>
<th data-column-id="severity"></th>
<th data-column-id="timestamp">{{ __('Timestamp') }}</th>
<th data-column-id="rule">{{ __('Rule') }}</th>
<th data-column-id="details" data-sortable="false"></th>
<th data-column-id="hostname">{{ __('Hostname') }}</th>
<th data-column-id="location" data-visible="{{ $location ? 'true' : 'false' }}">{{ __('Location') }}</th>
<th data-column-id="ack_ico" data-sortable="false">{{ __('ACK') }}</th>
<th data-column-id="notes" data-sortable="false">{{ __('Notes') }}</th>
<th data-column-id="proc" data-sortable="false" data-visible="{{ $proc ? 'true' : 'false' }}">URL</th>
</tr>
</thead>
</table>
</div>
</div>
<script>
$(function () {
(function () {
var alerts_grid = $("#alerts-{{ $id }}").bootgrid({
ajax: true,
requestHandler: request => ({
Expand Down Expand Up @@ -75,11 +77,11 @@
});
$('#alerts_container-{{ $id }}').on('refresh', function (event) {
grid.bootgrid('reload');
alerts_grid.bootgrid('reload');
});
$('#alerts_container-{{ $id }}').on('destroy', function (event) {
grid.bootgrid('destroy');
delete grid;
alerts_grid.bootgrid('destroy');
delete alerts_grid;
});
});
})();
</script>
26 changes: 14 additions & 12 deletions resources/views/widgets/eventlog.blade.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<div id="eventlog_container-{{ $id }}" class="table-responsive">
<table id="eventlog-{{ $id }}" class="table table-hover table-condensed table-striped" data-ajax="true">
<thead>
<tr>
<th data-column-id="datetime" data-order="desc">{{ __('Timestamp') }}</th>
<th data-column-id="type">{{ __('Type') }}</th>
<th data-column-id="device_id">{{ __('Hostname') }}</th>
<th data-column-id="message">{{ __('Message') }}</th>
<th data-column-id="username">{{ __('User') }}</th>
</tr>
</thead>
</table>
<div id="eventlog_container-{{ $id }}" data-reload="false">
<div class="table-responsive">
<table id="eventlog-{{ $id }}" class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th data-column-id="datetime" data-order="desc">{{ __('Timestamp') }}</th>
<th data-column-id="type">{{ __('Type') }}</th>
<th data-column-id="device_id">{{ __('Hostname') }}</th>
<th data-column-id="message">{{ __('Message') }}</th>
<th data-column-id="username">{{ __('User') }}</th>
</tr>
</thead>
</table>
</div>
</div>
<script>
$(function () {
Expand Down
34 changes: 18 additions & 16 deletions resources/views/widgets/graylog.blade.php
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
<div id="graylog_container-{{ $id }}" class="table-responsive" data-reload="false">
<table id="graylog-{{ $id }}" class="table table-hover table-condensed graylog">
<thead>
<tr>
<th data-column-id="severity" data-sortable="false"></th>
<th data-column-id="origin">{{ __('Origin') }}</th>
<th data-column-id="timestamp" data-formatter="browserTime">{{ __('Timestamp') }}</th>
<th data-column-id="level" data-sortable="false">{{ __('Level') }}</th>
<th data-column-id="source">{{ __('Source') }}</th>
<th data-column-id="message" data-sortable="false">{{ __('Message') }}</th>
<th data-column-id="facility" data-sortable="false">{{ __('Facility') }}</th>
</tr>
</thead>
</table>
<div id="graylog_container-{{ $id }}" data-reload="false">
<div class="table-responsive">
<table id="graylog-{{ $id }}" class="table table-hover table-condensed graylog">
<thead>
<tr>
<th data-column-id="severity" data-sortable="false"></th>
<th data-column-id="origin">{{ __('Origin') }}</th>
<th data-column-id="timestamp" data-formatter="browserTime">{{ __('Timestamp') }}</th>
<th data-column-id="level" data-sortable="false">{{ __('Level') }}</th>
<th data-column-id="source">{{ __('Source') }}</th>
<th data-column-id="message" data-sortable="false">{{ __('Message') }}</th>
<th data-column-id="facility" data-sortable="false">{{ __('Facility') }}</th>
</tr>
</thead>
</table>
</div>
</div>

<script>
$(function () {
(function () {
var grid = $("#graylog-{{ $id }}").bootgrid({
ajax: true,
rowCount: ['{{ $limit }}', 25,50,100,250,-1],
Expand Down Expand Up @@ -48,5 +50,5 @@
grid.bootgrid('destroy');
delete grid;
});
});
})();
</script>
34 changes: 18 additions & 16 deletions resources/views/widgets/syslog.blade.php
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
<div id="syslog_container-{{ $id }}" class="table-responsive" data-reload="false">
<table id="syslog-{{ $id }}" class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th data-column-id="label"></th>
<th data-column-id="timestamp" data-order="desc">{{ __('Timestamp') }}</th>
<th data-column-id="level">{{ __('Level') }}</th>
<th data-column-id="device_id">{{ __('Hostname') }}</th>
<th data-column-id="program">{{ __('Program') }}</th>
<th data-column-id="msg">{{ __('Message') }}</th>
<th data-column-id="priority">{{ __('Priority') }}</th>
</tr>
</thead>
</table>
<div id="syslog_container-{{ $id }}" data-reload="false">
<div class="table-responsive">
<table id="syslog-{{ $id }}" class="table table-hover table-condensed table-striped">
<thead>
<tr>
<th data-column-id="label"></th>
<th data-column-id="timestamp" data-order="desc">{{ __('Timestamp') }}</th>
<th data-column-id="level">{{ __('Level') }}</th>
<th data-column-id="device_id">{{ __('Hostname') }}</th>
<th data-column-id="program">{{ __('Program') }}</th>
<th data-column-id="msg">{{ __('Message') }}</th>
<th data-column-id="priority">{{ __('Priority') }}</th>
</tr>
</thead>
</table>
</div>
</div>
<script type="application/javascript">
$(function () {
(function () {
var grid = $("#syslog-{{ $id }}").bootgrid({
ajax: true,
rowCount: [50, 100, 250, -1],
Expand All @@ -37,5 +39,5 @@
grid.bootgrid('destroy');
delete grid;
});
});
})();
</script>

0 comments on commit 0e4803a

Please sign in to comment.