From c46a1e22f5662eabcc9ea879b4ff1bf71f40b7f1 Mon Sep 17 00:00:00 2001 From: Alex <40072887+alexdcrane@users.noreply.github.com> Date: Tue, 9 Sep 2025 11:44:17 -0700 Subject: [PATCH] Add dashboard filter by name via GET method (#7484) * Add dashboard filter by name via GET method * Update index.php --- core/dashboard/index.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/core/dashboard/index.php b/core/dashboard/index.php index a8dbca9c8d..26abc0b51f 100644 --- a/core/dashboard/index.php +++ b/core/dashboard/index.php @@ -76,16 +76,17 @@ $sql = "select dashboard_uuid "; $sql .= "from v_dashboards "; $sql .= "where dashboard_enabled = 'true' "; - $sql .= "and domain_uuid = :domain_uuid "; + $sql .= "and ("; + $sql .= " domain_uuid = :domain_uuid "; + $sql .= " or domain_uuid is null "; + $sql .= ") "; + if (!empty($_GET['name'])) { + $sql .= "and dashboard_name = :dashboard_name "; + $parameters['dashboard_name'] = $_GET['name']; + } + $sql .= "order by case when domain_uuid = :domain_uuid then 0 else 1 end "; $parameters['domain_uuid'] = $_SESSION['domain_uuid']; $result = $database->select($sql, $parameters ?? null, 'all'); - if (empty($result)) { - $sql = "select dashboard_uuid "; - $sql .= "from v_dashboards "; - $sql .= "where dashboard_enabled = 'true' "; - $sql .= "and domain_uuid is null"; - $result = $database->select($sql, null, 'all'); - } $dashboard_uuid = $result[0]['dashboard_uuid'] ?? null; unset($sql, $parameters); @@ -195,7 +196,7 @@ //redirect the browser message::add($text['message-update']); - header("Location: /core/dashboard/index.php"); + header("Location: /core/dashboard/".(!empty($_GET['name']) ? "?name=".$_GET['name'] : null)); return; } }