Merge remote-tracking branch 'origin/develop' into ent-4136-button-styles

This commit is contained in:
fbsanchez 2019-06-18 17:48:03 +02:00
commit 24025ebb74
82 changed files with 682 additions and 338 deletions

View File

@ -1,5 +1,5 @@
package: pandorafms-agent-unix
Version: 7.0NG.735-190612
Version: 7.0NG.735-190618
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.735-190612"
pandora_version="7.0NG.735-190618"
echo "Test if you has the tools for to make the packages."
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null

View File

@ -42,7 +42,7 @@ my $Sem = undef;
my $ThreadSem = undef;
use constant AGENT_VERSION => '7.0NG.735';
use constant AGENT_BUILD => '190612';
use constant AGENT_BUILD => '190618';
# Agent log default file size maximum and instances
use constant DEFAULT_MAX_LOG_SIZE => 600000;

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.735
%define release 190612
%define release 190618
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_agent_unix
%define version 7.0NG.735
%define release 190612
%define release 190618
Summary: Pandora FMS Linux agent, PERL version
Name: %{name}

View File

@ -10,7 +10,7 @@
# **********************************************************************
PI_VERSION="7.0NG.735"
PI_BUILD="190612"
PI_BUILD="190618"
OS_NAME=`uname -s`
FORCE=0

View File

@ -186,7 +186,7 @@ UpgradeApplicationID
{}
Version
{190612}
{190618}
ViewReadme
{Yes}

View File

@ -30,7 +30,7 @@ using namespace Pandora;
using namespace Pandora_Strutils;
#define PATH_SIZE _MAX_PATH+1
#define PANDORA_VERSION ("7.0NG.735(Build 190612)")
#define PANDORA_VERSION ("7.0NG.735(Build 190618)")
string pandora_path;
string pandora_dir;

View File

@ -11,7 +11,7 @@ BEGIN
VALUE "LegalCopyright", "Artica ST"
VALUE "OriginalFilename", "PandoraAgent.exe"
VALUE "ProductName", "Pandora FMS Windows Agent"
VALUE "ProductVersion", "(7.0NG.735(Build 190612))"
VALUE "ProductVersion", "(7.0NG.735(Build 190618))"
VALUE "FileVersion", "1.0.0.0"
END
END

View File

@ -1,5 +1,5 @@
package: pandorafms-console
Version: 7.0NG.735-190612
Version: 7.0NG.735-190618
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.735-190612"
pandora_version="7.0NG.735-190618"
package_pear=0
package_pandora=1

View File

@ -1,23 +1,24 @@
<?php
/**
* Pandora FMS - http://pandorafms.com
* ==================================================
* Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
* Please see http://pandorafms.org for full contribution list
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; version 2
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2011 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
$refr = (int) get_parameter('refresh', 0);
// By default 30 seconds
function mainAgentsModules()
{
global $config;
// Load global vars
// Load global vars.
include_once 'include/config.php';
include_once 'include/functions_reporting.php';
include_once $config['homedir'].'/include/functions_agents.php';
@ -25,7 +26,7 @@ function mainAgentsModules()
include_once $config['homedir'].'/include/functions_users.php';
check_login();
// ACL Check
// ACL Check.
if (! check_acl($config['id_user'], 0, 'AR')) {
db_pandora_audit(
'ACL Violation',
@ -37,7 +38,7 @@ function mainAgentsModules()
// Update network modules for this group
// Check for Network FLAG change request
// Made it a subquery, much faster on both the database and server side
// Made it a subquery, much faster on both the database and server side.
if (isset($_GET['update_netgroup'])) {
$group = get_parameter_get('update_netgroup', 0);
if (check_acl($config['id_user'], $group, 'AW')) {
@ -62,7 +63,7 @@ function mainAgentsModules()
$modulegroup = get_parameter('modulegroup', 0);
$refr = (int) get_parameter('refresh', 0);
// By default 30 seconds
// By default 30 seconds.
$recursion = get_parameter('recursion', 0);
$group_id = (int) get_parameter('group_id', 0);
$offset = (int) get_parameter('offset', 0);
@ -79,7 +80,8 @@ function mainAgentsModules()
$full_modules_selected = explode(';', get_parameter('full_modules_selected', 0));
$full_agents_id = explode(';', get_parameter('full_agents_id', 0));
if ($save_serialize && $update_item == '') {
// In full screen there is no pagination neither filters.
if (( ($config['pure'] == 0 && $save_serialize) && $update_item == '' ) || ( ($config['pure'] == 1 && $save_serialize == 0) && $update_item == '' )) {
$unserialize_modules_selected = unserialize_in_temp($config['id_user'].'_agent_module', true, 1);
$unserialize_agents_id = unserialize_in_temp($config['id_user'].'_agents', true, 1);
if ($unserialize_modules_selected) {
@ -102,7 +104,6 @@ function mainAgentsModules()
serialize_in_temp($agents_id, $config['id_user'].'_agents', 1);
}
// if($agents_id != -1) $agents_id = null;
if ($config['pure'] == 0) {
if ($modules_selected[0] && $agents_id[0]) {
$full_modules = urlencode(implode(';', $modules_selected));
@ -124,13 +125,13 @@ function mainAgentsModules()
}
}
// groups
// Groups.
$filter_groups_label = '<b>'.__('Group').'</b>';
$filter_groups = html_print_select_groups(false, 'AR', true, 'group_id', $group_id, '', '', '', true, false, true, '', false, 'width: auto;');
$filter_recursion_label = '<b>'.__('Recursion').'</b>';
$filter_recursion = html_print_checkbox('recursion', 1, 0, true);
// groups module
// Groups module.
$filter_module_groups_label = '<b>'.__('Module group').'</b>';
$filter_module_groups = html_print_select_from_sql(
'SELECT * FROM tmodule_group ORDER BY name',
@ -146,7 +147,7 @@ function mainAgentsModules()
'width: auto;'
);
// agent
// Agent.
$agents = agents_get_group_agents($group_id);
if ((empty($agents)) || $agents == -1) {
$agents = [];
@ -155,7 +156,7 @@ function mainAgentsModules()
$filter_agents_label = '<b>'.__('Agents').'</b>';
$filter_agents = html_print_select($agents, 'id_agents2[]', $agents_id, '', '', 0, true, true, true, '', false, 'min-width: 180px; max-width: 200px;');
// type show
// Type show.
$selection = [
0 => __('Show common modules'),
1 => __('Show all modules'),
@ -163,12 +164,12 @@ function mainAgentsModules()
$filter_type_show_label = '<b>'.__('Show common modules').'</b>';
$filter_type_show = html_print_select($selection, 'selection_agent_module', $selection_a_m, '', '', 0, true, false, true, '', false, 'min-width: 180px;');
// modules
// Modules.
$all_modules = select_modules_for_agent_group($group_id, $agents_id, $selection_a_m, false);
$filter_modules_label = '<b>'.__('Module').'</b>';
$filter_modules = html_print_select($all_modules, 'module[]', $modules_selected, '', '', 0, true, true, false, '', false, 'min-width: 180px; max-width: 200px;');
// update
// Update.
$filter_update = html_print_submit_button(__('Update item'), 'edit_item', false, 'class="sub upd"', true);
$onheader = [
@ -178,8 +179,11 @@ function mainAgentsModules()
'combo_groups' => $filter_groups,
];
// Old style table, we need a lot of special formatting,don't use table function
// Prepare old-style table
/*
* Old style table, we need a lot of special formatting,don't use table function.
* Prepare old-style table.
*/
if ($config['pure'] == 0) {
// Header.
ui_print_page_header(
@ -200,38 +204,51 @@ function mainAgentsModules()
$full_modules = urlencode(implode(';', $full_modules_selected));
$full_agents = urlencode(implode(';', $full_agents_id));
$url = " index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset
$url = 'index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset
&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr&full_modules_selected=$full_modules
&full_agents_id=$full_agents&selection_agent_module=$selection_a_m";
&full_agents_id=$full_agents&selection_agent_module=$selection_a_m';
} else {
$url = " index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr";
$url = 'index.php?sec=view&sec2=extensions/agents_modules&amp;pure=0&amp;offset=$offset&group_id=$group_id&modulegroup=$modulegroup&refresh=$refr';
}
// Floating menu - Start
// Floating menu - Start.
echo '<div id="vc-controls" style="z-index: 999">';
echo '<div id="menu_tab">';
echo '<ul class="mn">';
// Quit fullscreen
// Quit fullscreen.
echo '<li class="nomn">';
echo '<a target="_top" href="'.$url.'">';
echo html_print_image('images/normal_screen.png', true, ['title' => __('Back to normal mode')]);
echo '</a>';
echo '</li>';
// Countdown
// Countdown.
echo '<li class="nomn">';
echo '<div class="vc-refr">';
echo '<div class="vc-countdown"></div>';
echo '<div class="vc-countdown style="display: inline;"></div>';
echo '<div id="vc-refr-form">';
echo __('Refresh').':';
echo html_print_select(get_refresh_time_array(), 'refresh', $refr, '', '', 0, true, false, false);
echo html_print_select(
get_refresh_time_array(),
'refresh',
$refr,
'',
'',
0,
true,
false,
false,
'',
false,
'margin-top: 3px;'
);
echo '</div>';
echo '</div>';
echo '</li>';
// Console name
// Console name.
echo '<li class="nomn">';
echo '<div class="vc-title">'.__('Agent/module view').'</div>';
echo '</li>';
@ -240,35 +257,35 @@ function mainAgentsModules()
echo '</div>';
echo '</div>';
// Floating menu - End
// Floating menu - End.
ui_require_jquery_file('countdown');
}
if ($config['pure'] != 1) {
echo '<form method="post" action="'.ui_get_url_refresh(['offset' => $offset, 'hor_offset' => $offset, 'group_id' => $group_id, 'modulegroup' => $modulegroup]).'">';
echo '<table class="databox filters" cellpadding="0" cellspacing="0" border="0" style="width:100%;">';
echo '<tr>';
echo '<td>'.$filter_groups_label.'</td>';
echo '<td>'.$filter_groups.'&nbsp;&nbsp;&nbsp;'.$filter_recursion_label.$filter_recursion.'</td>';
echo '<td></td>';
echo '<td></td>';
echo '<td>'.$filter_module_groups_label.'</td>';
echo '<td>'.$filter_module_groups.'</td>';
echo '</tr>';
echo '<tr>';
echo '<td>'.$filter_agents_label.'</td>';
echo '<td>'.$filter_agents.'</td>';
echo '<td>'.$filter_type_show_label.'</td>';
echo '<td>'.$filter_type_show.'</td>';
echo '<td>'.$filter_modules_label.'</td>';
echo '<td>'.$filter_modules.'</td>';
echo '</tr>';
echo '<tr>';
echo "<td colspan=6 ><span style='float: right; padding-right: 20px;'>".$filter_update.'</sapn></td>';
echo '</tr>';
echo '</table>';
echo '</form>';
$show_filters = '<form method="post" action="'.ui_get_url_refresh(['offset' => $offset, 'hor_offset' => $offset, 'group_id' => $group_id, 'modulegroup' => $modulegroup]).'" style="width:100%;">';
$show_filters .= '<table class="white_table" cellpadding="0" cellspacing="0" border="0" style="width:100%; border:none;">';
$show_filters .= '<tr>';
$show_filters .= '<td>'.$filter_groups_label.'</td>';
$show_filters .= '<td>'.$filter_groups.'&nbsp;&nbsp;&nbsp;'.$filter_recursion_label.$filter_recursion.'</td>';
$show_filters .= '<td></td>';
$show_filters .= '<td></td>';
$show_filters .= '<td>'.$filter_module_groups_label.'</td>';
$show_filters .= '<td>'.$filter_module_groups.'</td>';
$show_filters .= '</tr>';
$show_filters .= '<tr>';
$show_filters .= '<td>'.$filter_agents_label.'</td>';
$show_filters .= '<td>'.$filter_agents.'</td>';
$show_filters .= '<td>'.$filter_type_show_label.'</td>';
$show_filters .= '<td>'.$filter_type_show.'</td>';
$show_filters .= '<td>'.$filter_modules_label.'</td>';
$show_filters .= '<td>'.$filter_modules.'</td>';
$show_filters .= '</tr>';
$show_filters .= '<tr>';
$show_filters .= "<td colspan=6 ><span style='float: right; padding-right: 20px;'>".$filter_update.'</sapn></td>';
$show_filters .= '</tr>';
$show_filters .= '</table>';
$show_filters .= '</form>';
ui_toggle($show_filters, __('Filters'));
}
if ($agents_id[0] != -1) {
@ -291,7 +308,7 @@ function mainAgentsModules()
$count = 0;
foreach ($agents as $agent) {
// TODO TAGS agents_get_modules
// TODO TAGS agents_get_modules.
$module = agents_get_modules(
$agent,
false,
@ -339,7 +356,7 @@ function mainAgentsModules()
}
}
} else {
// TODO TAGS agents_get_modules
// TODO TAGS agents_get_modules.
$all_modules = agents_get_modules(
$agents,
false,
@ -414,11 +431,11 @@ function mainAgentsModules()
if ($hor_offset > 0) {
$new_hor_offset = ($hor_offset - $block);
echo "<th width='20px' "."style='vertical-align:top; padding-top: 35px;' "."rowspan='".($nagents + 1)."'>"."<a href='index.php?".'extension_in_menu=estado&'.'sec=extensions&'.'sec2=extensions/agents_modules&'.'refr=0&'.'save_serialize=1&'.'selection_a_m='.$selection_a_m.'&'.'hor_offset='.$new_hor_offset.'&'.'offset='.$offset."'>".html_print_image(
'images/arrow_left.png',
echo "<th width='20px' style='vertical-align: middle; text-align: center;' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&refr=0&save_serialize=1&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
'images/arrow_left_green.png',
true,
['title' => __('Previous modules')]
).'</a>'.'</th>';
).'</a></th>';
}
$nmodules = 0;
@ -440,11 +457,11 @@ function mainAgentsModules()
if (($hor_offset + $block) < $nmodules) {
$new_hor_offset = ($hor_offset + $block);
echo "<th width='20px' "."style='vertical-align:top; padding-top: 35px;' "."rowspan='".($nagents + 1)."'>"."<a href='index.php?".'extension_in_menu=estado&'.'sec=extensions&'.'sec2=extensions/agents_modules&'.'save_serialize=1&'.'selection_a_m='.$selection_a_m.'&'.'hor_offset='.$new_hor_offset.'&'.'offset='.$offset."'>".html_print_image(
'images/arrow.png',
echo "<th width='20px' style='vertical-align: middle; text-align: center;' rowspan='".($nagents + 1)."'><a href='index.php?".'extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&selection_a_m='.$selection_a_m.'&hor_offset='.$new_hor_offset.'&offset='.$offset."'>".html_print_image(
'images/arrow_right_green.png',
true,
['title' => __('More modules')]
).'</a>'.'</th>';
).'</a></th>';
}
echo '</tr>';
@ -457,12 +474,12 @@ function mainAgentsModules()
$filter_agents['id_grupo'] = $group_id;
}
// Prepare pagination
$url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&'.'hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m;
// Prepare pagination.
$url = 'index.php?extension_in_menu=estado&sec=extensions&sec2=extensions/agents_modules&save_serialize=1&hor_offset='.$hor_offset.'&selection_a_m='.$selection_a_m;
ui_pagination($total_pagination, $url);
foreach ($agents as $agent) {
// Get stats for this group
// Get stats for this group.
$agent_status = agents_get_status($agent['id_agente']);
$alias = db_get_row('tagente', 'id_agente', $agent['id_agente']);
if (empty($alias['alias'])) {
@ -471,29 +488,29 @@ function mainAgentsModules()
switch ($agent_status) {
case 4:
// Alert fired status
// Alert fired status.
$rowcolor = 'group_view_alrm';
break;
case 1:
// Critical status
// Critical status.
$rowcolor = 'group_view_crit';
break;
case 2:
// Warning status
// Warning status.
$rowcolor = 'group_view_warn';
break;
case 0:
// Normal status
// Normal status.
$rowcolor = 'group_view_ok';
break;
case 3:
case -1:
default:
// Unknown status
// Unknown status.
$rowcolor = 'group_view_unk';
break;
}
@ -502,7 +519,7 @@ function mainAgentsModules()
echo "<td class='$rowcolor'>
<a class='$rowcolor' href='index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=".$agent['id_agente']."'>".$alias['alias'].'</a></td>';
// TODO TAGS agents_get_modules
// TODO TAGS agents_get_modules.
$agent_modules = agents_get_modules($agent['id_agente'], false, $filter_module_group, true, true);
$nmodules = 0;
@ -572,18 +589,23 @@ function mainAgentsModules()
echo '</table>';
echo "<div class='legend_basic' style='width: 96%'>";
$show_legend = "<div class='legend_white'>";
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></div>".__('Orange cell when the module has fired alerts').'</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></div>".__('Red cell when the module has a critical status').'
</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></div>".__('Yellow cell when the module has a warning status').'</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></div>".__('Green cell when the module has a normal status').'</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></div>".__('Grey cell when the module has an unknown status').'</div>';
$show_legend .= "<div style='display: flex;align-items: center;'>
<div class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></div>".__("Cell turns blue when the module is in 'not initialize' status").'</div>';
$show_legend .= '</div>';
ui_toggle($show_legend, __('Legend'));
echo '<table>';
echo "<tr><td colspan='2' style='padding-bottom: 10px;'><b>".__('Legend').'</b></td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_ALERTFIRED.";'></div></td><td>".__('Orange cell when the module has fired alerts').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_CRITICAL.";'></div></td><td>".__('Red cell when the module has a critical status').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_WARNING.";'></div></td><td>".__('Yellow cell when the module has a warning status').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NORMAL.";'></div></td><td>".__('Green cell when the module has a normal status').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_UNKNOWN.";'></div></td><td>".__('Grey cell when the module has an unknown status').'</td></tr>';
echo "<tr><td class='legend_square_simple'><div style='background-color: ".COL_NOTINIT.";'></div></td><td>".__("Cell turns blue when the module is in 'not initialize' status").'</td></tr>';
echo '</table>';
echo '</div>';
$pure_var = $config['pure'];
if ($pure_var) {
$pure_var = 1;
@ -627,16 +649,14 @@ $ignored_params['refresh'] = '';
$.each($('.th_class_module_r'), function (i, elem) {
id = $(elem).attr('id').replace('th_module_r_', '');
$("#th_module_r_" + id).height(($("#div_module_r_" + id).width() + 10) + 'px');
//$("#div_module_r_" + id).css('margin-top', (max_width - $("#div_module_r_" + id).width()) + 'px');
$("#div_module_r_" + id).css('margin-top', (max_width - 20) + 'px');
$("#div_module_r_" + id).show();
});
var refr =" . $refr . ";
var pure =" . $pure_var . ";
var href ='" . ui_get_url_refresh ($ignored_params) . "';
var refr = '<?php echo get_parameter('refresh', 0); ?>';
var pure = '<?php echo get_parameter('pure', 0); ?>';
var href =' <?php echo ui_get_url_refresh($ignored_params); ?>';
if (pure) {
var startCountDown = function (duration, cb) {
$('div.vc-countdown').countdown('destroy');
@ -646,7 +666,7 @@ $ignored_params['refresh'] = '';
$('div.vc-countdown').countdown({
until: t,
format: 'MS',
layout: '(%M%nn%M:%S%nn%S Until refresh)',
layout: '(%M%nn%M:%S%nn%S <?php echo __('Until next'); ?>) ',
alwaysExpire: true,
onExpiry: function () {
$('div.vc-countdown').countdown('destroy');
@ -655,8 +675,11 @@ $ignored_params['refresh'] = '';
}
});
}
startCountDown(refr, false);
if(refr>0){
startCountDown(refr, false);
}
var controls = document.getElementById('vc-controls');
autoHideElement(controls, 1000);

View File

@ -322,7 +322,7 @@ if ($create_modules) {
} else if (preg_match('/ifAdminStatus/', $name_array[1])) {
$module_type = 2;
} else if (preg_match('/ifOperStatus/', $name_array[1])) {
$module_type = 18;
$module_type = 2;
} else {
$module_type = 4;
}
@ -608,11 +608,11 @@ ui_require_jquery_file('bgiframe');
$(document).ready (function () {
var inputActive = true;
$(document).data('text_for_module', $("#none_text").html());
$("#id_snmp").change(snmp_changed_by_multiple_snmp);
$("#snmp_version").change(function () {
if (this.value == "3") {
$("#snmp3_options").css("display", "");
@ -621,7 +621,7 @@ $(document).ready (function () {
$("#snmp3_options").css("display", "none");
}
});
$("#walk_form").submit(function() {
$("#submit-snmp_walk").disable ();
$("#oid_loading").show ();
@ -632,15 +632,15 @@ $(document).ready (function () {
function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
var idSNMP = Array();
jQuery.each ($("#id_snmp option:selected"), function (i, val) {
idSNMP.push($(val).val());
});
$('#module').attr ('disabled', 1);
$('#module').empty ();
$('#module').append ($('<option></option>').html ("Loading...").attr ("value", 0));
jQuery.post ('ajax.php',
jQuery.post ('ajax.php',
{"page" : "godmode/agentes/agent_manager",
"get_modules_json_for_multiple_snmp": 1,
"id_snmp[]": idSNMP,
@ -655,7 +655,7 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
$('#module').fadeIn ('normal');
c++;
});
if (c == 0) {
if (typeof($(document).data('text_for_module')) != 'undefined') {
$('#module').append ($('<option></option>').html ($(document).data('text_for_module')).attr("value", 0).prop('selected', true));
@ -666,11 +666,11 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
}
else {
var anyText = $("#any_text").html(); //Trick for catch the translate text.
if (anyText == null) {
anyText = 'Any';
}
$('#module').append ($('<option></option>').html (anyText).attr ("value", 0).prop('selected', true));
}
}
@ -684,4 +684,3 @@ function snmp_changed_by_multiple_snmp (event, id_snmp, selected) {
/* ]]> */
</script>

View File

@ -725,7 +725,6 @@ echo '</form>';
}
});
$modulesSelect.change();
}
var processGet = function (params, callback) {

View File

@ -221,7 +221,7 @@ switch ($action) {
$server_name = $item['server_name'];
// Metaconsole db connection.
if ($meta && $server_name != '') {
if ($meta && !empty($server_name)) {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) {
continue;
@ -547,8 +547,43 @@ switch ($action) {
break;
case 'event_report_agent':
case 'event_report_group':
$description = $item['description'];
$period = $item['period'];
$group = $item['id_group'];
$recursion = $item['recursion'];
$idAgent = $item['id_agent'];
$idAgentModule = $item['id_agent_module'];
$show_summary_group = $style['show_summary_group'];
$filter_event_severity = json_decode($style['filter_event_severity'], true);
$filter_event_status = json_decode($style['filter_event_status'], true);
$filter_event_type = json_decode($style['filter_event_type'], true);
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$include_extended_events = $item['show_extended_events'];
$filter_search = $style['event_filter_search'];
break;
case 'event_report_group':
$description = $item['description'];
$period = $item['period'];
$group = $item['id_group'];
$recursion = $item['recursion'];
$event_graph_by_agent = $style['event_graph_by_agent'];
$event_graph_by_user_validator = $style['event_graph_by_user_validator'];
$event_graph_by_criticity = $style['event_graph_by_criticity'];
$event_graph_validated_vs_unvalidated = $style['event_graph_validated_vs_unvalidated'];
$filter_search = $style['event_filter_search'];
$include_extended_events = $item['show_extended_events'];
break;
@ -2805,7 +2840,7 @@ function print_SLA_list($width, $action, $idItem=null)
foreach ($itemsSLA as $item) {
$server_name = $item['server_name'];
// Metaconsole db connection.
if ($meta && $server_name != '') {
if ($meta && !empty($server_name)) {
$connection = metaconsole_get_connection(
$server_name
);
@ -3133,7 +3168,7 @@ function print_General_list($width, $action, $idItem=null, $type='general')
foreach ($itemsGeneral as $item) {
$server_name = $item['server_name'];
// Metaconsole db connection.
if ($meta && $server_name != '') {
if ($meta && !empty($server_name)) {
$connection = metaconsole_get_connection(
$server_name
);
@ -3491,6 +3526,7 @@ $(document).ready (function () {
$("#submit-create_item").click(function () {
var type = $('#type').val();
var name = $('#text-name').val();
switch (type){
case 'alert_report_module':
case 'alert_report_agent':
@ -3521,6 +3557,13 @@ $(document).ready (function () {
default:
break;
}
if($('#text-name').val() == ''){
alert( <?php echo "'".__('Please insert a name')."'"; ?> );
return false;
}
});
$("#submit-edit_item").click(function () {

View File

@ -1345,6 +1345,8 @@ switch ($action) {
$values['description'] = get_parameter('description');
$values['type'] = get_parameter('type', null);
$values['recursion'] = get_parameter('recursion', null);
$values['show_extended_events'] = get_parameter('include_extended_events', null);
$label = get_parameter('label', '');
// Add macros name.
@ -1900,8 +1902,8 @@ switch ($action) {
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
$style['event_filter_search'] = $event_filter_search;
if ($label != '') {
$style['label'] = $label;
} else {
@ -2007,6 +2009,7 @@ switch ($action) {
);
$name_it = (string) get_parameter('name');
$values['recursion'] = get_parameter('recursion', null);
$values['show_extended_events'] = get_parameter('include_extended_events', null);
$values['name'] = reporting_label_macro(
$items_label,
$name_it
@ -2418,6 +2421,7 @@ switch ($action) {
case 'event_report_agent':
case 'event_report_group':
case 'event_report_module':
$show_summary_group = get_parameter(
'show_summary_group',
0
@ -2473,22 +2477,11 @@ switch ($action) {
$style['event_graph_by_user_validator'] = $event_graph_by_user_validator;
$style['event_graph_by_criticity'] = $event_graph_by_criticity;
$style['event_graph_validated_vs_unvalidated'] = $event_graph_validated_vs_unvalidated;
switch ($values['type']) {
case 'event_report_group':
case 'event_report_agent':
$style['event_filter_search'] = $event_filter_search;
if ($label != '') {
$style['label'] = $label;
} else {
$style['label'] = '';
}
break;
default:
// Default.
break;
$style['event_filter_search'] = $event_filter_search;
if ($label != '') {
$style['label'] = $label;
} else {
$style['label'] = '';
}
break;

View File

@ -254,7 +254,12 @@ function update_button_palette_callback() {
var values = {};
values = readFields();
if (values["map_linked"] == 0) {
if (values["agent"] == "" || values["agent"] == "none") {
dialog_message("#message_alert_no_agent");
return false;
}
}
// TODO VALIDATE DATA
switch (selectedItem) {
case "background":
@ -1260,6 +1265,7 @@ function create_button_palette_callback() {
dialog_message("#message_alert_max_height");
validate = false;
}
break;
case "group_item":
if (values["height"] == "") {
@ -1323,6 +1329,12 @@ function create_button_palette_callback() {
dialog_message("#message_alert_no_image");
validate = false;
}
if (values["map_linked"] == 0) {
if (values["agent"] == "" || values["agent"] == "none") {
dialog_message("#message_alert_no_agent");
validate = false;
}
}
break;
case "auto_sla_graph":

View File

@ -135,7 +135,9 @@ $table->data[9][0] = '<strong>'.__('Licensed to').'</strong>';
$table->data[9][1] = html_print_input_text('licensed_to', $license['licensed_to'], '', 64, 255, true, true);
html_print_table($table);
if (enterprise_installed()) {
// If DESTDIR is defined the enterprise license is expired.
if (enterprise_installed() || defined('DESTDIR')) {
echo '<div class="action-buttons" style="width: '.$table->width.'">';
html_print_input_hidden('update_settings', 1);
html_print_submit_button(__('Validate'), 'update_button', false, 'class="sub upd"');

View File

@ -659,18 +659,18 @@ class Wizard
if ($input['arguments']['inline'] != 'true') {
$output .= '<div class="edit_discovery_input">';
} else {
$output .= '<div style="display: flex; margin-bottom: 25px;">';
$output .= '<div style="display: flex; margin-bottom: 25px; flex-wrap: wrap;">';
if (!isset($input['extra'])) {
$output .= '<div style="width: 50%;">';
}
if (isset($input['extra'])) {
$output .= '<div style="width: 50%; display: flex;">';
$output .= '<div style="display: flex; margin-right:10px;">';
}
}
if ($input['arguments']['inline'] == 'true' && isset($input['extra'])) {
$output .= '<div style="width: 50%">';
$output .= '<div style="margin-right:10px;">';
}
$output .= '<div class="label_select">';
@ -690,11 +690,11 @@ class Wizard
$output .= $this->printInput($input['arguments']);
$output .= '</div>';
} else if ($input['arguments']['inline'] == 'true') {
$output .= '<div style="width: 50%;">';
if (isset($input['extra'])) {
$output .= '<div style="float: center;">';
$output .= '<div style="">';
$output .= '<div style="float: left;">';
} else {
$output .= '<div style="width:50%;">';
$output .= '<div style="float: right;">';
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

View File

@ -392,11 +392,16 @@ if (check_login()) {
switch ($row['module_type']) {
case 15:
$value = db_get_value('snmp_oid', 'tagente_modulo', 'id_agente_modulo', $module_id);
// System Uptime:
// In case of System Uptime module, shows data in format "Days hours minutes seconds" if and only if
// selected module unit is "_timeticks_"
// Take notice that selected unit may not be postrocess unit
if ($value == '.1.3.6.1.2.1.1.3.0' || $value == '.1.3.6.1.2.1.25.1.1.0') {
if ($post_process > 0) {
$data[] = human_milliseconds_to_string(($row['data'] / $post_process));
$data_macro = modules_get_unit_macro($row[$attr[0]], $unit);
if ($data_macro) {
$data[] = $data_macro;
} else {
$data[] = human_milliseconds_to_string($row['data']);
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision']));
}
} else {
$data[] = remove_right_zeros(number_format($row[$attr[0]], $config['graph_precision']));

View File

@ -72,6 +72,8 @@ class TreeService extends Tree
protected function getFirstLevel()
{
global $config;
$processed_items = $this->getProcessedServices();
$ids = array_keys($processed_items);

View File

@ -20,7 +20,7 @@
/**
* Pandora build version and version
*/
$build_version = 'PC190612';
$build_version = 'PC190618';
$pandora_version = 'v7.0NG.735';
// Do not overwrite default timezone set if defined.

View File

@ -1433,6 +1433,11 @@ function enterprise_installed()
{
$return = false;
// Load enterprise extensions.
if (defined('DESTDIR')) {
return $return;
}
if (defined('PANDORA_ENTERPRISE')) {
if (PANDORA_ENTERPRISE) {
$return = true;
@ -1485,7 +1490,7 @@ function enterprise_include($filename)
{
global $config;
// Load enterprise extensions
// Load enterprise extensions.
if (defined('DESTDIR')) {
$destdir = DESTDIR;
} else {
@ -1515,7 +1520,13 @@ function enterprise_include_once($filename)
{
global $config;
// Load enterprise extensions
// Load enterprise extensions.
if (defined('DESTDIR')) {
$destdir = DESTDIR;
} else {
$destdir = '';
}
$filepath = realpath($config['homedir'].'/'.ENTERPRISE_DIR.'/'.$filename);
if ($filepath === false) {

View File

@ -11519,7 +11519,7 @@ function api_set_create_event($id, $trash1, $other, $returnType)
if ($other['data'][18] != '') {
$values['id_extra'] = $other['data'][18];
$sql_validation = 'SELECT id_evento FROM tevento where estado=0 and id_extra ="'.$other['data'][18].'";';
$sql_validation = 'SELECT id_evento FROM tevento where estado IN (0,2) and id_extra ="'.$other['data'][18].'";';
$validation = db_get_all_rows_sql($sql_validation);
if ($validation) {
foreach ($validation as $val) {

View File

@ -180,7 +180,7 @@ function config_update_config()
$error_update[] = __('Automatic check for updates');
}
if (!config_update_value('cert_path', (bool) get_parameter('cert_path'))) {
if (!config_update_value('cert_path', get_parameter('cert_path'))) {
$error_update[] = __('SSL cert path');
}

View File

@ -5669,7 +5669,7 @@ function events_list_events_grouped_agents($sql)
$sql = sprintf(
'SELECT * FROM %s
LEFT JOIN tagent_secondary_group
ON tagent_secondary_group.id_agent = tevento.id_agente
ON tagent_secondary_group.id_agent = id_agente
WHERE %s',
$table,
$sql

View File

@ -2235,6 +2235,7 @@ function combined_graph_summatory_average(
$data_array_pop[$key_reverse] = array_pop(
$data_array_reverse[$key_reverse]
);
$count_data_array_reverse--;
}
}

View File

@ -2230,6 +2230,7 @@ function modules_get_agentmodule_data(
'module_name' => $values[$key]['module_name'],
'agent_id' => $values[$key]['agent_id'],
'agent_name' => $values[$key]['agent_name'],
'module_type' => $values[$key]['module_type'],
];
}

View File

@ -1383,7 +1383,7 @@ function reporting_event_top_n(
foreach ($tops as $key => $row) {
// Metaconsole connection.
$server_name = $row['server_name'];
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
@ -1426,7 +1426,7 @@ function reporting_event_top_n(
}
// Restore dbconnection.
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
metaconsole_restore_db();
}
}
@ -2330,7 +2330,7 @@ function reporting_exception(
do {
// Metaconsole connection.
$server_name = $exceptions[$i]['server_name'];
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
@ -2372,7 +2372,7 @@ function reporting_exception(
$i++;
// Restore dbconnection.
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
metaconsole_restore_db();
}
} while ($min === false && $i < count($exceptions));
@ -2385,7 +2385,7 @@ function reporting_exception(
foreach ($exceptions as $exc) {
// Metaconsole connection.
$server_name = $exc['server_name'];
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
@ -2499,7 +2499,7 @@ function reporting_exception(
}
// Restore dbconnection
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
metaconsole_restore_db();
}
}
@ -2693,7 +2693,7 @@ function reporting_group_report($report, $content)
{
global $config;
$metaconsole_on = ($config['metaconsole'] == 1) && defined('METACONSOLE');
$metaconsole_on = ($config['metaconsole'] == 1) && is_metaconsole();
$return['type'] = 'group_report';
@ -6173,7 +6173,7 @@ function reporting_availability($report, $content, $date=false, $time=false)
foreach ($items as $item) {
// aaMetaconsole connection
$server_name = $item['server_name'];
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
@ -6185,7 +6185,7 @@ function reporting_availability($report, $content, $date=false, $time=false)
|| modules_is_not_init($item['id_agent_module'])
) {
// Restore dbconnection
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
metaconsole_restore_db();
}
@ -6242,7 +6242,7 @@ function reporting_availability($report, $content, $date=false, $time=false)
$text = $row['data']['agent'].' ('.$text.')';
// Restore dbconnection
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
metaconsole_restore_db();
}
@ -6807,7 +6807,7 @@ function reporting_increment($report, $content)
$return['data'] = [];
if (defined('METACONSOLE')) {
if (is_metaconsole()) {
$sql1 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.'
AND utimestamp <= '.(time() - $period).' ORDER BY utimestamp DESC';
$sql2 = 'SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC';
@ -6845,7 +6845,7 @@ function reporting_increment($report, $content)
$last_data = db_get_value_sql('SELECT datos FROM tagente_datos WHERE id_agente_modulo = '.$id_agent_module.' ORDER BY utimestamp DESC');
}
if (!defined('METACONSOLE')) {
if (!is_metaconsole()) {
}
if ($old_data === false || $last_data === false) {
@ -6934,7 +6934,7 @@ function reporting_general($report, $content)
foreach ($generals as $row) {
// Metaconsole connection
$server_name = $row['server_name'];
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
$connection = metaconsole_get_connection($server_name);
if (metaconsole_load_external_db($connection) != NOERR) {
// ui_print_error_message ("Error connecting to ".$server_name);
@ -7085,7 +7085,7 @@ function reporting_general($report, $content)
$i++;
// Restore dbconnection
if (($config['metaconsole'] == 1) && $server_name != '' && defined('METACONSOLE')) {
if (($config['metaconsole'] == 1) && $server_name != '' && is_metaconsole()) {
metaconsole_restore_db();
}
}

View File

@ -67,6 +67,13 @@ function createVisualConsole(
? JSON.parse(data.items)
: data.items;
// Add the datetime when the item was received.
var receivedAt = new Date();
items.map(function(item) {
item["receivedAt"] = receivedAt;
return item;
});
var prevProps = visualConsole.props;
// Update the data structure.
visualConsole.props = props;

View File

@ -319,7 +319,7 @@ final class Container extends Model
// Default filter.
$filter = ['id_layout' => $layoutId];
$fields = [
'id',
'DISTINCT(id) AS id',
'type',
'cache_expiration',
'id_layout',
@ -340,8 +340,9 @@ final class Container extends Model
// Only true condition if type is GROUP_ITEM.
$filter[] = '('.\db_format_array_where_clause_sql(
[
'type' => GROUP_ITEM,
'id_group' => $groupsFilter,
'id_layout' => $layoutId,
'type' => GROUP_ITEM,
'id_group' => $groupsFilter,
]
).')';
}

View File

@ -13,16 +13,22 @@
display: flex;
-webkit-box-orient: initial;
-webkit-box-direction: initial;
-ms-flex-direction: initial;
flex-direction: initial;
-ms-flex-direction: initial;
flex-direction: initial;
justify-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-ms-flex-align: center;
align-items: center;
-webkit-user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
-moz-user-select: text;
-ms-user-select: text;
user-select: text;
}
.visual-console-item.is-editing {
border: 2px dashed #33ccff;
-webkit-transform: translateX(-2px) translateY(-2px);
transform: translateX(-2px) translateY(-2px);
}
@font-face {
@ -38,17 +44,17 @@
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-ms-flex-direction: column;
flex-direction: column;
-ms-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-ms-flex-pack: center;
justify-content: center;
-ms-flex-pack: center;
justify-content: center;
justify-items: center;
-ms-flex-line-pack: center;
align-content: center;
align-content: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
-ms-flex-align: center;
align-items: center;
}
.visual-console-item .digital-clock > span {
@ -78,18 +84,17 @@
.visual-console-item .analogic-clock .hour-hand {
-webkit-animation: rotate-hour 43200s infinite linear;
animation: rotate-hour 43200s infinite linear;
animation: rotate-hour 43200s infinite linear;
}
.visual-console-item .analogic-clock .minute-hand {
-webkit-animation: rotate-minute 3600s infinite linear;
animation: rotate-minute 3600s infinite linear;
animation: rotate-minute 3600s infinite linear;
}
.visual-console-item .analogic-clock .second-hand {
-webkit-animation: rotate-second 60s infinite linear;
animation: rotate-second 60s infinite linear;
animation: rotate-second 60s infinite linear;
}
/*# sourceMappingURL=vc.main.css.map*/
/*# sourceMappingURL=vc.main.css.map*/

View File

@ -1 +1 @@
{"version":3,"sources":["webpack:///main.css","webpack:///styles.css"],"names":[],"mappings":"AAAA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,4BAA4B;EAC5B,0BAA0B;EAC1B,2BAA2B;AAC7B;;AAEA;EACE,kBAAkB;EAClB,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,2BAAuB;EAAvB,8BAAuB;MAAvB,2BAAuB;UAAvB,uBAAuB;EACvB,qBAAqB;EACrB,yBAAmB;MAAnB,sBAAmB;UAAnB,mBAAmB;EACnB,yBAAiB;KAAjB,sBAAiB;MAAjB,qBAAiB;UAAjB,iBAAiB;AACnB;;ACfA;EACE,wBAAwB;EACxB,0BAA2B;AAC7B;;AAEA,kBAAkB;;AAElB;EACE,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,4BAAsB;EAAtB,6BAAsB;MAAtB,0BAAsB;UAAtB,sBAAsB;EACtB,wBAAuB;MAAvB,qBAAuB;UAAvB,uBAAuB;EACvB,qBAAqB;EACrB,0BAAqB;MAArB,qBAAqB;EACrB,yBAAmB;MAAnB,sBAAmB;UAAnB,mBAAmB;AACrB;;AAEA;EACE,6DAA6D;EAC7D,eAAe;;EAEf,0BAA0B;EAC1B,mCAAmC;EACnC,kCAAkC;EAClC,kCAAkC;EAClC,wCAAwC;AAC1C;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,eAAe;AACjB;;AAEA,iBAAiB;;AAEjB;EACE,kBAAkB;AACpB;;AAEA;EACE,qDAA6C;UAA7C,6CAA6C;AAC/C;;AAEA;EACE,sDAA8C;UAA9C,8CAA8C;AAChD;;AAEA;EACE,oDAA4C;UAA5C,4CAA4C;AAC9C","file":"vc.main.css","sourcesContent":["#visual-console-container {\n margin: 0px auto;\n position: relative;\n background-repeat: no-repeat;\n background-size: 100% 100%;\n background-position: center;\n}\n\n.visual-console-item {\n position: absolute;\n display: flex;\n flex-direction: initial;\n justify-items: center;\n align-items: center;\n user-select: text;\n}\n","@font-face {\n font-family: Alarm Clock;\n src: url(./alarm-clock.ttf);\n}\n\n/* Digital clock */\n\n.visual-console-item .digital-clock {\n display: flex;\n flex-direction: column;\n justify-content: center;\n justify-items: center;\n align-content: center;\n align-items: center;\n}\n\n.visual-console-item .digital-clock > span {\n font-family: \"Alarm Clock\", \"Courier New\", Courier, monospace;\n font-size: 50px;\n\n /* To improve legibility */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n text-shadow: rgba(0, 0, 0, 0.01) 0 0 1px;\n}\n\n.visual-console-item .digital-clock > span.date {\n font-size: 25px;\n}\n\n.visual-console-item .digital-clock > span.timezone {\n font-size: 25px;\n}\n\n/* Analog clock */\n\n.visual-console-item .analogic-clock {\n text-align: center;\n}\n\n.visual-console-item .analogic-clock .hour-hand {\n animation: rotate-hour 43200s infinite linear;\n}\n\n.visual-console-item .analogic-clock .minute-hand {\n animation: rotate-minute 3600s infinite linear;\n}\n\n.visual-console-item .analogic-clock .second-hand {\n animation: rotate-second 60s infinite linear;\n}\n"],"sourceRoot":""}
{"version":3,"sources":["webpack:///main.css","webpack:///styles.css"],"names":[],"mappings":"AAAA;EACE,gBAAgB;EAChB,kBAAkB;EAClB,4BAA4B;EAC5B,0BAA0B;EAC1B,2BAA2B;AAC7B;;AAEA;EACE,kBAAkB;EAClB,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,2BAAuB;EAAvB,8BAAuB;MAAvB,2BAAuB;UAAvB,uBAAuB;EACvB,qBAAqB;EACrB,yBAAmB;MAAnB,sBAAmB;UAAnB,mBAAmB;EACnB,yBAAiB;KAAjB,sBAAiB;MAAjB,qBAAiB;UAAjB,iBAAiB;AACnB;;AAEA;EACE,0BAA0B;EAC1B,oDAA4C;UAA5C,4CAA4C;AAC9C;;ACpBA;EACE,wBAAwB;EACxB,0BAA2B;AAC7B;;AAEA,kBAAkB;;AAElB;EACE,oBAAa;EAAb,oBAAa;EAAb,aAAa;EACb,4BAAsB;EAAtB,6BAAsB;MAAtB,0BAAsB;UAAtB,sBAAsB;EACtB,wBAAuB;MAAvB,qBAAuB;UAAvB,uBAAuB;EACvB,qBAAqB;EACrB,0BAAqB;MAArB,qBAAqB;EACrB,yBAAmB;MAAnB,sBAAmB;UAAnB,mBAAmB;AACrB;;AAEA;EACE,6DAA6D;EAC7D,eAAe;;EAEf,0BAA0B;EAC1B,mCAAmC;EACnC,kCAAkC;EAClC,kCAAkC;EAClC,wCAAwC;AAC1C;;AAEA;EACE,eAAe;AACjB;;AAEA;EACE,eAAe;AACjB;;AAEA,iBAAiB;;AAEjB;EACE,kBAAkB;AACpB;;AAEA;EACE,qDAA6C;UAA7C,6CAA6C;AAC/C;;AAEA;EACE,sDAA8C;UAA9C,8CAA8C;AAChD;;AAEA;EACE,oDAA4C;UAA5C,4CAA4C;AAC9C","file":"vc.main.css","sourcesContent":["#visual-console-container {\n margin: 0px auto;\n position: relative;\n background-repeat: no-repeat;\n background-size: 100% 100%;\n background-position: center;\n}\n\n.visual-console-item {\n position: absolute;\n display: flex;\n flex-direction: initial;\n justify-items: center;\n align-items: center;\n user-select: text;\n}\n\n.visual-console-item.is-editing {\n border: 2px dashed #33ccff;\n transform: translateX(-2px) translateY(-2px);\n}\n","@font-face {\n font-family: Alarm Clock;\n src: url(./alarm-clock.ttf);\n}\n\n/* Digital clock */\n\n.visual-console-item .digital-clock {\n display: flex;\n flex-direction: column;\n justify-content: center;\n justify-items: center;\n align-content: center;\n align-items: center;\n}\n\n.visual-console-item .digital-clock > span {\n font-family: \"Alarm Clock\", \"Courier New\", Courier, monospace;\n font-size: 50px;\n\n /* To improve legibility */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n text-rendering: optimizeLegibility;\n text-shadow: rgba(0, 0, 0, 0.01) 0 0 1px;\n}\n\n.visual-console-item .digital-clock > span.date {\n font-size: 25px;\n}\n\n.visual-console-item .digital-clock > span.timezone {\n font-size: 25px;\n}\n\n/* Analog clock */\n\n.visual-console-item .analogic-clock {\n text-align: center;\n}\n\n.visual-console-item .analogic-clock .hour-hand {\n animation: rotate-hour 43200s infinite linear;\n}\n\n.visual-console-item .analogic-clock .minute-hand {\n animation: rotate-minute 3600s infinite linear;\n}\n\n.visual-console-item .analogic-clock .second-hand {\n animation: rotate-second 60s infinite linear;\n}\n"],"sourceRoot":""}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -129,7 +129,7 @@
<div style='height: 10px'>
<?php
$version = '7.0NG.735';
$build = '190612';
$build = '190618';
$banner = "v$version Build $build";
error_reporting(0);

View File

@ -263,7 +263,7 @@ if ($date > $now) {
echo '<div class="module_graph_menu_dropdown">
<div id="module_graph_menu_header" class="module_graph_menu_header">
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).'
<span>'.__('Graph configuration menu').ui_print_help_icon('graphs', true, $config['homeurl'], 'images/help_g.png', true).'</span>
<span>'.__('Graph configuration menu').'</span>
'.html_print_image('images/config.png', true, ['float' => 'right'], false, false, true).'
</div>
<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">'.$form_table.'</div>

View File

@ -403,7 +403,7 @@ $alias = db_get_value('alias', 'tagente', 'id_agente', $id_agent);
echo '<div class="module_graph_menu_dropdown">
<div id="module_graph_menu_header" class="module_graph_menu_header">
'.html_print_image('images/arrow_down_green.png', true, ['class' => 'module_graph_menu_arrow', 'float' => 'left'], false, false, true).'
<span>'.__('Graph configuration menu').ui_print_help_icon('graphs', true, $config['homeurl'], 'images/help_g.png', true).'</span>
<span>'.__('Graph configuration menu').'</span>
'.html_print_image('images/config.png', true, ['float' => 'right'], false, false, true).'
</div>
<div class="module_graph_menu_content module_graph_menu_content_closed" style="display:none;">'.$form_table.'</div>

View File

@ -66,7 +66,7 @@ if (check_acl($config['id_user'], 0, 'AR')) {
enterprise_hook('inventory_menu');
if ($config['activate_netflow'] || $config['activate_nta']) {
$sub['network'] = [
$sub['network_traffic'] = [
'text' => __('Network'),
'id' => 'Network',
'type' => 'direct',
@ -117,7 +117,7 @@ if (check_acl($config['id_user'], 0, 'AR')) {
);
}
$sub['network']['sub2'] = $netflow_sub;
$sub['network_traffic']['sub2'] = $netflow_sub;
}
if ($config['log_collector'] == 1) {

View File

@ -198,6 +198,14 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
}
}
}
// Add the datetime when the item was received.
var receivedAt = new Date();
items.map(function(item) {
item["receivedAt"] = receivedAt;
return item;
});
var visualConsoleManager = createVisualConsole(
container,
props,

View File

@ -155,6 +155,16 @@ if (!is_metaconsole()) {
html_print_input_hidden('metaconsole', 1);
}
if ($pure === false) {
echo '<div class="visual-console-edit-controls">';
echo '<span>'.__('Move and resize mode').'</span>';
echo '<span>';
echo html_print_checkbox_switch('edit-mode', 1, false, true);
echo '</span>';
echo '</div>';
echo '<br />';
}
echo '<div id="visual-console-container"></div>';
if ($pure === true) {
@ -306,6 +316,14 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
}
}
}
// Add the datetime when the item was received.
var receivedAt = new Date();
items.map(function(item) {
item["receivedAt"] = receivedAt;
return item;
});
var visualConsoleManager = createVisualConsole(
container,
props,
@ -315,6 +333,17 @@ $visualConsoleItems = VisualConsole::getItemsFromDB(
handleUpdate
);
// Enable/disable the edition mode.
$('input[name=edit-mode]').change(function(event) {
if ($(this).prop('checked')) {
visualConsoleManager.visualConsole.enableEditMode();
visualConsoleManager.changeUpdateInterval(0);
} else {
visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
}
});
// Update the data fetch interval.
$('select#vc-refr').change(function(event) {
var refr = Number.parseInt(event.target.value);

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.735
%define release 190612
%define release 190618
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.735
%define release 190612
%define release 190618
# User and Group under which Apache is running
%define httpd_name httpd

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_console
%define version 7.0NG.735
%define release 190612
%define release 190618
%define httpd_name httpd
# User and Group under which Apache is running
%define httpd_name apache2

View File

@ -1,5 +1,5 @@
package: pandorafms-server
Version: 7.0NG.735-190612
Version: 7.0NG.735-190618
Architecture: all
Priority: optional
Section: admin

View File

@ -14,7 +14,7 @@
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
pandora_version="7.0NG.735-190612"
pandora_version="7.0NG.735-190618"
package_cpan=0
package_pandora=1

View File

@ -45,7 +45,7 @@ our @EXPORT = qw(
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.735";
my $pandora_build = "190612";
my $pandora_build = "190618";
our $VERSION = $pandora_version." ".$pandora_build;
# Setup hash

View File

@ -3352,7 +3352,7 @@ sub pandora_event ($$$$$$$$$$;$$$$$$$$$$$) {
# Validate events with the same event id
if (defined ($id_extra) && $id_extra ne '') {
logger($pa_config, "Updating events with extended id '$id_extra'.", 10);
db_do ($dbh, 'UPDATE ' . $event_table . ' SET estado = 1, ack_utimestamp = ? WHERE estado = 0 AND id_extra=?', $utimestamp, $id_extra);
db_do ($dbh, 'UPDATE ' . $event_table . ' SET estado = 1, ack_utimestamp = ? WHERE estado IN (0,2) AND id_extra=?', $utimestamp, $id_extra);
}
# Create the event

View File

@ -32,7 +32,7 @@ our @ISA = qw(Exporter);
# version: Defines actual version of Pandora Server for this module only
my $pandora_version = "7.0NG.735";
my $pandora_build = "190612";
my $pandora_build = "190618";
our $VERSION = $pandora_version." ".$pandora_build;
our %EXPORT_TAGS = ( 'all' => [ qw() ] );

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.735
%define release 190612
%define release 190618
Summary: Pandora FMS Server
Name: %{name}

View File

@ -3,7 +3,7 @@
#
%define name pandorafms_server
%define version 7.0NG.735
%define release 190612
%define release 190618
Summary: Pandora FMS Server
Name: %{name}

View File

@ -9,7 +9,7 @@
# **********************************************************************
PI_VERSION="7.0NG.735"
PI_BUILD="190612"
PI_BUILD="190618"
MODE=$1
if [ $# -gt 1 ]; then

View File

@ -34,7 +34,7 @@ use PandoraFMS::Config;
use PandoraFMS::DB;
# version: define current version
my $version = "7.0NG.735 PS190612";
my $version = "7.0NG.735 PS190618";
# Pandora server configuration
my %conf;

View File

@ -36,7 +36,7 @@ use Encode::Locale;
Encode::Locale::decode_argv;
# version: define current version
my $version = "7.0NG.735 PS190612";
my $version = "7.0NG.735 PS190618";
# save program name for logging
my $progname = basename($0);

View File

@ -68,27 +68,16 @@ then
help
fi
TMPFILE=/tmp/dns_$DNS_CHECK.tmp
dig @$DNS_CHECK $DOMAIN_CHECK > $TMPFILE
RETURN_IP=`cat $TMPFILE | grep "^$DOMAIN_CHECK" | awk '{print $5}'`
RETURN_TIMEOUT=`cat $TMPFILE | grep "Query time" | grep -o "[0-9]*"`
rm $TMPFILE 2> /dev/null
if [ $TIMEOUT_CHECK == 1 ]
then
echo $RETURN_TIMEOUT
exit 0
fi
if [ "$RETURN_IP" != "$IP_CHECK" ]
then
echo 0
exit 1
else
echo 1
exit 0
fi
results=`dig @$DNS_CHECK +nocmd $DOMAIN_CHECK +multiline +noall +answer A`
targets=`echo "$results"| awk '{print $5}'`
for x in $targets; do
if [ "$x" == "$IP_CHECK" ]; then
echo 1
exit 0
fi
done
echo 0
exit 0

View File

@ -1,4 +1,10 @@
import { Position, Size, UnknownObject, WithModuleProps } from "./types";
import {
Position,
Size,
AnyObject,
WithModuleProps,
ItemMeta
} from "./lib/types";
import {
sizePropsDecoder,
positionPropsDecoder,
@ -9,7 +15,7 @@ import {
humanDate,
humanTime
} from "./lib";
import TypedEvent, { Listener, Disposable } from "./TypedEvent";
import TypedEvent, { Listener, Disposable } from "./lib/TypedEvent";
// Enum: https://www.typescriptlang.org/docs/handbook/enums.html.
export const enum ItemType {
@ -52,14 +58,14 @@ export interface ItemProps extends Position, Size {
// FIXME: Fix type compatibility.
export interface ItemClickEvent<Props extends ItemProps> {
// data: Props;
data: UnknownObject;
data: AnyObject;
nativeEvent: Event;
}
// FIXME: Fix type compatibility.
export interface ItemRemoveEvent<Props extends ItemProps> {
// data: Props;
data: UnknownObject;
data: AnyObject;
}
/**
@ -89,7 +95,7 @@ const parseLabelPosition = (
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function itemBasePropsDecoder(data: UnknownObject): ItemProps | never {
export function itemBasePropsDecoder(data: AnyObject): ItemProps | never {
if (data.id == null || isNaN(parseInt(data.id))) {
throw new TypeError("invalid id.");
}
@ -118,6 +124,8 @@ export function itemBasePropsDecoder(data: UnknownObject): ItemProps | never {
abstract class VisualConsoleItem<Props extends ItemProps> {
// Properties of the item.
private itemProps: Props;
// Metadata of the item.
private _metadata: ItemMeta;
// Reference to the DOM element which will contain the item.
public elementRef: HTMLElement;
public readonly labelElementRef: HTMLElement;
@ -138,8 +146,9 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
*/
protected abstract createDomElement(): HTMLElement;
public constructor(props: Props) {
public constructor(props: Props, metadata: ItemMeta) {
this.itemProps = props;
this._metadata = metadata;
/*
* Get a HTMLElement which represents the container box
@ -185,8 +194,14 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
box.style.zIndex = this.props.isOnTop ? "2" : "1";
box.style.left = `${this.props.x}px`;
box.style.top = `${this.props.y}px`;
box.onclick = e =>
this.clickEventManager.emit({ data: this.props, nativeEvent: e });
box.addEventListener("click", e => {
if (this.meta.editMode) {
e.preventDefault();
e.stopPropagation();
} else {
this.clickEventManager.emit({ data: this.props, nativeEvent: e });
}
});
return box;
}
@ -310,7 +325,34 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
// From this point, things which rely on this.props can access to the changes.
// Check if we should re-render.
if (this.shouldBeUpdated(prevProps, newProps)) this.render(prevProps);
if (this.shouldBeUpdated(prevProps, newProps))
this.render(prevProps, this._metadata);
}
/**
* Public accessor of the `meta` property.
* @return Properties.
*/
public get meta(): ItemMeta {
return { ...this._metadata }; // Return a copy.
}
/**
* Public setter of the `meta` property.
* If the new meta are different enough than the
* stored meta, a render would be fired.
* @param newProps
*/
public set meta(newMetadata: ItemMeta) {
const prevMetadata = this._metadata;
// Update the internal meta.
this._metadata = newMetadata;
// From this point, things which rely on this.props can access to the changes.
// Check if we should re-render.
// if (this.shouldBeUpdated(prevMetadata, newMetadata))
this.render(this.itemProps, prevMetadata);
}
/**
@ -333,7 +375,10 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
* To recreate or update the HTMLElement which represents the item into the DOM.
* @param prevProps If exists it will be used to only perform DOM updates instead of a full replace.
*/
public render(prevProps: Props | null = null): void {
public render(
prevProps: Props | null = null,
prevMeta: ItemMeta | null = null
): void {
this.updateDomElement(this.childElementRef);
// Move box.
@ -378,6 +423,29 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
// Changed the reference to the main element. It's ugly, but needed.
this.elementRef = container;
}
// Change metadata related things.
if (!prevMeta || prevMeta.editMode !== this.meta.editMode) {
if (this.meta.editMode) {
this.elementRef.classList.add("is-editing");
} else {
this.elementRef.classList.remove("is-editing");
}
}
if (!prevMeta || prevMeta.isFetching !== this.meta.isFetching) {
if (this.meta.isFetching) {
this.elementRef.classList.add("is-fetching");
} else {
this.elementRef.classList.remove("is-fetching");
}
}
if (!prevMeta || prevMeta.isUpdating !== this.meta.isUpdating) {
if (this.meta.isUpdating) {
this.elementRef.classList.add("is-updating");
} else {
this.elementRef.classList.remove("is-updating");
}
}
}
/**

View File

@ -1,9 +1,10 @@
import { UnknownObject, Size } from "./types";
import { AnyObject, Size } from "./lib/types";
import {
parseBoolean,
sizePropsDecoder,
parseIntOr,
notEmptyStringOr
notEmptyStringOr,
itemMetaDecoder
} from "./lib";
import Item, {
ItemType,
@ -24,7 +25,7 @@ import EventsHistory, {
eventsHistoryPropsDecoder
} from "./items/EventsHistory";
import Percentile, { percentilePropsDecoder } from "./items/Percentile";
import TypedEvent, { Disposable, Listener } from "./TypedEvent";
import TypedEvent, { Disposable, Listener } from "./lib/TypedEvent";
import DonutGraph, { donutGraphPropsDecoder } from "./items/DonutGraph";
import BarsGraph, { barsGraphPropsDecoder } from "./items/BarsGraph";
import ModuleGraph, { moduleGraphPropsDecoder } from "./items/ModuleGraph";
@ -32,47 +33,49 @@ import Service, { servicePropsDecoder } from "./items/Service";
// TODO: Document.
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
function itemInstanceFrom(data: UnknownObject) {
function itemInstanceFrom(data: AnyObject) {
const type = parseIntOr(data.type, null);
if (type == null) throw new TypeError("missing item type.");
const meta = itemMetaDecoder(data);
switch (type as ItemType) {
case ItemType.STATIC_GRAPH:
return new StaticGraph(staticGraphPropsDecoder(data));
return new StaticGraph(staticGraphPropsDecoder(data), meta);
case ItemType.MODULE_GRAPH:
return new ModuleGraph(moduleGraphPropsDecoder(data));
return new ModuleGraph(moduleGraphPropsDecoder(data), meta);
case ItemType.SIMPLE_VALUE:
case ItemType.SIMPLE_VALUE_MAX:
case ItemType.SIMPLE_VALUE_MIN:
case ItemType.SIMPLE_VALUE_AVG:
return new SimpleValue(simpleValuePropsDecoder(data));
return new SimpleValue(simpleValuePropsDecoder(data), meta);
case ItemType.PERCENTILE_BAR:
case ItemType.PERCENTILE_BUBBLE:
case ItemType.CIRCULAR_PROGRESS_BAR:
case ItemType.CIRCULAR_INTERIOR_PROGRESS_BAR:
return new Percentile(percentilePropsDecoder(data));
return new Percentile(percentilePropsDecoder(data), meta);
case ItemType.LABEL:
return new Label(labelPropsDecoder(data));
return new Label(labelPropsDecoder(data), meta);
case ItemType.ICON:
return new Icon(iconPropsDecoder(data));
return new Icon(iconPropsDecoder(data), meta);
case ItemType.SERVICE:
return new Service(servicePropsDecoder(data));
return new Service(servicePropsDecoder(data), meta);
case ItemType.GROUP_ITEM:
return new Group(groupPropsDecoder(data));
return new Group(groupPropsDecoder(data), meta);
case ItemType.BOX_ITEM:
return new Box(boxPropsDecoder(data));
return new Box(boxPropsDecoder(data), meta);
case ItemType.LINE_ITEM:
return new Line(linePropsDecoder(data));
return new Line(linePropsDecoder(data), meta);
case ItemType.AUTO_SLA_GRAPH:
return new EventsHistory(eventsHistoryPropsDecoder(data));
return new EventsHistory(eventsHistoryPropsDecoder(data), meta);
case ItemType.DONUT_GRAPH:
return new DonutGraph(donutGraphPropsDecoder(data));
return new DonutGraph(donutGraphPropsDecoder(data), meta);
case ItemType.BARS_GRAPH:
return new BarsGraph(barsGraphPropsDecoder(data));
return new BarsGraph(barsGraphPropsDecoder(data), meta);
case ItemType.CLOCK:
return new Clock(clockPropsDecoder(data));
return new Clock(clockPropsDecoder(data), meta);
case ItemType.COLOR_CLOUD:
return new ColorCloud(colorCloudPropsDecoder(data));
return new ColorCloud(colorCloudPropsDecoder(data), meta);
default:
throw new TypeError("item not found");
}
@ -80,7 +83,7 @@ function itemInstanceFrom(data: UnknownObject) {
// TODO: Document.
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
function decodeProps(data: UnknownObject) {
function decodeProps(data: AnyObject) {
const type = parseIntOr(data.type, null);
if (type == null) throw new TypeError("missing item type.");
@ -147,7 +150,7 @@ export interface VisualConsoleProps extends Size {
* is missing from the raw object or have an invalid type.
*/
export function visualConsolePropsDecoder(
data: UnknownObject
data: AnyObject
): VisualConsoleProps | never {
// Object destructuring: http://es6-features.org/#ObjectMatchingShorthandNotation
const {
@ -226,8 +229,8 @@ export default class VisualConsole {
public constructor(
container: HTMLElement,
props: UnknownObject,
items: UnknownObject[]
props: AnyObject,
items: AnyObject[]
) {
this.containerRef = container;
this._props = visualConsolePropsDecoder(props);
@ -288,13 +291,13 @@ export default class VisualConsole {
* Public setter of the `elements` property.
* @param items.
*/
public updateElements(items: UnknownObject[]): void {
const itemIds = items.map(item => item.id || null).filter(id => id != null);
itemIds as number[]; // Tell the type system to rely on us.
public updateElements(items: AnyObject[]): void {
// Ensure the type cause Typescript doesn't know the filter removes null items.
const itemIds = items
.map(item => item.id || null)
.filter(id => id != null) as number[];
// Get the elements we should delete.
const deletedIds: number[] = this.elementIds.filter(
id => itemIds.indexOf(id) < 0
);
const deletedIds = this.elementIds.filter(id => itemIds.indexOf(id) < 0);
// Delete the elements.
deletedIds.forEach(id => {
if (this.elementsById[id] != null) {
@ -530,6 +533,9 @@ export default class VisualConsole {
height: 0,
lineWidth: this.props.relationLineWidth,
color: "#CCCCCC"
}),
itemMetaDecoder({
receivedAt: new Date()
})
);
// Save a reference to the line item.
@ -557,4 +563,22 @@ export default class VisualConsole {
return disposable;
}
/**
* Enable the edition mode.
*/
public enableEditMode(): void {
this.elements.forEach(item => {
item.meta = { ...item.meta, editMode: true };
});
}
/**
* Disable the edition mode.
*/
public disableEditMode(): void {
this.elements.forEach(item => {
item.meta = { ...item.meta, editMode: false };
});
}
}

View File

@ -1,4 +1,4 @@
import { UnknownObject, WithModuleProps } from "../types";
import { AnyObject, WithModuleProps } from "../lib/types";
import { modulePropsDecoder, decodeBase64, stringIsEmpty } from "../lib";
import Item, { ItemType, ItemProps, itemBasePropsDecoder } from "../Item";
@ -17,9 +17,7 @@ export type BarsGraphProps = {
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function barsGraphPropsDecoder(
data: UnknownObject
): BarsGraphProps | never {
export function barsGraphPropsDecoder(data: AnyObject): BarsGraphProps | never {
if (stringIsEmpty(data.html) && stringIsEmpty(data.encodedHtml)) {
throw new TypeError("missing html content.");
}

View File

@ -1,4 +1,4 @@
import { UnknownObject } from "../types";
import { AnyObject } from "../lib/types";
import { parseIntOr, notEmptyStringOr } from "../lib";
import Item, { ItemType, ItemProps, itemBasePropsDecoder } from "../Item";
@ -24,7 +24,7 @@ interface BoxProps extends ItemProps {
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function boxPropsDecoder(data: UnknownObject): BoxProps | never {
export function boxPropsDecoder(data: AnyObject): BoxProps | never {
return {
...itemBasePropsDecoder(data), // Object spread. It will merge the properties of the two objects.
type: ItemType.BOX_ITEM,

View File

@ -1,6 +1,11 @@
import "./styles.css";
import { LinkedVisualConsoleProps, UnknownObject, Size } from "../../types";
import {
LinkedVisualConsoleProps,
AnyObject,
Size,
ItemMeta
} from "../../lib/types";
import {
linkedVCPropsDecoder,
parseIntOr,
@ -60,7 +65,7 @@ const parseClockFormat = (clockFormat: unknown): ClockProps["clockFormat"] => {
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function clockPropsDecoder(data: UnknownObject): ClockProps | never {
export function clockPropsDecoder(data: AnyObject): ClockProps | never {
if (
typeof data.clockTimezone !== "string" ||
data.clockTimezone.length === 0
@ -85,9 +90,9 @@ export default class Clock extends Item<ClockProps> {
public static readonly TICK_INTERVAL = 1000; // In ms.
private intervalRef: number | null = null;
public constructor(props: ClockProps) {
public constructor(props: ClockProps, meta: ItemMeta) {
// Call the superclass constructor.
super(props);
super(props, meta);
/* The item is already loaded and inserted into the DOM.
* The class properties are now initialized.

View File

@ -1,4 +1,5 @@
import Clock, { clockPropsDecoder } from ".";
import { itemMetaDecoder } from "../../lib";
const genericRawProps = {
id: 1,
@ -46,6 +47,9 @@ describe("Clock item", () => {
...sizeRawProps,
...linkedModuleProps,
...digitalClockProps
}),
itemMetaDecoder({
receivedAt: new Date(1)
})
);

View File

@ -1,4 +1,5 @@
import ColorCloud, { colorCloudPropsDecoder } from "./ColorCloud";
import { itemMetaDecoder } from "../lib";
const genericRawProps = {
id: 1,
@ -41,6 +42,9 @@ describe("Color cloud item", () => {
...sizeRawProps,
...linkedModuleProps,
...colorCloudProps
}),
itemMetaDecoder({
receivedAt: new Date(1)
})
);

View File

@ -1,8 +1,8 @@
import {
WithModuleProps,
LinkedVisualConsoleProps,
UnknownObject
} from "../types";
AnyObject
} from "../lib/types";
import { modulePropsDecoder, linkedVCPropsDecoder } from "../lib";
import Item, { itemBasePropsDecoder, ItemType, ItemProps } from "../Item";
@ -24,7 +24,7 @@ export type ColorCloudProps = {
* is missing from the raw object or have an invalid type.
*/
export function colorCloudPropsDecoder(
data: UnknownObject
data: AnyObject
): ColorCloudProps | never {
// TODO: Validate the color.
if (typeof data.color !== "string" || data.color.length === 0) {

View File

@ -1,8 +1,8 @@
import {
LinkedVisualConsoleProps,
UnknownObject,
AnyObject,
WithModuleProps
} from "../types";
} from "../lib/types";
import {
linkedVCPropsDecoder,
modulePropsDecoder,
@ -28,7 +28,7 @@ export type DonutGraphProps = {
* is missing from the raw object or have an invalid type.
*/
export function donutGraphPropsDecoder(
data: UnknownObject
data: AnyObject
): DonutGraphProps | never {
if (stringIsEmpty(data.html) && stringIsEmpty(data.encodedHtml)) {
throw new TypeError("missing html content.");

View File

@ -1,4 +1,4 @@
import { UnknownObject, WithModuleProps } from "../types";
import { AnyObject, WithModuleProps } from "../lib/types";
import {
modulePropsDecoder,
parseIntOr,
@ -24,7 +24,7 @@ export type EventsHistoryProps = {
* is missing from the raw object or have an invalid type.
*/
export function eventsHistoryPropsDecoder(
data: UnknownObject
data: AnyObject
): EventsHistoryProps | never {
if (stringIsEmpty(data.html) && stringIsEmpty(data.encodedHtml)) {
throw new TypeError("missing html content.");

View File

@ -1,4 +1,5 @@
import Group, { groupPropsDecoder } from "./Group";
import { itemMetaDecoder } from "../lib";
const genericRawProps = {
id: 1,
@ -33,6 +34,9 @@ describe("Group item", () => {
...positionRawProps,
...sizeRawProps,
...groupRawProps
}),
itemMetaDecoder({
receivedAt: new Date(1)
})
);

View File

@ -1,4 +1,4 @@
import { LinkedVisualConsoleProps, UnknownObject } from "../types";
import { LinkedVisualConsoleProps, AnyObject } from "../lib/types";
import {
linkedVCPropsDecoder,
parseIntOr,
@ -19,7 +19,7 @@ export type GroupProps = {
} & ItemProps &
LinkedVisualConsoleProps;
function extractHtml(data: UnknownObject): string | null {
function extractHtml(data: AnyObject): string | null {
if (!stringIsEmpty(data.html)) return data.html;
if (!stringIsEmpty(data.encodedHtml)) return decodeBase64(data.encodedHtml);
return null;
@ -34,7 +34,7 @@ function extractHtml(data: UnknownObject): string | null {
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function groupPropsDecoder(data: UnknownObject): GroupProps | never {
export function groupPropsDecoder(data: AnyObject): GroupProps | never {
if (
(typeof data.imageSrc !== "string" || data.imageSrc.length === 0) &&
data.encodedHtml === null

View File

@ -1,4 +1,4 @@
import { LinkedVisualConsoleProps, UnknownObject } from "../types";
import { LinkedVisualConsoleProps, AnyObject } from "../lib/types";
import { linkedVCPropsDecoder } from "../lib";
import Item, { ItemType, ItemProps, itemBasePropsDecoder } from "../Item";
@ -17,7 +17,7 @@ export type IconProps = {
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function iconPropsDecoder(data: UnknownObject): IconProps | never {
export function iconPropsDecoder(data: AnyObject): IconProps | never {
if (typeof data.imageSrc !== "string" || data.imageSrc.length === 0) {
throw new TypeError("invalid image src.");
}

View File

@ -1,4 +1,4 @@
import { LinkedVisualConsoleProps, UnknownObject } from "../types";
import { LinkedVisualConsoleProps, AnyObject } from "../lib/types";
import { linkedVCPropsDecoder } from "../lib";
import Item, { ItemType, ItemProps, itemBasePropsDecoder } from "../Item";
@ -16,7 +16,7 @@ export type LabelProps = {
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function labelPropsDecoder(data: UnknownObject): LabelProps | never {
export function labelPropsDecoder(data: AnyObject): LabelProps | never {
return {
...itemBasePropsDecoder(data), // Object spread. It will merge the properties of the two objects.
type: ItemType.LABEL,

View File

@ -1,4 +1,4 @@
import { UnknownObject, Position, Size } from "../types";
import { AnyObject, Position, Size, ItemMeta } from "../lib/types";
import { parseIntOr, notEmptyStringOr } from "../lib";
import Item, { ItemType, ItemProps, itemBasePropsDecoder } from "../Item";
@ -25,7 +25,7 @@ interface LineProps extends ItemProps {
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function linePropsDecoder(data: UnknownObject): LineProps | never {
export function linePropsDecoder(data: AnyObject): LineProps | never {
const props: LineProps = {
...itemBasePropsDecoder({ ...data, width: 1, height: 1 }), // Object spread. It will merge the properties of the two objects.
type: ItemType.LINE_ITEM,
@ -71,17 +71,20 @@ export default class Line extends Item<LineProps> {
/**
* @override
*/
public constructor(props: LineProps) {
public constructor(props: LineProps, meta: ItemMeta) {
/*
* We need to override the constructor cause we need to obtain
* the
* box size and position from the start and finish points
* of the line.
*/
super({
...props,
...Line.extractBoxSizeAndPosition(props)
});
super(
{
...props,
...Line.extractBoxSizeAndPosition(props)
},
meta
);
}
/**

View File

@ -1,8 +1,8 @@
import {
LinkedVisualConsoleProps,
UnknownObject,
AnyObject,
WithModuleProps
} from "../types";
} from "../lib/types";
import {
linkedVCPropsDecoder,
modulePropsDecoder,
@ -28,7 +28,7 @@ export type ModuleGraphProps = {
* is missing from the raw object or have an invalid type.
*/
export function moduleGraphPropsDecoder(
data: UnknownObject
data: AnyObject
): ModuleGraphProps | never {
if (stringIsEmpty(data.html) && stringIsEmpty(data.encodedHtml)) {
throw new TypeError("missing html content.");

View File

@ -2,9 +2,9 @@ import { arc as arcFactory } from "d3-shape";
import {
LinkedVisualConsoleProps,
UnknownObject,
AnyObject,
WithModuleProps
} from "../types";
} from "../lib/types";
import {
linkedVCPropsDecoder,
modulePropsDecoder,
@ -81,7 +81,7 @@ function extractValueType(valueType: unknown): PercentileProps["valueType"] {
* is missing from the raw object or have an invalid type.
*/
export function percentilePropsDecoder(
data: UnknownObject
data: AnyObject
): PercentileProps | never {
return {
...itemBasePropsDecoder(data), // Object spread. It will merge the properties of the two objects.

View File

@ -1,4 +1,4 @@
import { UnknownObject } from "../types";
import { AnyObject } from "../lib/types";
import {
stringIsEmpty,
notEmptyStringOr,
@ -24,7 +24,7 @@ export type ServiceProps = {
* @throws Will throw a TypeError if some property
* is missing from the raw object or have an invalid type.
*/
export function servicePropsDecoder(data: UnknownObject): ServiceProps | never {
export function servicePropsDecoder(data: AnyObject): ServiceProps | never {
if (data.imageSrc !== null) {
if (
typeof data.statusImageSrc !== "string" ||

View File

@ -1,8 +1,8 @@
import {
LinkedVisualConsoleProps,
UnknownObject,
AnyObject,
WithModuleProps
} from "../types";
} from "../lib/types";
import {
linkedVCPropsDecoder,
parseIntOr,
@ -69,7 +69,7 @@ const parseProcessValue = (
* is missing from the raw object or have an invalid type.
*/
export function simpleValuePropsDecoder(
data: UnknownObject
data: AnyObject
): SimpleValueProps | never {
if (typeof data.value !== "string" || data.value.length === 0) {
throw new TypeError("invalid value");

View File

@ -1,8 +1,8 @@
import {
WithModuleProps,
LinkedVisualConsoleProps,
UnknownObject
} from "../types";
AnyObject
} from "../lib/types";
import {
modulePropsDecoder,
@ -47,7 +47,7 @@ const parseShowLastValueTooltip = (
* is missing from the raw object or have an invalid type.
*/
export function staticGraphPropsDecoder(
data: UnknownObject
data: AnyObject
): StaticGraphProps | never {
if (typeof data.imageSrc !== "string" || data.imageSrc.length === 0) {
throw new TypeError("invalid image src.");

View File

@ -1,4 +1,4 @@
import TypedEvent, { Disposable, Listener } from "../TypedEvent";
import TypedEvent, { Disposable, Listener } from "./TypedEvent";
interface Cancellable {
cancel(): void;

View File

@ -1,12 +1,14 @@
import {
UnknownObject,
AnyObject,
Position,
Size,
WithAgentProps,
WithModuleProps,
LinkedVisualConsoleProps,
LinkedVisualConsolePropsStatus
} from "../types";
LinkedVisualConsolePropsStatus,
UnknownObject,
ItemMeta
} from "./types";
/**
* Return a number or a default value from a raw value.
@ -72,6 +74,23 @@ export function parseBoolean(value: unknown): boolean {
else return false;
}
/**
* Return a valid date or a default value from a raw value.
* @param value Raw value from which we will try to extract a valid date.
* @param defaultValue Default value to use if we cannot extract a valid date.
* @return A valid date or the default value.
*/
export function parseDateOr<T>(value: unknown, defaultValue: T): Date | T {
if (value instanceof Date) return value;
else if (typeof value === "number") return new Date(value * 1000);
else if (
typeof value === "string" &&
!Number.isNaN(new Date(value).getTime())
)
return new Date(value);
else return defaultValue;
}
/**
* Pad the current string with another string (multiple times, if needed)
* until the resulting string reaches the given length.
@ -113,7 +132,7 @@ export function leftPad(
* @param data Raw object.
* @return An object representing the position.
*/
export function positionPropsDecoder(data: UnknownObject): Position {
export function positionPropsDecoder(data: AnyObject): Position {
return {
x: parseIntOr(data.x, 0),
y: parseIntOr(data.y, 0)
@ -126,7 +145,7 @@ export function positionPropsDecoder(data: UnknownObject): Position {
* @return An object representing the size.
* @throws Will throw a TypeError if the width and height are not valid numbers.
*/
export function sizePropsDecoder(data: UnknownObject): Size | never {
export function sizePropsDecoder(data: AnyObject): Size | never {
if (
data.width == null ||
isNaN(parseInt(data.width)) ||
@ -147,7 +166,7 @@ export function sizePropsDecoder(data: UnknownObject): Size | never {
* @param data Raw object.
* @return An object representing the agent properties.
*/
export function agentPropsDecoder(data: UnknownObject): WithAgentProps {
export function agentPropsDecoder(data: AnyObject): WithAgentProps {
const agentProps: WithAgentProps = {
agentId: parseIntOr(data.agent, null),
agentName: notEmptyStringOr(data.agentName, null),
@ -169,7 +188,7 @@ export function agentPropsDecoder(data: UnknownObject): WithAgentProps {
* @param data Raw object.
* @return An object representing the module and agent properties.
*/
export function modulePropsDecoder(data: UnknownObject): WithModuleProps {
export function modulePropsDecoder(data: AnyObject): WithModuleProps {
return {
moduleId: parseIntOr(data.moduleId, null),
moduleName: notEmptyStringOr(data.moduleName, null),
@ -185,7 +204,7 @@ export function modulePropsDecoder(data: UnknownObject): WithModuleProps {
* @throws Will throw a TypeError if the status calculation properties are invalid.
*/
export function linkedVCPropsDecoder(
data: UnknownObject
data: AnyObject
): LinkedVisualConsoleProps | never {
// Object destructuring: http://es6-features.org/#ObjectMatchingShorthandNotation
const {
@ -246,6 +265,29 @@ export function linkedVCPropsDecoder(
: linkedLayoutBaseProps;
}
/**
* Build a valid typed object from a raw object.
* @param data Raw object.
* @return An object representing the item's meta properties.
*/
export function itemMetaDecoder(data: UnknownObject): ItemMeta | never {
const receivedAt = parseDateOr(data.receivedAt, null);
if (receivedAt === null) throw new TypeError("invalid meta structure");
let error = null;
if (data.error instanceof Error) error = data.error;
else if (typeof data.error === "string") error = new Error(data.error);
return {
receivedAt,
error,
editMode: parseBoolean(data.editMode),
isFromCache: parseBoolean(data.isFromCache),
isFetching: false,
isUpdating: false
};
}
/**
* To get a CSS rule with the most used prefixes.
* @param ruleName Name of the CSS rule.

View File

@ -7,7 +7,8 @@ import {
decodeBase64,
humanDate,
humanTime,
replaceMacros
replaceMacros,
itemMetaDecoder
} from ".";
describe("function parseIntOr", () => {
@ -72,14 +73,14 @@ describe("function prefixedCssRules", () => {
describe("function decodeBase64", () => {
it("should decode the base64 without errors", () => {
expect(decodeBase64("SGkgSSdtIGRlY29kZWQ=")).toEqual("Hi I'm decoded");
expect(decodeBase64("Rk9PQkFSQkFa")).toEqual("FOOBARBAZ");
expect(decodeBase64("eyJpZCI6MSwibmFtZSI6ImZvbyJ9")).toEqual(
expect(decodeBase64("SGkgSSdtIGRlY29kZWQ=")).toBe("Hi I'm decoded");
expect(decodeBase64("Rk9PQkFSQkFa")).toBe("FOOBARBAZ");
expect(decodeBase64("eyJpZCI6MSwibmFtZSI6ImZvbyJ9")).toBe(
'{"id":1,"name":"foo"}'
);
expect(
decodeBase64("PGRpdj5Cb3ggPHA+UGFyYWdyYXBoPC9wPjxociAvPjwvZGl2Pg==")
).toEqual("<div>Box <p>Paragraph</p><hr /></div>");
).toBe("<div>Box <p>Paragraph</p><hr /></div>");
});
});
@ -118,3 +119,46 @@ describe("replaceMacros function", () => {
expect(replaceMacros(macros, text)).toBe("Lorem foo Ipsum baz");
});
});
describe("itemMetaDecoder function", () => {
it("should extract a default meta object", () => {
expect(
itemMetaDecoder({
receivedAt: 1
})
).toEqual({
receivedAt: new Date(1000),
error: null,
isFromCache: false,
isFetching: false,
isUpdating: false,
editMode: false
});
});
it("should extract a valid meta object", () => {
expect(
itemMetaDecoder({
receivedAt: new Date(1000),
error: new Error("foo"),
editMode: 1
})
).toEqual({
receivedAt: new Date(1000),
error: new Error("foo"),
isFromCache: false,
isFetching: false,
isUpdating: false,
editMode: true
});
});
it("should fail when a invalid structure is used", () => {
expect(() => itemMetaDecoder({})).toThrowError(TypeError);
expect(() =>
itemMetaDecoder({
receivedAt: "foo"
})
).toThrowError(TypeError);
});
});

View File

@ -1,7 +1,11 @@
export interface UnknownObject {
export interface AnyObject {
[key: string]: any; // eslint-disable-line @typescript-eslint/no-explicit-any
}
export interface UnknownObject {
[key: string]: unknown;
}
export interface Position {
x: number;
y: number;
@ -45,3 +49,12 @@ export type LinkedVisualConsoleProps = {
linkedLayoutId: number | null;
linkedLayoutAgentId: number | null;
} & LinkedVisualConsolePropsStatus;
export interface ItemMeta {
receivedAt: Date;
error: Error | null;
isFromCache: boolean;
isFetching: boolean;
isUpdating: boolean;
editMode: boolean;
}

View File

@ -14,3 +14,8 @@
align-items: center;
user-select: text;
}
.visual-console-item.is-editing {
border: 2px dashed #33ccff;
transform: translateX(-2px) translateY(-2px);
}