#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'];
}
if (empty(parent::getPeriod()) === false) {
$this->values['period'] = parent::getPeriod();
}
$params = [
'agent_module_id' => $this->values['moduleId'],
'period' => $this->values['period'],

View File

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

View File

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

View File

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

View File

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

View File

@ -134,6 +134,7 @@ class SecurityHardening extends Widget
// Includes.
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.
parent::__construct(
$cellId,
@ -325,6 +326,11 @@ class SecurityHardening extends Widget
$id_groups = $this->checkAcl($values['group']);
$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) {
case 'top_n_agents_sh':
$output .= $this->loadTopNAgentsSh($id_groups, $values['limit']);

View File

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

View File

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

View File

@ -119,12 +119,12 @@ $inputs = [
'arguments' => [
'name' => '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',
'date_init' => $arrayDashboard['date_from'],
'time_init' => $arrayDashboard['date_from'],
'date_end' => $arrayDashboard['date_to'],
'time_end' => $arrayDashboard['date_to'],
'date_init' => date('Y/m/d', $arrayDashboard['date_from']),
'time_init' => date('H:i:s', $arrayDashboard['date_from']),
'date_end' => date('Y/m/d', $arrayDashboard['date_to']),
'time_end' => date('H:i:s', $arrayDashboard['date_to']),
],
],
[
@ -167,6 +167,19 @@ HTML::printForm(
function handle_date_range(element){
if(element.checked) {
$(".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 {
$(".row_date_range").hide();
}