From 2362fe81463148fe20f48f607788228a844b8651 Mon Sep 17 00:00:00 2001 From: Pablo Aragon Date: Tue, 18 Apr 2023 17:05:08 +0200 Subject: [PATCH] 9555-Modules hitorical & styles --- pandora_console/mobile/include/style/main.css | 55 +++ pandora_console/mobile/index.php | 11 + pandora_console/mobile/operation/agent.php | 6 + pandora_console/mobile/operation/events.php | 2 +- .../mobile/operation/module_data.php | 354 ++++++++++++++++++ pandora_console/mobile/operation/modules.php | 5 +- .../mobile/operation/server_status.php | 37 +- pandora_console/mobile/operation/services.php | 17 +- 8 files changed, 458 insertions(+), 29 deletions(-) create mode 100644 pandora_console/mobile/operation/module_data.php diff --git a/pandora_console/mobile/include/style/main.css b/pandora_console/mobile/include/style/main.css index 1bba3990b9..3c63b13a82 100755 --- a/pandora_console/mobile/include/style/main.css +++ b/pandora_console/mobile/include/style/main.css @@ -56,10 +56,20 @@ body { font-family: "Lato" !important; } +a { + text-decoration: underline !important; + text-decoration-color: var(--muted-color) !important; + color: var(--primary-color); +} + .small { font-size: 10px !important; } +.font-10pt { + font-size: 10pt !important; +} + .center { text-align: center; } @@ -488,6 +498,7 @@ table.event_details td.cell_event_name { @media screen and (max-width: 35em) { /* Hide the title of event name */ + #last_agent_events tbody tr.events td.cell_0 b.ui-table-cell-label, #list_events tbody tr.events td.cell_0 b.ui-table-cell-label { display: none; } @@ -520,26 +531,36 @@ table.event_details td.cell_event_name { font-weight: bold; } +.agents_tiny_stats span { + background-color: transparent !important; +} + +.agents_tiny_stats .red, .color-red { color: #c00 !important; } +.agents_tiny_stats .green, .color-green { color: #5a8629 !important; } +.agents_tiny_stats .orange, .color-orange { color: #fd7304 !important; } +.agents_tiny_stats .yellow, .color-yellow { color: #f3c500 !important; } +.agents_tiny_stats .grey, .color-grey { color: #808080 !important; } +.agents_tiny_stats .blue, .color-blue { color: #4a83f3 !important; } @@ -903,6 +924,7 @@ table.event_details td.cell_event_name { font-size: 12px !important; } + table#list_module_data tr, table#list_servers tr, table[id^="service-table-"] tr { display: flex; @@ -911,6 +933,7 @@ table.event_details td.cell_event_name { align-items: center; } + table#list_module_data b.ui-table-cell-label, table#list_servers b.ui-table-cell-label, table[id^="service-table-"] b.ui-table-cell-label { display: none; @@ -2114,33 +2137,65 @@ table#last-activity > tbody > tr > td > b { } /* Events table */ +table#last_agent_events > tbody > tr.events > td.cell_0, table#list_events > tbody > tr.events > td.cell_0 { border-top-left-radius: 8px !important; border-top-right-radius: 8px !important; } +table#last_agent_events > tbody > tr.events > td.vertical_middle, table#list_events > tbody > tr.events > td.vertical_middle { border-bottom-left-radius: 8px !important; border-bottom-right-radius: 8px !important; color: #4a4a4a; } +table#last_agent_events > tbody > tr.events, table#list_events > tbody > tr.events { background-color: var(--secondary-color) !important; } +table#last_agent_events > tbody > tr.events.datos_green > td, table#list_events > tbody > tr.events.datos_green > td { background-color: #81b92e40; } +table#last_agent_events > tbody > tr.events.datos_red > td, table#list_events > tbody > tr.events.datos_red > td { background-color: #ed474a40; } +table#last_agent_events > tbody > tr.events.datos_yellow > td, table#list_events > tbody > tr.events.datos_yellow > td { background-color: #fcab1040; } +table#last_agent_events > tbody > tr.events.datos_blue > td, table#list_events > tbody > tr.events.datos_blue > td { background-color: #25a8ff40; } +table#last_agent_events > tbody > tr.events.datos_grey > td, table#list_events > tbody > tr.events.datos_grey > td { background-color: #adadad40; } + +table#list_module_data > thead > tr > th { + display: initial; +} + +h4[id^="service-"].ui-collapsible-heading + > a + > span.ui-icon.ui-collapsible-icon-right { + margin-top: 2px !important; +} + +h4[id^="service-"].ui-collapsible-heading + > a.ui-collapsible-heading-toggle.ui-button.ui-button-a { + padding-left: 10px !important; +} + +table[id^="service-table-"] { + padding: 0px !important; +} + +table[id^="service-table-"] > tbody > tr { + padding: 0px 5px !important; + height: 48px !important; +} diff --git a/pandora_console/mobile/index.php b/pandora_console/mobile/index.php index 401f96ae11..fe0eb231d8 100644 --- a/pandora_console/mobile/index.php +++ b/pandora_console/mobile/index.php @@ -45,6 +45,7 @@ require_once 'operation/visualmaps.php'; require_once 'operation/visualmap.php'; require_once 'operation/server_status.php'; require_once 'operation/services.php'; +require_once 'operation/module_data.php'; $enterpriseHook = enterprise_include('mobile/include/enterprise.class.php'); $enterpriseHook = enterprise_include('mobile/operation/home.php'); @@ -189,6 +190,11 @@ switch ($action) { $services->ajax($parameter2); break; + case 'module_data': + $module_data = new ModuleData(); + $module_data->ajax($parameter2); + break; + default: if (class_exists('Enterprise')) { $enterprise->enterpriseAjax($parameter1, $parameter2); @@ -429,6 +435,11 @@ switch ($action) { $services = new Services(); $services->show(); break; + + case 'module_data': + $module_data = new ModuleData(); + $module_data->show(); + break; } break; } diff --git a/pandora_console/mobile/operation/agent.php b/pandora_console/mobile/operation/agent.php index 5bd28c3350..f1ff032862 100644 --- a/pandora_console/mobile/operation/agent.php +++ b/pandora_console/mobile/operation/agent.php @@ -27,6 +27,8 @@ * ============================================================================ */ +use PandoraFMS\Event; + // Begin. require_once '../include/functions_users.php'; @@ -130,9 +132,13 @@ class Agent { $ui = Ui::getInstance(); $system = System::getInstance(); + $eventObj = new Events; $ui->createPage(); + $options = $eventObj->getEventDialogOptions(); + $ui->addDialog($options); + if ($this->id != 0) { $agent_alias = (string) $this->agent['alias']; diff --git a/pandora_console/mobile/operation/events.php b/pandora_console/mobile/operation/events.php index 1021bd862c..9b08557d7d 100644 --- a/pandora_console/mobile/operation/events.php +++ b/pandora_console/mobile/operation/events.php @@ -1201,7 +1201,7 @@ class Events data: postvars, success: function (data) { - if (data.correct) { + if (data.correct) { event = data.event; //Fill the dialog $("#detail_event_dialog .cell_event_name") diff --git a/pandora_console/mobile/operation/module_data.php b/pandora_console/mobile/operation/module_data.php new file mode 100644 index 0000000000..101397de47 --- /dev/null +++ b/pandora_console/mobile/operation/module_data.php @@ -0,0 +1,354 @@ +checkACL($this->acl)) { + $this->correct_acl = true; + } else { + $this->correct_acl = false; + } + + $this->moduleId = $system->getRequest('module_id'); + } + + + public function ajax($parameter2=false) + { + $system = System::getInstance(); + + if (!$this->correct_acl) { + return; + } else { + switch ($parameter2) { + case 'get_module_data': + $this->getFilters(); + $page = $system->getRequest('page', 0); + $module_id = $system->getRequest('module_id'); + $servers = []; + $end = 1; + + $listData = $this->getListData($page, true); + + if (!empty($listData['data'])) { + $end = 0; + $servers = $listData['data']; + } + + echo json_encode(['end' => $end, 'servers' => $servers]); + break; + } + } + } + + + public function show() + { + if (!$this->correct_acl) { + $this->show_fail_acl(); + } else { + $this->show_module_data(); + } + } + + + private function show_fail_acl() + { + $error['type'] = 'onStart'; + $error['title_text'] = __('You don\'t have access to this page'); + $error['content_text'] = System::getDefaultACLFailText(); + if (class_exists('HomeEnterprise')) { + $home = new HomeEnterprise(); + } else { + $home = new Home(); + } + + $home->show($error); + } + + + private function show_module_data() + { + $ui = Ui::getInstance(); + + $ui->createPage(); + $ui->createDefaultHeader( + __('Module data'), + $ui->createHeaderButton( + [ + 'icon' => 'ui-icon-back', + 'pos' => 'left', + 'text' => __('Back'), + 'href' => 'index.php?page=modules', + 'class' => 'header-button-left', + ] + ) + ); + $ui->showFooter(false); + $ui->beginContent(); + $this->listDataHtml(); + $ui->endContent(); + $ui->showPage(); + } + + + private function getListData($page=0, $ajax=false) + { + global $config; + $system = System::getInstance(); + + $total = 0; + $data = []; + + $module_data = modules_get_agentmodule_data( + $this->moduleId, + 604800, + 0, + false, + false, + 'DESC' + ); + + $total = (int) count($module_data); + + foreach ($module_data as $module) { + $row[__('Data')] = ''.$module['data'].''; + $row[__('Timestamp')] = ''.human_time_comparation($module['utimestamp'], 'tiny').''; + + array_push($data, $row); + } + + return [ + 'data' => $data, + 'total' => $total, + ]; + } + + + public function listDataHtml($page=0, $return=false) + { + $system = System::getInstance(); + $ui = Ui::getInstance(); + + $listData = $this->getListData($page); + if ($listData['total'] == 0) { + $html = '

'.__('No data').'

'; + if (!$return) { + $ui->contentAddHtml($html); + } else { + return $html; + } + } else { + if (!$return) { + $table = new Table(); + $table->id = 'list_module_data'; + $table->importFromHash($listData['data']); + + $ui->contentAddHtml('
'); + + $agent_id = agents_get_agent_id_by_module_id($this->moduleId); + $agent_name = agents_get_name($agent_id); + $module_name = modules_get_agentmodule_name($this->moduleId); + $ui->contentAddHtml('

'.$module_name.'

'); + $ui->contentAddHtml('

'.$agent_name.'

'); + + $ui->contentAddHtml($table->getHTML()); + + $ui->contentAddHtml('
'); + } else { + $table = new Table(); + $table->id = 'list_module_data'; + + $table->importFromHash($listData['data']); + + $html = $table->getHTML(); + + return $html; + } + + // if ($system->getPageSize() < $listData['total']) { + // $ui->contentAddHtml( + // '
'.html_print_image('images/spinner.gif', true, false, false, false, false, true).' '.__('Loading...').'
' + // ); + // $this->addJavascriptAddBottom(); + // } + } + + $ui->contentAddLinkListener('list_servers'); + } + + + private function addJavascriptAddBottom() + { + $ui = Ui::getInstance(); + + $ui->contentAddHtml( + "" + ); + } + + + private function filterServersGetString() + { + if ($this->default) { + return __('(Default)'); + } else { + $filters_to_serialize = []; + + if (!$this->default_filters['group']) { + $filters_to_serialize[] = sprintf( + __('Group: %s'), + groups_get_name($this->group, true) + ); + } + + if (!$this->default_filters['module_group']) { + $module_group = db_get_value( + 'name', + 'tmodule_group', + 'id_mg', + $this->module_group + ); + $module_group = io_safe_output($module_group); + + $filters_to_serialize[] = sprintf( + __('Module group: %s'), + $module_group + ); + } + + if (!$this->default_filters['status']) { + $filters_to_serialize[] = sprintf( + __('Status: %s'), + $this->list_status[$this->status] + ); + } + + if (!$this->default_filters['free_search']) { + $filters_to_serialize[] = sprintf( + __('Free Search: %s'), + $this->free_search + ); + } + + if (!$this->default_filters['tag']) { + $tag_name = tags_get_name($this->tag); + $filters_to_serialize[] = sprintf( + __('Tag: %s'), + $tag_name + ); + } + + $string = '('.implode(' - ', $filters_to_serialize).')'; + + return $string; + } + } + + +} diff --git a/pandora_console/mobile/operation/modules.php b/pandora_console/mobile/operation/modules.php index 89f39912f0..ba558e5726 100644 --- a/pandora_console/mobile/operation/modules.php +++ b/pandora_console/mobile/operation/modules.php @@ -853,7 +853,7 @@ class Modules '.__('Graph').' - + '.__('Historical data').' @@ -927,11 +927,14 @@ class Modules var historical = ''; if (serverId === 'node') { graph = 'index.php?page=module_graph&id='+moduleId+'&id_agent='+agentId; + historical = 'index.php?page=module_data&module_id='+moduleId; } else { graph = 'index.php?page=module_graph&id='+moduleId+'&id_agent='+agentId+'&server_id='+serverId; + historical = 'index.php?page=module_data&module_id='+moduleId; } $('#graph-option').attr('href', graph); + $('#historical-option').attr('href', historical); $('#module-dialog-button').click(); } diff --git a/pandora_console/mobile/operation/server_status.php b/pandora_console/mobile/operation/server_status.php index 7435ea41ea..d3bba4656b 100644 --- a/pandora_console/mobile/operation/server_status.php +++ b/pandora_console/mobile/operation/server_status.php @@ -354,12 +354,6 @@ class ServerStatus } } - echo ""; - return [ 'servers' => $servers, 'total' => $total, @@ -386,7 +380,20 @@ class ServerStatus $table->id = 'list_servers'; $table->importFromHash($listServers['servers']); + $ui->contentAddHtml('
'); $ui->contentAddHtml($table->getHTML()); + + if ($this->all_servers === true) { + if ($system->getPageSize() < $listServers['total']) { + $ui->contentAddHtml( + '
'.html_print_image('images/spinner.gif', true, false, false, false, false, true).' '.__('Loading...').'
' + ); + + $this->addJavascriptAddBottom(); + } + } + + $ui->contentAddHtml('
'); } else { $table = new Table(); $table->id = 'list_servers_status'; @@ -397,16 +404,6 @@ class ServerStatus return $html; } - - if ($this->all_servers === true) { - if ($system->getPageSize() < $listServers['total']) { - $ui->contentAddHtml( - '
'.html_print_image('images/spinner.gif', true, false, false, false, false, true).' '.__('Loading...').'
' - ); - - $this->addJavascriptAddBottom(); - } - } } $ui->contentAddLinkListener('list_servers'); @@ -454,12 +451,8 @@ class ServerStatus load_more_rows = 1; refresh_link_listener_list_servers() } - - }, \"json\"); - - } } } @@ -473,6 +466,10 @@ class ServerStatus $(window).on(\"touchmove\", function(event) { custom_scroll(); }); + + window.addEventListener('DOMContentLoaded', (event) => { + document.querySelector('table#list_servers span.data a').href = '#'; + }); }); " ); diff --git a/pandora_console/mobile/operation/services.php b/pandora_console/mobile/operation/services.php index b0fae9d354..346f7716d3 100644 --- a/pandora_console/mobile/operation/services.php +++ b/pandora_console/mobile/operation/services.php @@ -171,7 +171,8 @@ class Services ' ); $ui->contentAddHtml('
'); - $ui->contentAddHtml('

'.$group_icon.' '.$service['description'].'

'); + $arrow = ''; + $ui->contentAddHtml('

'.$arrow.$group_icon.' '.$service['description'].'

'); $spinner = '
@@ -236,7 +237,6 @@ class Services } } - $name .= ''; if (is_metaconsole() && ((int) $item->id_server_meta()) !== 0 ) { @@ -244,7 +244,6 @@ class Services } $name .= $item->agent()->alias(); - $name .= ''; $name .= ''; if (((bool) $item->agent()->disabled()) === true) { @@ -303,7 +302,6 @@ class Services } } - $name .= ''; if (is_metaconsole() && ((int) $item->id_server_meta()) !== 0 ) { @@ -311,7 +309,6 @@ class Services } $name .= $item->service()->name(); - $name .= ''; $name .= ''; if (((bool) $item->service()->disabled()) === true) { @@ -340,7 +337,6 @@ class Services 'index.php?sec=eventos&sec2=operation/events/events&event_view_hr=8&severity=4&id_agent='.$item->module()->id_agente().'&id_agent_module='.$item->id_agente_modulo() ); $name = ''; - $name .= ''; if (((bool) $item->module()->disabled()) === true) { $disabled_element = true; @@ -367,7 +363,6 @@ class Services ).''; } - $name .= ''; $name .= ''; } break; @@ -527,6 +522,14 @@ class Services $('h4#service-'+id+' + div.ui-collapsible-content').html(data); }, \"html\"); + + var arrow = document.querySelector('h4#service-'+id+' > a > span.ui-icon.ui-icon-arrow-d'); + + if (arrow.style.transform == 'rotate(180deg)') { + arrow.style.transform = ''; + } else { + arrow.style.transform = 'rotate(180deg)'; + } } " );