Skip to content

Commit

Permalink
Merge pull request #1948 from pi-hole/tweak/datatables
Browse files Browse the repository at this point in the history
Tweak to datatables column rendering
  • Loading branch information
yubiuser committed Oct 28, 2021
2 parents 98ec9ee + 0e483a8 commit 5aeb52e
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 10 deletions.
5 changes: 5 additions & 0 deletions scripts/pi-hole/js/customcname.js
Expand Up @@ -64,6 +64,10 @@ $(function () {
);
},
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
lengthMenu: [
[10, 25, 50, 100, -1],
Expand All @@ -82,6 +86,7 @@ $(function () {
$(".deleteCustomCNAME").on("click", deleteCustomCNAME);
},
});

// Disable autocorrect in the search box
var input = document.querySelector("input[type=search]");
input.setAttribute("autocomplete", "off");
Expand Down
4 changes: 4 additions & 0 deletions scripts/pi-hole/js/customdns.js
Expand Up @@ -64,6 +64,10 @@ $(function () {
);
},
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
lengthMenu: [
[10, 25, 50, 100, -1],
Expand Down
8 changes: 6 additions & 2 deletions scripts/pi-hole/js/db_queries.js
Expand Up @@ -340,8 +340,8 @@ $(function () {
},
},
{ width: "10%" },
{ width: "40%", render: $.fn.dataTable.render.text() },
{ width: "20%", type: "ip-address", render: $.fn.dataTable.render.text() },
{ width: "40%" },
{ width: "20%", type: "ip-address" },
{ width: "10%" },
{ width: "5%" },
],
Expand All @@ -355,6 +355,10 @@ $(function () {
data: null,
defaultContent: "",
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
initComplete: reloadCallback,
});
Expand Down
10 changes: 10 additions & 0 deletions scripts/pi-hole/js/groups-adlists.js
Expand Up @@ -124,6 +124,16 @@ function initTable() {
{ data: "groups", searchable: false },
{ data: null, width: "80px", orderable: false },
],
columnDefs: [
{
targets: [0, 2],
orderable: false,
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteAdlist_"]').on("click", deleteAdlist);
// Remove visible dropdown to prevent orphaning
Expand Down
6 changes: 6 additions & 0 deletions scripts/pi-hole/js/groups-clients.js
Expand Up @@ -97,6 +97,12 @@ function initTable() {
{ data: "groups", searchable: false },
{ data: "name", width: "80px", orderable: false },
],
columnDefs: [
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteClient_"]').on("click", deleteClient);
// Remove visible dropdown to prevent orphaning
Expand Down
6 changes: 6 additions & 0 deletions scripts/pi-hole/js/groups-domains.js
Expand Up @@ -76,6 +76,12 @@ function initTable() {
{ data: "groups", searchable: false, visible: showtype === "all" },
{ data: null, width: "80px", orderable: false },
],
columnDefs: [
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteDomain_"]').on("click", deleteDomain);
// Remove visible dropdown to prevent orphaning
Expand Down
6 changes: 6 additions & 0 deletions scripts/pi-hole/js/groups.js
Expand Up @@ -27,6 +27,12 @@ $(function () {
{ data: "description" },
{ data: null, width: "60px", orderable: false },
],
columnDefs: [
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteGroup_"]').on("click", deleteGroup);
},
Expand Down
6 changes: 6 additions & 0 deletions scripts/pi-hole/js/messages.js
Expand Up @@ -114,6 +114,12 @@ $(function () {
{ data: "blob5", visible: false },
{ data: null, width: "80px", orderable: false },
],
columnDefs: [
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
drawCallback: function () {
$('button[id^="deleteMessage_"]').on("click", deleteMessage);
// Remove visible dropdown to prevent orphaning
Expand Down
13 changes: 9 additions & 4 deletions scripts/pi-hole/js/network.js
Expand Up @@ -236,10 +236,10 @@ $(function () {
order: [[6, "desc"]],
columns: [
{ data: "id", visible: false },
{ data: "ip", type: "ip-address", width: "10%", render: $.fn.dataTable.render.text() },
{ data: "hwaddr", width: "10%", render: $.fn.dataTable.render.text() },
{ data: "interface", width: "4%", render: $.fn.dataTable.render.text() },
{ data: "name", width: "15%", render: $.fn.dataTable.render.text() },
{ data: "ip", type: "ip-address", width: "10%" },
{ data: "hwaddr", width: "10%" },
{ data: "interface", width: "4%" },
{ data: "name", width: "15%" },
{
data: "firstSeen",
width: "8%",
Expand All @@ -266,6 +266,7 @@ $(function () {
{ data: "", width: "6%", orderable: false },
{ data: "", width: "6%", orderable: false },
],

drawCallback: function () {
$('button[id^="deleteNetworkEntry_"]').on("click", deleteNetworkEntry);
// Remove visible dropdown to prevent orphaning
Expand All @@ -289,6 +290,10 @@ $(function () {
data: null,
defaultContent: "",
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
});
// Disable autocorrect in the search box
Expand Down
8 changes: 6 additions & 2 deletions scripts/pi-hole/js/queries.js
Expand Up @@ -323,8 +323,8 @@ $(function () {
},
},
{ width: "4%" },
{ width: "36%", render: $.fn.dataTable.render.text() },
{ width: "8%", type: "ip-address", render: $.fn.dataTable.render.text() },
{ width: "36%" },
{ width: "8%", type: "ip-address" },
{ width: "14%", orderData: 4 },
{ width: "8%", orderData: 5 },
{ width: "10%", orderData: 4 },
Expand All @@ -347,6 +347,10 @@ $(function () {
data: null,
defaultContent: "",
},
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
initComplete: function () {
var api = this.api();
Expand Down
16 changes: 14 additions & 2 deletions scripts/pi-hole/js/settings.js
Expand Up @@ -216,7 +216,13 @@ $(function () {
if (document.getElementById("DHCPLeasesTable")) {
leasetable = $("#DHCPLeasesTable").DataTable({
dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-6'i><'col-sm-6'f>>",
columnDefs: [{ bSortable: false, orderable: false, targets: -1 }],
columnDefs: [
{ bSortable: false, orderable: false, targets: -1 },
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
paging: false,
scrollCollapse: true,
scrollY: "200px",
Expand All @@ -236,7 +242,13 @@ $(function () {
if (document.getElementById("DHCPStaticLeasesTable")) {
staticleasetable = $("#DHCPStaticLeasesTable").DataTable({
dom: "<'row'<'col-sm-12'tr>><'row'<'col-sm-12'i>>",
columnDefs: [{ bSortable: false, orderable: false, targets: -1 }],
columnDefs: [
{ bSortable: false, orderable: false, targets: -1 },
{
targets: "_all",
render: $.fn.dataTable.render.text(),
},
],
paging: false,
scrollCollapse: true,
scrollY: "200px",
Expand Down

0 comments on commit 5aeb52e

Please sign in to comment.