From 69f5ef89b76540212a86ffcfb4d0ac5c77a0684d Mon Sep 17 00:00:00 2001 From: caoyanyi Date: Tue, 14 Nov 2023 14:52:45 +0800 Subject: [PATCH] * Adjust host treemap load type. --- module/host/js/treemap.ui.js | 4 ++++ module/host/model.php | 8 ++++---- module/host/ui/treemap.html.php | 3 ++- 3 files changed, 10 insertions(+), 5 deletions(-) create mode 100644 module/host/js/treemap.ui.js diff --git a/module/host/js/treemap.ui.js b/module/host/js/treemap.ui.js new file mode 100644 index 0000000000..91163d2fc7 --- /dev/null +++ b/module/host/js/treemap.ui.js @@ -0,0 +1,4 @@ +window.onTreemapNodeClick = function(node) +{ + loadModal($.createLink('host', 'view', 'hostID=' + node.hostid)); +} diff --git a/module/host/model.php b/module/host/model.php index 2cfbdf8717..468dc9e306 100644 --- a/module/host/model.php +++ b/module/host/model.php @@ -309,7 +309,7 @@ class hostModel extends model if(is_array($hosts)) { $hostNameList = array(); - foreach($hosts as $host) $hostNameList[] = array('text' => htmlspecialchars($host->name)); + foreach($hosts as $host) $hostNameList[] = array('text' => htmlspecialchars($host->name), 'hostid' => $host->id); $subChildren['children'][] = array( 'text' => htmlspecialchars($cabinet), 'collapsed' => false, @@ -318,7 +318,7 @@ class hostModel extends model } else { - $subChildren['children'][] = array('text' => htmlspecialchars($hosts->name)); + $subChildren['children'][] = array('text' => htmlspecialchars($hosts->name), 'hostid' => $hosts->id); } } $children['children'][] = $subChildren; @@ -372,7 +372,7 @@ class hostModel extends model $treemap[$module->id] = array('text' => $module->name, 'collapsed' => false, 'children' => array()); foreach($hostGroups[$module->id] as $host) { - $treemap[$module->id]['children'][] = array('text' => htmlspecialchars($host->name)); + $treemap[$module->id]['children'][] = array('text' => htmlspecialchars($host->name), 'hostid' => $host->id); } } } @@ -383,7 +383,7 @@ class hostModel extends model if(isset($hostGroups[0])) { - foreach($hostGroups[0] as $host) $groupTree['children'][] = array('text' => htmlspecialchars($host->name)); + foreach($hostGroups[0] as $host) $groupTree['children'][] = array('text' => htmlspecialchars($host->name), 'hostid' => $host->id)); } $treemap[0] = $groupTree; } diff --git a/module/host/ui/treemap.html.php b/module/host/ui/treemap.html.php index 425f457863..90a098db37 100644 --- a/module/host/ui/treemap.html.php +++ b/module/host/ui/treemap.html.php @@ -24,5 +24,6 @@ featureBar treemap ( setClass('canvas'), - set::data($treemap) + set::data($treemap), + set::onNodeClick(jsRaw('(node) => window.onTreemapNodeClick(node)')) );