#10983 revised widgets with intervals

This commit is contained in:
Daniel Cebrian 2023-10-23 14:48:34 +02:00
parent 4d9679648d
commit dbf315e407
9 changed files with 54 additions and 5 deletions

View File

@ -637,6 +637,10 @@ class BasicChart extends Widget
$color_status = $this->values['colorValue']; $color_status = $this->values['colorValue'];
} }
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
$params = [ $params = [
'agent_module_id' => $this->values['moduleId'], 'agent_module_id' => $this->values['moduleId'],
'period' => $this->values['period'], 'period' => $this->values['period'],

View File

@ -473,6 +473,10 @@ class DataMatrix extends Widget
return $output; return $output;
} }
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
if (is_metaconsole() === true) { if (is_metaconsole() === true) {
$modules_nodes = array_reduce( $modules_nodes = array_reduce(
$this->values['moduleDataMatrix'], $this->values['moduleDataMatrix'],

View File

@ -472,6 +472,10 @@ class CustomGraphWidget extends Widget
$size = parent::getSize(); $size = parent::getSize();
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
switch ($this->values['type']) { switch ($this->values['type']) {
case CUSTOM_GRAPH_STACKED_LINE: case CUSTOM_GRAPH_STACKED_LINE:
case CUSTOM_GRAPH_STACKED_AREA: case CUSTOM_GRAPH_STACKED_AREA:

View File

@ -302,6 +302,10 @@ class GraphModuleHistogramWidget extends Widget
$values['period'] = SECONDS_1DAY; $values['period'] = SECONDS_1DAY;
} }
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
if (isset($values['sizeLabel']) === false) { if (isset($values['sizeLabel']) === false) {
$values['sizeLabel'] = 30; $values['sizeLabel'] = 30;
} }

View File

@ -309,6 +309,12 @@ class Netflow extends Widget
$start_date = (time() - $this->values['period']); $start_date = (time() - $this->values['period']);
$end_date = time(); $end_date = time();
if (empty(parent::getPeriod()) === false) {
$start_date = parent::getDateFrom();
$end_date = parent::getDateTo();
}
if ($this->values['chart_type'] === 'usage_map') { if ($this->values['chart_type'] === 'usage_map') {
$map_data = netflow_build_map_data( $map_data = netflow_build_map_data(
$start_date, $start_date,

View File

@ -134,6 +134,7 @@ class SecurityHardening extends Widget
// Includes. // Includes.
include_once ENTERPRISE_DIR.'/include/functions_security_hardening.php'; include_once ENTERPRISE_DIR.'/include/functions_security_hardening.php';
include_once $config['homedir'].'/include/graphs/fgraph.php';
// WARNING: Do not edit. This chunk must be in the constructor. // WARNING: Do not edit. This chunk must be in the constructor.
parent::__construct( parent::__construct(
$cellId, $cellId,
@ -325,6 +326,11 @@ class SecurityHardening extends Widget
$id_groups = $this->checkAcl($values['group']); $id_groups = $this->checkAcl($values['group']);
$output .= '<b>'.$this->elements[$data_type].'</b>'; $output .= '<b>'.$this->elements[$data_type].'</b>';
if (empty(parent::getPeriod()) === false) {
$values['date_init'] = parent::getDateFrom();
$values['date_end'] = parent::getDateTo();
}
switch ($data_type) { switch ($data_type) {
case 'top_n_agents_sh': case 'top_n_agents_sh':
$output .= $this->loadTopNAgentsSh($id_groups, $values['limit']); $output .= $this->loadTopNAgentsSh($id_groups, $values['limit']);

View File

@ -300,6 +300,10 @@ class SingleGraphWidget extends Widget
$values['period'] = SECONDS_1DAY; $values['period'] = SECONDS_1DAY;
} }
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
if (isset($values['showLegend']) === false) { if (isset($values['showLegend']) === false) {
$values['showLegend'] = 1; $values['showLegend'] = 1;
} }

View File

@ -374,6 +374,10 @@ class TopNWidget extends Widget
$size = parent::getSize(); $size = parent::getSize();
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
$quantity = $this->values['quantity']; $quantity = $this->values['quantity'];
$period = $this->values['period']; $period = $this->values['period'];

View File

@ -119,12 +119,12 @@ $inputs = [
'arguments' => [ 'arguments' => [
'name' => 'range', 'name' => 'range',
'id' => 'range', 'id' => 'range',
'selected' => ($arrayDashboard['date_to'] - $arrayDashboard['date_from']), 'selected' => ($arrayDashboard['date_from'] === '0' && $arrayDashboard['date_to'] === '0') ? 300 : 'chose_range',
'type' => 'date_range', 'type' => 'date_range',
'date_init' => $arrayDashboard['date_from'], 'date_init' => date('Y/m/d', $arrayDashboard['date_from']),
'time_init' => $arrayDashboard['date_from'], 'time_init' => date('H:i:s', $arrayDashboard['date_from']),
'date_end' => $arrayDashboard['date_to'], 'date_end' => date('Y/m/d', $arrayDashboard['date_to']),
'time_end' => $arrayDashboard['date_to'], 'time_end' => date('H:i:s', $arrayDashboard['date_to']),
], ],
], ],
[ [
@ -167,6 +167,19 @@ HTML::printForm(
function handle_date_range(element){ function handle_date_range(element){
if(element.checked) { if(element.checked) {
$(".row_date_range").show(); $(".row_date_range").show();
var def_state_range = $('#range_range').is(':visible');
var def_state_default = $('#range_default').is(':visible');
var def_state_extend = $('#range_extend').is(':visible');
if (
def_state_range === false
&& def_state_default === false
&& def_state_extend === false
&& $('#range').val() !== 'chose_range'
) {
$('#range_default').show();
} else if ($('#range').val() === 'chose_range') {
$('#range_range').show();
}
} else { } else {
$(".row_date_range").hide(); $(".row_date_range").hide();
} }