Skip to content

Commit 7ce2ce4

Browse files
committed
Merge branch 'next_release' of github.com:netalertx/NetAlertX into next_release
2 parents b1fe243 + 6256149 commit 7ce2ce4

2 files changed

Lines changed: 59 additions & 1 deletion

File tree

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<!-- Plugins Sub-Tab Table Skeleton (shared: Objects / Events / History) === -->
2+
<div class="skel-table-box">
3+
<div class="skel-table-header-row">
4+
<?php for ($j = 0; $j < 5; $j++): ?>
5+
<span class="skel-th skel-shimmer"></span>
6+
<?php endfor; ?>
7+
</div>
8+
<?php
9+
$rowWidths = [
10+
[15, 14, 18, 12, 20],
11+
[15, 14, 18, 12, 20],
12+
[15, 14, 18, 12, 20],
13+
[15, 14, 18, 12, 20],
14+
[15, 14, 18, 12, 20],
15+
[15, 14, 18, 12, 20],
16+
[15, 14, 18, 12, 20],
17+
[15, 14, 18, 12, 20],
18+
[15, 14, 18, 12, 20],
19+
[15, 14, 18, 12, 20],
20+
[15, 14, 18, 12, 20],
21+
[15, 14, 18, 12, 20],
22+
[15, 14, 18, 12, 20],
23+
[15, 14, 18, 12, 20],
24+
[15, 14, 18, 12, 20],
25+
[15, 14, 18, 12, 20],
26+
[15, 14, 18, 12, 20],
27+
[15, 14, 18, 12, 20],
28+
[15, 14, 18, 12, 20],
29+
[15, 14, 18, 12, 20],
30+
];
31+
foreach ($rowWidths as $widths):
32+
?>
33+
<div class="skel-tr">
34+
<?php foreach ($widths as $w): ?>
35+
<span class="skel-td skel-shimmer" style="flex:1; max-width:<?= $w ?>%"></span>
36+
<?php endforeach; ?>
37+
</div>
38+
<?php endforeach; ?>
39+
</div>
40+
<div class="skel-form-footer" style="padding:8px 0;">
41+
<span class="skel-form-btn skel-shimmer"></span>
42+
<span class="skel-form-btn skel-shimmer"></span>
43+
</div>

front/pluginsCore.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22
//------------------------------------------------------------------------------
33
// check if authenticated
44
require_once $_SERVER['DOCUMENT_ROOT'] . '/php/templates/security.php';
5+
6+
// Capture shared sub-tab skeleton template for JS injection
7+
ob_start(); require $_SERVER['DOCUMENT_ROOT'] . '/php/templates/skel_tab_plugins_table.php'; $skelPluginsTable = ob_get_clean();
58
?>
69

710
<!-- Main content ---------------------------------------------------------- -->
@@ -27,6 +30,9 @@
2730

2831
<script>
2932

33+
// Sub-tab skeleton HTML (server-rendered, shared across Objects / Events / History panes)
34+
const skelPluginsTable = <?= json_encode($skelPluginsTable) ?>;
35+
3036
// Global variable to track the last MAC we initialized with
3137
let lastMac = null;
3238
let keepUpdating = true;
@@ -620,8 +626,11 @@ function generateDataTable(prefix, tableType, colDefinitions) {
620626
// Generate HTML for a DataTable and associated buttons for a given table type
621627
const headersHtml = colDefinitions.map(colDef => `<th class="${colDef.css_classes}">${getString(`${prefix}_${colDef.column}_name`)}</th>`).join('');
622628

629+
const skelHtml = skelPluginsTable;
630+
623631
return `
624-
<div id="${tableType.toLowerCase()}Target_${prefix}" class="tab-pane ${tableType == "Objects" ? "active":""}">
632+
<div id="${tableType.toLowerCase()}Target_${prefix}" class="tab-pane ${tableType == "Objects" ? "active":""}" style="position:relative;">
633+
<div id="skel-${tableType.toLowerCase()}Target_${prefix}" class="skel-plugins-tab-pane" style="position:absolute;top:0;left:0;right:0;z-index:1;background:inherit;">${skelHtml}</div>
625634
<table id="${tableType.toLowerCase()}Table_${prefix}" class="display table table-striped table-stretched" data-my-dbtable="Plugins_${tableType}">
626635
<thead><tr>${headersHtml}</tr></thead>
627636
</table>
@@ -647,6 +656,7 @@ function buildDT(tableId, gqlField, countId, badgeId) {
647656
if ($.fn.DataTable.isDataTable(`#${tableId}`)) {
648657
return; // already initialized
649658
}
659+
const skelId = `#skel-${tableId.replace('Table_', 'Target_')}`;
650660
$(`#${tableId}`).DataTable({
651661
processing: true,
652662
serverSide: true,
@@ -655,6 +665,11 @@ function buildDT(tableId, gqlField, countId, badgeId) {
655665
ordering: false,
656666
pageLength: 25,
657667
lengthMenu: [[10, 25, 50, 100], [10, 25, 50, 100]],
668+
// Fade out the skeleton only after the first draw so there is no gap
669+
// between the skeleton disappearing and the table rows appearing.
670+
initComplete: function() {
671+
$(skelId).fadeOut(250, function() { $(this).remove(); });
672+
},
658673
createdRow: function(row, data) {
659674
$(row).attr('data-my-index', data.index);
660675
},

0 commit comments

Comments
 (0)