From 6e0188fac18d5fd37a188697667203119ac728f0 Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 9 Mar 2021 16:32:12 +0000 Subject: [PATCH] add summary report availability graph --- pandora_console/extras/mr/45.sql | 3 ++ .../pandoradb_migrate_6.0_to_7.0.mysql.sql | 2 ++ .../reporting_builder.item_editor.php | 27 ++++++++++++++- .../godmode/reporting/reporting_builder.php | 11 ++++++- .../include/functions_reporting.php | 33 +++++++++---------- .../include/functions_reporting_html.php | 31 ++++++++++++++++- pandora_console/pandoradb.sql | 2 ++ visual_console_client/src/Item.ts | 3 +- 8 files changed, 91 insertions(+), 21 deletions(-) diff --git a/pandora_console/extras/mr/45.sql b/pandora_console/extras/mr/45.sql index a1259e4a77..90f821dae5 100644 --- a/pandora_console/extras/mr/45.sql +++ b/pandora_console/extras/mr/45.sql @@ -1,5 +1,8 @@ START TRANSACTION; +ALTER TABLE `treport_content` ADD COLUMN `summary` tinyint(1) DEFAULT 0; +ALTER TABLE `treport_content_template` ADD COLUMN `summary` tinyint(1) DEFAULT 0; + ALTER TABLE `tinventory_alert` ADD COLUMN `alert_groups` TEXT NOT NULL; UPDATE `tinventory_alert` t1 INNER JOIN `tinventory_alert` t2 ON t1.id = t2.id SET t1.alert_groups = t2.id_group; diff --git a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql index 8f4cbf6209..2742e7e197 100644 --- a/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql +++ b/pandora_console/extras/pandoradb_migrate_6.0_to_7.0.mysql.sql @@ -865,6 +865,7 @@ ALTER TABLE `treport_content_template` ADD COLUMN `agent_min_value` TINYINT(1) D ALTER TABLE `treport_content_template` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '1'; ALTER TABLE `treport_content_template` ADD COLUMN `failover_type` tinyint(1) DEFAULT '1'; +ALTER TABLE `treport_content_template` ADD COLUMN `summary` tinyint(1) DEFAULT 0; ALTER TABLE `treport_content_template` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; ALTER TABLE `treport_content_template` MODIFY COLUMN `historical_db` tinyint(1) unsigned NOT NULL DEFAULT '0', MODIFY COLUMN `lapse_calc` tinyint(1) unsigned NOT NULL DEFAULT '0', @@ -1725,6 +1726,7 @@ ALTER TABLE `treport_content` ADD COLUMN `agent_min_value` TINYINT(1) DEFAULT '1 ALTER TABLE `treport_content` ADD COLUMN `current_month` TINYINT(1) DEFAULT '1'; ALTER TABLE `treport_content` ADD COLUMN `failover_mode` tinyint(1) DEFAULT '0'; ALTER TABLE `treport_content` ADD COLUMN `failover_type` tinyint(1) DEFAULT '0'; +ALTER TABLE `treport_content` ADD COLUMN `summary` tinyint(1) DEFAULT 0; ALTER table `treport_content` MODIFY COLUMN `name` varchar(300) NULL; ALTER TABLE `treport_content` ADD COLUMN `uncompressed_module` TINYINT DEFAULT '0'; ALTER TABLE `treport_content` MODIFY COLUMN `historical_db` tinyint(1) unsigned NOT NULL DEFAULT '0', diff --git a/pandora_console/godmode/reporting/reporting_builder.item_editor.php b/pandora_console/godmode/reporting/reporting_builder.item_editor.php index f3c3070ef1..e90acee5cb 100755 --- a/pandora_console/godmode/reporting/reporting_builder.item_editor.php +++ b/pandora_console/godmode/reporting/reporting_builder.item_editor.php @@ -185,6 +185,7 @@ switch ($action) { $dyn_height = 230; $landscape = false; $pagebreak = false; + $summary = 0; break; case 'save': @@ -314,11 +315,12 @@ switch ($action) { $idCustomGraph = $item['id_gs']; break; + case 'availability_graph': + $summary = $item['summary']; case 'SLA': case 'SLA_weekly': case 'SLA_monthly': case 'SLA_hourly': - case 'availability_graph': $description = $item['description']; $only_display_wrong = $item['only_display_wrong']; $monday = $item['monday']; @@ -2750,6 +2752,27 @@ $class = 'databox filters'; + + + + + + + + + @@ -5116,6 +5139,7 @@ function chooseType() { $("#row_current_month").hide(); $("#row_failover_mode").hide(); $("#row_failover_type").hide(); + $("#row_summary").hide(); $("#row_working_time").hide(); $("#row_working_time_compare").hide(); $("#row_only_display_wrong").hide(); @@ -5310,6 +5334,7 @@ function chooseType() { if(failover_checked){ $("#row_failover_type").show(); } + $("#row_summary").show(); break; case 'module_histogram_graph': diff --git a/pandora_console/godmode/reporting/reporting_builder.php b/pandora_console/godmode/reporting/reporting_builder.php index 39448a084b..6f77f643ec 100755 --- a/pandora_console/godmode/reporting/reporting_builder.php +++ b/pandora_console/godmode/reporting/reporting_builder.php @@ -1518,12 +1518,16 @@ switch ($action) { $values['text'] = $intervals; break; + case 'availability_graph': + $values['summary'] = get_parameter( + 'summary', + 0 + ); case 'SLA_monthly': case 'SLA_weekly': case 'SLA_hourly': case 'SLA_services': case 'SLA': - case 'availability_graph': $values['period'] = get_parameter('period'); $values['top_n'] = get_parameter( 'combo_sla_sort_options', @@ -2570,6 +2574,11 @@ switch ($action) { REPORT_FAILOVER_TYPE_NORMAL ); + $values['summary'] = get_parameter( + 'summary', + 0 + ); + $style = []; $style['show_in_same_row'] = get_parameter( 'show_in_same_row', diff --git a/pandora_console/include/functions_reporting.php b/pandora_console/include/functions_reporting.php index 627b2b5a33..80f0801493 100755 --- a/pandora_console/include/functions_reporting.php +++ b/pandora_console/include/functions_reporting.php @@ -7551,6 +7551,7 @@ function reporting_availability_graph( $return['pagebreak'] = $content['pagebreak']; $return['description'] = $content['description']; $return['failover_type'] = $content['failover_type']; + $return['summary'] = $content['summary']; $return['date'] = reporting_get_date_text($report, $content); // Get chart. @@ -7669,24 +7670,22 @@ function reporting_availability_graph( } foreach ($sla_failover as $k_sla => $v_sla) { - if ($content['failover_type'] == REPORT_FAILOVER_TYPE_NORMAL) { - $sla_array = data_compare_24x7( - $v_sla, - $content, - $report['datetime'], - $slice - ); + $sla_array = data_compare_24x7( + $v_sla, + $content, + $report['datetime'], + $slice + ); - $return = prepare_data_for_paint( - $v_sla, - $sla_array, - $content, - $report['datetime'], - $return, - $k_sla, - $pdf - ); - } + $return = prepare_data_for_paint( + $v_sla, + $sla_array, + $content, + $report['datetime'], + $return, + $k_sla, + $pdf + ); if (isset($v_sla['compare']) === true && empty($v_sla['compare']) === false diff --git a/pandora_console/include/functions_reporting_html.php b/pandora_console/include/functions_reporting_html.php index 6bf753cd8d..8f27e19933 100644 --- a/pandora_console/include/functions_reporting_html.php +++ b/pandora_console/include/functions_reporting_html.php @@ -3835,6 +3835,10 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $tables_chart = ''; + $total_values = 0; + + $count_total_charts = 0; + if (isset($item['failed']) === true && empty($item['failed']) === false) { $tables_chart .= $item['failed']; } else { @@ -3896,6 +3900,8 @@ function reporting_html_availability_graph($table, $item, $pdf=0) $table1->data[$k_chart][0] .= ' (24 x 7)'; } + $total_values += $sla_value; + $count_total_charts++; $table1->data[$k_chart][1] = $chart['chart']; $table1->data[$k_chart][2] = "".$sla_value.'
'; @@ -3922,7 +3928,7 @@ function reporting_html_availability_graph($table, $item, $pdf=0) || $item['data'][$k_chart]['compare'] === 1) ) { $table1 = new stdClass(); - $table1->width = '99%'; + $table1->width = '100%'; $table1->data = []; $table1->size = []; $table1->size[0] = '10%'; @@ -3971,6 +3977,8 @@ function reporting_html_availability_graph($table, $item, $pdf=0) case 'result': default: + $total_values += $sla_value; + $count_total_charts++; $title = ''.__('Result').''; $sla_value_text = "".$sla_value.''; $checks_resume_text = ''; @@ -3996,6 +4004,27 @@ function reporting_html_availability_graph($table, $item, $pdf=0) } } + if ((bool) $item['summary'] === true) { + $table_summary = new stdClass(); + $table_summary->width = '20%'; + + $table_summary->size = []; + $table_summary->size[0] = '50%'; + $table_summary->size[1] = '50%'; + + $table_summary->data = []; + $table_summary->data[0][0] = ''.__('Summary').''; + $table_summary->data[0][1] = ''; + $table_summary->data[0][1] .= sla_truncate($total_values / $count_total_charts); + $table_summary->data[0][1] .= ' %'; + $table_summary->data[0][1] .= ''; + + $tables_chart .= html_print_table( + $table_summary, + true + ); + } + if ($item['type'] == 'availability_graph') { // Table_legend_graphs. $table2 = new stdClass(); diff --git a/pandora_console/pandoradb.sql b/pandora_console/pandoradb.sql index ce3b347df2..a4c3174889 100644 --- a/pandora_console/pandoradb.sql +++ b/pandora_console/pandoradb.sql @@ -1560,6 +1560,7 @@ CREATE TABLE IF NOT EXISTS `treport_content` ( `failover_mode` tinyint(1) DEFAULT '1', `failover_type` tinyint(1) DEFAULT '1', `uncompressed_module` TINYINT DEFAULT '0', + `summary` tinyint(1) DEFAULT 0, `landscape` tinyint(1) UNSIGNED NOT NULL default 0, `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0, `compare_work_time` tinyint(1) UNSIGNED NOT NULL default 0, @@ -3163,6 +3164,7 @@ CREATE TABLE IF NOT EXISTS `treport_content_template` ( `current_month` TINYINT(1) DEFAULT '1', `failover_mode` tinyint(1) DEFAULT '1', `failover_type` tinyint(1) DEFAULT '1', + `summary` tinyint(1) DEFAULT 0, `uncompressed_module` TINYINT DEFAULT '0', `landscape` tinyint(1) UNSIGNED NOT NULL default 0, `pagebreak` tinyint(1) UNSIGNED NOT NULL default 0, diff --git a/visual_console_client/src/Item.ts b/visual_console_client/src/Item.ts index 4aeb5f5c88..d0fe304255 100644 --- a/visual_console_client/src/Item.ts +++ b/visual_console_client/src/Item.ts @@ -844,7 +844,8 @@ abstract class VisualConsoleItem { if ( prevProps && - this.props.isLinkEnabled && prevProps.link !== this.props.link + this.props.isLinkEnabled && + prevProps.link !== this.props.link ) { if (this.props.link !== null) { this.elementRef.setAttribute("href", this.props.link);