Skip to content

Commit

Permalink
Add "Reset Sorting" button to remaining pages.
Browse files Browse the repository at this point in the history
Signed-off-by: DL6ER <[email protected]>
  • Loading branch information
DL6ER committed Dec 20, 2019
1 parent 4f54796 commit ede9d41
Show file tree
Hide file tree
Showing 7 changed files with 52 additions and 4 deletions.
2 changes: 2 additions & 0 deletions groups-adlists.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
<table id="adlistsTable" class="display table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Address</th>
<th>Status</th>
<th>Comment</th>
Expand All @@ -63,6 +64,7 @@
</tr>
</thead>
</table>
<button type="button" id="resetButton" hidden="true">Reset sorting</button>
</div>
<!-- /.box-body -->
</div>
Expand Down
2 changes: 2 additions & 0 deletions groups-clients.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,14 @@
<table id="clientsTable" class="display table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>IP address</th>
<th>Group assignment</th>
<th>Action</th>
</tr>
</thead>
</table>
<button type="button" id="resetButton" hidden="true">Reset sorting</button>
</div>
<!-- /.box-body -->
</div>
Expand Down
2 changes: 2 additions & 0 deletions groups-domains.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
<table id="domainsTable" class="display table table-striped table-bordered" cellspacing="0" width="100%">
<thead>
<tr>
<th>ID</th>
<th>Domain</th>
<th>Type</th>
<th>Status</th>
Expand All @@ -73,6 +74,7 @@
</tr>
</thead>
</table>
<button type="button" id="resetButton" hidden="true">Reset sorting</button>
</div>
<!-- /.box-body -->
</div>
Expand Down
14 changes: 14 additions & 0 deletions scripts/pi-hole/js/groups-adlists.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function initTable() {
},
order: [[0, "asc"]],
columns: [
{ data: "id", visible: false },
{ data: "address" },
{ data: "enabled", searchable: false },
{ data: "comment" },
Expand Down Expand Up @@ -201,6 +202,19 @@ function initTable() {
return data;
}
});

table.on("order.dt", function() {
var order = table.order();
if (order[0][0] !== 0 || order[0][1] !== "asc") {
$("#resetButton").show();
} else {
$("#resetButton").hide();
}
});
$("#resetButton").on("click", function() {
table.order([[0, "asc"]]).draw();
$("#resetButton").hide();
});
}

function addAdlist() {
Expand Down
14 changes: 14 additions & 0 deletions scripts/pi-hole/js/groups-clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ function initTable() {
},
order: [[0, "asc"]],
columns: [
{ data: "id", visible: false },
{ data: "ip" },
{ data: "groups", searchable: false },
{ data: "name", width: "80px", orderable: false }
Expand Down Expand Up @@ -209,6 +210,19 @@ function initTable() {
return data;
}
});

table.on("order.dt", function() {
var order = table.order();
if (order[0][0] !== 0 || order[0][1] !== "asc") {
$("#resetButton").show();
} else {
$("#resetButton").hide();
}
});
$("#resetButton").on("click", function() {
table.order([[0, "asc"]]).draw();
$("#resetButton").hide();
});
}

function addClient() {
Expand Down
14 changes: 14 additions & 0 deletions scripts/pi-hole/js/groups-domains.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ function initTable() {
},
order: [[0, "asc"]],
columns: [
{ data: "id", visible: false },
{ data: "domain" },
{ data: "type", searchable: false },
{ data: "enabled", searchable: false },
Expand Down Expand Up @@ -218,6 +219,19 @@ function initTable() {
return data;
}
});

table.on("order.dt", function() {
var order = table.order();
if (order[0][0] !== 0 || order[0][1] !== "asc") {
$("#resetButton").show();
} else {
$("#resetButton").hide();
}
});
$("#resetButton").on("click", function() {
table.order([[0, "asc"]]).draw();
$("#resetButton").hide();
});
}

function addDomain() {
Expand Down
8 changes: 4 additions & 4 deletions scripts/pi-hole/js/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,6 @@ function datetime(date) {

$(document).ready(function() {
$("#btnAdd").on("click", addGroup);
$("#resetButton").on("click", function() {
table.order([[0, "asc"]]).draw();
$("#resetButton").hide();
});

table = $("#groupsTable").DataTable({
ajax: {
Expand Down Expand Up @@ -173,6 +169,10 @@ $(document).ready(function() {
$("#resetButton").hide();
}
});
$("#resetButton").on("click", function() {
table.order([[0, "asc"]]).draw();
$("#resetButton").hide();
});
});

function addGroup() {
Expand Down

0 comments on commit ede9d41

Please sign in to comment.