From 01e5e7250560da81eaf37c5804f5cb4577095d01 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 15:29:56 +0200 Subject: Adding upstream version 20160720. Signed-off-by: Daniel Baumann --- application/controllers/IndexController.php | 59 +++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 application/controllers/IndexController.php (limited to 'application/controllers/IndexController.php') diff --git a/application/controllers/IndexController.php b/application/controllers/IndexController.php new file mode 100644 index 0000000..705ed53 --- /dev/null +++ b/application/controllers/IndexController.php @@ -0,0 +1,59 @@ +hostList = new HostList($this->backend); + $this->hostList->addFilter(Filter::matchAll()); + + $this->getTabs()->add( + 'show', + array( + 'title' => 'Show Status Map', + 'label' => 'Status Map', + 'url' => Url::fromRequest(), + ) + )->activate('show'); + } + + public function indexAction() { + $this->hostList->setColumns(array( + 'host_name', + 'host_display_name', + 'host_state', + )); + + $hosts = $this->hostList->fetch(); + + $dependencies = $this->backend->select() + ->from('hostdependency', array('host_name', 'dependent_host_name')) + ->fetchAll(); + + $data_dep = array(); + foreach ($dependencies as $dependency) { + $data_dep[] = array( + 'parent' => $dependency->host_name, + 'child' => $dependency->dependent_host_name, + ); + } + $this->view->data_dependencies = json_encode($data_dep); + + $data_hosts = array(); + foreach ($hosts as $host) { + $data_hosts[] = array( + 'host_name' => $host->host_name, + 'display_name' => $host->host_display_name, + 'state' => (int) $host->host_state, + ); + } + $this->view->data_hosts = json_encode($data_hosts); + } + +} -- cgit v1.2.3