From a97f52ad768a77d151296a7fe60d41f0f0c67ebb Mon Sep 17 00:00:00 2001 From: DL6ER Date: Thu, 30 Jan 2020 21:03:25 +0000 Subject: [PATCH] Add possibility to highlight line on the Groups Domain Management page with specifying the domainid as GET parameter. Signed-off-by: DL6ER --- scripts/pi-hole/js/groups-domains.js | 27 +++++++++++++++++++++++++++ style/pi-hole.css | 4 ++++ 2 files changed, 31 insertions(+) diff --git a/scripts/pi-hole/js/groups-domains.js b/scripts/pi-hole/js/groups-domains.js index 6646a957..907e89f7 100644 --- a/scripts/pi-hole/js/groups-domains.js +++ b/scripts/pi-hole/js/groups-domains.js @@ -11,6 +11,7 @@ var table; var groups = []; var token = $("#token").html(); var info = null; +var GETDict = {}; function showAlert(type, icon, title, message) { var opts = {}; @@ -88,6 +89,13 @@ function datetime(date) { } $(document).ready(function() { + window.location.search + .substr(1) + .split("&") + .forEach(function(item) { + GETDict[item.split("=")[0]] = item.split("=")[1]; + }); + $("#btnAdd").on("click", addDomain); get_groups(); @@ -186,6 +194,13 @@ function initTable() { ); } + // Highlight row + if ("domainid" in GETDict && data.id === parseInt(GETDict.domainid)) { + $(row) + .find("td") + .addClass("highlight"); + } + // Select assigned groups sel.val(data.groups); // Initialize multiselect @@ -230,6 +245,18 @@ function initTable() { data.columns[0].visible = false; // Apply loaded state to table return data; + }, + initComplete: function() { + if ("domainid" in GETDict) { + var pos = table + .column(0, { order: "current" }) + .data() + .indexOf(parseInt(GETDict.domainid)); + if (pos >= 0) { + var page = Math.floor(pos / table.page.info().length); + table.page(page).draw(false); + } + } } }); diff --git a/style/pi-hole.css b/style/pi-hole.css index 419db78f..eb986c22 100644 --- a/style/pi-hole.css +++ b/style/pi-hole.css @@ -239,3 +239,7 @@ .text-vivid-blue { color: #36f !important; } + +td.highlight { + background-color: yellow; +} \ No newline at end of file