mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Merge remote-tracking branch 'origin/develop' into ent-4266-eliminar-los-flashes-al-recargar-graficas-en-la-consola-visuall
This commit is contained in:
commit
f36e7966a1
@ -1,5 +1,5 @@
|
||||
package: pandorafms-agent-unix
|
||||
Version: 7.0NG.735-190624
|
||||
Version: 7.0NG.735-190626
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -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-190624"
|
||||
pandora_version="7.0NG.735-190626"
|
||||
|
||||
echo "Test if you has the tools for to make the packages."
|
||||
whereis dpkg-deb | cut -d":" -f2 | grep dpkg-deb > /dev/null
|
||||
|
@ -42,7 +42,7 @@ my $Sem = undef;
|
||||
my $ThreadSem = undef;
|
||||
|
||||
use constant AGENT_VERSION => '7.0NG.735';
|
||||
use constant AGENT_BUILD => '190624';
|
||||
use constant AGENT_BUILD => '190626';
|
||||
|
||||
# Agent log default file size maximum and instances
|
||||
use constant DEFAULT_MAX_LOG_SIZE => 600000;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.735
|
||||
%define release 190624
|
||||
%define release 190626
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_agent_unix
|
||||
%define version 7.0NG.735
|
||||
%define release 190624
|
||||
%define release 190626
|
||||
|
||||
Summary: Pandora FMS Linux agent, PERL version
|
||||
Name: %{name}
|
||||
|
@ -10,7 +10,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.735"
|
||||
PI_BUILD="190624"
|
||||
PI_BUILD="190626"
|
||||
OS_NAME=`uname -s`
|
||||
|
||||
FORCE=0
|
||||
|
@ -186,7 +186,7 @@ UpgradeApplicationID
|
||||
{}
|
||||
|
||||
Version
|
||||
{190624}
|
||||
{190626}
|
||||
|
||||
ViewReadme
|
||||
{Yes}
|
||||
|
@ -30,7 +30,7 @@ using namespace Pandora;
|
||||
using namespace Pandora_Strutils;
|
||||
|
||||
#define PATH_SIZE _MAX_PATH+1
|
||||
#define PANDORA_VERSION ("7.0NG.735(Build 190624)")
|
||||
#define PANDORA_VERSION ("7.0NG.735(Build 190626)")
|
||||
|
||||
string pandora_path;
|
||||
string pandora_dir;
|
||||
|
@ -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 190624))"
|
||||
VALUE "ProductVersion", "(7.0NG.735(Build 190626))"
|
||||
VALUE "FileVersion", "1.0.0.0"
|
||||
END
|
||||
END
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-console
|
||||
Version: 7.0NG.735-190624
|
||||
Version: 7.0NG.735-190626
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -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-190624"
|
||||
pandora_version="7.0NG.735-190626"
|
||||
|
||||
package_pear=0
|
||||
package_pandora=1
|
||||
|
@ -42,4 +42,5 @@ ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_user` VARCHAR(60);
|
||||
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_pass` VARCHAR(45);
|
||||
ALTER TABLE `tusuario` ADD COLUMN `ehorus_user_level_enabled` TINYINT(1) DEFAULT '1';
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
@ -1,6 +1,27 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `tmetaconsole_agent` ADD INDEX `id_tagente_idx` (`id_tagente`);
|
||||
|
||||
DELETE FROM `ttipo_modulo` WHERE `nombre` LIKE 'log4x';
|
||||
|
||||
CREATE TABLE IF NOT EXISTS `tcredential_store` (
|
||||
`identifier` varchar(100) NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL DEFAULT 0,
|
||||
`product` enum('CUSTOM', 'AWS', 'AZURE', 'GOOGLE') default 'CUSTOM',
|
||||
`username` text,
|
||||
`password` text,
|
||||
`extra_1` text,
|
||||
`extra_2` text,
|
||||
PRIMARY KEY (`identifier`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
|
||||
INSERT INTO `tcredential_store` (`identifier`, `id_group`, `product`, `username`, `password`) VALUES ("imported_aws_account", 0, "AWS", (SELECT `value` FROM `tconfig` WHERE `token` = "aws_access_key_id" LIMIT 1), (SELECT `value` FROM `tconfig` WHERE `token` = "aws_secret_access_key" LIMIT 1));
|
||||
DELETE FROM `tcredential_store` WHERE `username` IS NULL AND `password` IS NULL;
|
||||
|
||||
UPDATE `tagente` ta INNER JOIN `tagente` taa on ta.`id_parent` = taa.`id_agente` AND taa.`nombre` IN ("us-east-1", "us-east-2", "us-west-1", "us-west-2", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-south-1", "sa-east-1") SET ta.nombre = md5(concat((SELECT `username` FROM `tcredential_store` WHERE `identifier` = "imported_aws_account" LIMIT 1), ta.`nombre`));
|
||||
|
||||
UPDATE `tagente` SET `nombre` = md5(concat((SELECT `username` FROM `tcredential_store` WHERE `identifier` = "imported_aws_account" LIMIT 1), `nombre`)) WHERE `nombre` IN ("Aws", "us-east-1", "us-east-2", "us-west-1", "us-west-2", "ca-central-1", "eu-central-1", "eu-west-1", "eu-west-2", "eu-west-3", "ap-northeast-1", "ap-northeast-2", "ap-southeast-1", "ap-southeast-2", "ap-south-1", "sa-east-1");
|
||||
|
||||
|
||||
COMMIT;
|
||||
|
@ -2192,3 +2192,16 @@ CREATE TABLE `tvisual_console_elements_cache` (
|
||||
ON UPDATE CASCADE
|
||||
) engine=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tcredential_store`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tcredential_store` (
|
||||
`identifier` varchar(100) NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL DEFAULT 0,
|
||||
`product` enum('CUSTOM', 'AWS', 'AZURE', 'GOOGLE') default 'CUSTOM',
|
||||
`username` text,
|
||||
`password` text,
|
||||
`extra_1` text,
|
||||
`extra_2` text,
|
||||
PRIMARY KEY (`identifier`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
@ -35,6 +35,7 @@ ui_require_css_file('firts_task');
|
||||
</p>
|
||||
<form action="index.php?sec=gservers&sec2=godmode/servers/discovery" method="post">
|
||||
<input type="submit" class="button_task" value="<?php echo __('Discover'); ?>" />
|
||||
<input type="hidden" name="discovery_hint" value="1"/>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -777,7 +777,7 @@ $table_adv_options = '
|
||||
'.$adv_secondary_groups_right.'
|
||||
</div>
|
||||
</div>
|
||||
<div class="adv_right" >
|
||||
<div class="agent_av_opt_right" >
|
||||
'.$table_adv_parent.$table_adv_module_mode.$table_adv_cascade;
|
||||
|
||||
if ($new_agent) {
|
||||
@ -788,7 +788,7 @@ if ($new_agent) {
|
||||
$table_adv_options .= '</div>';
|
||||
|
||||
$table_adv_options .= '
|
||||
<div class="adv_left" >
|
||||
<div class="agent_av_opt_left" >
|
||||
'.$table_adv_gis.$table_adv_agent_icon.$table_adv_url.$table_adv_quiet.$table_adv_status.$table_adv_remote.$table_adv_safe.'
|
||||
</div>';
|
||||
|
||||
|
@ -1213,7 +1213,7 @@ if ($update_module || $create_module) {
|
||||
|
||||
$max_timeout = (int) get_parameter('max_timeout');
|
||||
$max_retries = (int) get_parameter('max_retries');
|
||||
$min = (int) get_parameter_post('min');
|
||||
$min = (int) get_parameter('min');
|
||||
$max = (int) get_parameter('max');
|
||||
$interval = (int) get_parameter('module_interval', $intervalo);
|
||||
$ff_interval = (int) get_parameter('module_ff_interval');
|
||||
|
@ -163,7 +163,7 @@ echo '<td>';
|
||||
|
||||
echo __('Group').' ';
|
||||
$own_info = get_user_info($config['id_user']);
|
||||
if (!$own_info['is_admin'] && !check_acl($config['id_user'], 0, 'AW')) {
|
||||
if (!$own_info['is_admin'] && check_acl($config['id_user'], 0, 'AW')) {
|
||||
$return_all_group = false;
|
||||
} else {
|
||||
$return_all_group = true;
|
||||
|
@ -267,10 +267,10 @@ if ($id_agent_module) {
|
||||
$cron_interval = explode(' ', $module['cron_interval']);
|
||||
if (isset($cron_interval[4])) {
|
||||
$minute_from = $cron_interval[0];
|
||||
$min = explode('-', $minute_from);
|
||||
$minute_from = $min[0];
|
||||
if (isset($min[1])) {
|
||||
$minute_to = $min[1];
|
||||
$minute = explode('-', $minute_from);
|
||||
$minute_from = $minute[0];
|
||||
if (isset($minute[1])) {
|
||||
$minute_to = $minute[1];
|
||||
}
|
||||
|
||||
$hour_from = $cron_interval[1];
|
||||
|
@ -317,9 +317,9 @@ $(document).ready (function () {
|
||||
jQuery.post (<?php echo "'".ui_get_full_url('ajax.php', false, false, false)."'"; ?>,
|
||||
values,
|
||||
function (data, status) {
|
||||
original_command = js_html_entity_decode (data["command"]);
|
||||
original_command = data["command"];
|
||||
render_command_preview (original_command);
|
||||
command_description = js_html_entity_decode (data["description"]);
|
||||
command_description = data["description"];
|
||||
render_command_description(command_description);
|
||||
|
||||
var max_fields = parseInt('<?php echo $config['max_macro_fields']; ?>');
|
||||
|
@ -113,6 +113,8 @@ $fields_available['instructions'] = __('Instructions');
|
||||
$fields_available['server_name'] = __('Server Name');
|
||||
$fields_available['data'] = __('Data');
|
||||
$fields_available['module_status'] = __('Module Status');
|
||||
$fields_available['mini_severity'] = __('Severity mini');
|
||||
|
||||
|
||||
// Remove fields already selected.
|
||||
foreach ($fields_available as $key => $available) {
|
||||
|
@ -50,17 +50,10 @@ if (check_acl($config['id_user'], 0, 'PM')) {
|
||||
'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=responses&pure='.$config['pure'].'">'.html_print_image('images/event_responses.png', true, ['title' => __('Event responses')]).'</a>',
|
||||
];
|
||||
|
||||
if (!is_metaconsole()) {
|
||||
$buttons['fields'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=fields&pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
|
||||
];
|
||||
} else {
|
||||
$buttons['fields'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=eventos&sec2=event/custom_events&section=fields&pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
|
||||
];
|
||||
}
|
||||
$buttons['fields'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=fields&pure='.$config['pure'].'">'.html_print_image('images/custom_columns.png', true, ['title' => __('Custom fields')]).'</a>',
|
||||
];
|
||||
}
|
||||
|
||||
switch ($section) {
|
||||
|
632
pandora_console/godmode/groups/credential_store.php
Normal file
632
pandora_console/godmode/groups/credential_store.php
Normal file
@ -0,0 +1,632 @@
|
||||
<?php
|
||||
/**
|
||||
* Credentials management view.
|
||||
*
|
||||
* @category Credentials management
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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 for 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
'Trying to access event viewer'
|
||||
);
|
||||
|
||||
if (is_ajax()) {
|
||||
return ['error' => 'noaccess'];
|
||||
}
|
||||
|
||||
include 'general/noaccess.php';
|
||||
return;
|
||||
}
|
||||
|
||||
// Required files.
|
||||
ui_require_css_file('credential_store');
|
||||
require_once $config['homedir'].'/include/functions_credential_store.php';
|
||||
require_once $config['homedir'].'/include/functions_io.php';
|
||||
|
||||
if (is_ajax()) {
|
||||
$draw = get_parameter('draw', 0);
|
||||
$filter = get_parameter('filter', []);
|
||||
$get_key = get_parameter('get_key', 0);
|
||||
$new_form = get_parameter('new_form', 0);
|
||||
$new_key = get_parameter('new_key', 0);
|
||||
$update_key = get_parameter('update_key', 0);
|
||||
$delete_key = get_parameter('delete_key', 0);
|
||||
|
||||
if ($new_form) {
|
||||
echo print_inputs();
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($delete_key) {
|
||||
$identifier = get_parameter('identifier', null);
|
||||
|
||||
if (empty($identifier)) {
|
||||
ajax_msg('error', __('identifier cannot be empty'));
|
||||
}
|
||||
|
||||
if (db_process_sql_delete(
|
||||
'tcredential_store',
|
||||
['identifier' => $identifier]
|
||||
) === false
|
||||
) {
|
||||
ajax_msg('error', $config['dbconnection']->error, true);
|
||||
} else {
|
||||
ajax_msg('result', $identifier, true);
|
||||
}
|
||||
}
|
||||
|
||||
if ($update_key) {
|
||||
$data = get_parameter('values', null);
|
||||
|
||||
if ($data === null || !is_array($data)) {
|
||||
echo json_encode(['error' => __('Invalid parameters, please retry')]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($data as $key => $value) {
|
||||
if ($key == 'identifier') {
|
||||
$identifier = base64_decode($value);
|
||||
} else if ($key == 'product') {
|
||||
$product = base64_decode($value);
|
||||
} else {
|
||||
$values[$key] = base64_decode($value);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($identifier)) {
|
||||
ajax_msg('error', __('identifier cannot be empty'));
|
||||
}
|
||||
|
||||
if (empty($product)) {
|
||||
ajax_msg('error', __('product cannot be empty'));
|
||||
}
|
||||
|
||||
if (db_process_sql_update(
|
||||
'tcredential_store',
|
||||
$values,
|
||||
['identifier' => $identifier]
|
||||
) === false
|
||||
) {
|
||||
ajax_msg('error', $config['dbconnection']->error);
|
||||
} else {
|
||||
ajax_msg('result', $identifier);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($new_key) {
|
||||
$data = get_parameter('values', null);
|
||||
|
||||
if ($data === null || !is_array($data)) {
|
||||
echo json_encode(['error' => __('Invalid parameters, please retry')]);
|
||||
exit;
|
||||
}
|
||||
|
||||
$values = [];
|
||||
foreach ($data as $key => $value) {
|
||||
$values[$key] = base64_decode($value);
|
||||
if ($key == 'identifier') {
|
||||
$values[$key] = preg_replace('/\s+/', '-', trim($values[$key]));
|
||||
}
|
||||
}
|
||||
|
||||
$identifier = $values['identifier'];
|
||||
|
||||
if (empty($identifier)) {
|
||||
ajax_msg('error', __('identifier cannot be empty'));
|
||||
}
|
||||
|
||||
if (empty($values['product'])) {
|
||||
ajax_msg('error', __('product cannot be empty'));
|
||||
}
|
||||
|
||||
if (db_process_sql_insert('tcredential_store', $values) === false) {
|
||||
ajax_msg('error', $config['dbconnection']->error);
|
||||
} else {
|
||||
ajax_msg('result', $identifier);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($get_key) {
|
||||
$identifier = get_parameter('identifier', null);
|
||||
|
||||
$key = get_key($identifier);
|
||||
echo print_inputs($key);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if ($draw) {
|
||||
// Datatables offset, limit and order.
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
$order = get_datatable_order(true);
|
||||
try {
|
||||
ob_start();
|
||||
|
||||
$fields = [
|
||||
'cs.*',
|
||||
'tg.nombre as `group`',
|
||||
];
|
||||
|
||||
// Retrieve data.
|
||||
$data = credentials_get_all(
|
||||
// Fields.
|
||||
$fields,
|
||||
// Filter.
|
||||
$filter,
|
||||
// Offset.
|
||||
$start,
|
||||
// Limit.
|
||||
$length,
|
||||
// Order.
|
||||
$order['direction'],
|
||||
// Sort field.
|
||||
$order['field']
|
||||
);
|
||||
|
||||
// Retrieve counter.
|
||||
$count = credentials_get_all(
|
||||
'count',
|
||||
$filter
|
||||
);
|
||||
|
||||
if ($data) {
|
||||
$data = array_reduce(
|
||||
$data,
|
||||
function ($carry, $item) {
|
||||
// Transforms array of arrays $data into an array
|
||||
// of objects, making a post-process of certain fields.
|
||||
$tmp = (object) $item;
|
||||
$tmp->username = io_safe_output($tmp->username);
|
||||
|
||||
if (empty($tmp->group)) {
|
||||
$tmp->group = __('All');
|
||||
} else {
|
||||
$tmp->group = io_safe_output($tmp->group);
|
||||
}
|
||||
|
||||
$carry[] = $tmp;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
// Datatables format: RecordsTotal && recordsfiltered.
|
||||
echo json_encode(
|
||||
[
|
||||
'data' => $data,
|
||||
'recordsTotal' => $count,
|
||||
'recordsFiltered' => $count,
|
||||
]
|
||||
);
|
||||
// Capture output.
|
||||
$response = ob_get_clean();
|
||||
} catch (Exception $e) {
|
||||
return json_encode(['error' => $e->getMessage()]);
|
||||
}
|
||||
|
||||
// If not valid, show error with issue.
|
||||
json_decode($response);
|
||||
if (json_last_error() == JSON_ERROR_NONE) {
|
||||
// If valid dump.
|
||||
echo $response;
|
||||
} else {
|
||||
echo json_encode(
|
||||
['error' => $response]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
// Datatables list.
|
||||
try {
|
||||
$columns = [
|
||||
'group',
|
||||
'identifier',
|
||||
'product',
|
||||
'username',
|
||||
'options',
|
||||
];
|
||||
|
||||
$column_names = [
|
||||
__('Group'),
|
||||
__('Identifier'),
|
||||
__('Product'),
|
||||
__('User'),
|
||||
[
|
||||
'text' => __('Options'),
|
||||
'class' => 'action_buttons',
|
||||
],
|
||||
];
|
||||
|
||||
$table_id = 'keystore';
|
||||
// Load datatables user interface.
|
||||
ui_print_datatable(
|
||||
[
|
||||
'id' => $table_id,
|
||||
'class' => 'info_table',
|
||||
'style' => 'width: 100%',
|
||||
'columns' => $columns,
|
||||
'column_names' => $column_names,
|
||||
'ajax_url' => 'godmode/groups/credential_store',
|
||||
'ajax_postprocess' => 'process_datatables_item(item)',
|
||||
'no_sortable_columns' => [-1],
|
||||
'order' => [
|
||||
'field' => 'identifier',
|
||||
'direction' => 'asc',
|
||||
],
|
||||
'search_button_class' => 'sub filter float-right',
|
||||
'form' => [
|
||||
'inputs' => [
|
||||
[
|
||||
'label' => __('Group'),
|
||||
'type' => 'select',
|
||||
'id' => 'filter_id_group',
|
||||
'name' => 'filter_id_group',
|
||||
'options' => users_get_groups_for_select(
|
||||
$config['id_user'],
|
||||
'AR',
|
||||
true,
|
||||
true,
|
||||
false
|
||||
),
|
||||
],
|
||||
[
|
||||
'label' => __('Free search'),
|
||||
'type' => 'text',
|
||||
'class' => 'mw250px',
|
||||
'id' => 'free_search',
|
||||
'name' => 'free_search',
|
||||
],
|
||||
],
|
||||
],
|
||||
]
|
||||
);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
// Auxiliar div.
|
||||
$new = '<div id="new_key" style="display: none"><form id="form_new">';
|
||||
$new .= '</form></div>';
|
||||
$details = '<div id="info_key" style="display: none"><form id="form_update">';
|
||||
$details .= '</form></div>';
|
||||
$aux = '<div id="aux" style="display: none"></div>';
|
||||
|
||||
|
||||
echo $new.$details.$aux;
|
||||
|
||||
// Create button.
|
||||
echo '<div class="w100p flex-content-right">';
|
||||
html_print_submit_button(
|
||||
__('Add key'),
|
||||
'create',
|
||||
false,
|
||||
'class="sub next"'
|
||||
);
|
||||
echo '</div>';
|
||||
|
||||
?>
|
||||
|
||||
<script type="text/javascript">
|
||||
function process_datatables_item(item) {
|
||||
item.options = '<a href="javascript:" onclick="display_key(\'';
|
||||
item.options += item.identifier;
|
||||
item.options += '\')" ><?php echo html_print_image('images/eye.png', true, ['title' => __('Show')]); ?></a>';
|
||||
|
||||
item.options += '<a href="javascript:" onclick="delete_key(\'';
|
||||
item.options += item.identifier;
|
||||
item.options += '\')" ><?php echo html_print_image('images/cross.png', true, ['title' => __('Delete')]); ?></a>';
|
||||
}
|
||||
|
||||
function handle_response(data) {
|
||||
var title = "<?php echo __('Success'); ?>";
|
||||
var text = '';
|
||||
var failed = 0;
|
||||
try {
|
||||
data = JSON.parse(data);
|
||||
text = data['result'];
|
||||
} catch (err) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = err.message;
|
||||
failed = 1;
|
||||
}
|
||||
if (!failed && data['error']) {
|
||||
title = "<?php echo __('Failed'); ?>";
|
||||
text = data['error'];
|
||||
failed = 1;
|
||||
}
|
||||
|
||||
$('#aux').empty();
|
||||
$('#aux').html(text);
|
||||
$('#aux').dialog({
|
||||
width: 450,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: title,
|
||||
buttons: [
|
||||
{
|
||||
text: 'OK',
|
||||
click: function(e) {
|
||||
if (!failed) {
|
||||
dt_<?php echo $table_id; ?>.draw(0);
|
||||
$(".ui-dialog-content").dialog("close");
|
||||
cleanupDOM();
|
||||
} else {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function delete_key(id) {
|
||||
$('#aux').empty();
|
||||
$('#aux').text('<?php echo __('Are you sure?'); ?>');
|
||||
$('#aux').dialog({
|
||||
title: '<?php echo __('Delete'); ?> ' + id,
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
cleanupDOM();
|
||||
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Delete',
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
click: function(e) {
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
delete_key: 1,
|
||||
identifier: id
|
||||
},
|
||||
datatype: "json",
|
||||
success: function (data) {
|
||||
handle_response(data);
|
||||
},
|
||||
error: function(e) {
|
||||
handle_response(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
function display_key(id) {
|
||||
$('#form_update').empty();
|
||||
$('#form_update').html('Loading...');
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
get_key: 1,
|
||||
identifier: id
|
||||
},
|
||||
success: function (data) {
|
||||
$('#info_key').dialog({
|
||||
width: 580,
|
||||
height: 400,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: id,
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: '<?php echo __('Cancel'); ?>',
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
cleanupDOM();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: 'Update',
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
click: function(e) {
|
||||
var values = {};
|
||||
|
||||
$('#form_update :input').each(function() {
|
||||
values[this.name] = btoa($(this).val());
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
update_key: 1,
|
||||
values: values
|
||||
},
|
||||
datatype: "json",
|
||||
success: function (data) {
|
||||
handle_response(data);
|
||||
},
|
||||
error: function(e) {
|
||||
handle_response(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
]
|
||||
});
|
||||
$('#form_update').html(data);
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
function cleanupDOM() {
|
||||
$('#div-identifier').empty();
|
||||
$('#div-product').empty();
|
||||
$('#div-username').empty();
|
||||
$('#div-password').empty();
|
||||
$('#div-extra_1').empty();
|
||||
$('#div-extra_2').empty();
|
||||
}
|
||||
|
||||
function calculate_inputs() {
|
||||
if ($('#product :selected').val() == "CUSTOM") {
|
||||
$('#div-username label').text('<?php echo __('Username'); ?>');
|
||||
$('#div-password label').text('<?php echo __('Password'); ?>');
|
||||
$('#div-extra_1 label').text('<?php echo __('Extra'); ?>');
|
||||
$('#div-extra_2 label').text('<?php echo __('Extra (2)'); ?>');
|
||||
$('#div-extra_1').show();
|
||||
$('#div-extra_2').show();
|
||||
} else if ($('#product :selected').val() == "AWS") {
|
||||
$('#div-username label').text('<?php echo __('Access key ID'); ?>');
|
||||
$('#div-password label').text('<?php echo __('Secret access key'); ?>');
|
||||
$('#div-extra_1').hide();
|
||||
$('#div-extra_2').hide();
|
||||
} else if ($('#product :selected').val() == "AZURE") {
|
||||
$('#div-username label').text('<?php echo __('Account ID'); ?>');
|
||||
$('#div-password label').text('<?php echo __('Password'); ?>');
|
||||
$('#div-extra_1 label').text('<?php echo __('Tenant or domain name'); ?>');
|
||||
$('#div-extra_2 label').text('<?php echo __('Subscription id'); ?>');
|
||||
$('#div-extra_1').show();
|
||||
$('#div-extra_2').show();
|
||||
}
|
||||
}
|
||||
|
||||
function add_key() {
|
||||
// Clear form.
|
||||
$('#form_update').empty();
|
||||
$('#form_update').html('Loading...');
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
new_form: 1
|
||||
},
|
||||
success: function(data) {
|
||||
$('#form_new').html(data);
|
||||
$('#id_group').val(0);
|
||||
// By default AWS.
|
||||
$('#product').val('AWS');
|
||||
calculate_inputs();
|
||||
|
||||
$('#product').on('change', function() {
|
||||
calculate_inputs()
|
||||
});
|
||||
|
||||
// Show form.
|
||||
$('#new_key').dialog({
|
||||
width: 580,
|
||||
height: 400,
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window,
|
||||
collision: 'fit'
|
||||
},
|
||||
title: "<?php echo __('Register new key into keystore'); ?>",
|
||||
buttons: [
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-cancel',
|
||||
text: "<?php echo __('Cancel'); ?>",
|
||||
click: function(e) {
|
||||
$(this).dialog('close');
|
||||
cleanupDOM();
|
||||
}
|
||||
},
|
||||
{
|
||||
class: 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub ok submit-next',
|
||||
text: 'OK',
|
||||
click: function(e) {
|
||||
var values = {};
|
||||
|
||||
console.log($('#form_new'));
|
||||
|
||||
$('#form_new :input').each(function() {
|
||||
values[this.name] = btoa($(this).val());
|
||||
});
|
||||
|
||||
$.ajax({
|
||||
method: 'post',
|
||||
url: '<?php echo ui_get_full_url('ajax.php', false, false, false); ?>',
|
||||
data: {
|
||||
page: 'godmode/groups/credential_store',
|
||||
new_key: 1,
|
||||
values: values
|
||||
},
|
||||
datatype: "json",
|
||||
success: function (data) {
|
||||
handle_response(data);
|
||||
},
|
||||
error: function(e) {
|
||||
handle_response(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
]
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
$(document).ready(function(){
|
||||
|
||||
$("#submit-create").on('click', function(){
|
||||
add_key();
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
@ -1,20 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* Group management view.
|
||||
*
|
||||
* @category Group View
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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 for 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-2010 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 for 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.
|
||||
// Begin.
|
||||
ui_require_css_file('tree');
|
||||
ui_require_css_file('fixed-bottom-box');
|
||||
|
||||
// Load global vars
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
@ -76,15 +92,17 @@ if (is_ajax()) {
|
||||
$recursion = (int) get_parameter('recursion', 0);
|
||||
$privilege = (string) get_parameter('privilege', '');
|
||||
$all_agents = (int) get_parameter('all_agents', 0);
|
||||
// Is is possible add keys prefix to avoid auto sorting in js object conversion
|
||||
// Is is possible add keys prefix to avoid auto sorting in
|
||||
// js object conversion.
|
||||
$keys_prefix = (string) get_parameter('keys_prefix', '');
|
||||
// This attr is for the operation "bulk alert accions add", it controls the query that take the agents
|
||||
// from db
|
||||
// This attr is for the operation "bulk alert accions add", it controls
|
||||
// the query that take the agents from db.
|
||||
$add_alert_bulk_op = get_parameter('add_alert_bulk_op', false);
|
||||
// Ids of agents to be include in the SQL clause as id_agent IN ()
|
||||
// Ids of agents to be include in the SQL clause as id_agent IN ().
|
||||
$filter_agents_json = (string) get_parameter('filter_agents_json', '');
|
||||
$status_agents = (int) get_parameter('status_agents', AGENT_STATUS_ALL);
|
||||
// Juanma (22/05/2014) Fix: If setted remove void agents from result (by default and for compatibility show void agents)
|
||||
// Juanma (22/05/2014) Fix: If setted remove void agents from result
|
||||
// (by default and for compatibility show void agents).
|
||||
$show_void_agents = (int) get_parameter('show_void_agents', 1);
|
||||
$serialized = (bool) get_parameter('serialized', false);
|
||||
$serialized_separator = (string) get_parameter('serialized_separator', '|');
|
||||
@ -121,7 +139,7 @@ if (is_ajax()) {
|
||||
$filter['status'] = $status_agents;
|
||||
}
|
||||
|
||||
// Juanma (22/05/2014) Fix: If remove void agents setted
|
||||
// Juanma (22/05/2014) Fix: If remove void agents set.
|
||||
$_sql_post = ' 1=1 ';
|
||||
if ($show_void_agents == 0) {
|
||||
$_sql_post .= ' AND id_agente IN (SELECT a.id_agente FROM tagente a, tagente_modulo b WHERE a.id_agente=b.id_agente AND b.delete_pending=0) AND \'1\'';
|
||||
@ -131,8 +149,9 @@ if (is_ajax()) {
|
||||
$id_groups_get_agents = $id_group;
|
||||
if ($id_group == 0 && $privilege != '') {
|
||||
$groups = users_get_groups($config['id_user'], $privilege, false);
|
||||
// if group ID doesn't matter and $privilege is specified (like 'AW'),
|
||||
// retruns all agents that current user has $privilege privilege for.
|
||||
// If group ID doesn't matter and $privilege is specified
|
||||
// (like 'AW'), retruns all agents that current user has $privilege
|
||||
// privilege for.
|
||||
$id_groups_get_agents = array_keys($groups);
|
||||
}
|
||||
|
||||
@ -149,13 +168,13 @@ if (is_ajax()) {
|
||||
);
|
||||
|
||||
$agents_disabled = [];
|
||||
// Add keys prefix
|
||||
// Add keys prefix.
|
||||
if ($keys_prefix !== '') {
|
||||
foreach ($agents as $k => $v) {
|
||||
$agents[$keys_prefix.$k] = $v;
|
||||
unset($agents[$k]);
|
||||
if ($all_agents) {
|
||||
// Unserialize to get the status
|
||||
// Unserialize to get the status.
|
||||
if ($serialized && is_metaconsole()) {
|
||||
$agent_info = explode($serialized_separator, $k);
|
||||
$agent_disabled = db_get_value_filter(
|
||||
@ -174,7 +193,8 @@ if (is_ajax()) {
|
||||
['id_agente' => $agent_info[1]]
|
||||
);
|
||||
} else if (!$serialized && is_metaconsole()) {
|
||||
// Cannot retrieve the disabled status. Mark all as not disabled
|
||||
// Cannot retrieve the disabled status.
|
||||
// Mark all as not disabled.
|
||||
$agent_disabled = 0;
|
||||
} else {
|
||||
$agent_disabled = db_get_value_filter(
|
||||
@ -226,11 +246,13 @@ if (! check_acl($config['id_user'], 0, 'PM')) {
|
||||
}
|
||||
|
||||
$sec = defined('METACONSOLE') ? 'advanced' : 'gagente';
|
||||
$url_tree = "index.php?sec=$sec&sec2=godmode/groups/group_list&tab=tree";
|
||||
$url_groups = "index.php?sec=$sec&sec2=godmode/groups/group_list&tab=groups";
|
||||
$url_credbox = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=credbox';
|
||||
$url_tree = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=tree';
|
||||
$url_groups = 'index.php?sec='.$sec.'&sec2=godmode/groups/group_list&tab=groups';
|
||||
|
||||
$buttons['tree'] = [
|
||||
'active' => false,
|
||||
'text' => "<a href='$url_tree'>".html_print_image(
|
||||
'text' => '<a href="'.$url_tree.'">'.html_print_image(
|
||||
'images/gm_massive_operations.png',
|
||||
true,
|
||||
[
|
||||
@ -241,7 +263,7 @@ $buttons['tree'] = [
|
||||
|
||||
$buttons['groups'] = [
|
||||
'active' => false,
|
||||
'text' => "<a href='$url_groups'>".html_print_image(
|
||||
'text' => '<a href="'.$url_groups.'">'.html_print_image(
|
||||
'images/group.png',
|
||||
true,
|
||||
[
|
||||
@ -250,21 +272,38 @@ $buttons['groups'] = [
|
||||
).'</a>',
|
||||
];
|
||||
|
||||
$buttons['credbox'] = [
|
||||
'active' => false,
|
||||
'text' => '<a href="'.$url_credbox.'">'.html_print_image(
|
||||
'images/key.png',
|
||||
true,
|
||||
[
|
||||
'title' => __('Credential Store'),
|
||||
]
|
||||
).'</a>',
|
||||
];
|
||||
|
||||
$tab = (string) get_parameter('tab', 'groups');
|
||||
|
||||
// Marks correct tab
|
||||
$title = __('Groups defined in %s', get_product_name());
|
||||
// Marks correct tab.
|
||||
switch ($tab) {
|
||||
case 'tree':
|
||||
$buttons['tree']['active'] = true;
|
||||
break;
|
||||
|
||||
case 'credbox':
|
||||
$buttons['credbox']['active'] = true;
|
||||
$title = __('Credential store');
|
||||
break;
|
||||
|
||||
case 'groups':
|
||||
default:
|
||||
$buttons['groups']['active'] = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// Header
|
||||
// Header.
|
||||
if (defined('METACONSOLE')) {
|
||||
agents_meta_print_header();
|
||||
echo '<div class="notify">';
|
||||
@ -272,7 +311,7 @@ if (defined('METACONSOLE')) {
|
||||
echo '</div>';
|
||||
} else {
|
||||
ui_print_page_header(
|
||||
__('Groups defined in %s', get_product_name()),
|
||||
$title,
|
||||
'images/group.png',
|
||||
false,
|
||||
'group_list_tab',
|
||||
@ -281,12 +320,19 @@ if (defined('METACONSOLE')) {
|
||||
);
|
||||
}
|
||||
|
||||
// Load credential store view before parse list-tree forms.
|
||||
if ($tab == 'credbox') {
|
||||
include_once __DIR__.'/credential_store.php';
|
||||
// Stop script.
|
||||
return;
|
||||
}
|
||||
|
||||
$create_group = (bool) get_parameter('create_group');
|
||||
$update_group = (bool) get_parameter('update_group');
|
||||
$delete_group = (bool) get_parameter('delete_group');
|
||||
$pure = get_parameter('pure', 0);
|
||||
|
||||
// Create group
|
||||
// Create group.
|
||||
if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
$name = (string) get_parameter('name');
|
||||
$icon = (string) get_parameter('icon');
|
||||
@ -301,7 +347,7 @@ if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
$check = db_get_value('nombre', 'tgrupo', 'nombre', $name);
|
||||
$propagate = (bool) get_parameter('propagate');
|
||||
|
||||
// Check if name field is empty
|
||||
// Check if name field is empty.
|
||||
if ($name != '') {
|
||||
if (!$check) {
|
||||
$values = [
|
||||
@ -328,12 +374,11 @@ if (($create_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
ui_print_error_message(__('Each group must have a different name'));
|
||||
}
|
||||
} else {
|
||||
// $result = false;
|
||||
ui_print_error_message(__('Group must have a name'));
|
||||
}
|
||||
}
|
||||
|
||||
// Update group
|
||||
// Update group.
|
||||
if ($update_group) {
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
$name = (string) get_parameter('name');
|
||||
@ -349,49 +394,35 @@ if ($update_group) {
|
||||
$contact = (string) get_parameter('contact');
|
||||
$other = (string) get_parameter('other');
|
||||
|
||||
// Check if name field is empty
|
||||
// Check if name field is empty.
|
||||
if ($name != '') {
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
$sql = sprintf(
|
||||
'UPDATE tgrupo SET nombre = "%s",
|
||||
icon = "%s", disabled = %d, parent = %d, custom_id = "%s", propagate = %d, id_skin = %d, description = "%s", contact = "%s", other = "%s", password = "%s"
|
||||
WHERE id_grupo = %d',
|
||||
$name,
|
||||
empty($icon) ? '' : substr($icon, 0, -4),
|
||||
!$alerts_enabled,
|
||||
$id_parent,
|
||||
$custom_id,
|
||||
$propagate,
|
||||
$skin,
|
||||
$description,
|
||||
$contact,
|
||||
$other,
|
||||
$group_pass,
|
||||
$id_group
|
||||
);
|
||||
break;
|
||||
|
||||
case 'postgresql':
|
||||
case 'oracle':
|
||||
$sql = sprintf(
|
||||
'UPDATE tgrupo SET nombre = \'%s\',
|
||||
icon = \'%s\', disabled = %d, parent = %d, custom_id = \'%s\', propagate = %d, id_skin = %d, description = \'%s\', contact = \'%s\', other = \'%s\'
|
||||
WHERE id_grupo = %d',
|
||||
$name,
|
||||
substr($icon, 0, -4),
|
||||
!$alerts_enabled,
|
||||
$id_parent,
|
||||
$custom_id,
|
||||
$propagate,
|
||||
$skin,
|
||||
$description,
|
||||
$contact,
|
||||
$other,
|
||||
$id_group
|
||||
);
|
||||
break;
|
||||
}
|
||||
$sql = sprintf(
|
||||
'UPDATE tgrupo
|
||||
SET nombre = "%s",
|
||||
icon = "%s",
|
||||
disabled = %d,
|
||||
parent = %d,
|
||||
custom_id = "%s",
|
||||
propagate = %d,
|
||||
id_skin = %d,
|
||||
description = "%s",
|
||||
contact = "%s",
|
||||
other = "%s",
|
||||
password = "%s"
|
||||
WHERE id_grupo = %d',
|
||||
$name,
|
||||
empty($icon) ? '' : substr($icon, 0, -4),
|
||||
!$alerts_enabled,
|
||||
$id_parent,
|
||||
$custom_id,
|
||||
$propagate,
|
||||
$skin,
|
||||
$description,
|
||||
$contact,
|
||||
$other,
|
||||
$group_pass,
|
||||
$id_group
|
||||
);
|
||||
|
||||
$result = db_process_sql($sql);
|
||||
} else {
|
||||
@ -405,7 +436,7 @@ if ($update_group) {
|
||||
}
|
||||
}
|
||||
|
||||
// Delete group
|
||||
// Delete group.
|
||||
if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
|
||||
@ -445,7 +476,14 @@ if (($delete_group) && (check_acl($config['id_user'], 0, 'PM'))) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Credential store is loaded previously in this document to avoid
|
||||
// process group tree - list forms.
|
||||
if ($tab == 'tree') {
|
||||
/*
|
||||
* Group tree view.
|
||||
*/
|
||||
|
||||
echo html_print_image(
|
||||
'images/spinner.gif',
|
||||
true,
|
||||
@ -456,6 +494,10 @@ if ($tab == 'tree') {
|
||||
);
|
||||
echo "<div id='tree-controller-recipient'></div>";
|
||||
} else {
|
||||
/*
|
||||
* Group list view.
|
||||
*/
|
||||
|
||||
$acl = '';
|
||||
$search_name = '';
|
||||
$offset = (int) get_parameter('offset', 0);
|
||||
@ -463,17 +505,22 @@ if ($tab == 'tree') {
|
||||
$block_size = $config['block_size'];
|
||||
|
||||
if (!empty($search)) {
|
||||
$search_name = "AND t.nombre LIKE '%$search%'";
|
||||
$search_name = 'AND t.nombre LIKE "%'.$search.'%"';
|
||||
}
|
||||
|
||||
if (!users_can_manage_group_all('AR')) {
|
||||
$user_groups_acl = users_get_groups(false, 'AR');
|
||||
$groups_acl = implode(',', $user_groups_ACL);
|
||||
if (empty($groups_acl)) {
|
||||
return ui_print_info_message(['no_close' => true, 'message' => __('There are no defined groups') ]);
|
||||
return ui_print_info_message(
|
||||
[
|
||||
'no_close' => true,
|
||||
'message' => __('There are no defined groups'),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
$acl = "AND t.id_grupo IN ($groups_acl)";
|
||||
$acl = 'AND t.id_grupo IN ('.$groups_acl.')';
|
||||
}
|
||||
|
||||
$form = "<form method='post' action=''>";
|
||||
@ -488,29 +535,37 @@ if ($tab == 'tree') {
|
||||
|
||||
echo $form;
|
||||
|
||||
$groups_sql = "SELECT t.*,
|
||||
$groups_sql = sprintf(
|
||||
'SELECT t.*,
|
||||
p.nombre AS parent_name,
|
||||
IF(t.parent=p.id_grupo, 1, 0) AS has_child
|
||||
FROM tgrupo t
|
||||
LEFT JOIN tgrupo p
|
||||
FROM tgrupo t
|
||||
LEFT JOIN tgrupo p
|
||||
ON t.parent=p.id_grupo
|
||||
WHERE 1=1
|
||||
$acl
|
||||
$search_name
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
ORDER BY nombre
|
||||
LIMIT $offset, $block_size
|
||||
";
|
||||
LIMIT %d, %d',
|
||||
$acl,
|
||||
$search_name,
|
||||
$offset,
|
||||
$block_size
|
||||
);
|
||||
|
||||
$groups = db_get_all_rows_sql($groups_sql);
|
||||
|
||||
if (!empty($groups)) {
|
||||
// Count all groups for pagination only saw user and filters
|
||||
$groups_sql_count = "SELECT count(*)
|
||||
// Count all groups for pagination only saw user and filters.
|
||||
$groups_sql_count = sprintf(
|
||||
'SELECT count(*)
|
||||
FROM tgrupo t
|
||||
WHERE 1=1
|
||||
$acl
|
||||
$search_name
|
||||
";
|
||||
%s
|
||||
%s',
|
||||
$acl,
|
||||
$search_name
|
||||
);
|
||||
$groups_count = db_get_value_sql($groups_sql_count);
|
||||
|
||||
$table = new StdClass();
|
||||
@ -545,7 +600,7 @@ if ($tab == 'tree') {
|
||||
$url = 'index.php?sec=gagente&sec2=godmode/groups/configure_group&id_group='.$group['id_grupo'];
|
||||
$url_delete = 'index.php?sec=gagente&sec2=godmode/groups/group_list&delete_group=1&id_group='.$group['id_grupo'];
|
||||
$table->data[$key][0] = $group['id_grupo'];
|
||||
$table->data[$key][1] = "<a href='$url'>".$group['nombre'].'</a>';
|
||||
$table->data[$key][1] = '<a href="'.$url.'">'.$group['nombre'].'</a>';
|
||||
if ($group['icon'] != '') {
|
||||
$table->data[$key][2] = html_print_image(
|
||||
'images/groups_small/'.$group['icon'].'.png',
|
||||
@ -553,22 +608,25 @@ if ($tab == 'tree') {
|
||||
[
|
||||
'style' => '',
|
||||
'class' => 'bot',
|
||||
'alt' => $group['nombre'],
|
||||
'alt' => $group['nombre'],
|
||||
'title' => $group['nombre'],
|
||||
false, false, false, true
|
||||
]
|
||||
],
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
$table->data[$key][2] = '';
|
||||
}
|
||||
|
||||
|
||||
// reporting_get_group_stats
|
||||
$table->data[$key][3] = $group['disabled'] ? __('Disabled') : __('Enabled');
|
||||
// Reporting_get_group_stats.
|
||||
$table->data[$key][3] = ($group['disabled']) ? __('Disabled') : __('Enabled');
|
||||
$table->data[$key][4] = $group['parent_name'];
|
||||
$table->data[$key][5] = $group['description'];
|
||||
$table->cellclass[$key][6] = 'action_buttons';
|
||||
$table->data[$key][6] = "<a href='$url'>".html_print_image(
|
||||
$table->data[$key][6] = '<a href="'.$url.'">'.html_print_image(
|
||||
'images/config.png',
|
||||
true,
|
||||
[
|
||||
|
@ -208,7 +208,7 @@ if (!empty($sub)) {
|
||||
}
|
||||
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'PM') || check_acl($config['id_user'], 0, 'RR')) {
|
||||
if (check_acl($config['id_user'], 0, 'AW') || check_acl($config['id_user'], 0, 'PM')) {
|
||||
// Servers
|
||||
$menu_godmode['gservers']['text'] = __('Servers');
|
||||
$menu_godmode['gservers']['sec2'] = 'godmode/servers/modificar_server';
|
||||
|
@ -254,10 +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;
|
||||
if (selectedItem == "static_graph") {
|
||||
if (values["map_linked"] == 0) {
|
||||
if (values["agent"] == "" || values["agent"] == "none") {
|
||||
dialog_message("#message_alert_no_agent");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// TODO VALIDATE DATA
|
||||
|
@ -130,5 +130,11 @@ if ($classname_selected === null) {
|
||||
}
|
||||
}
|
||||
|
||||
// Show hints if there is no task
|
||||
if (get_parameter('discovery_hint', 0)) {
|
||||
ui_require_css_file('discovery-hint');
|
||||
ui_print_info_message(__('You must create a task first'));
|
||||
}
|
||||
|
||||
Wizard::printBigButtonsList($wiz_data);
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ if (($create != '') || ($view != '')) {
|
||||
} else {
|
||||
if ($create != '') {
|
||||
ui_print_page_header(
|
||||
__('Plugin creation'),
|
||||
__('Plugin registration'),
|
||||
'images/gm_servers.png',
|
||||
false,
|
||||
'plugin_definition',
|
||||
|
@ -1113,15 +1113,6 @@ $row++;
|
||||
|
||||
|
||||
|
||||
$table_other->data[$row][0] = __('Show QR Code icon in the header');
|
||||
$table_other->data[$row][1] = html_print_checkbox_switch(
|
||||
'show_qr_code_header',
|
||||
1,
|
||||
$config['show_qr_code_header'],
|
||||
true
|
||||
);
|
||||
$row++;
|
||||
|
||||
$table_other->data[$row][0] = __('Custom graphviz directory').ui_print_help_tip(__('Custom directory where the graphviz binaries are stored.'), true);
|
||||
$table_other->data[$row][1] = html_print_input_text(
|
||||
'graphviz_bin_dir',
|
||||
|
@ -699,7 +699,7 @@ class DiscoveryTaskList extends Wizard
|
||||
if ($script !== false) {
|
||||
switch ($script['type']) {
|
||||
case DISCOVERY_SCRIPT_CLOUD_AWS:
|
||||
return 'wiz=cloud&mode=amazonws&page=1';
|
||||
return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&page=1';
|
||||
|
||||
case DISCOVERY_SCRIPT_APP_VMWARE:
|
||||
return 'wiz=app&mode=vmware&page=0';
|
||||
@ -722,7 +722,7 @@ class DiscoveryTaskList extends Wizard
|
||||
|
||||
case DISCOVERY_CLOUD_AWS:
|
||||
case DISCOVERY_CLOUD_AWS_EC2:
|
||||
return 'wiz=cloud&mode=amazonws&page=1';
|
||||
return 'wiz=cloud&mode=amazonws&ki='.$task['auth_strings'].'&page=1';
|
||||
|
||||
case DISCOVERY_CLOUD_AWS_RDS:
|
||||
return 'wiz=cloud&mode=amazonws&sub=rds&page=0';
|
||||
|
@ -1048,7 +1048,7 @@ class Wizard
|
||||
*/
|
||||
public static function printBigButtonsList($list_data)
|
||||
{
|
||||
echo '<ul>';
|
||||
echo '<ul class="bigbuttonlist">';
|
||||
array_map('self::printBigButtonElement', $list_data);
|
||||
echo '</ul>';
|
||||
}
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 387 KiB After Width: | Height: | Size: 18 KiB |
Binary file not shown.
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 17 KiB |
@ -75,13 +75,73 @@ $graphic_event_group = (bool) get_parameter('graphic_event_group');
|
||||
$get_table_response_command = (bool) get_parameter('get_table_response_command');
|
||||
$save_filter_modal = get_parameter('save_filter_modal', 0);
|
||||
$load_filter_modal = get_parameter('load_filter_modal', 0);
|
||||
$save_filter = get_parameter('save_filter', 0);
|
||||
$get_filter_values = get_parameter('get_filter_values', 0);
|
||||
$update_event_filter = get_parameter('update_event_filter', 0);
|
||||
$save_event_filter = get_parameter('save_event_filter', 0);
|
||||
$in_process_event = get_parameter('in_process_event', 0);
|
||||
$validate_event = get_parameter('validate_event', 0);
|
||||
$delete_event = get_parameter('delete_event', 0);
|
||||
$get_event_filters = get_parameter('get_event_filters', 0);
|
||||
$get_comments = get_parameter('get_comments', 0);
|
||||
|
||||
if ($get_comments) {
|
||||
$event = get_parameter('event', false);
|
||||
$filter = get_parameter('filter', false);
|
||||
|
||||
if ($event === false) {
|
||||
return __('Failed to retrieve comments');
|
||||
}
|
||||
|
||||
if ($filter['group_rep'] == 1) {
|
||||
$events = events_get_all(
|
||||
['te.*'],
|
||||
// Filter.
|
||||
$filter,
|
||||
// Offset.
|
||||
null,
|
||||
// Limit.
|
||||
null,
|
||||
// Order.
|
||||
null,
|
||||
// Sort_field.
|
||||
null,
|
||||
// History.
|
||||
$filter['history'],
|
||||
// Return_sql.
|
||||
false,
|
||||
// Having.
|
||||
sprintf(
|
||||
' HAVING max_id_evento = %d',
|
||||
$event['id_evento']
|
||||
)
|
||||
);
|
||||
if ($events !== false) {
|
||||
$event = $events[0];
|
||||
}
|
||||
} else {
|
||||
$events = events_get_event(
|
||||
$event['id_evento'],
|
||||
false,
|
||||
$meta,
|
||||
$history
|
||||
);
|
||||
|
||||
if ($events !== false) {
|
||||
$event = $events[0];
|
||||
}
|
||||
}
|
||||
|
||||
echo events_page_comments($event, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ($get_event_filters) {
|
||||
$event_filter = events_get_event_filter_select();
|
||||
|
||||
echo io_json_mb_encode($event_filter);
|
||||
return;
|
||||
}
|
||||
|
||||
// Delete event (filtered or not).
|
||||
if ($delete_event) {
|
||||
@ -267,6 +327,17 @@ if ($get_filter_values) {
|
||||
|
||||
$event_filter = events_get_event_filter($id_filter);
|
||||
|
||||
if ($event_filter === false) {
|
||||
$event_filter = [
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
];
|
||||
}
|
||||
|
||||
$event_filter['search'] = io_safe_output($event_filter['search']);
|
||||
$event_filter['id_name'] = io_safe_output($event_filter['id_name']);
|
||||
$event_filter['tag_with'] = base64_encode(
|
||||
@ -590,7 +661,7 @@ function save_new_filter() {
|
||||
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{
|
||||
"page" : "operation/events/events_list",
|
||||
"page" : "include/ajax/events",
|
||||
"save_event_filter" : 1,
|
||||
"id_name" : $("#text-id_name").val(),
|
||||
"id_group" : $("select#id_group").val(),
|
||||
@ -659,7 +730,7 @@ function save_update_filter() {
|
||||
var name_filter_update = $("#overwrite_filter option[value='"+id_filter_update+"']").text();
|
||||
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{"page" : "operation/events/events_list",
|
||||
{"page" : "include/ajax/events",
|
||||
"update_event_filter" : 1,
|
||||
"id" : $("#overwrite_filter").val(),
|
||||
"id_group" : $("select#id_group").val(),
|
||||
@ -712,7 +783,7 @@ function save_update_filter() {
|
||||
$('#filter_id').append ($('<option></option>').html ( <?php echo "'".__('none')."'"; ?> ).attr ("value", 0));
|
||||
// Reload filters select
|
||||
jQuery.post ("<?php echo ui_get_full_url('ajax.php', false, false, false); ?>",
|
||||
{"page" : "operation/events/events_list",
|
||||
{"page" : "include/ajax/events",
|
||||
"get_event_filters" : 1
|
||||
},
|
||||
function (data) {
|
||||
@ -1040,6 +1111,7 @@ if ($get_extended_event) {
|
||||
global $config;
|
||||
|
||||
$event = get_parameter('event', false);
|
||||
$filter = get_parameter('filter', false);
|
||||
|
||||
if ($event === false) {
|
||||
return;
|
||||
@ -1079,29 +1151,37 @@ if ($get_extended_event) {
|
||||
}
|
||||
|
||||
// Check ACLs.
|
||||
$access = false;
|
||||
if (is_user_admin($config['id_user'])) {
|
||||
// Do nothing if you're admin, you get full access.
|
||||
$__ignored_line = 0;
|
||||
$access = true;
|
||||
} else if ($config['id_user'] == $event['owner_user']) {
|
||||
// Do nothing if you're the owner user, you get access.
|
||||
$__ignored_line = 0;
|
||||
$access = true;
|
||||
} else if ($event['id_grupo'] == 0) {
|
||||
// If the event has access to all groups, you get access.
|
||||
$__ignored_line = 0;
|
||||
$access = true;
|
||||
} else {
|
||||
// Get your groups.
|
||||
$groups = users_get_groups($config['id_user'], 'ER');
|
||||
|
||||
if (in_array($event['id_grupo'], array_keys($groups))) {
|
||||
// If event group is among the groups of the user, you get access.
|
||||
$__ignored_line = 0;
|
||||
} else {
|
||||
// If all the access types fail, abort.
|
||||
echo 'Access denied';
|
||||
return false;
|
||||
$access = true;
|
||||
} else if ($event['id_agente']
|
||||
&& agents_check_access_agent($event['id_agente'], 'ER')
|
||||
) {
|
||||
// Secondary group, indirect access.
|
||||
$access = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!$access) {
|
||||
// If all the access types fail, abort.
|
||||
echo 'Access denied';
|
||||
return false;
|
||||
}
|
||||
|
||||
// Print group_rep in a hidden field to recover it from javascript.
|
||||
html_print_input_hidden('group_rep', (int) $group_rep);
|
||||
|
||||
@ -1227,7 +1307,7 @@ if ($get_extended_event) {
|
||||
|
||||
$general = events_page_general($event);
|
||||
|
||||
$comments = events_page_comments($event);
|
||||
$comments = '<div id="extended_event_comments_page" class="extended_event_pages"></div>';
|
||||
|
||||
$notifications = '<div id="notification_comment_error" style="display:none">'.ui_print_error_message(__('Error adding comment'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_comment_success" style="display:none">'.ui_print_success_message(__('Comment added successfully'), '', true).'</div>';
|
||||
@ -1238,6 +1318,18 @@ if ($get_extended_event) {
|
||||
|
||||
$loading = '<div id="response_loading" style="display:none">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
|
||||
$i = 0;
|
||||
$tab['general'] = $i++;
|
||||
$tab['details'] = $i++;
|
||||
if (!empty($related)) {
|
||||
$tab['related'] = $i++;
|
||||
}
|
||||
|
||||
$tab['custom_fields'] = $i++;
|
||||
$tab['comments'] = $i++;
|
||||
$tab['responses'] = $i++;
|
||||
$tab['custom_data'] = $i++;
|
||||
|
||||
$out = '<div id="tabs">'.$tabs.$notifications.$loading.$general.$details.$related.$custom_fields.$comments.$responses.$custom_data.html_print_input_hidden('id_event', $event['id_evento']).'</div>';
|
||||
|
||||
$js = '<script>
|
||||
@ -1249,31 +1341,31 @@ if ($get_extended_event) {
|
||||
// Load the required tab.
|
||||
switch ($dialog_page) {
|
||||
case 'general':
|
||||
$js .= '$tabs.tabs( "option", "active", 0);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['general'].');';
|
||||
break;
|
||||
|
||||
case 'details':
|
||||
$js .= '$tabs.tabs( "option", "active", 1);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['details'].');';
|
||||
break;
|
||||
|
||||
case 'related':
|
||||
$js .= '$tabs.tabs( "option", "active", 2);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['related'].');';
|
||||
break;
|
||||
|
||||
case 'custom_fields':
|
||||
$js .= '$tabs.tabs( "option", "active", 3);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['custom_fields'].');';
|
||||
break;
|
||||
|
||||
case 'comments':
|
||||
$js .= '$tabs.tabs( "option", "active", 4);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['comments'].');';
|
||||
break;
|
||||
|
||||
case 'responses':
|
||||
$js .= '$tabs.tabs( "option", "active", 5);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['responses'].');';
|
||||
break;
|
||||
|
||||
case 'custom_data':
|
||||
$js .= '$tabs.tabs( "option", "active", 6);';
|
||||
$js .= '$tabs.tabs( "option", "active", '.$tab['custom_data'].');';
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -1283,6 +1375,24 @@ if ($get_extended_event) {
|
||||
|
||||
$js .= '});';
|
||||
|
||||
$js .= '
|
||||
$("#link_comments").click(function (){
|
||||
$.post ({
|
||||
url : "ajax.php",
|
||||
data : {
|
||||
page: "include/ajax/events",
|
||||
get_comments: 1,
|
||||
event: '.json_encode($event).',
|
||||
filter: '.json_encode($filter).'
|
||||
},
|
||||
dataType : "html",
|
||||
success: function (data) {
|
||||
$("#extended_event_comments_page").empty();
|
||||
$("#extended_event_comments_page").html(data);
|
||||
}
|
||||
});
|
||||
});';
|
||||
|
||||
if (events_has_extended_info($event['id_evento']) === true) {
|
||||
$js .= '
|
||||
$("#link_related").click(function (){
|
||||
|
@ -1257,11 +1257,8 @@ function fill_permissions_ldap($sr)
|
||||
global $config;
|
||||
$permissions = [];
|
||||
$permissions_profile = [];
|
||||
if (defined('METACONSOLE')) {
|
||||
$meta = true;
|
||||
}
|
||||
|
||||
if ($meta && (bool) $config['ldap_save_profile'] === false && $config['ldap_advanced_config'] == 0) {
|
||||
if ((bool) $config['ldap_save_profile'] === false && ($config['ldap_advanced_config'] == 0 || $config['ldap_advanced_config'] == '')) {
|
||||
$result = 0;
|
||||
$result = db_get_all_rows_filter(
|
||||
'tusuario_perfil',
|
||||
@ -1287,43 +1284,9 @@ function fill_permissions_ldap($sr)
|
||||
return $permissions_profile;
|
||||
}
|
||||
|
||||
if ((bool) $config['ldap_save_profile'] === false && $config['ldap_advanced_config'] == '') {
|
||||
$result = db_get_all_rows_filter(
|
||||
'tusuario_perfil',
|
||||
['id_usuario' => $sr['uid'][0]]
|
||||
);
|
||||
if ($result == false) {
|
||||
$permissions[0]['profile'] = $config['default_remote_profile'];
|
||||
$permissions[0]['groups'][] = $config['default_remote_group'];
|
||||
$permissions[0]['tags'] = $config['default_assign_tags'];
|
||||
$permissions[0]['no_hierarchy'] = $config['default_no_hierarchy'];
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
foreach ($result as $perms) {
|
||||
$permissions_profile[] = [
|
||||
'profile' => $perms['id_perfil'],
|
||||
'groups' => [$perms['id_grupo']],
|
||||
'tags' => $perms['tags'],
|
||||
'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
return $permissions_profile;
|
||||
}
|
||||
|
||||
if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 1) {
|
||||
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
|
||||
foreach ($ldap_adv_perms as $ldap_adv_perm) {
|
||||
$permissions[] = [
|
||||
'profile' => $ldap_adv_perm['profile'],
|
||||
'groups' => $ldap_adv_perm['group'],
|
||||
'tags' => implode(',', $ldap_adv_perm['tags']),
|
||||
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
return $permissions;
|
||||
return get_advanced_permissions($ldap_adv_perms, $sr);
|
||||
}
|
||||
|
||||
if ($config['ldap_advanced_config'] == 1 && $config['ldap_save_profile'] == 0) {
|
||||
@ -1333,25 +1296,16 @@ function fill_permissions_ldap($sr)
|
||||
);
|
||||
if ($result == false) {
|
||||
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
|
||||
foreach ($ldap_adv_perms as $ldap_adv_perm) {
|
||||
$permissions[] = [
|
||||
'profile' => $ldap_adv_perm['profile'],
|
||||
'groups' => $ldap_adv_perm['group'],
|
||||
'tags' => implode(',', $ldap_adv_perm['tags']),
|
||||
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
}
|
||||
|
||||
return $permissions;
|
||||
return get_advanced_permissions($ldap_adv_perms, $sr);
|
||||
}
|
||||
|
||||
foreach ($result as $perms) {
|
||||
$permissions_profile[] = [
|
||||
'profile' => $perms['id_perfil'],
|
||||
'groups' => [$perms['id_grupo']],
|
||||
'tags' => $perms['tags'],
|
||||
'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
$permissions_profile[] = [
|
||||
'profile' => $perms['id_perfil'],
|
||||
'groups' => [$perms['id_grupo']],
|
||||
'tags' => $perms['tags'],
|
||||
'no_hierarchy' => (bool) $perms['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
};
|
||||
|
||||
return $permissions_profile;
|
||||
@ -1365,22 +1319,43 @@ function fill_permissions_ldap($sr)
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
// Decode permissions in advanced mode
|
||||
$ldap_adv_perms = json_decode(io_safe_output($config['ldap_adv_perms']), true);
|
||||
return $permissions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get permissions in advanced mode.
|
||||
*
|
||||
* @param array ldap_adv_perms
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function get_advanced_permissions($ldap_adv_perms, $sr)
|
||||
{
|
||||
$permissions = [];
|
||||
foreach ($ldap_adv_perms as $ldap_adv_perm) {
|
||||
$attributes = $ldap_adv_perm['groups_ldap'];
|
||||
foreach ($attributes as $attr) {
|
||||
$attr = explode('=', $attr, 2);
|
||||
foreach ($sr[$attr[0]] as $s_attr) {
|
||||
if (preg_match('/'.$attr[1].'/', $s_attr)) {
|
||||
$permissions[] = [
|
||||
'profile' => $ldap_adv_perm['profile'],
|
||||
'groups' => $ldap_adv_perm['group'],
|
||||
'tags' => implode(',', $ldap_adv_perm['tags']),
|
||||
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
if (!empty($attributes[0])) {
|
||||
foreach ($attributes as $attr) {
|
||||
$attr = explode('=', $attr, 2);
|
||||
foreach ($sr[$attr[0]] as $s_attr) {
|
||||
if (preg_match('/'.$attr[1].'/', $s_attr)) {
|
||||
$permissions[] = [
|
||||
'profile' => $ldap_adv_perm['profile'],
|
||||
'groups' => $ldap_adv_perm['group'],
|
||||
'tags' => implode(',', $ldap_adv_perm['tags']),
|
||||
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$permissions[] = [
|
||||
'profile' => $ldap_adv_perm['profile'],
|
||||
'groups' => $ldap_adv_perm['group'],
|
||||
'tags' => implode(',', $ldap_adv_perm['tags']),
|
||||
'no_hierarchy' => (bool) $ldap_adv_perm['no_hierarchy'] ? 1 : 0,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
/**
|
||||
* Pandora build version and version
|
||||
*/
|
||||
$build_version = 'PC190624';
|
||||
$build_version = 'PC190626';
|
||||
$pandora_version = 'v7.0NG.735';
|
||||
|
||||
// Do not overwrite default timezone set if defined.
|
||||
|
@ -146,7 +146,7 @@ define('COL_NOTINIT', '#4a83f3');
|
||||
define('COL_UNKNOWN', '#B2B2B2');
|
||||
define('COL_DOWNTIME', '#976DB1');
|
||||
define('COL_IGNORED', '#DDD');
|
||||
define('COL_ALERTFIRED', '#FFA631');
|
||||
define('COL_ALERTFIRED', '#F36201');
|
||||
define('COL_MINOR', '#B2B2B2');
|
||||
define('COL_MAJOR', '#C97A4A');
|
||||
define('COL_INFORMATIONAL', '#E4E4E4');
|
||||
|
439
pandora_console/include/functions_credential_store.php
Normal file
439
pandora_console/include/functions_credential_store.php
Normal file
@ -0,0 +1,439 @@
|
||||
<?php
|
||||
/**
|
||||
* Credentials management auxiliary functions.
|
||||
*
|
||||
* @category Credentials management library.
|
||||
* @package Pandora FMS
|
||||
* @subpackage Opensource
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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 for 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Begin.
|
||||
|
||||
|
||||
/**
|
||||
* Returns an array with all the credentials matching filter and ACL.
|
||||
*
|
||||
* @param array $fields Fields array or 'count' keyword to retrieve count.
|
||||
* @param array $filter Filters to be applied.
|
||||
* @param integer $offset Offset (pagination).
|
||||
* @param integer $limit Limit (pagination).
|
||||
* @param string $order Sort order.
|
||||
* @param string $sort_field Sort field.
|
||||
*
|
||||
* @return array With all results or false if error.
|
||||
* @throws Exception On error.
|
||||
*/
|
||||
function credentials_get_all(
|
||||
$fields,
|
||||
array $filter,
|
||||
$offset=null,
|
||||
$limit=null,
|
||||
$order=null,
|
||||
$sort_field=null
|
||||
) {
|
||||
$sql_filters = [];
|
||||
$order_by = '';
|
||||
$pagination = '';
|
||||
|
||||
global $config;
|
||||
|
||||
$user_is_admin = users_is_admin();
|
||||
|
||||
if (!is_array($filter)) {
|
||||
error_log('[credential_get_all] Filter must be an array.');
|
||||
throw new Exception('[credential_get_all] Filter must be an array.');
|
||||
}
|
||||
|
||||
$count = false;
|
||||
if (!is_array($fields) && $fields == 'count') {
|
||||
$fields = ['cs.*'];
|
||||
$count = true;
|
||||
} else if (!is_array($fields)) {
|
||||
error_log('[credential_get_all] Fields must be an array or "count".');
|
||||
throw new Exception('[credential_get_all] Fields must be an array or "count".');
|
||||
}
|
||||
|
||||
if (isset($filter['free_search']) && !empty($filter['free_search'])) {
|
||||
$sql_filters[] = vsprintf(
|
||||
' AND (lower(cs.username) like lower("%%%s%%")
|
||||
OR cs.identifier like "%%%s%%"
|
||||
OR lower(cs.product) like lower("%%%s%%"))',
|
||||
array_fill(0, 3, $filter['free_search'])
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($filter['filter_id_group']) && $filter['filter_id_group'] > 0) {
|
||||
$propagate = db_get_value(
|
||||
'propagate',
|
||||
'tgrupo',
|
||||
'id_grupo',
|
||||
$filter['filter_id_group']
|
||||
);
|
||||
|
||||
if (!$propagate) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND cs.id_group = %d ',
|
||||
$filter['filter_id_group']
|
||||
);
|
||||
} else {
|
||||
$groups = [ $filter['filter_id_group'] ];
|
||||
$childrens = groups_get_childrens($id_group, null, true);
|
||||
if (!empty($childrens)) {
|
||||
foreach ($childrens as $child) {
|
||||
$groups[] = (int) $child['id_grupo'];
|
||||
}
|
||||
}
|
||||
|
||||
$filter['filter_id_group'] = $groups;
|
||||
$sql_filters[] = sprintf(
|
||||
' AND cs.id_group IN (%s) ',
|
||||
join(',', $filter['filter_id_group'])
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($filter['group_list']) && is_array($filter['group_list'])) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND cs.id_group IN (%s) ',
|
||||
join(',', $filter['group_list'])
|
||||
);
|
||||
}
|
||||
|
||||
if (isset($order)) {
|
||||
$dir = 'asc';
|
||||
if ($order == 'desc') {
|
||||
$dir = 'desc';
|
||||
};
|
||||
|
||||
if (in_array(
|
||||
$sort_field,
|
||||
[
|
||||
'group',
|
||||
'identifier',
|
||||
'product',
|
||||
'username',
|
||||
'options',
|
||||
]
|
||||
)
|
||||
) {
|
||||
$order_by = sprintf(
|
||||
'ORDER BY `%s` %s',
|
||||
$sort_field,
|
||||
$dir
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($limit) && $limit > 0
|
||||
&& isset($offset) && $offset >= 0
|
||||
) {
|
||||
$pagination = sprintf(
|
||||
' LIMIT %d OFFSET %d ',
|
||||
$limit,
|
||||
$offset
|
||||
);
|
||||
}
|
||||
|
||||
$sql = sprintf(
|
||||
'SELECT %s
|
||||
FROM tcredential_store cs
|
||||
LEFT JOIN tgrupo tg
|
||||
ON tg.id_grupo = cs.id_group
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
%s',
|
||||
join(',', $fields),
|
||||
join(',', $sql_filters),
|
||||
$order_by,
|
||||
$pagination
|
||||
);
|
||||
|
||||
if ($count) {
|
||||
$sql = sprintf('SELECT count(*) as n FROM ( %s ) tt', $sql);
|
||||
|
||||
return db_get_value_sql($sql);
|
||||
}
|
||||
|
||||
return db_get_all_rows_sql($sql);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieves target key from keystore or false in case of error.
|
||||
*
|
||||
* @param string $identifier Key identifier.
|
||||
*
|
||||
* @return array Key or false if error.
|
||||
*/
|
||||
function get_key($identifier)
|
||||
{
|
||||
return db_get_row_filter(
|
||||
'tcredential_store',
|
||||
[ 'identifier' => $identifier ]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Minor function to dump json message as ajax response.
|
||||
*
|
||||
* @param string $type Type: result || error.
|
||||
* @param string $msg Message.
|
||||
* @param boolean $delete Deletion messages.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function ajax_msg($type, $msg, $delete=false)
|
||||
{
|
||||
$msg_err = 'Failed while saving: %s';
|
||||
$msg_ok = 'Successfully saved into keystore ';
|
||||
|
||||
if ($delete) {
|
||||
$msg_err = 'Failed while removing: %s';
|
||||
$msg_ok = 'Successfully deleted ';
|
||||
}
|
||||
|
||||
if ($type == 'error') {
|
||||
echo json_encode(
|
||||
[
|
||||
$type => ui_print_error_message(
|
||||
__(
|
||||
$msg_err,
|
||||
$msg
|
||||
),
|
||||
'',
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
} else {
|
||||
echo json_encode(
|
||||
[
|
||||
$type => ui_print_success_message(
|
||||
__(
|
||||
$msg_ok,
|
||||
$msg
|
||||
),
|
||||
'',
|
||||
true
|
||||
),
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates inputs for new/update forms.
|
||||
*
|
||||
* @param array $values Values or null.
|
||||
*
|
||||
* @return string Inputs.
|
||||
*/
|
||||
function print_inputs($values=null)
|
||||
{
|
||||
if (!is_array($values)) {
|
||||
$values = [];
|
||||
}
|
||||
|
||||
$return = '';
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => __('Identifier'),
|
||||
'name' => 'identifier',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'value' => $values['identifier'],
|
||||
'disabled' => (bool) $values['identifier'],
|
||||
'return' => true,
|
||||
'script' => 'alert(\'puta\')',
|
||||
]
|
||||
);
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => __('Group'),
|
||||
'name' => 'id_group',
|
||||
'id' => 'id_group',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select_groups',
|
||||
'selected' => $values['id_group'],
|
||||
'return' => true,
|
||||
'class' => 'w50p',
|
||||
]
|
||||
);
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => __('Product'),
|
||||
'name' => 'product',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'select',
|
||||
'script' => 'calculate_inputs()',
|
||||
'fields' => [
|
||||
// 'CUSTOM' => __('Custom'),
|
||||
'AWS' => __('Aws'),
|
||||
// 'AZURE' => __('Azure'),
|
||||
// 'GOOGLE' => __('Google'),
|
||||
],
|
||||
'selected' => $values['product'],
|
||||
'disabled' => (bool) $values['product'],
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
$user_label = __('Username');
|
||||
$pass_label = __('Password');
|
||||
$extra_1_label = __('Extra');
|
||||
$extra_2_label = __('Extra (2)');
|
||||
$extra1 = true;
|
||||
$extra2 = true;
|
||||
|
||||
// Remember to update credential_store.php also.
|
||||
switch ($values['product']) {
|
||||
case 'AWS':
|
||||
$user_label = __('Access key ID');
|
||||
$pass_label = __('Secret access key');
|
||||
$extra1 = false;
|
||||
$extra2 = false;
|
||||
break;
|
||||
|
||||
case 'AZURE':
|
||||
$user_label = __('Account ID');
|
||||
$pass_label = __('Password');
|
||||
$extra_1_label = __('Tenant or domain name');
|
||||
$extra_2_label = __('Subscription id');
|
||||
break;
|
||||
|
||||
case 'GOOGLE':
|
||||
// Need further investigation.
|
||||
case 'CUSTOM':
|
||||
default:
|
||||
// Use defaults.
|
||||
break;
|
||||
}
|
||||
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => $user_label,
|
||||
'name' => 'username',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'text',
|
||||
'value' => $values['username'],
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => $pass_label,
|
||||
'name' => 'password',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'password',
|
||||
'value' => $values['password'],
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
if ($extra1) {
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => $extra_1_label,
|
||||
'name' => 'extra_1',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'password',
|
||||
'value' => $values['extra_1'],
|
||||
'return' => true,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
if ($extra2) {
|
||||
$return .= html_print_input(
|
||||
[
|
||||
'label' => $extra_2_label,
|
||||
'name' => 'extra_2',
|
||||
'input_class' => 'flex-row',
|
||||
'type' => 'password',
|
||||
'value' => $values['extra_2'],
|
||||
'return' => true,
|
||||
'display' => $extra2,
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve all identifiers available for current user.
|
||||
*
|
||||
* @param string $product Target product.
|
||||
*
|
||||
* @return array Of account identifiers.
|
||||
*/
|
||||
function credentials_list_accounts($product)
|
||||
{
|
||||
global $config;
|
||||
|
||||
check_login();
|
||||
|
||||
include_once $config['homedir'].'/include/functions_users.php';
|
||||
|
||||
static $user_groups;
|
||||
|
||||
if (!isset($user_groups)) {
|
||||
$user_groups = users_get_groups(
|
||||
$config['id_user'],
|
||||
'AR'
|
||||
);
|
||||
|
||||
// Always add group 'ALL' because 'ALL' group credentials
|
||||
// must be available for all users.
|
||||
if (is_array($user_groups)) {
|
||||
$user_groups = ([0] + array_keys($user_groups));
|
||||
} else {
|
||||
$user_groups = [0];
|
||||
}
|
||||
}
|
||||
|
||||
$creds = credentials_get_all(
|
||||
['identifier'],
|
||||
[
|
||||
'product' => $product,
|
||||
'group_list' => $user_groups,
|
||||
]
|
||||
);
|
||||
|
||||
if ($creds === false) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$ret = array_reduce(
|
||||
$creds,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['identifier']] = $item['identifier'];
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
|
||||
return $ret;
|
||||
}
|
@ -184,7 +184,7 @@ function custom_graphs_search($id_group, $search)
|
||||
FROM tgraph_source
|
||||
WHERE id_graph = '.$graph['id_graph'].''
|
||||
);
|
||||
|
||||
$graphs[$graph['id_graph']]['id_graph'] = $graph['id_graph'];
|
||||
$graphs[$graph['id_graph']]['graphs_count'] = $graphsCount;
|
||||
$graphs[$graph['id_graph']]['name'] = $graph['name'];
|
||||
$graphs[$graph['id_graph']]['description'] = $graph['description'];
|
||||
|
@ -2023,3 +2023,58 @@ function db_check_minor_relase_available_to_um($package, $ent, $offline)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tries to get a lock with current name.
|
||||
*
|
||||
* @param string $lockname Lock name.
|
||||
* @param integer $expiration_time Expiration time.
|
||||
*
|
||||
* @return integer 1 - lock OK, able to continue executing
|
||||
* 0 - already locked by another process.
|
||||
* NULL: something really bad happened
|
||||
*/
|
||||
function db_get_lock($lockname, $expiration_time=86400)
|
||||
{
|
||||
$lock_status = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT IS_FREE_LOCK("%s")',
|
||||
$lockname
|
||||
)
|
||||
);
|
||||
|
||||
if ($lock_status == 1) {
|
||||
$lock_status = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT GET_LOCK("%s", %d)',
|
||||
$lockname,
|
||||
$expiration_time
|
||||
)
|
||||
);
|
||||
|
||||
return $lock_status;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Release a previously defined lock.
|
||||
*
|
||||
* @param string $lockname Lock name.
|
||||
*
|
||||
* @return integer 1 Lock released.
|
||||
* 0 cannot release (not owned).
|
||||
* NULL lock does not exist.
|
||||
*/
|
||||
function db_release_lock($lockname)
|
||||
{
|
||||
return db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT RELEASE_LOCK("%s")',
|
||||
$lockname
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -34,6 +34,143 @@ enterprise_include_once('meta/include/functions_agents_meta.php');
|
||||
enterprise_include_once('meta/include/functions_modules_meta.php');
|
||||
|
||||
|
||||
/**
|
||||
* Translates a numeric value module_status into descriptive text.
|
||||
*
|
||||
* @param integer $status Module status.
|
||||
*
|
||||
* @return string Descriptive text.
|
||||
*/
|
||||
function events_translate_module_status($status)
|
||||
{
|
||||
switch ($status) {
|
||||
case AGENT_MODULE_STATUS_NORMAL:
|
||||
return __('NORMAL');
|
||||
|
||||
case AGENT_MODULE_STATUS_CRITICAL_BAD:
|
||||
return __('CRITICAL');
|
||||
|
||||
case AGENT_MODULE_STATUS_NO_DATA:
|
||||
return __('NOT INIT');
|
||||
|
||||
case AGENT_MODULE_STATUS_CRITICAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_NORMAL_ALERT:
|
||||
case AGENT_MODULE_STATUS_WARNING_ALERT:
|
||||
return __('ALERT');
|
||||
|
||||
case AGENT_MODULE_STATUS_WARNING:
|
||||
return __('WARNING');
|
||||
|
||||
default:
|
||||
return __('UNKNOWN');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates a numeric value event_type into descriptive text.
|
||||
*
|
||||
* @param integer $event_type Event type.
|
||||
*
|
||||
* @return string Descriptive text.
|
||||
*/
|
||||
function events_translate_event_type($event_type)
|
||||
{
|
||||
// Event type prepared.
|
||||
switch ($event_type) {
|
||||
case EVENTS_ALERT_FIRED:
|
||||
case EVENTS_ALERT_RECOVERED:
|
||||
case EVENTS_ALERT_CEASED:
|
||||
case EVENTS_ALERT_MANUAL_VALIDATION:
|
||||
return __('ALERT');
|
||||
|
||||
case EVENTS_RECON_HOST_DETECTED:
|
||||
case EVENTS_SYSTEM:
|
||||
case EVENTS_ERROR:
|
||||
case EVENTS_NEW_AGENT:
|
||||
case EVENTS_CONFIGURATION_CHANGE:
|
||||
return __('SYSTEM');
|
||||
|
||||
case EVENTS_GOING_UP_WARNING:
|
||||
case EVENTS_GOING_DOWN_WARNING:
|
||||
return __('WARNING');
|
||||
|
||||
case EVENTS_GOING_DOWN_NORMAL:
|
||||
case EVENTS_GOING_UP_NORMAL:
|
||||
return __('NORMAL');
|
||||
|
||||
case EVENTS_GOING_DOWN_CRITICAL:
|
||||
case EVENTS_GOING_UP_CRITICAL:
|
||||
return __('CRITICAL');
|
||||
|
||||
case EVENTS_UNKNOWN:
|
||||
case EVENTS_GOING_UNKNOWN:
|
||||
default:
|
||||
return __('UNKNOWN');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates a numeric value event_status into descriptive text.
|
||||
*
|
||||
* @param integer $status Event status.
|
||||
*
|
||||
* @return string Descriptive text.
|
||||
*/
|
||||
function events_translate_event_status($status)
|
||||
{
|
||||
switch ($status) {
|
||||
case EVENT_STATUS_NEW:
|
||||
default:
|
||||
return __('NEW');
|
||||
|
||||
case EVENT_STATUS_INPROCESS:
|
||||
return __('IN PROCESS');
|
||||
|
||||
case EVENT_STATUS_VALIDATED:
|
||||
return __('VALIDATED');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Translates a numeric value criticity into descriptive text.
|
||||
*
|
||||
* @param integer $criticity Event criticity.
|
||||
*
|
||||
* @return string Descriptive text.
|
||||
*/
|
||||
function events_translate_event_criticity($criticity)
|
||||
{
|
||||
switch ($criticity) {
|
||||
case EVENT_CRIT_CRITICAL:
|
||||
return __('CRITICAL');
|
||||
|
||||
case EVENT_CRIT_MAINTENANCE:
|
||||
return __('MAINTENANCE');
|
||||
|
||||
case EVENT_CRIT_INFORMATIONAL:
|
||||
return __('INFORMATIONAL');
|
||||
|
||||
case EVENT_CRIT_MAJOR:
|
||||
return __('MAJOR');
|
||||
|
||||
case EVENT_CRIT_MINOR:
|
||||
return __('MINOR');
|
||||
|
||||
case EVENT_CRIT_NORMAL:
|
||||
return __('NORMAL');
|
||||
|
||||
case EVENT_CRIT_WARNING:
|
||||
return __('WARNING');
|
||||
|
||||
default:
|
||||
return __('UNKNOWN');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all header string for each event field.
|
||||
*
|
||||
@ -151,6 +288,9 @@ function events_get_column_name($field)
|
||||
case 'options':
|
||||
return __('Options');
|
||||
|
||||
case 'mini_severity':
|
||||
return 'S';
|
||||
|
||||
default:
|
||||
return __($field);
|
||||
}
|
||||
@ -641,32 +781,35 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($filter['id_group_filter']) && $filter['id_group_filter'] > 0) {
|
||||
$groups = $filter['id_group_filter'];
|
||||
if (isset($groups) && $groups > 0) {
|
||||
$propagate = db_get_value(
|
||||
'propagate',
|
||||
'tgrupo',
|
||||
'id_grupo',
|
||||
$filter['id_group_filter']
|
||||
$groups
|
||||
);
|
||||
|
||||
if (!$propagate) {
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_grupo = %d ',
|
||||
$filter['id_group_filter']
|
||||
' AND (te.id_grupo = %d OR tasg.id_group = %d)',
|
||||
$groups
|
||||
);
|
||||
} else {
|
||||
$groups = [ $filter['id_group_filter'] ];
|
||||
$childrens = groups_get_childrens($id_group, null, true);
|
||||
if (!empty($childrens)) {
|
||||
foreach ($childrens as $child) {
|
||||
$groups[] = (int) $child['id_grupo'];
|
||||
$children = groups_get_children($groups);
|
||||
$_groups = [ $groups ];
|
||||
if (!empty($children)) {
|
||||
foreach ($children as $child) {
|
||||
$_groups[] = (int) $child['id_grupo'];
|
||||
}
|
||||
}
|
||||
|
||||
$filter['id_group_filter'] = $groups;
|
||||
$groups = $_groups;
|
||||
|
||||
$sql_filters[] = sprintf(
|
||||
' AND id_group IN (%s) ',
|
||||
join(',', $filter['id_group_filter'])
|
||||
' AND (te.id_grupo IN (%s) OR tasg.id_group IN (%s))',
|
||||
join(',', $groups),
|
||||
join(',', $groups)
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -702,8 +845,6 @@ function events_get_all(
|
||||
}
|
||||
}
|
||||
|
||||
$sg_active = enterprise_hook('agents_is_using_secondary_groups');
|
||||
|
||||
if (!$user_is_admin) {
|
||||
$ER_groups = users_get_groups($config['id_user'], 'ER', false);
|
||||
$EM_groups = users_get_groups($config['id_user'], 'EM', false, true);
|
||||
@ -713,7 +854,8 @@ function events_get_all(
|
||||
if (!$user_is_admin && !users_can_manage_group_all('ER')) {
|
||||
// Get groups where user have ER grants.
|
||||
$sql_filters[] = sprintf(
|
||||
' AND te.id_grupo IN ( %s )',
|
||||
' AND (te.id_grupo IN ( %s ) OR tasg.id_group IN (%s))',
|
||||
join(', ', array_keys($ER_groups)),
|
||||
join(', ', array_keys($ER_groups))
|
||||
);
|
||||
}
|
||||
@ -912,7 +1054,9 @@ function events_get_all(
|
||||
// Force_group_and_tag.
|
||||
true,
|
||||
// Table tag for id_grupo.
|
||||
'te.'
|
||||
'te.',
|
||||
// Alt table tag for id_grupo.
|
||||
'tasg.'
|
||||
);
|
||||
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
|
||||
} else if (check_acl($config['id_user'], 0, 'EW')) {
|
||||
@ -936,7 +1080,9 @@ function events_get_all(
|
||||
// Force_group_and_tag.
|
||||
true,
|
||||
// Table tag for id_grupo.
|
||||
'te.'
|
||||
'te.',
|
||||
// Alt table tag for id_grupo.
|
||||
'tasg.'
|
||||
);
|
||||
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
|
||||
} else if (check_acl($config['id_user'], 0, 'EM')) {
|
||||
@ -960,7 +1106,9 @@ function events_get_all(
|
||||
// Force_group_and_tag.
|
||||
true,
|
||||
// Table tag for id_grupo.
|
||||
'te.'
|
||||
'te.',
|
||||
// Alt table tag for id_grupo.
|
||||
'tasg.'
|
||||
);
|
||||
// FORCE CHECK SQL "(TAG = tag1 AND id_grupo = 1)".
|
||||
}
|
||||
@ -1036,12 +1184,37 @@ function events_get_all(
|
||||
|
||||
$tgrupo_join = 'LEFT';
|
||||
$tgrupo_join_filters = [];
|
||||
if (isset($filter['id_group_filter']) && $filter['id_group_filter'] > 0) {
|
||||
if (isset($groups)
|
||||
&& (is_array($groups)
|
||||
|| $groups > 0)
|
||||
) {
|
||||
$tgrupo_join = 'INNER';
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' AND tg.id_grupo = %s',
|
||||
$filter['id_group_filter']
|
||||
);
|
||||
if (is_array($groups)) {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' AND (tg.id_grupo IN (%s) OR tasg.id_group IN (%s))',
|
||||
join(', ', $groups),
|
||||
join(', ', $groups)
|
||||
);
|
||||
} else {
|
||||
$tgrupo_join_filters[] = sprintf(
|
||||
' AND (tg.id_grupo = %s OR tasg.id_group = %s)',
|
||||
$groups,
|
||||
$groups
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$server_join = '';
|
||||
if (is_metaconsole()) {
|
||||
$server_join = ' LEFT JOIN tmetaconsole_setup ts
|
||||
ON ts.id = te.server_id';
|
||||
if (!empty($filter['server_id'])) {
|
||||
$server_join = sprintf(
|
||||
' LEFT JOIN tmetaconsole_setup ts
|
||||
ON ts.id = te.server_id AND ts.id= %d',
|
||||
$filter['server_id']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Secondary groups.
|
||||
@ -1076,6 +1249,7 @@ function events_get_all(
|
||||
%s JOIN tgrupo tg
|
||||
ON te.id_grupo = tg.id_grupo
|
||||
%s
|
||||
%s
|
||||
WHERE 1=1
|
||||
%s
|
||||
%s
|
||||
@ -1094,6 +1268,7 @@ function events_get_all(
|
||||
join(' ', $agent_join_filters),
|
||||
$tgrupo_join,
|
||||
join(' ', $tgrupo_join_filters),
|
||||
$server_join,
|
||||
join(' ', $sql_filters),
|
||||
$group_by,
|
||||
$order_by,
|
||||
@ -4363,7 +4538,7 @@ function events_page_general($event)
|
||||
*
|
||||
* @return string HTML.
|
||||
*/
|
||||
function events_page_comments($event)
|
||||
function events_page_comments($event, $ajax=false)
|
||||
{
|
||||
// Comments.
|
||||
global $config;
|
||||
@ -4372,7 +4547,7 @@ function events_page_comments($event)
|
||||
|
||||
$comments = $event['user_comment'];
|
||||
if (isset($event['comments'])) {
|
||||
$comments = $event['comments'];
|
||||
$comments = explode('<br>', $event['comments']);
|
||||
}
|
||||
|
||||
$table_comments = new stdClass;
|
||||
@ -4383,100 +4558,102 @@ function events_page_comments($event)
|
||||
|
||||
$comments = str_replace(["\n", '
'], '<br>', $comments);
|
||||
|
||||
// If comments are not stored in json, the format is old.
|
||||
$comments_array = json_decode(io_safe_output($comments), true);
|
||||
if (!empty($comments) && json_last_error() != JSON_ERROR_NONE) {
|
||||
$comments_array = [
|
||||
[
|
||||
'comment' => 'Error retrieving comments',
|
||||
'action' => 'Internal message',
|
||||
'id_user' => 'SYSTEM',
|
||||
'utimestamp' => time(),
|
||||
],
|
||||
];
|
||||
}
|
||||
if (is_array($comments)) {
|
||||
foreach ($comments as $comm) {
|
||||
if (empty($comm)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Show the comments more recent first.
|
||||
if (is_array($comments_array)) {
|
||||
$comments_array = array_reverse($comments_array);
|
||||
}
|
||||
|
||||
if (empty($comments_array)) {
|
||||
$comments_format = 'old';
|
||||
$comments_array[] = json_decode(io_safe_output($comm), true);
|
||||
}
|
||||
} else {
|
||||
$comments_format = 'new';
|
||||
// If comments are not stored in json, the format is old.
|
||||
$comments_array = json_decode(io_safe_output($comments), true);
|
||||
}
|
||||
|
||||
switch ($comments_format) {
|
||||
case 'new':
|
||||
if (empty($comments_array)) {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
$data = [];
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
foreach ($comments_array as $comm) {
|
||||
// Show the comments more recent first.
|
||||
if (is_array($comm)) {
|
||||
$comm = array_reverse($comm);
|
||||
}
|
||||
|
||||
if (isset($comments_array) === true
|
||||
&& is_array($comments_array) === true
|
||||
) {
|
||||
foreach ($comments_array as $c) {
|
||||
$data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>';
|
||||
$data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
|
||||
$data[1] = $c['comment'];
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
}
|
||||
break;
|
||||
if (empty($comm)) {
|
||||
$comments_format = 'old';
|
||||
} else {
|
||||
$comments_format = 'new';
|
||||
}
|
||||
|
||||
case 'old':
|
||||
$comments_array = explode('<br>', $comments);
|
||||
|
||||
// Split comments and put in table.
|
||||
$col = 0;
|
||||
$data = [];
|
||||
|
||||
foreach ($comments_array as $c) {
|
||||
switch ($col) {
|
||||
case 0:
|
||||
$row_text = preg_replace('/\s*--\s*/', '', $c);
|
||||
$row_text = preg_replace('/\<\/b\>/', '</i>', $row_text);
|
||||
$row_text = preg_replace('/\[/', '</b><br><br><i>[', $row_text);
|
||||
$row_text = preg_replace('/[\[|\]]/', '', $row_text);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$row_text = preg_replace("/[\r\n|\r|\n]/", '<br>', io_safe_output(strip_tags($c)));
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$data[$col] = $row_text;
|
||||
|
||||
$col++;
|
||||
|
||||
if ($col == 2) {
|
||||
$col = 0;
|
||||
$table_comments->data[] = $data;
|
||||
switch ($comments_format) {
|
||||
case 'new':
|
||||
if (empty($comm)) {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
$data = [];
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($comments_array) == 1 && $comments_array[0] == '') {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
if (isset($comm) === true
|
||||
&& is_array($comm) === true
|
||||
) {
|
||||
foreach ($comm as $c) {
|
||||
$data[0] = '<b>'.$c['action'].' by '.$c['id_user'].'</b>';
|
||||
$data[0] .= '<br><br><i>'.date($config['date_format'], $c['utimestamp']).'</i>';
|
||||
$data[1] = $c['comment'];
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'old':
|
||||
$comm = explode('<br>', $comments);
|
||||
|
||||
// Split comments and put in table.
|
||||
$col = 0;
|
||||
$data = [];
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
foreach ($comm as $c) {
|
||||
switch ($col) {
|
||||
case 0:
|
||||
$row_text = preg_replace('/\s*--\s*/', '', $c);
|
||||
$row_text = preg_replace('/\<\/b\>/', '</i>', $row_text);
|
||||
$row_text = preg_replace('/\[/', '</b><br><br><i>[', $row_text);
|
||||
$row_text = preg_replace('/[\[|\]]/', '', $row_text);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
$row_text = preg_replace("/[\r\n|\r|\n]/", '<br>', io_safe_output(strip_tags($c)));
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
$data[$col] = $row_text;
|
||||
|
||||
$col++;
|
||||
|
||||
if ($col == 2) {
|
||||
$col = 0;
|
||||
$table_comments->data[] = $data;
|
||||
$data = [];
|
||||
}
|
||||
}
|
||||
|
||||
if (count($comm) == 1 && $comm[0] == '') {
|
||||
$table_comments->style[0] = 'text-align:center;';
|
||||
$table_comments->colspan[0][0] = 2;
|
||||
$data = [];
|
||||
$data[0] = __('There are no comments');
|
||||
$table_comments->data[] = $data;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (((tags_checks_event_acl(
|
||||
@ -4519,9 +4696,11 @@ function events_page_comments($event)
|
||||
);
|
||||
}
|
||||
|
||||
$comments = '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>';
|
||||
if ($ajax) {
|
||||
return $comments_form.html_print_table($table_comments, true);
|
||||
}
|
||||
|
||||
return $comments;
|
||||
return '<div id="extended_event_comments_page" class="extended_event_pages">'.$comments_form.html_print_table($table_comments, true).'</div>';
|
||||
}
|
||||
|
||||
|
||||
@ -6449,10 +6628,6 @@ function events_get_sql_order($sort_field='timestamp', $sort='DESC', $group_rep=
|
||||
*/
|
||||
function events_get_secondary_groups_left_join($table)
|
||||
{
|
||||
if (users_is_admin()) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($table == 'tevento') {
|
||||
return 'LEFT JOIN tagent_secondary_group tasg ON te.id_agente = tasg.id_agent';
|
||||
}
|
||||
|
@ -298,6 +298,52 @@ function groups_get_childrens_ids($parent, $groups=null)
|
||||
|
||||
|
||||
/**
|
||||
* Return a array of id_group of children of given parent.
|
||||
*
|
||||
* @param integer $parent The id_grupo parent to search its children.
|
||||
* @param array $ignorePropagate Ignore propagate.
|
||||
*/
|
||||
function groups_get_children($parent, $ignorePropagate=false)
|
||||
{
|
||||
static $groups;
|
||||
|
||||
if (empty($groups)) {
|
||||
$groups = db_get_all_rows_in_table('tgrupo');
|
||||
$groups = array_reduce(
|
||||
$groups,
|
||||
function ($carry, $item) {
|
||||
$carry[$item['id_grupo']] = $item;
|
||||
return $carry;
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$return = [];
|
||||
foreach ($groups as $key => $g) {
|
||||
if ($g['id_grupo'] == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($ignorePropagate || $parent == 0 || $groups[$parent]['propagate']) {
|
||||
if ($g['parent'] == $parent) {
|
||||
$return += [$g['id_grupo'] => $g];
|
||||
if ($g['propagate'] || $ignorePropagate) {
|
||||
$return += groups_get_children(
|
||||
$g['id_grupo'],
|
||||
$ignorePropagate
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* XXX: This is not working. Expects 'propagate' on CHILD not on PARENT!!!
|
||||
*
|
||||
* Return a array of id_group of childrens (to branches down)
|
||||
*
|
||||
* @param integer $parent The id_group parent to search the childrens.
|
||||
|
@ -3066,3 +3066,290 @@ function html_print_link_with_params($text, $params=[], $type='text', $style='')
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Print input using functions html lib.
|
||||
*
|
||||
* @param array $data Input definition.
|
||||
*
|
||||
* @return string HTML code for desired input.
|
||||
*/
|
||||
function html_print_input($data)
|
||||
{
|
||||
if (is_array($data) === false) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$output = '';
|
||||
|
||||
if ($data['label']) {
|
||||
$output = '<div id="div-'.$data['name'].'" ';
|
||||
$output .= ' class="'.$data['input_class'].'">';
|
||||
$output .= '<label class="'.$data['label_class'].'">';
|
||||
$output .= $data['label'];
|
||||
$output .= '</label>';
|
||||
|
||||
if (!$data['return']) {
|
||||
echo $output;
|
||||
}
|
||||
}
|
||||
|
||||
switch ($data['type']) {
|
||||
case 'text':
|
||||
$output .= html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
$output .= html_print_input_image(
|
||||
$data['name'],
|
||||
$data['src'],
|
||||
$data['value'],
|
||||
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'text_extended':
|
||||
$output .= html_print_input_text_extended(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
$data['alt'],
|
||||
$data['size'],
|
||||
$data['maxlength'],
|
||||
$data['disabled'],
|
||||
$data['script'],
|
||||
$data['attributes'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['password']) === true) ? $data['password'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'password':
|
||||
$output .= html_print_input_password(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'text':
|
||||
$output .= html_print_input_text(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['alt']) === true) ? $data['alt'] : ''),
|
||||
((isset($data['size']) === true) ? $data['size'] : 50),
|
||||
((isset($data['maxlength']) === true) ? $data['maxlength'] : 255),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['required']) === true) ? $data['required'] : false),
|
||||
((isset($data['function']) === true) ? $data['function'] : ''),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['onChange']) === true) ? $data['onChange'] : ''),
|
||||
((isset($data['autocomplete']) === true) ? $data['autocomplete'] : '')
|
||||
);
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
$output .= html_print_input_image(
|
||||
$data['name'],
|
||||
$data['src'],
|
||||
$data['value'],
|
||||
((isset($data['style']) === true) ? $data['style'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'hidden':
|
||||
$output .= html_print_input_hidden(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'hidden_extended':
|
||||
$output .= html_print_input_hidden_extended(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
$data['id'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'color':
|
||||
$output .= html_print_input_color(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['class']) === true) ? $data['class'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'file':
|
||||
$output .= html_print_input_file(
|
||||
$data['name'],
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['options']) === true) ? $data['options'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select':
|
||||
$output .= html_print_select(
|
||||
$data['fields'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['modal']) === true) ? $data['modal'] : false),
|
||||
((isset($data['message']) === true) ? $data['message'] : ''),
|
||||
((isset($data['select_all']) === true) ? $data['select_all'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select_from_sql':
|
||||
$output .= html_print_select_from_sql(
|
||||
$data['sql'],
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : '0'),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['trucate_size']) === true) ? $data['trucate_size'] : GENERIC_SIZE_TEXT)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'select_groups':
|
||||
$output .= html_print_select_groups(
|
||||
((isset($data['id_user']) === true) ? $data['id_user'] : false),
|
||||
((isset($data['privilege']) === true) ? $data['privilege'] : 'AR'),
|
||||
((isset($data['returnAllGroup']) === true) ? $data['returnAllGroup'] : true),
|
||||
$data['name'],
|
||||
((isset($data['selected']) === true) ? $data['selected'] : ''),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['multiple']) === true) ? $data['multiple'] : false),
|
||||
((isset($data['sort']) === true) ? $data['sort'] : true),
|
||||
((isset($data['class']) === true) ? $data['class'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['style']) === true) ? $data['style'] : false),
|
||||
((isset($data['option_style']) === true) ? $data['option_style'] : false),
|
||||
((isset($data['id_group']) === true) ? $data['id_group'] : false),
|
||||
((isset($data['keys_field']) === true) ? $data['keys_field'] : 'id_grupo'),
|
||||
((isset($data['strict_user']) === true) ? $data['strict_user'] : false),
|
||||
((isset($data['delete_groups']) === true) ? $data['delete_groups'] : false),
|
||||
((isset($data['include_groups']) === true) ? $data['include_groups'] : false),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['simple_multiple_options']) === true) ? $data['simple_multiple_options'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'submit':
|
||||
$output .= '<div class="action-buttons" style="width: 100%">'.html_print_submit_button(
|
||||
((isset($data['label']) === true) ? $data['label'] : 'OK'),
|
||||
((isset($data['name']) === true) ? $data['name'] : ''),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false)
|
||||
).'</div>';
|
||||
break;
|
||||
|
||||
case 'checkbox':
|
||||
$output .= html_print_checkbox(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['checked']) === true) ? $data['checked'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['disabled']) === true) ? $data['disabled'] : false),
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['disabled_hidden']) === true) ? $data['disabled_hidden'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'switch':
|
||||
$output .= html_print_switch($data);
|
||||
break;
|
||||
|
||||
case 'interval':
|
||||
$output .= html_print_extended_select_for_time(
|
||||
$data['name'],
|
||||
$data['value'],
|
||||
((isset($data['script']) === true) ? $data['script'] : ''),
|
||||
((isset($data['nothing']) === true) ? $data['nothing'] : ''),
|
||||
((isset($data['nothing_value']) === true) ? $data['nothing_value'] : 0),
|
||||
((isset($data['size']) === true) ? $data['size'] : false),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['style']) === true) ? $data['selected'] : false),
|
||||
((isset($data['unique']) === true) ? $data['unique'] : false)
|
||||
);
|
||||
break;
|
||||
|
||||
case 'textarea':
|
||||
$output .= html_print_textarea(
|
||||
$data['name'],
|
||||
$data['rows'],
|
||||
$data['columns'],
|
||||
((isset($data['value']) === true) ? $data['value'] : ''),
|
||||
((isset($data['attributes']) === true) ? $data['attributes'] : ''),
|
||||
((isset($data['return']) === true) ? $data['return'] : false),
|
||||
((isset($data['class']) === true) ? $data['class'] : '')
|
||||
);
|
||||
|
||||
default:
|
||||
// Ignore.
|
||||
break;
|
||||
}
|
||||
|
||||
if ($data['label']) {
|
||||
$output .= '</div>';
|
||||
if (!$data['return']) {
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
|
@ -50,6 +50,12 @@ function menu_print_menu(&$menu)
|
||||
|
||||
$sec = (string) get_parameter('sec');
|
||||
$sec2 = (string) get_parameter('sec2');
|
||||
if ($sec2 == 'operation/agentes/ver_agente') {
|
||||
$sec2 = 'godmode/agentes/configurar_agente';
|
||||
} else {
|
||||
$sec2 = (string) get_parameter('sec2');
|
||||
}
|
||||
|
||||
$menu_selected = false;
|
||||
|
||||
$allsec2 = explode('sec2=', $_SERVER['REQUEST_URI']);
|
||||
|
@ -597,7 +597,7 @@ function snmp_browser_print_oid(
|
||||
*
|
||||
* @return string The container div.
|
||||
*/
|
||||
function snmp_browser_print_container($return=false, $width='100%', $height='500px', $display='')
|
||||
function snmp_browser_print_container($return=false, $width='100%', $height='60%', $display='')
|
||||
{
|
||||
// Target selection
|
||||
$table = new stdClass();
|
||||
@ -773,7 +773,7 @@ function snmp_browser_print_container($return=false, $width='100%', $height='500
|
||||
|
||||
$output .= '<div id="search_results" style="display: none; padding: 5px; background-color: #EAEAEA; border: 1px solid #E2E2E2; border-radius: 4px;"></div>';
|
||||
$output .= '<div id="spinner" style="position: absolute; top:0; left:0px; display:none; padding: 5px;">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
$output .= '<div id="snmp_browser" style="height: 100%; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
|
||||
$output .= '<div id="snmp_browser" style="height: 100%; min-height:100px; overflow: auto; background-color: #F4F5F4; border: 1px solid #E2E2E2; border-radius: 4px; padding: 5px;"></div>';
|
||||
$output .= '<div class="databox" id="snmp_data" style="margin: 5px;"></div>';
|
||||
$output .= '</div>';
|
||||
$output .= '</div>';
|
||||
|
@ -745,7 +745,8 @@ function tags_get_acl_tags(
|
||||
$meta=false,
|
||||
$childrens_ids=[],
|
||||
$force_group_and_tag=false,
|
||||
$id_grupo_table_pretag=''
|
||||
$id_grupo_table_pretag='',
|
||||
$alt_id_grupo_table_pretag=''
|
||||
) {
|
||||
global $config;
|
||||
|
||||
@ -820,7 +821,8 @@ function tags_get_acl_tags(
|
||||
$meta,
|
||||
$force_group_and_tag,
|
||||
false,
|
||||
$id_grupo_table_pretag
|
||||
$id_grupo_table_pretag,
|
||||
$alt_id_grupo_table_pretag
|
||||
);
|
||||
|
||||
if (!empty($condition)) {
|
||||
@ -917,7 +919,8 @@ function tags_get_acl_tags_event_condition(
|
||||
$meta=false,
|
||||
$force_group_and_tag=false,
|
||||
$force_equal=false,
|
||||
$id_grupo_table_pretag=''
|
||||
$id_grupo_table_pretag='',
|
||||
$alt_id_grupo_table_pretag=''
|
||||
) {
|
||||
global $config;
|
||||
$condition = [];
|
||||
@ -935,7 +938,7 @@ function tags_get_acl_tags_event_condition(
|
||||
|
||||
// Group condition (The module belongs to an agent of the group X)
|
||||
// $group_condition = sprintf('id_grupo IN (%s)', implode(',', array_values(groups_get_id_recursive($group_id, true))));.
|
||||
$group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR id_group = '.$group_id.')';
|
||||
$group_condition = '('.$id_grupo_table_pretag.'id_grupo = '.$group_id.' OR '.$alt_id_grupo_table_pretag.'id_group = '.$group_id.')';
|
||||
|
||||
// Tags condition (The module has at least one of the restricted tags).
|
||||
$tags_condition = '';
|
||||
@ -971,7 +974,7 @@ function tags_get_acl_tags_event_condition(
|
||||
}
|
||||
|
||||
$in_group = implode(',', $without_tags);
|
||||
$condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR id_group IN (%s))', $in_group, $in_group);
|
||||
$condition .= sprintf('('.$id_grupo_table_pretag.'id_grupo IN (%s) OR '.$alt_id_grupo_table_pretag.'id_group IN (%s))', $in_group, $in_group);
|
||||
}
|
||||
|
||||
$condition = !empty($condition) ? "($condition)" : '';
|
||||
|
@ -760,6 +760,12 @@ function ui_print_os_icon(
|
||||
$subfolder .= '/so_big_icons';
|
||||
}
|
||||
|
||||
if (is_metaconsole()) {
|
||||
$no_in_meta = true;
|
||||
} else {
|
||||
$no_in_meta = false;
|
||||
}
|
||||
|
||||
$icon = (string) db_get_value('icon_name', 'tconfig_os', 'id_os', (int) $id_os);
|
||||
$os_name = get_os_name($id_os);
|
||||
if (empty($icon)) {
|
||||
@ -770,7 +776,7 @@ function ui_print_os_icon(
|
||||
$options,
|
||||
true,
|
||||
$relative,
|
||||
false,
|
||||
$no_in_meta,
|
||||
true
|
||||
);
|
||||
} else {
|
||||
@ -778,13 +784,13 @@ function ui_print_os_icon(
|
||||
}
|
||||
} else if ($apply_skin) {
|
||||
if ($only_src) {
|
||||
$output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, true, $relative, false, true);
|
||||
$output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, true, $relative, $no_in_meta, true);
|
||||
} else {
|
||||
if (!isset($options['title'])) {
|
||||
$options['title'] = $os_name;
|
||||
}
|
||||
|
||||
$output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, false, $relative, false, true);
|
||||
$output = html_print_image('images/'.$subfolder.'/'.$icon, true, $options, false, $relative, $no_in_meta, true);
|
||||
}
|
||||
} else {
|
||||
// $output = "<img src='images/os_icons/" . $icon . "' alt='" . $os_name . "' title='" . $os_name . "'>";
|
||||
@ -2907,8 +2913,10 @@ function ui_print_datatable(array $parameters)
|
||||
|
||||
if (isset($parameters['id'])) {
|
||||
$table_id = $parameters['id'];
|
||||
$form_id = 'form_'.$parameters['id'];
|
||||
} else {
|
||||
$table_id = uniqid('datatable_');
|
||||
$form_id = uniqid('datatable_filter_');
|
||||
}
|
||||
|
||||
if (!isset($parameters['columns']) || !is_array($parameters['columns'])) {
|
||||
@ -2936,15 +2944,15 @@ function ui_print_datatable(array $parameters)
|
||||
}
|
||||
|
||||
if (!isset($parameters['order']['field'])) {
|
||||
$order = 1;
|
||||
$order = 0;
|
||||
} else {
|
||||
$order = array_search(
|
||||
$parameters['order']['field'],
|
||||
$parameters['columns']
|
||||
);
|
||||
|
||||
if (empty($order)) {
|
||||
$order = 1;
|
||||
if ($order === false) {
|
||||
$order = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2995,8 +3003,6 @@ function ui_print_datatable(array $parameters)
|
||||
if (isset($parameters['form']) && is_array($parameters['form'])) {
|
||||
if (isset($parameters['form']['id'])) {
|
||||
$form_id = $parameters['form']['id'];
|
||||
} else {
|
||||
$form_id = uniqid('datatable_filter_');
|
||||
}
|
||||
|
||||
if (isset($parameters['form']['class'])) {
|
||||
@ -3026,27 +3032,35 @@ function ui_print_datatable(array $parameters)
|
||||
$filter .= $parameters['form']['html'];
|
||||
}
|
||||
|
||||
$filter .= '<ul class="content">';
|
||||
$filter .= '<ul class="datatable_filter content">';
|
||||
|
||||
foreach ($parameters['form']['inputs'] as $input) {
|
||||
$filter .= '<li>';
|
||||
$filter .= '<label>'.$input['label'].'</label>';
|
||||
if ($input['type'] != 'select') {
|
||||
$filter .= '<input type="'.$input['type'].'" ';
|
||||
$filter .= ' style="'.$input['style'].'" ';
|
||||
$filter .= ' class="'.$input['class'].'" ';
|
||||
$filter .= ' value="'.$input['value'].'" ';
|
||||
$filter .= ' name="'.$input['name'].'" id="'.$input['id'].'" />';
|
||||
} else {
|
||||
// Select.
|
||||
$filter .= '<select name="'.$input['name'].'" ';
|
||||
$filter .= '<select class="'.$input['class'].'"';
|
||||
$filter .= ' style="'.$input['style'].'" ';
|
||||
$filter .= ' name="'.$input['name'].'" ';
|
||||
$filter .= 'id="'.$input['id'].'">';
|
||||
|
||||
foreach ($input['options'] as $opt => $selected) {
|
||||
$filter .= '<option value="'.$opt['value'].'"';
|
||||
if ($selected) {
|
||||
$filter .= ' selected="yes" >';
|
||||
}
|
||||
foreach ($input['options'] as $key => $opt) {
|
||||
if (is_array($opt)) {
|
||||
$filter .= '<option value="'.$opt['value'].'"';
|
||||
if ($opt['selected']) {
|
||||
$filter .= ' selected="yes" >';
|
||||
}
|
||||
|
||||
$filter .= __($opt['text']).'</option>';
|
||||
$filter .= __($opt['text']).'</option>';
|
||||
} else {
|
||||
$filter .= '<option value="'.$key.'">'.$opt.'</option>';
|
||||
}
|
||||
}
|
||||
|
||||
$filter .= '</select>';
|
||||
@ -3074,7 +3088,7 @@ function ui_print_datatable(array $parameters)
|
||||
|
||||
$filter .= '</li>';
|
||||
|
||||
$filter .= '</ul></form>';
|
||||
$filter .= '</ul><div style="clear:both"></div></form>';
|
||||
$filter = ui_toggle(
|
||||
$filter,
|
||||
__('Filter'),
|
||||
@ -3220,8 +3234,10 @@ function ui_print_datatable(array $parameters)
|
||||
$.extend(data, {
|
||||
filter: values,'."\n";
|
||||
|
||||
foreach ($parameters['ajax_data'] as $k => $v) {
|
||||
$js .= $k.':'.json_encode($v).",\n";
|
||||
if (is_array($parameters['ajax_data'])) {
|
||||
foreach ($parameters['ajax_data'] as $k => $v) {
|
||||
$js .= $k.':'.json_encode($v).",\n";
|
||||
}
|
||||
}
|
||||
|
||||
$js .= 'page: "'.$parameters['ajax_url'].'"
|
||||
|
@ -32,7 +32,7 @@ function clippy_module_unknow()
|
||||
$return_tours['tours']['module_unknow']['steps'] = [];
|
||||
$return_tours['tours']['module_unknow']['steps'][] = [
|
||||
'init_step_context' => true,
|
||||
'intro' => '<table>'.'<tr>'.'<td class="context_help_title">'.__('You have unknown modules in this agent.').'</td>'.'</tr>'.'<tr>'.'<td class="context_help_body">'.__('Unknown modules are modules which receive data normally at least in one occassion, but at this time are not receving data. Please check our troubleshoot help page to help you determine why you have unknown modules.').ui_print_help_icon('context_module_unknow', true, '', 'images/help.png').'</td>'.'</tr>'.'</table>',
|
||||
'intro' => '<table>'.'<tr>'.'<td class="context_help_title">'.__('You have unknown modules in this agent.').'</td>'.'</tr>'.'<tr>'.'<td class="context_help_body">'.__('Unknown modules are modules which receive data normally at least in one occassion, but at this time are not receving data. Please check our troubleshoot help page to help you determine why you have unknown modules.').'</td>'.'</tr>'.'</table>',
|
||||
];
|
||||
$return_tours['tours']['module_unknow']['conf'] = [];
|
||||
$return_tours['tours']['module_unknow']['conf']['autostart'] = false;
|
||||
|
@ -1,386 +1,405 @@
|
||||
(function($) {
|
||||
$.fn.check = function () {
|
||||
return this.each (function () {
|
||||
this.checked = true;
|
||||
});};
|
||||
$.fn.check = function() {
|
||||
return this.each(function() {
|
||||
this.checked = true;
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.uncheck = function () {
|
||||
return this.each (function () {
|
||||
this.checked = false;
|
||||
});};
|
||||
$.fn.uncheck = function() {
|
||||
return this.each(function() {
|
||||
this.checked = false;
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.enable = function () {
|
||||
return $(this).removeAttr ("disabled");
|
||||
};
|
||||
$.fn.enable = function() {
|
||||
return $(this).removeAttr("disabled");
|
||||
};
|
||||
|
||||
$.fn.disable = function () {
|
||||
return $(this).attr ("disabled", "disabled");
|
||||
};
|
||||
$.fn.disable = function() {
|
||||
return $(this).attr("disabled", "disabled");
|
||||
};
|
||||
|
||||
$.fn.pulsate = function () {
|
||||
var i = 0;
|
||||
for (i = 0; i <= 2; i++) {
|
||||
$(this).fadeOut ("slow").fadeIn ("slow");
|
||||
}
|
||||
};
|
||||
$.fn.pulsate = function() {
|
||||
var i = 0;
|
||||
for (i = 0; i <= 2; i++) {
|
||||
$(this)
|
||||
.fadeOut("slow")
|
||||
.fadeIn("slow");
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.showMessage = function (msg) {
|
||||
return $(this).hide ().empty ()
|
||||
// here, previously .text (msg)
|
||||
.html (msg)
|
||||
.slideDown ();
|
||||
};
|
||||
}) (jQuery);
|
||||
$.fn.showMessage = function(msg) {
|
||||
return (
|
||||
$(this)
|
||||
.hide()
|
||||
.empty()
|
||||
// here, previously .text (msg)
|
||||
.html(msg)
|
||||
.slideDown()
|
||||
);
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
$(document).ready (function () {
|
||||
$("a#show_messages_dialog").click (function () {
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "operation/messages/message_list"
|
||||
},
|
||||
function (data, status) {
|
||||
$("#dialog_messages").hide ()
|
||||
.empty ()
|
||||
.append (data)
|
||||
.dialog ({
|
||||
title: $("a#show_messages_dialog").attr ("title"),
|
||||
resizable: false,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 700,
|
||||
height: 300
|
||||
}).show ();
|
||||
},
|
||||
"html"
|
||||
);
|
||||
$(document).ready(function() {
|
||||
$("a#show_messages_dialog").click(function() {
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "operation/messages/message_list"
|
||||
},
|
||||
function(data, status) {
|
||||
$("#dialog_messages")
|
||||
.hide()
|
||||
.empty()
|
||||
.append(data)
|
||||
.dialog({
|
||||
title: $("a#show_messages_dialog").attr("title"),
|
||||
resizable: false,
|
||||
modal: true,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
width: 700,
|
||||
height: 300
|
||||
})
|
||||
.show();
|
||||
},
|
||||
"html"
|
||||
);
|
||||
|
||||
return false;
|
||||
});
|
||||
return false;
|
||||
});
|
||||
|
||||
$("a.show_systemalert_dialog").click (function () {
|
||||
$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
|
||||
$("#opacidad").css('opacity', 0.5);
|
||||
$("a.show_systemalert_dialog").click(function() {
|
||||
$("body").append(
|
||||
"<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
|
||||
);
|
||||
$("#opacidad").css("opacity", 0.5);
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "operation/system_alert"},
|
||||
function (data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages").empty ().append (data);
|
||||
$("#alert_messages").css('opacity', 1);
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "operation/system_alert"
|
||||
},
|
||||
function(data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages")
|
||||
.empty()
|
||||
.append(data);
|
||||
$("#alert_messages").css("opacity", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
});
|
||||
|
||||
},
|
||||
"html"
|
||||
);
|
||||
});
|
||||
$("a.modalpopup").click(function() {
|
||||
var elem = $(this).attr("id");
|
||||
$("body").append(
|
||||
"<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
|
||||
);
|
||||
$("#opacidad").css("opacity", 0.5);
|
||||
|
||||
$("a.modalpopup").click (function () {
|
||||
var elem = $(this).attr("id");
|
||||
$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
|
||||
$("#opacidad").css('opacity', 0.5);
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "general/alert_enterprise",
|
||||
message: elem
|
||||
},
|
||||
function(data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages")
|
||||
.empty()
|
||||
.append(data);
|
||||
$("#alert_messages").css("opacity", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "general/alert_enterprise",
|
||||
"message": elem
|
||||
},
|
||||
function (data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages").empty ().append (data);
|
||||
$("#alert_messages").css('opacity', 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
// Creacion de ventana modal y botones
|
||||
$(".publienterprise").click(function() {
|
||||
var elem = $(this).attr("id");
|
||||
$("body").append(
|
||||
"<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
|
||||
);
|
||||
$("#opacidad").css("opacity", 0.5);
|
||||
|
||||
// Creacion de ventana modal y botones
|
||||
$(".publienterprise").click (function () {
|
||||
var elem = $(this).attr("id");
|
||||
$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
|
||||
$("#opacidad").css('opacity', 0.5);
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "general/alert_enterprise",
|
||||
message: elem
|
||||
},
|
||||
function(data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages")
|
||||
.empty()
|
||||
.append(data);
|
||||
$("#alert_messages").css("opacity", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "general/alert_enterprise",
|
||||
"message": elem
|
||||
},
|
||||
function (data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages").empty ().append (data);
|
||||
$("#alert_messages").css('opacity', 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
$(".publienterprisehide").click(function() {
|
||||
var elem = $(this).attr("id");
|
||||
$("body").append(
|
||||
"<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>"
|
||||
);
|
||||
$("#opacidad").css("opacity", 0.5);
|
||||
|
||||
jQuery.post(
|
||||
"ajax.php",
|
||||
{
|
||||
page: "general/alert_enterprise",
|
||||
message: elem
|
||||
},
|
||||
function(data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages")
|
||||
.empty()
|
||||
.append(data);
|
||||
$("#alert_messages").css("opacity", 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
|
||||
$(".publienterprisehide").click (function () {
|
||||
var elem = $(this).attr("id");
|
||||
$('body').append( "<div id='opacidad' style='position:fixed;background:black;z-index:1'></div>" );
|
||||
$("#opacidad").css('opacity', 0.5);
|
||||
if ($("#license_error_msg_dialog").length) {
|
||||
if (typeof process_login_ok == "undefined") process_login_ok = 0;
|
||||
|
||||
jQuery.post ("ajax.php",
|
||||
{
|
||||
"page": "general/alert_enterprise",
|
||||
"message": elem
|
||||
},
|
||||
function (data, status) {
|
||||
$("#alert_messages").show();
|
||||
$("#alert_messages").empty ().append (data);
|
||||
$("#alert_messages").css('opacity', 1);
|
||||
},
|
||||
"html"
|
||||
);
|
||||
return false;
|
||||
});
|
||||
if (typeof show_error_license == "undefined") show_error_license = 0;
|
||||
|
||||
if (process_login_ok || show_error_license) {
|
||||
$("#license_error_msg_dialog").dialog({
|
||||
dialogClass: "no-close",
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 470,
|
||||
width: 850,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
open: function() {
|
||||
var remaining = 30;
|
||||
|
||||
// Timeout counter.
|
||||
var count = function() {
|
||||
if (remaining > 0) {
|
||||
$("#license_error_remaining").text(remaining);
|
||||
remaining -= 1;
|
||||
} else {
|
||||
$("#license_error_remaining").hide();
|
||||
$("#ok_buttom").show();
|
||||
clearInterval(count);
|
||||
}
|
||||
};
|
||||
|
||||
if ($('#license_error_msg_dialog').length) {
|
||||
if (typeof(process_login_ok) == "undefined")
|
||||
process_login_ok = 0;
|
||||
setInterval(count, 1000);
|
||||
}
|
||||
});
|
||||
|
||||
if (typeof(show_error_license) == "undefined")
|
||||
show_error_license = 0;
|
||||
$("#submit-hide-license-error-msg").click(function() {
|
||||
$("#license_error_msg_dialog").dialog("close");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (process_login_ok || show_error_license) {
|
||||
if ($("#msg_change_password").length) {
|
||||
$("#msg_change_password").dialog({
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 450,
|
||||
width: 620,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
$( "#license_error_msg_dialog" ).dialog({
|
||||
dialogClass: "no-close",
|
||||
closeOnEscape: false,
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 450,
|
||||
width: 850,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
},
|
||||
open: function() {
|
||||
var remaining = 30;
|
||||
if ($("#login_blocked").length) {
|
||||
$("#login_blocked").dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 200,
|
||||
width: 520,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Timeout counter.
|
||||
var count = function() {
|
||||
if (remaining > 0) {
|
||||
$("#license_error_remaining").text(remaining);
|
||||
remaining -= 1;
|
||||
} else {
|
||||
$("#license_error_remaining").hide();
|
||||
$("#ok_buttom").show();
|
||||
clearInterval(count);
|
||||
}
|
||||
}
|
||||
if ($("#login_correct_pass").length) {
|
||||
$("#login_correct_pass").dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 200,
|
||||
width: 520,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
setInterval(count, 1000);
|
||||
}
|
||||
});
|
||||
forced_title_callback();
|
||||
|
||||
$("#submit-hide-license-error-msg").click (function () {
|
||||
$("#license_error_msg_dialog" ).dialog('close')
|
||||
});
|
||||
$(document).on("scroll", function() {
|
||||
if (
|
||||
document.documentElement.scrollTop != 0 ||
|
||||
document.body.scrollTop != 0
|
||||
) {
|
||||
if ($("#head").css("position") == "fixed") {
|
||||
if ($("#menu").css("position") == "fixed") {
|
||||
$("#menu").css("top", "80px");
|
||||
} else {
|
||||
$("#menu").css("top", "60px");
|
||||
}
|
||||
} else {
|
||||
if ($("#menu").css("position") == "fixed") {
|
||||
$("#menu").css("top", "20px");
|
||||
} else {
|
||||
$("#menu").css("top", "80px");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($("#head").css("position") == "fixed") {
|
||||
if ($("#menu").css("position") == "fixed") {
|
||||
$("#menu").css("top", "80px");
|
||||
} else {
|
||||
$("#menu").css("top", "60px");
|
||||
}
|
||||
} else {
|
||||
if ($("#menu").css("position") == "fixed") {
|
||||
$("#menu").css("top", "80px");
|
||||
} else {
|
||||
$("#menu").css("top", "80px");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($('#msg_change_password').length) {
|
||||
|
||||
$( "#msg_change_password" ).dialog({
|
||||
resizable: false,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 350,
|
||||
width: 620,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if ($('#login_blocked').length) {
|
||||
|
||||
$( "#login_blocked" ).dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 200,
|
||||
width: 520,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
if ($('#login_correct_pass').length) {
|
||||
|
||||
$( "#login_correct_pass" ).dialog({
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
height: 200,
|
||||
width: 520,
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
background: "black"
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
forced_title_callback();
|
||||
|
||||
|
||||
$(document).on("scroll", function(){
|
||||
|
||||
if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
|
||||
if($('#head').css('position') =='fixed'){
|
||||
if($('#menu').css('position') =='fixed'){
|
||||
$('#menu').css('top','80px');
|
||||
} else {
|
||||
$('#menu').css('top','60px');
|
||||
}
|
||||
} else {
|
||||
if($('#menu').css('position') =='fixed'){
|
||||
$('#menu').css('top','20px');
|
||||
} else {
|
||||
$('#menu').css('top','80px');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if($('#head').css('position') =='fixed'){
|
||||
if($('#menu').css('position') =='fixed'){
|
||||
$('#menu').css('top','80px');
|
||||
} else {
|
||||
$('#menu').css('top','60px');
|
||||
}
|
||||
} else {
|
||||
if($('#menu').css('position') =='fixed'){
|
||||
$('#menu').css('top','80px');
|
||||
} else {
|
||||
$('#menu').css('top','80px');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if((document.documentElement.scrollTop != 0 || document.body.scrollTop != 0) && $('#menu').css('position') =='fixed'){
|
||||
// if($('#head').css('position') =='fixed'){
|
||||
// $('#menu').css('top','80px');
|
||||
// }
|
||||
// else{
|
||||
// $('#menu').css('top','20px');
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// if($('#head').css('position') =='fixed'){
|
||||
// if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
|
||||
// $('#menu').css('top','60px');
|
||||
// }else{
|
||||
// $('#menu').css('top','80px');
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else{
|
||||
// $('#menu').css('top','60px');
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
$("#alert_messages").draggable();
|
||||
$("#alert_messages").css({'left':+parseInt(screen.width/2)-parseInt($("#alert_messages").css('width'))/2+'px'});
|
||||
// if((document.documentElement.scrollTop != 0 || document.body.scrollTop != 0) && $('#menu').css('position') =='fixed'){
|
||||
// if($('#head').css('position') =='fixed'){
|
||||
// $('#menu').css('top','80px');
|
||||
// }
|
||||
// else{
|
||||
// $('#menu').css('top','20px');
|
||||
// }
|
||||
// }
|
||||
// else{
|
||||
// if($('#head').css('position') =='fixed'){
|
||||
// if(document.documentElement.scrollTop != 0 || document.body.scrollTop != 0){
|
||||
// $('#menu').css('top','60px');
|
||||
// }else{
|
||||
// $('#menu').css('top','80px');
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// else{
|
||||
// $('#menu').css('top','60px');
|
||||
// }
|
||||
// }
|
||||
});
|
||||
|
||||
$("#alert_messages").draggable();
|
||||
$("#alert_messages").css({
|
||||
left:
|
||||
+parseInt(screen.width / 2) -
|
||||
parseInt($("#alert_messages").css("width")) / 2 +
|
||||
"px"
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function forced_title_callback() {
|
||||
// Forced title code
|
||||
$('body').on('mouseenter', '.forced_title', function() {
|
||||
///////////////////////////////////////////
|
||||
// Put the layer in the left-top corner to fill it
|
||||
///////////////////////////////////////////
|
||||
$('#forced_title_layer').css('left', 0);
|
||||
$('#forced_title_layer').css('top', 0);
|
||||
// Forced title code
|
||||
$("body").on("mouseenter", ".forced_title", function() {
|
||||
///////////////////////////////////////////
|
||||
// Put the layer in the left-top corner to fill it
|
||||
///////////////////////////////////////////
|
||||
$("#forced_title_layer").css("left", 0);
|
||||
$("#forced_title_layer").css("top", 0);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Get info of the image
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Get info of the image
|
||||
///////////////////////////////////////////
|
||||
|
||||
var img_top = $(this).offset().top;
|
||||
var img_width = $(this).width();
|
||||
var img_height = $(this).height();
|
||||
var img_id = $(this).attr('id');
|
||||
var img_left_mid = $(this).offset().left + (img_width / 2);
|
||||
var img_top = $(this).offset().top;
|
||||
var img_width = $(this).width();
|
||||
var img_height = $(this).height();
|
||||
var img_id = $(this).attr("id");
|
||||
var img_left_mid = $(this).offset().left + img_width / 2;
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Put title in the layer
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Put title in the layer
|
||||
///////////////////////////////////////////
|
||||
|
||||
// If the '.forced_title' element has 'use_title_for_force_title' = 1
|
||||
// into their 'data' prop, the element title will be used for the
|
||||
// content.
|
||||
if ($(this).data("use_title_for_force_title")) {
|
||||
var title = $(this).data("title");
|
||||
}
|
||||
else {
|
||||
var title = $('#forced_title_'+img_id).html();
|
||||
}
|
||||
// If the '.forced_title' element has 'use_title_for_force_title' = 1
|
||||
// into their 'data' prop, the element title will be used for the
|
||||
// content.
|
||||
if ($(this).data("use_title_for_force_title")) {
|
||||
var title = $(this).data("title");
|
||||
} else {
|
||||
var title = $("#forced_title_" + img_id).html();
|
||||
}
|
||||
|
||||
$('#forced_title_layer').html(title);
|
||||
$("#forced_title_layer").html(title);
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Get info of the layer
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Get info of the layer
|
||||
///////////////////////////////////////////
|
||||
|
||||
var layer_width = $('#forced_title_layer').width();
|
||||
var layer_height = $('#forced_title_layer').height();
|
||||
var layer_width = $("#forced_title_layer").width();
|
||||
var layer_height = $("#forced_title_layer").height();
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Obtain the new position of the layer
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Obtain the new position of the layer
|
||||
///////////////////////////////////////////
|
||||
|
||||
// Jquery doesnt know the padding of the layer
|
||||
var layer_padding = 4;
|
||||
// Jquery doesnt know the padding of the layer
|
||||
var layer_padding = 4;
|
||||
|
||||
// Deduct padding of both sides
|
||||
var layer_top = img_top - layer_height - (layer_padding * 2) - 5;
|
||||
if (layer_top < 0) {
|
||||
layer_top = img_top + img_height + (layer_padding * 2);
|
||||
}
|
||||
// Deduct padding of both sides
|
||||
var layer_top = img_top - layer_height - layer_padding * 2 - 5;
|
||||
if (layer_top < 0) {
|
||||
layer_top = img_top + img_height + layer_padding * 2;
|
||||
}
|
||||
|
||||
// Deduct padding of one side
|
||||
var layer_left = img_left_mid - (layer_width / 2) - layer_padding;
|
||||
if (layer_left < 0) {
|
||||
layer_left = 0;
|
||||
}
|
||||
// Deduct padding of one side
|
||||
var layer_left = img_left_mid - layer_width / 2 - layer_padding;
|
||||
if (layer_left < 0) {
|
||||
layer_left = 0;
|
||||
}
|
||||
|
||||
var real_layer_width = layer_width + (layer_padding * 2) + 5;
|
||||
var layer_right = layer_left + real_layer_width;
|
||||
var screen_width = $(window).width();
|
||||
if (screen_width < layer_right) {
|
||||
layer_left = screen_width - real_layer_width;
|
||||
}
|
||||
var real_layer_width = layer_width + layer_padding * 2 + 5;
|
||||
var layer_right = layer_left + real_layer_width;
|
||||
var screen_width = $(window).width();
|
||||
if (screen_width < layer_right) {
|
||||
layer_left = screen_width - real_layer_width;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////
|
||||
// Set the layer position and show
|
||||
///////////////////////////////////////////
|
||||
///////////////////////////////////////////
|
||||
// Set the layer position and show
|
||||
///////////////////////////////////////////
|
||||
|
||||
$('#forced_title_layer').css('left', layer_left);
|
||||
$('#forced_title_layer').css('top', layer_top);
|
||||
$('#forced_title_layer').show();
|
||||
});
|
||||
$('body').on('mouseout', '.forced_title', function () {
|
||||
$('#forced_title_layer').hide().empty();
|
||||
});
|
||||
$("#forced_title_layer").css("left", layer_left);
|
||||
$("#forced_title_layer").css("top", layer_top);
|
||||
$("#forced_title_layer").show();
|
||||
});
|
||||
$("body").on("mouseout", ".forced_title", function() {
|
||||
$("#forced_title_layer")
|
||||
.hide()
|
||||
.empty();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
var original_command = "";
|
||||
|
||||
function parse_alert_command(command, classs) {
|
||||
if (classs == "recovery") {
|
||||
classs = "fields_recovery";
|
||||
@ -34,13 +33,13 @@ function parse_alert_command(command, classs) {
|
||||
}
|
||||
|
||||
function render_command_preview(original_command) {
|
||||
$("#textarea_command_preview").text(
|
||||
$("#textarea_command_preview").html(
|
||||
parse_alert_command(original_command, "")
|
||||
);
|
||||
}
|
||||
|
||||
function render_command_recovery_preview(original_command) {
|
||||
$("#textarea_command_recovery_preview").text(
|
||||
$("#textarea_command_recovery_preview").html(
|
||||
parse_alert_command(original_command, "recovery")
|
||||
);
|
||||
}
|
||||
|
@ -231,7 +231,6 @@ function get_response(response_id) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
response = data;
|
||||
@ -255,7 +254,6 @@ function get_response_params(response_id) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
response_params = data;
|
||||
@ -279,7 +277,6 @@ function get_response_description(response_id) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
response_description = data;
|
||||
@ -305,7 +302,6 @@ function get_event_name(event_id, meta, history) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
name = data;
|
||||
@ -349,7 +345,6 @@ function get_response_target(
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: false,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
target = data;
|
||||
@ -394,7 +389,6 @@ function perform_response(target, response_id) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
var out = data.replace(/[\n|\r]/g, "<br>");
|
||||
@ -424,7 +418,6 @@ function perform_response_massive(target, response_id, out_iterator) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
var out = data.replace(/[\n|\r]/g, "<br>");
|
||||
@ -460,7 +453,6 @@ function event_change_status(event_ids) {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#button-status_button").removeAttr("disabled");
|
||||
@ -499,7 +491,6 @@ function event_change_owner() {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#button-owner_button").removeAttr("disabled");
|
||||
@ -553,13 +544,11 @@ function event_comment() {
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
$("#button-comment_button").removeAttr("disabled");
|
||||
$("#response_loading").show();
|
||||
dt_events.draw(false);
|
||||
show_event_dialog(current_event, "comments", data);
|
||||
$("#response_loading").hide();
|
||||
$("#link_comments").click();
|
||||
}
|
||||
});
|
||||
|
||||
@ -681,7 +670,6 @@ function update_event(table, id_evento, type, event_rep, row) {
|
||||
// Update events matching current filters and id_evento selected.
|
||||
$.ajax({
|
||||
async: true,
|
||||
timeout: 10000,
|
||||
type: "POST",
|
||||
url: $("#hidden-ajax_file").val(),
|
||||
data: {
|
||||
@ -700,7 +688,7 @@ function update_event(table, id_evento, type, event_rep, row) {
|
||||
var diff_s = diff_g / 1000;
|
||||
if (processed >= $(".chk_val:checked").length) {
|
||||
// If operation takes less than 2 seconds, redraw.
|
||||
if (diff_s < 2) {
|
||||
if (diff_s < 2 || $(".chk_val:checked").length > 1) {
|
||||
redraw = true;
|
||||
}
|
||||
if (redraw) {
|
||||
@ -722,6 +710,7 @@ function validate_event(table, id_evento, event_rep, row) {
|
||||
var button = document.getElementById("val-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
processed += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -734,6 +723,7 @@ function in_process_event(table, id_evento, event_rep, row) {
|
||||
var button = document.getElementById("proc-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
processed += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
@ -752,6 +742,7 @@ function delete_event(table, id_evento, event_rep, row) {
|
||||
var button = document.getElementById("del-" + id_evento);
|
||||
if (!button) {
|
||||
// Button does not exist. Ignore.
|
||||
processed += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ function createVisualConsole(
|
||||
try {
|
||||
visualConsole = new VisualConsole(container, props, items);
|
||||
// VC Item clicked.
|
||||
visualConsole.onClick(function(e) {
|
||||
visualConsole.onItemClick(function(e) {
|
||||
// Override the link to another VC if it isn't on remote console.
|
||||
if (
|
||||
e.data &&
|
||||
@ -139,6 +139,94 @@ function createVisualConsole(
|
||||
updateVisualConsole(e.data.linkedLayoutId, updateInterval);
|
||||
}
|
||||
});
|
||||
// VC Item moved.
|
||||
visualConsole.onItemMoved(function(e) {
|
||||
var id = e.item.props.id;
|
||||
var data = {
|
||||
x: e.newPosition.x,
|
||||
y: e.newPosition.y,
|
||||
type: e.item.props.type
|
||||
};
|
||||
var taskId = "visual-console-item-move-" + id;
|
||||
|
||||
// Persist the new position.
|
||||
asyncTaskManager
|
||||
.add(taskId, function(done) {
|
||||
var abortable = updateVisualConsoleItem(
|
||||
baseUrl,
|
||||
visualConsole.props.id,
|
||||
id,
|
||||
data,
|
||||
function(error, data) {
|
||||
// if (!error && !data) return;
|
||||
if (error || !data) {
|
||||
console.log(
|
||||
"[ERROR]",
|
||||
"[VISUAL-CONSOLE-CLIENT]",
|
||||
"[API]",
|
||||
error ? error.message : "Invalid response"
|
||||
);
|
||||
|
||||
// Move the element to its initial position.
|
||||
e.item.move(e.prevPosition.x, e.prevPosition.y);
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
abortable.abort();
|
||||
}
|
||||
};
|
||||
})
|
||||
.init();
|
||||
});
|
||||
// VC Item resized.
|
||||
visualConsole.onItemResized(function(e) {
|
||||
var id = e.item.props.id;
|
||||
var data = {
|
||||
width: e.newSize.width,
|
||||
height: e.newSize.height,
|
||||
type: e.item.props.type
|
||||
};
|
||||
var taskId = "visual-console-item-resize-" + id;
|
||||
|
||||
// Persist the new size.
|
||||
asyncTaskManager
|
||||
.add(taskId, function(done) {
|
||||
var abortable = updateVisualConsoleItem(
|
||||
baseUrl,
|
||||
visualConsole.props.id,
|
||||
id,
|
||||
data,
|
||||
function(error, data) {
|
||||
// if (!error && !data) return;
|
||||
if (error || !data) {
|
||||
console.log(
|
||||
"[ERROR]",
|
||||
"[VISUAL-CONSOLE-CLIENT]",
|
||||
"[API]",
|
||||
error ? error.message : "Invalid response"
|
||||
);
|
||||
|
||||
// Resize the element to its initial Size.
|
||||
e.item.resize(e.prevSize.width, e.prevSize.height);
|
||||
}
|
||||
|
||||
done();
|
||||
}
|
||||
);
|
||||
|
||||
return {
|
||||
cancel: function() {
|
||||
abortable.abort();
|
||||
}
|
||||
};
|
||||
})
|
||||
.init();
|
||||
});
|
||||
|
||||
if (updateInterval != null && updateInterval > 0) {
|
||||
// Start an interval to update the Visual Console.
|
||||
@ -266,6 +354,75 @@ function loadVisualConsoleData(baseUrl, vcId, callback) {
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch a Visual Console's structure and its items.
|
||||
* @param {string} baseUrl Base URL to build the API path.
|
||||
* @param {number} vcId Identifier of the Visual Console.
|
||||
* @param {number} vcItemId Identifier of the Visual Console's item.
|
||||
* @param {Object} data Data we want to save.
|
||||
* @param {function} callback Function to be executed on request success or fail.
|
||||
* @return {Object} Cancellable. Object which include and .abort([statusText]) function.
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function updateVisualConsoleItem(baseUrl, vcId, vcItemId, data, callback) {
|
||||
// var apiPath = baseUrl + "/include/rest-api";
|
||||
var apiPath = baseUrl + "/ajax.php";
|
||||
var jqXHR = null;
|
||||
|
||||
// Cancel the ajax requests.
|
||||
var abort = function(textStatus) {
|
||||
if (textStatus == null) textStatus = "abort";
|
||||
|
||||
// -- XMLHttpRequest.readyState --
|
||||
// Value State Description
|
||||
// 0 UNSENT Client has been created. open() not called yet.
|
||||
// 4 DONE The operation is complete.
|
||||
|
||||
if (jqXHR.readyState !== 0 && jqXHR.readyState !== 4)
|
||||
jqXHR.abort(textStatus);
|
||||
};
|
||||
|
||||
// Failed request handler.
|
||||
var handleFail = function(jqXHR, textStatus, errorThrown) {
|
||||
abort();
|
||||
// Manually aborted or not.
|
||||
if (textStatus === "abort") {
|
||||
callback();
|
||||
} else {
|
||||
var error = new Error(errorThrown);
|
||||
error.request = jqXHR;
|
||||
callback(error);
|
||||
}
|
||||
};
|
||||
|
||||
// Function which handle success case.
|
||||
var handleSuccess = function(data) {
|
||||
callback(null, data);
|
||||
};
|
||||
|
||||
// Visual Console container request.
|
||||
jqXHR = jQuery
|
||||
// .get(apiPath + "/visual-consoles/" + vcId, null, "json")
|
||||
.get(
|
||||
apiPath,
|
||||
{
|
||||
page: "include/rest-api/index",
|
||||
updateVisualConsoleItem: 1,
|
||||
visualConsoleId: vcId,
|
||||
visualConsoleItemId: vcItemId,
|
||||
data: data
|
||||
},
|
||||
"json"
|
||||
)
|
||||
.done(handleSuccess)
|
||||
.fail(handleFail);
|
||||
|
||||
// Abortable.
|
||||
return {
|
||||
abort: abort
|
||||
};
|
||||
}
|
||||
|
||||
// TODO: Delete the functions below when you can.
|
||||
/**************************************
|
||||
These functions require jQuery library
|
||||
|
@ -13,6 +13,7 @@ use Models\VisualConsole\Container as VisualConsole;
|
||||
$visualConsoleId = (int) get_parameter('visualConsoleId');
|
||||
$getVisualConsole = (bool) get_parameter('getVisualConsole');
|
||||
$getVisualConsoleItems = (bool) get_parameter('getVisualConsoleItems');
|
||||
$updateVisualConsoleItem = (bool) get_parameter('updateVisualConsoleItem');
|
||||
|
||||
// Check groups can access user.
|
||||
$aclUserGroups = [];
|
||||
@ -44,6 +45,21 @@ if ($getVisualConsole === true) {
|
||||
} else if ($getVisualConsoleItems === true) {
|
||||
$vcItems = VisualConsole::getItemsFromDB($visualConsoleId, $aclUserGroups);
|
||||
echo '['.implode($vcItems, ',').']';
|
||||
} else if ($updateVisualConsoleItem === true) {
|
||||
$visualConsoleId = (integer) get_parameter('visualConsoleId');
|
||||
$visualConsoleItemId = (integer) get_parameter('visualConsoleItemId');
|
||||
$data = get_parameter('data');
|
||||
|
||||
$class = VisualConsole::getItemClass($data['type']);
|
||||
|
||||
$item_data = [];
|
||||
$item_data['id'] = $visualConsoleItemId;
|
||||
$item_data['id_layout'] = $visualConsoleId;
|
||||
|
||||
$item = $class::fromDB($item_data);
|
||||
$result = $item->save($data);
|
||||
|
||||
echo json_encode($result);
|
||||
}
|
||||
|
||||
exit;
|
||||
|
@ -47,6 +47,30 @@ abstract class Model
|
||||
abstract protected function decode(array $data): array;
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
* @param array $data Input data.
|
||||
*
|
||||
* @return array Data structure representing a record in database.
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
abstract protected function encode(array $data): array;
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update an item in the database
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return boolean The modeled element data structure stored into the DB.
|
||||
*
|
||||
* @abstract
|
||||
*/
|
||||
abstract public function save(array $data=[]);
|
||||
|
||||
|
||||
/**
|
||||
* Constructor of the model. It won't be public. The instances
|
||||
* will be created through factories which start with from*.
|
||||
@ -62,6 +86,12 @@ abstract class Model
|
||||
}
|
||||
|
||||
|
||||
public function setData(array $data)
|
||||
{
|
||||
$this->data = $data;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Instance the class with the unknown input data.
|
||||
*
|
||||
@ -69,7 +99,7 @@ abstract class Model
|
||||
*
|
||||
* @return self Instance of the model.
|
||||
*/
|
||||
public static function fromArray(array $data)
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
// The reserved word static refers to the invoked class at runtime.
|
||||
return new static($data);
|
||||
|
@ -92,6 +92,37 @@ final class Container extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
* @param array $data Input data.
|
||||
*
|
||||
* @return array Data structure representing a record in database.
|
||||
*
|
||||
* @overrides Model::encode.
|
||||
*/
|
||||
protected function encode(array $data): array
|
||||
{
|
||||
$result = [];
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update an item in the database
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return boolean The modeled element data structure stored into the DB.
|
||||
*
|
||||
* @overrides Model::save.
|
||||
*/
|
||||
public function save(array $data=[]): bool
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a group Id value.
|
||||
*
|
||||
|
@ -240,7 +240,7 @@ class Item extends CachedModel
|
||||
private static function extractX(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['x', 'pos_x']),
|
||||
static::issetInArray($data, ['x', 'pos_x', 'posX', 'startX']),
|
||||
0
|
||||
);
|
||||
}
|
||||
@ -256,7 +256,7 @@ class Item extends CachedModel
|
||||
private static function extractY(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['y', 'pos_y']),
|
||||
static::issetInArray($data, ['y', 'pos_y', 'posY', 'startY']),
|
||||
0
|
||||
);
|
||||
}
|
||||
@ -272,7 +272,7 @@ class Item extends CachedModel
|
||||
private static function extractAclGroupId(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_group', 'aclGroupId']),
|
||||
static::issetInArray($data, ['id_group', 'aclGroupId', 'idGroup']),
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -288,7 +288,7 @@ class Item extends CachedModel
|
||||
private static function extractParentId(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['parentId', 'parent_item']),
|
||||
static::issetInArray($data, ['parentId', 'parent_item', 'parentItem']),
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -304,7 +304,7 @@ class Item extends CachedModel
|
||||
private static function extractIsOnTop(array $data): bool
|
||||
{
|
||||
return static::parseBool(
|
||||
static::issetInArray($data, ['isOnTop', 'show_on_top'])
|
||||
static::issetInArray($data, ['isOnTop', 'show_on_top', 'showOnTop'])
|
||||
);
|
||||
}
|
||||
|
||||
@ -319,7 +319,7 @@ class Item extends CachedModel
|
||||
private static function extractIsLinkEnabled(array $data): bool
|
||||
{
|
||||
return static::parseBool(
|
||||
static::issetInArray($data, ['isLinkEnabled', 'enable_link'])
|
||||
static::issetInArray($data, ['isLinkEnabled', 'enable_link', 'enableLink'])
|
||||
);
|
||||
}
|
||||
|
||||
@ -376,7 +376,23 @@ class Item extends CachedModel
|
||||
private static function extractAgentId(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['agentId', 'id_agent', 'id_agente']),
|
||||
static::issetInArray($data, ['agentId', 'id_agent', 'id_agente', 'idAgent', 'idAgente']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a custom id graph value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Valid identifier of an agent.
|
||||
*/
|
||||
private static function extractIdCustomGraph(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_custom_graph', 'idCustomGraph', 'customGraphId']),
|
||||
null
|
||||
);
|
||||
}
|
||||
@ -398,6 +414,9 @@ class Item extends CachedModel
|
||||
'moduleId',
|
||||
'id_agente_modulo',
|
||||
'id_modulo',
|
||||
'idModulo',
|
||||
'idAgenteModulo',
|
||||
'idAgentModule',
|
||||
]
|
||||
),
|
||||
null
|
||||
@ -1187,4 +1206,468 @@ class Item extends CachedModel
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
* @param array $data Input data.
|
||||
*
|
||||
* @return array Data structure representing a record in database.
|
||||
*
|
||||
* @overrides Model::encode.
|
||||
*/
|
||||
protected function encode(array $data): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$id = static::getId($data);
|
||||
if ($id) {
|
||||
$result['id'] = $id;
|
||||
}
|
||||
|
||||
$id_layout = static::getIdLayout($data);
|
||||
if ($id_layout) {
|
||||
$result['id_layout'] = $id_layout;
|
||||
}
|
||||
|
||||
$pos_x = static::parseIntOr(
|
||||
static::issetInArray($data, ['x', 'pos_x', 'posX']),
|
||||
null
|
||||
);
|
||||
if ($pos_x !== null) {
|
||||
$result['pos_x'] = $pos_x;
|
||||
}
|
||||
|
||||
$pos_y = static::parseIntOr(
|
||||
static::issetInArray($data, ['y', 'pos_y', 'posY']),
|
||||
null
|
||||
);
|
||||
if ($pos_y !== null) {
|
||||
$result['pos_y'] = $pos_y;
|
||||
}
|
||||
|
||||
$height = static::getHeight($data);
|
||||
if ($height !== null) {
|
||||
$result['height'] = $height;
|
||||
}
|
||||
|
||||
$width = static::getWidth($data);
|
||||
if ($width !== null) {
|
||||
$result['width'] = $width;
|
||||
}
|
||||
|
||||
$label = static::extractLabel($data);
|
||||
if ($label !== null) {
|
||||
$result['label'] = $label;
|
||||
}
|
||||
|
||||
$image = static::getImageSrc($data);
|
||||
if ($image !== null) {
|
||||
$result['image'] = $image;
|
||||
}
|
||||
|
||||
$type = static::parseIntOr(
|
||||
static::issetInArray($data, ['type']),
|
||||
null
|
||||
);
|
||||
if ($type !== null) {
|
||||
$result['type'] = $type;
|
||||
}
|
||||
|
||||
$period = static::parseIntOr(
|
||||
static::issetInArray($data, ['period', 'maxTime']),
|
||||
null
|
||||
);
|
||||
if ($period !== null) {
|
||||
$result['period'] = $period;
|
||||
}
|
||||
|
||||
$id_agente_modulo = static::extractModuleId($data);
|
||||
if ($id_agente_modulo !== null) {
|
||||
$result['id_agente_modulo'] = $id_agente_modulo;
|
||||
}
|
||||
|
||||
$id_agent = static::extractAgentId($data);
|
||||
if ($id_agent !== null) {
|
||||
$result['id_agent'] = $id_agent;
|
||||
}
|
||||
|
||||
$id_layout_linked = static::parseIntOr(
|
||||
static::issetInArray($data, ['linkedLayoutId', 'id_layout_linked', 'idLayoutLinked']),
|
||||
null
|
||||
);
|
||||
if ($id_layout_linked !== null) {
|
||||
$result['id_layout_linked'] = $id_layout_linked;
|
||||
}
|
||||
|
||||
$parent_item = static::extractParentId($data);
|
||||
if ($parent_item !== null) {
|
||||
$result['parent_item'] = $parent_item;
|
||||
}
|
||||
|
||||
$enable_link = static::issetInArray($data, ['isLinkEnabled', 'enable_link', 'enableLink']);
|
||||
if ($enable_link !== null) {
|
||||
$result['enable_link'] = static::parseBool($enable_link);
|
||||
}
|
||||
|
||||
$id_metaconsole = static::extractMetaconsoleId($data);
|
||||
if ($id_metaconsole !== null) {
|
||||
$result['id_metaconsole'] = $id_metaconsole;
|
||||
}
|
||||
|
||||
$id_group = static::extractAclGroupId($data);
|
||||
if ($id_group !== null) {
|
||||
$result['id_group'] = $id_group;
|
||||
}
|
||||
|
||||
$id_custom_graph = static::extractIdCustomGraph($data);
|
||||
if ($id_custom_graph !== null) {
|
||||
$result['id_custom_graph'] = $id_custom_graph;
|
||||
}
|
||||
|
||||
$border_width = static::getBorderWidth($data);
|
||||
if ($border_width !== null) {
|
||||
$result['border_width'] = $border_width;
|
||||
}
|
||||
|
||||
$type_graph = static::getTypeGraph($data);
|
||||
if ($type_graph !== null) {
|
||||
$result['type_graph'] = $type_graph;
|
||||
}
|
||||
|
||||
$label_position = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['labelPosition', 'label_position']),
|
||||
null
|
||||
);
|
||||
if ($label_position !== null) {
|
||||
$result['label_position'] = $label_position;
|
||||
}
|
||||
|
||||
$border_color = static::getBorderColor($data);
|
||||
if ($border_color !== null) {
|
||||
$result['border_color'] = $border_color;
|
||||
}
|
||||
|
||||
$fill_color = static::getFillColor($data);
|
||||
if ($fill_color !== null) {
|
||||
$result['fill_color'] = $fill_color;
|
||||
}
|
||||
|
||||
$show_statistics = static::issetInArray($data, ['showStatistics', 'show_statistics']);
|
||||
if ($show_statistics !== null) {
|
||||
$result['show_statistics'] = static::parseBool($show_statistics);
|
||||
}
|
||||
|
||||
$linked_layout_node_id = static::parseIntOr(
|
||||
static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'linkedLayoutAgentId',
|
||||
'linked_layout_node_id',
|
||||
]
|
||||
),
|
||||
null
|
||||
);
|
||||
if ($linked_layout_node_id !== null) {
|
||||
$result['linked_layout_node_id'] = $linked_layout_node_id;
|
||||
}
|
||||
|
||||
$linked_layout_status_type = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['linkedLayoutStatusType', 'linked_layout_status_type']),
|
||||
null
|
||||
);
|
||||
if ($linked_layout_status_type !== null) {
|
||||
$result['linked_layout_status_type'] = $linked_layout_status_type;
|
||||
}
|
||||
|
||||
$id_layout_linked_weight = static::parseIntOr(
|
||||
static::issetInArray($data, ['linkedLayoutStatusTypeWeight', 'id_layout_linked_weight']),
|
||||
null
|
||||
);
|
||||
if ($id_layout_linked_weight !== null) {
|
||||
$result['id_layout_linked_weight'] = $id_layout_linked_weight;
|
||||
}
|
||||
|
||||
$linked_layout_status_as_service_warning = static::parseIntOr(
|
||||
static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'linkedLayoutStatusTypeWarningThreshold',
|
||||
'linked_layout_status_as_service_warning',
|
||||
]
|
||||
),
|
||||
null
|
||||
);
|
||||
if ($linked_layout_status_as_service_warning !== null) {
|
||||
$result['linked_layout_status_as_service_warning'] = $linked_layout_status_as_service_warning;
|
||||
}
|
||||
|
||||
$linked_layout_status_as_service_critical = static::parseIntOr(
|
||||
static::issetInArray(
|
||||
$data,
|
||||
[
|
||||
'linkedLayoutStatusTypeCriticalThreshold',
|
||||
'linked_layout_status_as_service_critical',
|
||||
]
|
||||
),
|
||||
null
|
||||
);
|
||||
if ($linked_layout_status_as_service_critical !== null) {
|
||||
$result['linked_layout_status_as_service_critical'] = $linked_layout_status_as_service_critical;
|
||||
}
|
||||
|
||||
$element_group = static::parseIntOr(
|
||||
static::issetInArray($data, ['elementGroup', 'element_group']),
|
||||
null
|
||||
);
|
||||
if ($element_group !== null) {
|
||||
$result['element_group'] = $element_group;
|
||||
}
|
||||
|
||||
$show_on_top = static::issetInArray($data, ['isOnTop', 'show_on_top', 'showOnTop']);
|
||||
if ($show_on_top !== null) {
|
||||
$result['show_on_top'] = static::parseBool($show_on_top);
|
||||
}
|
||||
|
||||
$clock_animation = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['clockType', 'clock_animation', 'clockAnimation']),
|
||||
null
|
||||
);
|
||||
if ($clock_animation !== null) {
|
||||
$result['clock_animation'] = $clock_animation;
|
||||
}
|
||||
|
||||
$time_format = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['clockFormat', 'time_format', 'timeFormat']),
|
||||
null
|
||||
);
|
||||
if ($time_format !== null) {
|
||||
$result['time_format'] = $time_format;
|
||||
}
|
||||
|
||||
$timezone = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['timezone', 'timeZone', 'time_zone', 'clockTimezone']),
|
||||
null
|
||||
);
|
||||
if ($timezone !== null) {
|
||||
$result['timezone'] = $timezone;
|
||||
}
|
||||
|
||||
$show_last_value = static::parseIntOr(
|
||||
static::issetInArray($data, ['show_last_value', 'showLastValue']),
|
||||
null
|
||||
);
|
||||
if ($show_last_value !== null) {
|
||||
$result['show_last_value'] = $show_last_value;
|
||||
}
|
||||
|
||||
$cache_expiration = static::parseIntOr(
|
||||
static::issetInArray($data, ['cache_expiration', 'cacheExpiration']),
|
||||
null
|
||||
);
|
||||
if ($cache_expiration !== null) {
|
||||
$result['cache_expiration'] = $cache_expiration;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item id.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item id. 0 by default.
|
||||
*/
|
||||
private static function getId(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id', 'itemId']),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract layout id.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item id. 0 by default.
|
||||
*/
|
||||
private static function getIdLayout(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_layout', 'idLayout', 'layoutId']),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item width.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item width. 0 by default.
|
||||
*/
|
||||
private static function getWidth(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['width', 'endX']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item height.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item height. 0 by default.
|
||||
*/
|
||||
private static function getHeight(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['height', 'endY']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a image src value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed String representing the image url (not empty) or null.
|
||||
*/
|
||||
protected static function getImageSrc(array $data)
|
||||
{
|
||||
$imageSrc = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['image', 'imageSrc', 'backgroundColor', 'backgroundType', 'valueType']),
|
||||
null
|
||||
);
|
||||
|
||||
return $imageSrc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a border width value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Valid border width.
|
||||
*/
|
||||
private static function getBorderWidth(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['border_width', 'borderWidth']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a type graph value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return string One of 'vertical' or 'horizontal'. 'vertical' by default.
|
||||
*/
|
||||
private static function getTypeGraph(array $data)
|
||||
{
|
||||
return static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['typeGraph', 'type_graph', 'graphType']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a border color value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed String representing the border color (not empty) or null.
|
||||
*/
|
||||
private static function getBorderColor(array $data)
|
||||
{
|
||||
return static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['borderColor', 'border_color', 'gridColor', 'color', 'legendBackgroundColor']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a fill color value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return mixed String representing the fill color (not empty) or null.
|
||||
*/
|
||||
private static function getFillColor(array $data)
|
||||
{
|
||||
return static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['fillColor', 'fill_color', 'labelColor']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update an item in the database
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return boolean The modeled element data structure stored into the DB.
|
||||
*
|
||||
* @overrides Model::save.
|
||||
*/
|
||||
public function save(array $data=[]): bool
|
||||
{
|
||||
if (empty($data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$dataModelEncode = $this->encode($this->toArray());
|
||||
$dataEncode = $this->encode($data);
|
||||
|
||||
$save = \array_merge($dataModelEncode, $dataEncode);
|
||||
|
||||
if (!empty($save)) {
|
||||
if (empty($save['id'])) {
|
||||
// Insert.
|
||||
$result = \db_process_sql_insert('tlayout_data', $save);
|
||||
if ($result) {
|
||||
$item = static::fromDB(['id' => $result]);
|
||||
}
|
||||
} else {
|
||||
// Update.
|
||||
$result = \db_process_sql_update('tlayout_data', $save, ['id' => $save['id']]);
|
||||
// Invalidate the item's cache.
|
||||
if ($result !== false && $result > 0) {
|
||||
db_process_sql_delete(
|
||||
'tvisual_console_elements_cache',
|
||||
[
|
||||
'vc_item_id' => (int) $save['id'],
|
||||
]
|
||||
);
|
||||
|
||||
$item = static::fromDB(['id' => $save['id']]);
|
||||
// Update the model.
|
||||
if (!empty($item)) {
|
||||
$this->setData($item->toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -206,4 +206,203 @@ final class Line extends Model
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a valid representation of a record in database.
|
||||
*
|
||||
* @param array $data Input data.
|
||||
*
|
||||
* @return array Data structure representing a record in database.
|
||||
*
|
||||
* @overrides Model::encode.
|
||||
*/
|
||||
protected function encode(array $data): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
$id = static::getId($data);
|
||||
if ($id) {
|
||||
$result['id'] = $id;
|
||||
}
|
||||
|
||||
$id_layout = static::getIdLayout($data);
|
||||
if ($id_layout) {
|
||||
$result['id_layout'] = $id_layout;
|
||||
}
|
||||
|
||||
$pos_x = static::parseIntOr(
|
||||
static::issetInArray($data, ['x', 'pos_x', 'posX']),
|
||||
null
|
||||
);
|
||||
if ($pos_x !== null) {
|
||||
$result['pos_x'] = $pos_x;
|
||||
}
|
||||
|
||||
$pos_y = static::parseIntOr(
|
||||
static::issetInArray($data, ['y', 'pos_y', 'posY']),
|
||||
null
|
||||
);
|
||||
if ($pos_y !== null) {
|
||||
$result['pos_y'] = $pos_y;
|
||||
}
|
||||
|
||||
$height = static::getHeight($data);
|
||||
if ($height !== null) {
|
||||
$result['height'] = $height;
|
||||
}
|
||||
|
||||
$width = static::getWidth($data);
|
||||
if ($width !== null) {
|
||||
$result['width'] = $width;
|
||||
}
|
||||
|
||||
$type = static::parseIntOr(
|
||||
static::issetInArray($data, ['type']),
|
||||
null
|
||||
);
|
||||
if ($type !== null) {
|
||||
$result['type'] = $type;
|
||||
}
|
||||
|
||||
$border_width = static::getBorderWidth($data);
|
||||
if ($border_width !== null) {
|
||||
$result['border_width'] = $border_width;
|
||||
}
|
||||
|
||||
$border_color = static::extractBorderColor($data);
|
||||
if ($border_color !== null) {
|
||||
$result['border_color'] = $border_color;
|
||||
}
|
||||
|
||||
$show_on_top = static::issetInArray($data, ['isOnTop', 'show_on_top', 'showOnTop']);
|
||||
if ($show_on_top !== null) {
|
||||
$result['show_on_top'] = static::parseBool($show_on_top);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item id.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item id. 0 by default.
|
||||
*/
|
||||
private static function getId(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id', 'itemId']),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract layout id.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item id. 0 by default.
|
||||
*/
|
||||
private static function getIdLayout(array $data): int
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['id_layout', 'idLayout', 'layoutId']),
|
||||
0
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item width.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item width. 0 by default.
|
||||
*/
|
||||
private static function getWidth(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['width', 'endX']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract item height.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Item height. 0 by default.
|
||||
*/
|
||||
private static function getHeight(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['height', 'endY']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Extract a border width value.
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return integer Valid border width.
|
||||
*/
|
||||
private static function getBorderWidth(array $data)
|
||||
{
|
||||
return static::parseIntOr(
|
||||
static::issetInArray($data, ['border_width', 'borderWidth']),
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Insert or update an item in the database
|
||||
*
|
||||
* @param array $data Unknown input data structure.
|
||||
*
|
||||
* @return boolean The modeled element data structure stored into the DB.
|
||||
*
|
||||
* @overrides Model::save.
|
||||
*/
|
||||
public function save(array $data=[]): bool
|
||||
{
|
||||
$data_model = $this->encode($this->toArray());
|
||||
$newData = $this->encode($data);
|
||||
|
||||
$save = \array_merge($data_model, $newData);
|
||||
|
||||
if (!empty($save)) {
|
||||
if (empty($save['id'])) {
|
||||
// Insert.
|
||||
$result = \db_process_sql_insert('tlayout_data', $save);
|
||||
} else {
|
||||
// Update.
|
||||
$result = \db_process_sql_update('tlayout_data', $save, ['id' => $save['id']]);
|
||||
}
|
||||
}
|
||||
|
||||
// Update the model.
|
||||
if ($result) {
|
||||
if (empty($save['id'])) {
|
||||
$item = static::fromDB(['id' => $result]);
|
||||
} else {
|
||||
$item = static::fromDB(['id' => $save['id']]);
|
||||
}
|
||||
|
||||
if (!empty($item)) {
|
||||
$this->setData($item->toArray());
|
||||
}
|
||||
}
|
||||
|
||||
return (bool) $result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -119,8 +119,8 @@ a#qr_code_agent_view {
|
||||
border-bottom-right-radius: 0px;
|
||||
}
|
||||
|
||||
.adv_right,
|
||||
.adv_left,
|
||||
.agent_av_opt_right,
|
||||
.agent_av_opt_left,
|
||||
.secondary_groups_list {
|
||||
flex: 1;
|
||||
}
|
||||
@ -150,8 +150,8 @@ a#qr_code_agent_view {
|
||||
margin: 1em;
|
||||
}
|
||||
|
||||
.adv_left input,
|
||||
.adv_left select {
|
||||
.agent_av_opt_left input,
|
||||
.agent_av_opt_left select {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
|
12
pandora_console/include/styles/credential_store.css
Normal file
12
pandora_console/include/styles/credential_store.css
Normal file
@ -0,0 +1,12 @@
|
||||
#info_key .flex-row,
|
||||
#new_key .flex-row {
|
||||
margin: 1em auto;
|
||||
max-width: 80%;
|
||||
}
|
||||
|
||||
#info_key input,
|
||||
#info_key select,
|
||||
#new_key input,
|
||||
#new_key select {
|
||||
width: 60%;
|
||||
}
|
10
pandora_console/include/styles/discovery-hint.css
Normal file
10
pandora_console/include/styles/discovery-hint.css
Normal file
@ -0,0 +1,10 @@
|
||||
/*
|
||||
* Discovery show help css
|
||||
*/
|
||||
li.discovery:not(:first-child) > a:hover {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
li.discovery:not(:first-child) div.data_container:not(:hover) {
|
||||
box-shadow: 2px 2px 10px #80ba27;
|
||||
}
|
@ -2,6 +2,10 @@
|
||||
* Discovery css global
|
||||
*/
|
||||
|
||||
ul.bigbuttonlist {
|
||||
min-height: 200px;
|
||||
}
|
||||
|
||||
li.discovery {
|
||||
display: inline-block;
|
||||
float: left;
|
||||
@ -261,3 +265,8 @@ a.tip {
|
||||
.discovery_interval_select_width {
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
a.ext_link {
|
||||
margin-left: 1em;
|
||||
font-size: 8pt;
|
||||
}
|
||||
|
@ -96,14 +96,12 @@ table.dataTable tbody td {
|
||||
}
|
||||
|
||||
.sorting_desc {
|
||||
background: url(http://localhost/pandora_console/images/sort_down_green.png)
|
||||
no-repeat;
|
||||
background: url(../../images/sort_down_green.png) no-repeat;
|
||||
background-position-x: left;
|
||||
background-position-y: center;
|
||||
}
|
||||
.sorting_asc {
|
||||
background: url(http://localhost/pandora_console/images/sort_up_green.png)
|
||||
no-repeat;
|
||||
background: url(../../images/sort_up_green.png) no-repeat;
|
||||
background-position-x: left;
|
||||
background-position-y: center;
|
||||
}
|
||||
|
@ -78,3 +78,7 @@ div.new_task_cluster > div {
|
||||
#fuerte {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.flex-row-baseline * {
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
@ -406,6 +406,8 @@ div.form_message_alert ul li input {
|
||||
}
|
||||
|
||||
div.form_message_alert ul li label {
|
||||
display: inline-block;
|
||||
width: 145px;
|
||||
font-size: 10pt;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
@ -502,6 +502,13 @@ select:-internal-list-box {
|
||||
.no-text-imp {
|
||||
font-size: 0 !important;
|
||||
}
|
||||
.flex-content-right {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: nowrap;
|
||||
justify-content: flex-end;
|
||||
align-content: flex-end;
|
||||
}
|
||||
.flex-column {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
@ -517,6 +524,12 @@ select:-internal-list-box {
|
||||
justify-content: space-between;
|
||||
align-content: center;
|
||||
}
|
||||
.flex-row-baseline {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: baseline;
|
||||
}
|
||||
|
||||
.nowrap {
|
||||
flex-wrap: nowrap;
|
||||
@ -1158,7 +1171,6 @@ div.title_line {
|
||||
|
||||
#menu_tab {
|
||||
margin-right: 10px;
|
||||
min-width: 510px;
|
||||
}
|
||||
|
||||
#menu_tab .mn,
|
||||
@ -3539,31 +3551,6 @@ div.div_groups_status {
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
* ---------------------------------------------------------------------
|
||||
* - VISUAL MAPS -
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
div#vc-controls {
|
||||
position: fixed;
|
||||
top: 30px;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
div#vc-controls div.vc-title,
|
||||
div#vc-controls div.vc-refr {
|
||||
margin-top: 6px;
|
||||
margin-left: 3px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
div#vc-controls div.vc-refr > div {
|
||||
display: inline;
|
||||
}
|
||||
div#vc-controls img.vc-qr {
|
||||
margin-top: 6px;
|
||||
margin-left: 8px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
div.simple_value > span.text > p,
|
||||
div.simple_value > span.text > p > span > strong,
|
||||
div.simple_value > span.text > p > strong,
|
||||
|
@ -312,3 +312,31 @@ a.pandora_pagination.current:hover {
|
||||
border-color: #b6b6b6;
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
/* Default datatable filter style */
|
||||
.datatable_filter.content {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
.datatable_filter.content label {
|
||||
margin-right: 1em;
|
||||
}
|
||||
.datatable_filter.content li {
|
||||
flex: 1 1 auto;
|
||||
margin: 1em auto;
|
||||
}
|
||||
.sorting_desc {
|
||||
background: url(../../images/sort_down_green.png) no-repeat;
|
||||
background-position-x: left;
|
||||
background-position-y: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.sorting_asc {
|
||||
background: url(../../images/sort_up_green.png) no-repeat;
|
||||
background-position-x: left;
|
||||
background-position-y: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
@ -3,6 +3,37 @@
|
||||
* - VISUAL MAPS -
|
||||
* ---------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
div#vc-controls {
|
||||
position: fixed;
|
||||
top: 30px;
|
||||
right: 20px;
|
||||
}
|
||||
|
||||
div#vc-controls div.vc-title,
|
||||
div#vc-controls div.vc-refr {
|
||||
margin-top: 15px;
|
||||
margin-left: 3px;
|
||||
margin-right: 3px;
|
||||
}
|
||||
div#vc-controls div.vc-refr > div {
|
||||
display: inline;
|
||||
}
|
||||
div#vc-controls img.vc-qr {
|
||||
margin-top: 12px;
|
||||
margin-left: 8px;
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.visual-console-edit-controls {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.visual-console-edit-controls > span {
|
||||
margin: 4px;
|
||||
}
|
||||
|
||||
input.vs_button_ghost {
|
||||
background-color: transparent;
|
||||
border: 1px solid #82b92e;
|
||||
|
@ -13,22 +13,38 @@
|
||||
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;
|
||||
border: 2px dashed #b2b2b2;
|
||||
-webkit-transform: translateX(-2px) translateY(-2px);
|
||||
transform: translateX(-2px) translateY(-2px);
|
||||
transform: translateX(-2px) translateY(-2px);
|
||||
cursor: move;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.visual-console-item.is-editing > .resize-draggable {
|
||||
float: right;
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background: url(data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIGlkPSJDYXBhXzEiIAoJeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiAKCXhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB4PSIwcHgiIHk9IjBweCIgd2lkdGg9IjE1cHgiIGhlaWdodD0iMTVweCIgdmlld0JveD0iMCAwIDE1IDE1IiBlbmFibGUtYmFja2dyb3VuZD0ibmV3IDAgMCAxNSAxNSIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+Cgk8bGluZSBmaWxsPSJub25lIiBzdHJva2U9IiNCMkIyQjIiIHN0cm9rZS13aWR0aD0iMS41IiBzdHJva2UtbWl0ZXJsaW1pdD0iMTAiIHgxPSIwLjU2MiIgeTE9IjM2LjMxNyIgeDI9IjE0LjIzMSIgeTI9IjIyLjY0OCIvPgoJPGxpbmUgZmlsbD0ibm9uZSIgc3Ryb2tlPSIjQjJCMkIyIiBzdHJva2Utd2lkdGg9IjEuNSIgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIiB4MT0iNC45NzEiIHkxPSIzNi41OTUiIHgyPSIxNC40MDkiIHkyPSIyNy4xNTUiLz4KCTxsaW5lIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0IyQjJCMiIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgeDE9IjEwLjAxNyIgeTE9IjM2LjQzMyIgeDI9IjE0LjIzMSIgeTI9IjMyLjIxOCIvPgoJPGcgaWQ9ImpHRWVLbl8xXyI+CgoJCTxpbWFnZSBvdmVyZmxvdz0idmlzaWJsZSIgd2lkdGg9IjQ2IiBoZWlnaHQ9IjM3IiBpZD0iakdFZUtuIiB4bGluazpocmVmPSJkYXRhOmltYWdlL2pwZWc7YmFzZTY0LC85ai80QUFRU2taSlJnQUJBZ0VBU0FCSUFBRC83QUFSUkhWamEza0FBUUFFQUFBQUhnQUEvKzRBSVVGa2IySmxBR1RBQUFBQUFRTUEKRUFNQ0F3WUFBQUdSQUFBQnN3QUFBZ0wvMndDRUFCQUxDd3NNQ3hBTURCQVhEdzBQRnhzVUVCQVVHeDhYRnhjWEZ4OGVGeG9hR2hvWApIaDRqSlNjbEl4NHZMek16THk5QVFFQkFRRUJBUUVCQVFFQkFRRUFCRVE4UEVSTVJGUklTRlJRUkZCRVVHaFFXRmhRYUpob2FIQm9hCkpqQWpIaDRlSGlNd0t5NG5KeWN1S3pVMU1EQTFOVUJBUDBCQVFFQkFRRUJBUUVCQVFQL0NBQkVJQUNZQUx3TUJJZ0FDRVFFREVRSC8KeEFCNUFBRUJBUUVCQUFBQUFBQUFBQUFBQUFBQUFRUUNCZ0VCQUFBQUFBQUFBQUFBQUFBQUFBQUFBQkFBQVFRREFBQUFBQUFBQUFBQQpBQUFBQVFBeEFnTVFNQklSQUFFQkJnVUZBUUFBQUFBQUFBQUFBQUVDQUJFaFFXRURFQ0J4a1JJd01ZRXlFd1FTQVFBQUFBQUFBQUFBCkFBQUFBQUFBQURELzJnQU1Bd0VBQWhFREVRQUFBUGZBUzV6VFpUa0dQclVMWlFBQUQvL2FBQWdCQWdBQkJRRFQvOW9BQ0FFREFBRUYKQU5QLzJnQUlBUUVBQVFVQXpKZzJTUUJDMmQwdzJiWlN2Vk5jNW9NdUF1UXVBdVJwLzlvQUNBRUNBZ1kvQUIvLzJnQUlBUU1DQmo4QQpILy9hQUFnQkFRRUdQd0RFNlpYbUFZcXR3c0pCSEk5MUdsTXFudlQrZTM3UUwxa1MwYjdYQndBRHJWb1FDUlhHZTVhZTVhZTVhZms5CkgvL1oiIHRyYW5zZm9ybT0ibWF0cml4KDEgMCAwIDEgLTQ2Ljg3NSAtOS44OTA2KSI+CgkJPC9pbWFnZT4KCTwvZz4KCTxsaW5lIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0IyQjJCMiIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgeDE9IjEzLjQ4MyIgeTE9IjAuNjQ0IiB4Mj0iMC44MjgiIHkyPSIxMy4zMDEiLz4KCTxsaW5lIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0IyQjJCMiIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgeDE9IjEzLjczNCIgeTE9IjUuMTQxIiB4Mj0iNS4zMjUiIHkyPSIxMy41NDkiLz4KCTxsaW5lIGZpbGw9Im5vbmUiIHN0cm9rZT0iI0IyQjJCMiIgc3Ryb2tlLXdpZHRoPSIxLjUiIHN0cm9rZS1taXRlcmxpbWl0PSIxMCIgeDE9IjE0LjIzMSIgeTE9IjkuMzg4IiB4Mj0iOS44MDYiIHkyPSIxMy44MTMiLz4KPC9zdmc+Cg==);
|
||||
cursor: se-resize;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
@ -44,17 +60,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 {
|
||||
@ -84,17 +100,18 @@
|
||||
|
||||
.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*/
|
@ -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;;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":""}
|
||||
{"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;EAC5C,YAAY;EACZ,yBAAiB;KAAjB,sBAAiB;MAAjB,qBAAiB;UAAjB,iBAAiB;AACnB;;AAEA;EACE,YAAY;EACZ,kBAAkB;EAClB,QAAQ;EACR,SAAS;EACT,WAAW;EACX,YAAY;EACZ,yCAAoC;EACpC,iBAAiB;AACnB;;ACjCA;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 #b2b2b2;\n transform: translateX(-2px) translateY(-2px);\n cursor: move;\n user-select: none;\n}\n\n.visual-console-item.is-editing > .resize-draggable {\n float: right;\n position: absolute;\n right: 0;\n bottom: 0;\n width: 15px;\n height: 15px;\n background: url(./resize-handle.svg);\n cursor: se-resize;\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
@ -129,7 +129,7 @@
|
||||
<div style='height: 10px'>
|
||||
<?php
|
||||
$version = '7.0NG.735';
|
||||
$build = '190624';
|
||||
$build = '190626';
|
||||
$banner = "v$version Build $build";
|
||||
|
||||
error_reporting(0);
|
||||
|
@ -1,7 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* Extension to manage a list of gateways and the node address where they should
|
||||
* point to.
|
||||
* Event list.
|
||||
*
|
||||
* @category Events
|
||||
* @package Pandora FMS
|
||||
@ -45,9 +44,13 @@ require_once $config['homedir'].'/include/functions_ui.php';
|
||||
// Check access.
|
||||
check_login();
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'ER')
|
||||
&& ! check_acl($config['id_user'], 0, 'EW')
|
||||
&& ! check_acl($config['id_user'], 0, 'EM')
|
||||
$event_a = check_acl($config['id_user'], 0, 'ER');
|
||||
$event_w = check_acl($config['id_user'], 0, 'EW');
|
||||
$event_m = check_acl($config['id_user'], 0, 'EM');
|
||||
|
||||
if (! $event_a
|
||||
&& ! $event_w
|
||||
&& ! $event_m
|
||||
) {
|
||||
db_pandora_audit(
|
||||
'ACL Violation',
|
||||
@ -62,9 +65,6 @@ if (! check_acl($config['id_user'], 0, 'ER')
|
||||
}
|
||||
|
||||
|
||||
$event_a = check_acl($config['id_user'], 0, 'ER');
|
||||
$event_w = check_acl($config['id_user'], 0, 'EW');
|
||||
$event_m = check_acl($config['id_user'], 0, 'EM');
|
||||
$access = ($event_a == true) ? 'ER' : (($event_w == true) ? 'EW' : (($event_m == true) ? 'EM' : 'ER'));
|
||||
|
||||
|
||||
@ -88,32 +88,118 @@ if (is_metaconsole()) {
|
||||
ui_require_javascript_file('pandora_events');
|
||||
|
||||
// Get requests.
|
||||
$id_group = get_parameter('filter[id_group]');
|
||||
$event_type = get_parameter('filter[event_type]');
|
||||
$severity = get_parameter('filter[severity]');
|
||||
$status = get_parameter('filter[status]', EVENT_NO_VALIDATED);
|
||||
$search = get_parameter('filter[search]');
|
||||
$text_agent = get_parameter('filter[text_agent]');
|
||||
$id_agent = get_parameter('filter[id_agent]');
|
||||
$id_agent_module = get_parameter('filter[id_agent_module]');
|
||||
$pagination = get_parameter('filter[pagination]');
|
||||
$event_view_hr = get_parameter('filter[event_view_hr]', $config['event_view_hr']);
|
||||
$id_user_ack = get_parameter('filter[id_user_ack]');
|
||||
$group_rep = get_parameter('filter[group_rep]', 1);
|
||||
$tag_with = get_parameter('filter[tag_with]', []);
|
||||
$tag_without = get_parameter('filter[tag_without]', []);
|
||||
$filter_only_alert = get_parameter('filter[filter_only_alert]');
|
||||
$id_group_filter = get_parameter('filter[id_group_filter]');
|
||||
$date_from = get_parameter('filter[date_from]');
|
||||
$date_to = get_parameter('filter[date_to]');
|
||||
$source = get_parameter('filter[source]');
|
||||
$id_extra = get_parameter('filter[id_extra]');
|
||||
$user_comment = get_parameter('filter[user_comment]');
|
||||
$default_filter = [
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
];
|
||||
|
||||
$fb64 = get_parameter('fb64', null);
|
||||
if (isset($fb64)) {
|
||||
$filter = json_decode(base64_decode($fb64), true);
|
||||
} else {
|
||||
$filter = get_parameter(
|
||||
'filter',
|
||||
$default_filter
|
||||
);
|
||||
}
|
||||
|
||||
$id_group = get_parameter(
|
||||
'filter[id_group]',
|
||||
$filter['id_group']
|
||||
);
|
||||
$event_type = get_parameter(
|
||||
'filter[event_type]',
|
||||
$filter['event_type']
|
||||
);
|
||||
$severity = get_parameter(
|
||||
'filter[severity]',
|
||||
$filter['severity']
|
||||
);
|
||||
$status = get_parameter(
|
||||
'filter[status]',
|
||||
$filter['status']
|
||||
);
|
||||
$search = get_parameter(
|
||||
'filter[search]',
|
||||
$filter['search']
|
||||
);
|
||||
$text_agent = get_parameter(
|
||||
'filter[text_agent]',
|
||||
$filter['text_agent']
|
||||
);
|
||||
$id_agent = get_parameter(
|
||||
'filter[id_agent]',
|
||||
$filter['id_agent']
|
||||
);
|
||||
$id_agent_module = get_parameter(
|
||||
'filter[id_agent_module]',
|
||||
$filter['id_agent_module']
|
||||
);
|
||||
$pagination = get_parameter(
|
||||
'filter[pagination]',
|
||||
$filter['pagination']
|
||||
);
|
||||
$event_view_hr = get_parameter(
|
||||
'filter[event_view_hr]',
|
||||
$filter['event_view_hr']
|
||||
);
|
||||
$id_user_ack = get_parameter(
|
||||
'filter[id_user_ack]',
|
||||
$filter['id_user_ack']
|
||||
);
|
||||
$group_rep = get_parameter(
|
||||
'filter[group_rep]',
|
||||
$filter['group_rep']
|
||||
);
|
||||
$tag_with = get_parameter(
|
||||
'filter[tag_with]',
|
||||
$filter['tag_with']
|
||||
);
|
||||
$tag_without = get_parameter(
|
||||
'filter[tag_without]',
|
||||
$filter['tag_without']
|
||||
);
|
||||
$filter_only_alert = get_parameter(
|
||||
'filter[filter_only_alert]',
|
||||
$filter['filter_only_alert']
|
||||
);
|
||||
$id_group_filter = get_parameter(
|
||||
'filter[id_group_filter]',
|
||||
$filter['id_group_filter']
|
||||
);
|
||||
$date_from = get_parameter(
|
||||
'filter[date_from]',
|
||||
$filter['date_from']
|
||||
);
|
||||
$date_to = get_parameter(
|
||||
'filter[date_to]',
|
||||
$filter['date_to']
|
||||
);
|
||||
$source = get_parameter(
|
||||
'filter[source]',
|
||||
$filter['source']
|
||||
);
|
||||
$id_extra = get_parameter(
|
||||
'filter[id_extra]',
|
||||
$filter['id_extra']
|
||||
);
|
||||
$user_comment = get_parameter(
|
||||
'filter[user_comment]',
|
||||
$filter['user_comment']
|
||||
);
|
||||
$history = get_parameter(
|
||||
'history',
|
||||
$filter['history']
|
||||
);
|
||||
$section = get_parameter('section', false);
|
||||
|
||||
// Ajax responses.
|
||||
if (is_ajax()) {
|
||||
$get_events = get_parameter('get_events', 0);
|
||||
$filter = get_parameter('filter', []);
|
||||
// Datatables offset, limit.
|
||||
$start = get_parameter('start', 0);
|
||||
$length = get_parameter('length', $config['block_size']);
|
||||
@ -123,6 +209,10 @@ if (is_ajax()) {
|
||||
ob_start();
|
||||
$order = get_datatable_order(true);
|
||||
|
||||
if (is_array($order) && $order['field'] == 'mini_severity') {
|
||||
$order['field'] = 'te.criticity';
|
||||
}
|
||||
|
||||
$fields = [
|
||||
'te.id_evento',
|
||||
'te.id_agente',
|
||||
@ -151,11 +241,17 @@ if (is_ajax()) {
|
||||
'tg.nombre as group_name',
|
||||
];
|
||||
if (!is_metaconsole()) {
|
||||
$fields[] = 'am.nombre as id_agentmodule';
|
||||
$fields[] = 'am.nombre as module_name';
|
||||
$fields[] = 'am.id_agente_modulo as id_agentmodule';
|
||||
$fields[] = 'ta.server_name as server_name';
|
||||
} else {
|
||||
$fields[] = 'ts.server_name as server_name';
|
||||
}
|
||||
|
||||
$events = events_get_all(
|
||||
// Fields.
|
||||
$fields,
|
||||
// Filter.
|
||||
$filter,
|
||||
// Offset.
|
||||
$start,
|
||||
@ -164,7 +260,9 @@ if (is_ajax()) {
|
||||
// Order.
|
||||
$order['direction'],
|
||||
// Sort field.
|
||||
$order['field']
|
||||
$order['field'],
|
||||
// History.
|
||||
$history
|
||||
);
|
||||
$count = events_get_all(
|
||||
'count',
|
||||
@ -181,6 +279,11 @@ if (is_ajax()) {
|
||||
function ($carry, $item) {
|
||||
$tmp = (object) $item;
|
||||
$tmp->evento = io_safe_output($tmp->evento);
|
||||
if ($tmp->module_name) {
|
||||
$tmp->module_name = io_safe_output($tmp->module_name);
|
||||
}
|
||||
|
||||
$tmp->agent_name = io_safe_output($tmp->agent_name);
|
||||
$tmp->ack_utimestamp = ui_print_timestamp(
|
||||
$tmp->ack_utimestamp,
|
||||
true
|
||||
@ -191,6 +294,9 @@ if (is_ajax()) {
|
||||
);
|
||||
|
||||
$tmp->data = format_numeric($tmp->data, 1);
|
||||
|
||||
$tmp->b64 = base64_encode(json_encode($tmp));
|
||||
|
||||
$carry[] = $tmp;
|
||||
return $carry;
|
||||
}
|
||||
@ -487,34 +593,34 @@ if ($pure) {
|
||||
|
||||
// Fullscreen.
|
||||
$fullscreen['active'] = false;
|
||||
$fullscreen['text'] = '<a href="'.$url.'&pure=1">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).'</a>';
|
||||
$fullscreen['text'] = '<a class="events_link" href="'.$url.'&pure=1&">'.html_print_image('images/full_screen.png', true, ['title' => __('Full screen')]).'</a>';
|
||||
|
||||
// Event list.
|
||||
$list['active'] = false;
|
||||
$list['text'] = '<a href="index.php?sec=eventos&sec2=operation/events/events&pure='.$config['pure'].'">'.html_print_image('images/events_list.png', true, ['title' => __('Event list')]).'</a>';
|
||||
$list['text'] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&pure='.$config['pure'].'&">'.html_print_image('images/events_list.png', true, ['title' => __('Event list')]).'</a>';
|
||||
|
||||
// History event list.
|
||||
$history_list['active'] = false;
|
||||
$history_list['text'] = '<a href="index.php?sec=eventos&sec2=operation/events/events&pure='.$config['pure'].'&section=history&history=1">'.html_print_image('images/books.png', true, ['title' => __('History event list')]).'</a>';
|
||||
$history_list['text'] = '<a class="events_link" href="index.php?sec=eventos&sec2=operation/events/events&pure='.$config['pure'].'&section=history&history=1&">'.html_print_image('images/books.png', true, ['title' => __('History event list')]).'</a>';
|
||||
|
||||
// RSS.
|
||||
$rss['active'] = false;
|
||||
$rss['text'] = '<a href="operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&'.$params.'">'.html_print_image('images/rss.png', true, ['title' => __('RSS Events')]).'</a>';
|
||||
$rss['text'] = '<a class="events_link" href="operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&">'.html_print_image('images/rss.png', true, ['title' => __('RSS Events')]).'</a>';
|
||||
|
||||
// Marquee.
|
||||
$marquee['active'] = false;
|
||||
$marquee['text'] = '<a href="operation/events/events_marquee.php">'.html_print_image('images/heart.png', true, ['title' => __('Marquee display')]).'</a>';
|
||||
$marquee['text'] = '<a class="events_link" href="operation/events/events_marquee.php?">'.html_print_image('images/heart.png', true, ['title' => __('Marquee display')]).'</a>';
|
||||
|
||||
// CSV.
|
||||
$csv['active'] = false;
|
||||
$csv['text'] = '<a href="operation/events/export_csv.php?'.$params.'">'.html_print_image('images/csv_mc.png', true, ['title' => __('Export to CSV file')]).'</a>';
|
||||
$csv['text'] = '<a class="events_link" href="operation/events/export_csv.php?'.$filter_b64.'">'.html_print_image('images/csv_mc.png', true, ['title' => __('Export to CSV file')]).'</a>';
|
||||
|
||||
// Sound events.
|
||||
$sound_event['active'] = false;
|
||||
$sound_event['text'] = '<a href="javascript: openSoundEventWindow();">'.html_print_image('images/sound.png', true, ['title' => __('Sound events')]).'</a>';
|
||||
|
||||
// If the user has administrator permission display manage tab.
|
||||
if (check_acl($config['id_user'], 0, 'EW') || check_acl($config['id_user'], 0, 'EM')) {
|
||||
if ($event_w || $event_m) {
|
||||
// Manage events.
|
||||
$manage_events['active'] = false;
|
||||
$manage_events['text'] = '<a href="index.php?sec=eventos&sec2=godmode/events/events&section=filter&pure='.$config['pure'].'">'.html_print_image('images/setup.png', true, ['title' => __('Manage events')]).'</a>';
|
||||
@ -791,12 +897,14 @@ $buttons[] = [
|
||||
'onclick' => '',
|
||||
];
|
||||
|
||||
$buttons[] = [
|
||||
'id' => 'save-filter',
|
||||
'class' => 'float-left margin-right-2 sub wand',
|
||||
'text' => __('Save filter'),
|
||||
'onclick' => '',
|
||||
];
|
||||
if ($event_w || $event_m) {
|
||||
$buttons[] = [
|
||||
'id' => 'save-filter',
|
||||
'class' => 'float-left margin-right-2 sub wand',
|
||||
'text' => __('Save filter'),
|
||||
'onclick' => '',
|
||||
];
|
||||
}
|
||||
|
||||
/*
|
||||
* Advanced filter.
|
||||
@ -1067,6 +1175,10 @@ try {
|
||||
'text' => 'evento',
|
||||
'class' => 'mw120px',
|
||||
],
|
||||
[
|
||||
'text' => 'mini_severity',
|
||||
'class' => 'no-padding',
|
||||
],
|
||||
'id_evento',
|
||||
// 'id_agente',
|
||||
// 'id_usuario',
|
||||
@ -1112,6 +1224,12 @@ try {
|
||||
$fields = $default_fields;
|
||||
}
|
||||
|
||||
if (in_array('mini_severity', $fields) > 0) {
|
||||
$fields[array_search('mini_severity', $fields)] = [
|
||||
'text' => 'mini_severity',
|
||||
'class' => 'no-padding-imp',
|
||||
];
|
||||
}
|
||||
|
||||
$evento_id = array_search('evento', $fields);
|
||||
if ($evento_id !== false) {
|
||||
@ -1219,6 +1337,7 @@ try {
|
||||
$active_filters_div .= '</div>';
|
||||
|
||||
$table_id = 'events';
|
||||
$form_id = 'events_form';
|
||||
|
||||
// Print datatable.
|
||||
ui_print_datatable(
|
||||
@ -1227,9 +1346,12 @@ try {
|
||||
'class' => 'info_table events',
|
||||
'style' => 'width: 100%;',
|
||||
'ajax_url' => 'operation/events/events',
|
||||
'ajax_data' => ['get_events' => 1],
|
||||
'ajax_data' => [
|
||||
'get_events' => 1,
|
||||
'history' => (int) $history,
|
||||
],
|
||||
'form' => [
|
||||
'id' => 'events_form',
|
||||
'id' => $form_id,
|
||||
'class' => 'flex-row',
|
||||
'html' => $filter,
|
||||
'inputs' => [],
|
||||
@ -1280,39 +1402,41 @@ try {
|
||||
$sql_event_resp = "SELECT id, name FROM tevent_response WHERE type LIKE 'command'";
|
||||
$event_responses = db_get_all_rows_sql($sql_event_resp);
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'EW') == 1 && !$readonly) {
|
||||
$array_events_actions['in_progress_selected'] = __('In progress selected');
|
||||
$array_events_actions['validate_selected'] = __('Validate selected');
|
||||
}
|
||||
if ($config['event_replication'] != 1) {
|
||||
if ($event_w && !$readonly) {
|
||||
$array_events_actions['in_progress_selected'] = __('In progress selected');
|
||||
$array_events_actions['validate_selected'] = __('Validate selected');
|
||||
}
|
||||
|
||||
if (check_acl($config['id_user'], 0, 'EM') == 1 && !$readonly) {
|
||||
$array_events_actions['delete_selected'] = __('Delete selected');
|
||||
if ($event_m == 1 && !$readonly) {
|
||||
$array_events_actions['delete_selected'] = __('Delete selected');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($event_responses as $val) {
|
||||
$array_events_actions[$val['id']] = $val['name'];
|
||||
}
|
||||
|
||||
if ($config['event_replication'] != 1) {
|
||||
echo '<div class="multi-response-buttons">';
|
||||
echo '<form method="post" id="form_event_response">';
|
||||
echo '<input type="hidden" id="max_execution_event_response" value="'.$config['max_execution_event_response'].'" />';
|
||||
html_print_select($array_events_actions, 'response_id', '', '', '', 0, false, false, false);
|
||||
echo '  ';
|
||||
html_print_button(__('Execute event response'), 'submit_event_response', false, 'execute_event_response(true);', 'class="sub next"');
|
||||
echo "<span id='response_loading_dialog' style='display:none'>".html_print_image('images/spinner.gif', true).'</span>';
|
||||
echo '</form>';
|
||||
echo '<span id="max_custom_event_resp_msg" style="display:none; color:#e63c52; line-height: 200%;">';
|
||||
echo __(
|
||||
'A maximum of %s event custom responses can be selected',
|
||||
$config['max_execution_event_response']
|
||||
).'</span>';
|
||||
echo '<span id="max_custom_selected" style="display:none; color:#e63c52; line-height: 200%;">';
|
||||
echo __(
|
||||
'Please, select an event'
|
||||
).'</span>';
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
echo '<div class="multi-response-buttons">';
|
||||
echo '<form method="post" id="form_event_response">';
|
||||
echo '<input type="hidden" id="max_execution_event_response" value="'.$config['max_execution_event_response'].'" />';
|
||||
html_print_select($array_events_actions, 'response_id', '', '', '', 0, false, false, false);
|
||||
echo '  ';
|
||||
html_print_button(__('Execute event response'), 'submit_event_response', false, 'execute_event_response(true);', 'class="sub next"');
|
||||
echo "<span id='response_loading_dialog' style='display:none'>".html_print_image('images/spinner.gif', true).'</span>';
|
||||
echo '</form>';
|
||||
echo '<span id="max_custom_event_resp_msg" style="display:none; color:#e63c52; line-height: 200%;">';
|
||||
echo __(
|
||||
'A maximum of %s event custom responses can be selected',
|
||||
$config['max_execution_event_response']
|
||||
).'</span>';
|
||||
echo '<span id="max_custom_selected" style="display:none; color:#e63c52; line-height: 200%;">';
|
||||
echo __(
|
||||
'Please, select an event'
|
||||
).'</span>';
|
||||
echo '</div>';
|
||||
|
||||
|
||||
// Close viewer.
|
||||
enterprise_hook('close_meta_frame');
|
||||
@ -1477,16 +1601,17 @@ function process_datatables_item(item) {
|
||||
output += '</div>';
|
||||
|
||||
// Add event severity to end of text.
|
||||
evn = '<div class="event flex-row h100p nowrap">';
|
||||
evn += '<div><a href="javascript:" onclick="show_event_dialog(\'';
|
||||
evn += btoa(JSON.stringify(item))+'\','+$("#group_rep").val()+');">';
|
||||
evn = '<a href="javascript:" onclick="show_event_dialog(\'';
|
||||
evn += item.b64+'\','+$("#group_rep").val()+');">';
|
||||
// Grouped events.
|
||||
if(item.event_rep && item.event_rep > 1) {
|
||||
evn += '('+item.event_rep+') ';
|
||||
}
|
||||
evn += item.evento+'</a></div>';
|
||||
evn += output;
|
||||
evn += '</div>'
|
||||
evn += item.evento+'</a>';
|
||||
|
||||
item.mini_severity = '<div class="event flex-row h100p nowrap">';
|
||||
item.mini_severity += output;
|
||||
item.mini_severity += '</div>';
|
||||
|
||||
criticity = '<div class="criticity" style="background: ';
|
||||
criticity += color + '">' + text + "</div>";
|
||||
@ -1517,7 +1642,7 @@ function process_datatables_item(item) {
|
||||
|
||||
case "<?php echo EVENTS_GOING_UP_WARNING; ?>":
|
||||
case "<?php echo EVENTS_GOING_DOWN_WARNING; ?>":
|
||||
$tex = "<?php echo __('WARNING'); ?>";
|
||||
text = "<?php echo __('WARNING'); ?>";
|
||||
color = "<?php echo COL_WARNING; ?>";
|
||||
break;
|
||||
|
||||
@ -1580,42 +1705,10 @@ function process_datatables_item(item) {
|
||||
module_status = '<div class="criticity" style="background: ';
|
||||
module_status += color + '">' + text + "</div>";
|
||||
|
||||
|
||||
/* Agent name link */
|
||||
if (item.id_agente > 0) {
|
||||
item.agent_name = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>' +item.id_agente+'">' + item.agent_name + '</a>';
|
||||
} else {
|
||||
item.agent_name = '';
|
||||
}
|
||||
|
||||
/* Agent ID link */
|
||||
if (item.id_agente > 0) {
|
||||
<?php
|
||||
if (in_array('agent_name', $fields)) {
|
||||
?>
|
||||
item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.id_agente + '</a>';
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.agent_name + '</a>';
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
} else {
|
||||
item.id_agente = '';
|
||||
}
|
||||
|
||||
/* Group name */
|
||||
if (item.id_grupo == "0") {
|
||||
item.id_grupo = "<?php echo __('All'); ?>";
|
||||
} else {
|
||||
item.id_grupo = item.group_name;
|
||||
}
|
||||
|
||||
/* Options */
|
||||
// Show more.
|
||||
item.options = '<a href="javascript:" onclick="show_event_dialog(\'';
|
||||
item.options += btoa(JSON.stringify(item))+'\','+$("#group_rep").val();
|
||||
item.options += item.b64+'\','+$("#group_rep").val();
|
||||
item.options += ')" ><?php echo html_print_image('images/eye.png', true, ['title' => __('Show more')]); ?></a>';
|
||||
|
||||
<?php
|
||||
@ -1658,6 +1751,9 @@ function process_datatables_item(item) {
|
||||
item.options += '<?php echo html_print_image('images/cross.png', true, ['title' => __('Delete event')]); ?></a>';
|
||||
}
|
||||
}
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
// Multi select.
|
||||
item.m = '<input name="checkbox-multi[]" type="checkbox" value="';
|
||||
@ -1668,27 +1764,49 @@ function process_datatables_item(item) {
|
||||
item.m += ' event_rep="0" ';
|
||||
}
|
||||
item.m += 'class="candeleted chk_val">';
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
/* Status */
|
||||
img = '<?php echo html_print_image('images/star.png', true, ['title' => __('Unknown'), 'class' => 'forced-title']); ?>';
|
||||
switch (item.estado) {
|
||||
case "0":
|
||||
case "<?php echo EVENT_STATUS_NEW; ?>":
|
||||
img = '<?php echo html_print_image('images/star.png', true, ['title' => __('New event'), 'class' => 'forced-title']); ?>';
|
||||
break;
|
||||
|
||||
case "1":
|
||||
case "<?php echo EVENT_STATUS_VALIDATED; ?>":
|
||||
img = '<?php echo html_print_image('images/tick.png', true, [ 'title' => __('Event validated'), 'class' => 'forced-title']); ?>';
|
||||
break;
|
||||
|
||||
case "2":
|
||||
case "<?php echo EVENT_STATUS_INPROCESS; ?>":
|
||||
img = '<?php echo html_print_image('images/hourglass.png', true, [ 'title' => __('Event in process'), 'class' => 'forced-title']); ?>';
|
||||
break;
|
||||
}
|
||||
|
||||
/* Update column content now to avoid json poisoning. */
|
||||
|
||||
/* Agent name link */
|
||||
if (item.id_agente > 0) {
|
||||
item.agent_name = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>' +item.id_agente+'">' + item.agent_name + '</a>';
|
||||
} else {
|
||||
item.agent_name = '';
|
||||
}
|
||||
|
||||
/* Agent ID link */
|
||||
if (item.id_agente > 0) {
|
||||
<?php
|
||||
if (in_array('agent_name', $fields)) {
|
||||
?>
|
||||
item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.id_agente + '</a>';
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
item.id_agente = '<a href="<?php echo ui_get_full_url('index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='); ?>'+item.id_agente+'">' + item.agent_name + '</a>';
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
} else {
|
||||
item.id_agente = '';
|
||||
}
|
||||
|
||||
item.estado = '<div>';
|
||||
item.estado += img;
|
||||
item.estado += '</div>';
|
||||
@ -1708,6 +1826,15 @@ function process_datatables_item(item) {
|
||||
// Add event severity format to itself.
|
||||
item.evento = evn;
|
||||
|
||||
/* Group name */
|
||||
if (item.id_grupo == "0") {
|
||||
item.id_grupo = "<?php echo __('All'); ?>";
|
||||
} else {
|
||||
item.id_grupo = item.group_name;
|
||||
}
|
||||
|
||||
/* Module name */
|
||||
item.id_agentmodule = item.module_name;
|
||||
}
|
||||
|
||||
/* Datatables auxiliary functions ends */
|
||||
@ -1957,6 +2084,23 @@ function reorder_tags_inputs() {
|
||||
}
|
||||
/* Tag management ends */
|
||||
$(document).ready( function() {
|
||||
/* Filter to a href */
|
||||
$('.events_link').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
inputs = $("#<?php echo $form_id; ?> :input");
|
||||
values = {};
|
||||
inputs.each(function() {
|
||||
values[this.name] = $(this).val();
|
||||
})
|
||||
|
||||
values['history'] = "<?php echo (int) $history; ?>";
|
||||
|
||||
var url = e.currentTarget.href;
|
||||
url += 'fb64=' + btoa(JSON.stringify(values));
|
||||
document.location = url;
|
||||
|
||||
});
|
||||
|
||||
/* Multi select handler */
|
||||
$('#checkbox-all_validate_box').on('change', function() {
|
||||
|
@ -1,18 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* Event RSS exporter.
|
||||
*
|
||||
* @category Event RSS export
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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 for 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
// Don't display other errors, messes up XML.
|
||||
ini_set('display_errors', E_ALL);
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 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 for 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.
|
||||
ini_set('display_errors', 0);
|
||||
// Don't display other errors, messes up XML
|
||||
require_once '../../include/config.php';
|
||||
require_once '../../include/functions.php';
|
||||
require_once '../../include/functions_db.php';
|
||||
@ -22,65 +41,115 @@ require_once '../../include/functions_users.php';
|
||||
require_once '../../include/functions_tags.php';
|
||||
require_once '../../include/functions_groups.php';
|
||||
|
||||
$ipOrigin = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// Uncoment this to activate ACL on RSS Events
|
||||
if (!isInACL($ipOrigin)) {
|
||||
rss_error_handler(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
__('Your IP is not into the IP list with API access.')
|
||||
);
|
||||
|
||||
exit;
|
||||
/**
|
||||
* Generates an xml entry.
|
||||
*
|
||||
* @param string $key Key.
|
||||
* @param string $value Value.
|
||||
*
|
||||
* @return string XML entry.
|
||||
*/
|
||||
function xml_entry($key, $value)
|
||||
{
|
||||
$output = '<'.xml_entities($key).'>';
|
||||
$output .= '<![CDATA['.io_safe_output($value).']]>';
|
||||
$output .= '</'.xml_entities($key).'>';
|
||||
return $output."\n";
|
||||
}
|
||||
|
||||
// Check user credentials
|
||||
$user = get_parameter('user');
|
||||
$hashup = get_parameter('hashup');
|
||||
|
||||
$pss = get_user_info($user);
|
||||
$hashup2 = md5($user.$pss['password']);
|
||||
/**
|
||||
* Escape entities for XML.
|
||||
*
|
||||
* @param string $str String.
|
||||
*
|
||||
* @return string Escaped string.
|
||||
*/
|
||||
function xml_entities($str)
|
||||
{
|
||||
if (!is_string($str)) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if ($hashup != $hashup2) {
|
||||
rss_error_handler(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
__('The URL of your feed has bad hash.')
|
||||
);
|
||||
if (preg_match_all('/(&[^;]+;)/', $str, $matches) != 0) {
|
||||
$matches = $matches[0];
|
||||
|
||||
exit;
|
||||
foreach ($matches as $entity) {
|
||||
$char = html_entity_decode($entity, (ENT_COMPAT | ENT_HTML401), 'UTF-8');
|
||||
|
||||
$html_entity_numeric = '&#'.uniord($char).';';
|
||||
|
||||
$str = str_replace($entity, $html_entity_numeric, $str);
|
||||
}
|
||||
}
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
header('Content-Type: application/xml; charset=UTF-8');
|
||||
// Send header before starting to output
|
||||
|
||||
/**
|
||||
* Undocumented function.
|
||||
*
|
||||
* @param string $u U.
|
||||
*
|
||||
* @return integer Ord.
|
||||
*/
|
||||
function uniord($u)
|
||||
{
|
||||
$k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8');
|
||||
$k1 = ord(substr($k, 0, 1));
|
||||
$k2 = ord(substr($k, 1, 1));
|
||||
|
||||
return ($k2 * 256 + $k1);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generate RSS header.
|
||||
*
|
||||
* @param integer $lastbuild Date, last build.
|
||||
*
|
||||
* @return string RSS header.
|
||||
*/
|
||||
function rss_header($lastbuild=0)
|
||||
{
|
||||
$selfurl = ui_get_full_url('?'.$_SERVER['QUERY_STRING'], false, true);
|
||||
|
||||
// ' <?php ' -- Fixes highlighters thinking that the closing tag is PHP
|
||||
$rss_feed = '<?xml version="1.0" encoding="utf-8" ?>'."\n";
|
||||
$rss_feed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
|
||||
$rss_feed .= '<channel>'."\n";
|
||||
$rss_feed .= '<title>'.io_safe_output(get_product_name()).' Events Feed</title>'."\n";
|
||||
$rss_feed .= '<description>Latest events on '.get_product_name().'</description>'."\n";
|
||||
$rss_feed .= '<lastBuildDate>'.date(DATE_RFC822, $lastbuild).'</lastBuildDate>'."\n";
|
||||
// Last build date is the last event - that way readers won't mark it as having new posts.
|
||||
$rss_feed .= '<link>'.$url.'</link>'."\n";
|
||||
// Link back to the main Pandora page.
|
||||
$rss_feed .= '<atom:link href="'.xml_entities(io_safe_input($selfurl)).'" rel="self" type="application/rss+xml" />'."\n";
|
||||
|
||||
return $rss_feed;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* RSS error handler.
|
||||
*
|
||||
* @param string $errno Errno.
|
||||
* @param string $errstr Errstr.
|
||||
* @param string $errfile Errfile.
|
||||
* @param string $errline Errline.
|
||||
* @param string $error_human_description Error_human_description.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function rss_error_handler($errno, $errstr, $errfile, $errline, $error_human_description=null)
|
||||
{
|
||||
$url = ui_get_full_url(false);
|
||||
$selfurl = ui_get_full_url('?'.$_SERVER['QUERY_STRING'], false, true);
|
||||
|
||||
$rss_feed = '<?xml version="1.0" encoding="utf-8" ?>';
|
||||
// ' Fixes certain highlighters freaking out on the PHP closing tag
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">';
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '<channel>';
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '<title>'.get_product_name().' RSS Feed</title>';
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '<description>Latest events on '.get_product_name().'</description>';
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '<lastBuildDate>'.date(DATE_RFC822, 0).'</lastBuildDate>';
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '<link>'.$url.'</link>';
|
||||
// Link back to the main Pandora page
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '<atom:link href="'.xml_entities(io_safe_input($selfurl)).'" rel="self" type="application/rss+xml" />';
|
||||
// Alternative for Atom feeds. It's the same.
|
||||
// ' Fixes certain highlighters freaking out on the PHP closing tag.
|
||||
$rss_feed = rss_header(0);
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '<item>';
|
||||
$rss_feed .= "\n";
|
||||
@ -104,169 +173,206 @@ function rss_error_handler($errno, $errstr, $errfile, $errline, $error_human_des
|
||||
$rss_feed .= "\n";
|
||||
$rss_feed .= '</rss>';
|
||||
|
||||
exit($rss_feed);
|
||||
// Exit by displaying the feed
|
||||
echo $rss_feed;
|
||||
}
|
||||
|
||||
|
||||
// Errors output as RSS.
|
||||
set_error_handler('rss_error_handler', E_ERROR);
|
||||
// Errors output as RSS
|
||||
$id_group = get_parameter('id_group', 0);
|
||||
// group
|
||||
$event_type = get_parameter('event_type', '');
|
||||
// 0 all
|
||||
$severity = (int) get_parameter('severity', -1);
|
||||
// -1 all
|
||||
$status = (int) get_parameter('status', 0);
|
||||
// -1 all, 0 only red, 1 only green
|
||||
$id_agent = (int) get_parameter('id_agent', -1);
|
||||
|
||||
$id_event = (int) get_parameter('id_event', -1);
|
||||
// This will allow to select only 1 event (eg. RSS)
|
||||
$event_view_hr = (int) get_parameter('event_view_hr', 0);
|
||||
$id_user_ack = get_parameter('id_user_ack', 0);
|
||||
$search = io_safe_output(preg_replace('/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', rawurldecode(get_parameter('search'))));
|
||||
$text_agent = (string) get_parameter('text_agent', __('All'));
|
||||
// Send header before starting to output.
|
||||
header('Content-Type: application/xml; charset=UTF-8');
|
||||
|
||||
$tag_with_json = base64_decode(get_parameter('tag_with', ''));
|
||||
$tag_with_json_clean = io_safe_output($tag_with_json);
|
||||
$tag_with_base64 = base64_encode($tag_with_json_clean);
|
||||
$tag_with = json_decode($tag_with_json_clean, true);
|
||||
if (empty($tag_with)) {
|
||||
$tag_with = [];
|
||||
$ipOrigin = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
// Uncoment this to activate ACL on RSS Events.
|
||||
if (!isInACL($ipOrigin)) {
|
||||
rss_error_handler(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
__('Your IP is not into the IP list with API access.')
|
||||
);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$tag_with = array_diff($tag_with, [0 => 0]);
|
||||
// Check user credentials.
|
||||
$user = get_parameter('user');
|
||||
$hashup = get_parameter('hashup');
|
||||
|
||||
$tag_without_json = base64_decode(get_parameter('tag_without', ''));
|
||||
$tag_without_json_clean = io_safe_output($tag_without_json);
|
||||
$tag_without_base64 = base64_encode($tag_without_json_clean);
|
||||
$tag_without = json_decode($tag_without_json_clean, true);
|
||||
if (empty($tag_without)) {
|
||||
$tag_without = [];
|
||||
$pss = get_user_info($user);
|
||||
$hashup2 = md5($user.$pss['password']);
|
||||
|
||||
if ($hashup != $hashup2) {
|
||||
rss_error_handler(
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
__('The URL of your feed has bad hash.')
|
||||
);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$tag_without = array_diff($tag_without, [0 => 0]);
|
||||
|
||||
$filter_only_alert = (int) get_parameter('filter_only_alert', -1);
|
||||
|
||||
//
|
||||
// Build the condition of the events query
|
||||
$sql_post = '';
|
||||
$meta = false;
|
||||
|
||||
$id_user = $user;
|
||||
|
||||
require 'events.build_query.php';
|
||||
|
||||
// Now $sql_post have all the where condition
|
||||
//
|
||||
$sql = 'SELECT *
|
||||
FROM tevento te LEFT JOIN tagent_secondary_group tasg
|
||||
ON te.id_grupo = tasg.id_group
|
||||
WHERE 1=1 '.$sql_post.'
|
||||
ORDER BY utimestamp DESC';
|
||||
|
||||
$result = db_get_all_rows_sql($sql);
|
||||
|
||||
$url = ui_get_full_url(false);
|
||||
$selfurl = ui_get_full_url('?'.$_SERVER['QUERY_STRING'], false, true);
|
||||
|
||||
if (empty($result)) {
|
||||
$lastbuild = 0;
|
||||
// Last build in 1970
|
||||
} else {
|
||||
$lastbuild = (int) $result[0]['utimestamp'];
|
||||
$reset_session = false;
|
||||
if (empty($config['id_user'])) {
|
||||
$config['id_user'] = $user;
|
||||
$reset_session = true;
|
||||
}
|
||||
|
||||
$rss_feed = '<?xml version="1.0" encoding="utf-8" ?>'."\n";
|
||||
// ' <?php ' -- Fixes highlighters thinking that the closing tag is PHP
|
||||
$rss_feed .= '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'."\n";
|
||||
$rss_feed .= '<channel>'."\n";
|
||||
$rss_feed .= '<title>'.get_product_name().' RSS Feed</title>'."\n";
|
||||
$rss_feed .= '<description>Latest events on '.get_product_name().'</description>'."\n";
|
||||
$rss_feed .= '<lastBuildDate>'.date(DATE_RFC822, $lastbuild).'</lastBuildDate>'."\n";
|
||||
// Last build date is the last event - that way readers won't mark it as having new posts
|
||||
$rss_feed .= '<link>'.$url.'</link>'."\n";
|
||||
// Link back to the main Pandora page
|
||||
$rss_feed .= '<atom:link href="'.xml_entities(io_safe_input($selfurl)).'" rel="self" type="application/rss+xml" />'."\n";
|
||||
;
|
||||
// Alternative for Atom feeds. It's the same.
|
||||
if (empty($result)) {
|
||||
$result = [];
|
||||
$rss_feed .= '<item><guid>'.xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events')).'</guid><title>No results</title>';
|
||||
$rss_feed .= '<description>There are no results. Click on the link to see all Pending events</description>';
|
||||
$rss_feed .= '<link>'.xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events')).'</link></item>'."\n";
|
||||
}
|
||||
$column_names = [
|
||||
'id_evento',
|
||||
'evento',
|
||||
'timestamp',
|
||||
'estado',
|
||||
'event_type',
|
||||
'utimestamp',
|
||||
'id_agente',
|
||||
'agent_name',
|
||||
'id_usuario',
|
||||
'id_grupo',
|
||||
'id_agentmodule',
|
||||
'id_alert_am',
|
||||
'criticity',
|
||||
'user_comment',
|
||||
'tags',
|
||||
'source',
|
||||
'id_extra',
|
||||
'critical_instructions',
|
||||
'warning_instructions',
|
||||
'unknown_instructions',
|
||||
'owner_user',
|
||||
'ack_utimestamp',
|
||||
'custom_data',
|
||||
'data',
|
||||
'module_status',
|
||||
];
|
||||
|
||||
foreach ($result as $row) {
|
||||
if (!check_acl($user, $row['id_grupo'], 'ER')) {
|
||||
continue;
|
||||
$fields = [
|
||||
'te.id_evento',
|
||||
'te.evento',
|
||||
'te.timestamp',
|
||||
'te.estado',
|
||||
'te.event_type',
|
||||
'te.utimestamp',
|
||||
'te.id_agente',
|
||||
'ta.alias as agent_name',
|
||||
'te.id_usuario',
|
||||
'te.id_grupo',
|
||||
'te.id_agentmodule',
|
||||
'am.nombre as module_name',
|
||||
'te.id_alert_am',
|
||||
'te.criticity',
|
||||
'te.user_comment',
|
||||
'te.tags',
|
||||
'te.source',
|
||||
'te.id_extra',
|
||||
'te.critical_instructions',
|
||||
'te.warning_instructions',
|
||||
'te.unknown_instructions',
|
||||
'te.owner_user',
|
||||
'te.ack_utimestamp',
|
||||
'te.custom_data',
|
||||
'te.data',
|
||||
'te.module_status',
|
||||
'tg.nombre as group_name',
|
||||
];
|
||||
|
||||
|
||||
try {
|
||||
$fb64 = get_parameter('fb64', null);
|
||||
$plain_filter = base64_decode($fb64);
|
||||
$filter = json_decode($plain_filter, true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
throw new Exception('Invalid filter. ['.$plain_filter.']');
|
||||
}
|
||||
|
||||
if ($row['event_type'] == 'system') {
|
||||
$agent_name = __('System');
|
||||
} else if ($row['id_agente'] > 0) {
|
||||
// Agent name
|
||||
$agent_name = agents_get_alias($row['id_agente']);
|
||||
} else {
|
||||
$agent_name = __('Alert').__('SNMP');
|
||||
// Dump events.
|
||||
$limit = get_parameter('limit', 20);
|
||||
$offset = get_parameter('offset', 0);
|
||||
$events = events_get_all(
|
||||
$fields,
|
||||
$filter,
|
||||
$offset,
|
||||
$limit,
|
||||
'desc',
|
||||
'timestamp',
|
||||
$filter['history']
|
||||
);
|
||||
|
||||
$last_timestamp = 0;
|
||||
if (is_array($events)) {
|
||||
$last_timestamp = $events[0]['utimestamp'];
|
||||
}
|
||||
|
||||
// This is mandatory
|
||||
$rss_feed .= '<item><guid>';
|
||||
$rss_feed .= xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events&id_event='.$row['id_evento']));
|
||||
$rss_feed .= '</guid><title>';
|
||||
$rss_feed .= xml_entities($agent_name);
|
||||
$rss_feed .= '</title><description>';
|
||||
$rss_feed .= xml_entities($row['evento']);
|
||||
if ($row['estado'] == 1) {
|
||||
$rss_feed .= xml_entities(io_safe_input('<br /><br />'.'Validated by '.$row['id_usuario']));
|
||||
}
|
||||
// Dump headers.
|
||||
$rss = rss_header($last_timestamp);
|
||||
$url = ui_get_full_url(false);
|
||||
|
||||
$rss_feed .= '</description><link>';
|
||||
$rss_feed .= xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events&id_event='.$row['id_evento']));
|
||||
$rss_feed .= '</link>';
|
||||
if (is_array($events)) {
|
||||
foreach ($events as $row) {
|
||||
$rss .= '<item>';
|
||||
$rss .= xml_entry('title', $row['evento']);
|
||||
if (!empty($row['id_agente'])) {
|
||||
$rss .= xml_entry('link', $url.'index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente='.$row['id_agente']);
|
||||
}
|
||||
|
||||
// The rest is optional
|
||||
$rss_feed .= '<pubDate>'.date(DATE_RFC822, $row['utimestamp']).'</pubDate>';
|
||||
$rss .= xml_entry('comments', $row['']);
|
||||
$rss .= xml_entry('pubDate', $row['timestamp']);
|
||||
$rss .= xml_entry('category', $row['source']);
|
||||
foreach ($column_names as $val) {
|
||||
$key = $val;
|
||||
if ($val == 'id_grupo') {
|
||||
$key = 'group_name';
|
||||
} else if ($val == 'id_agentmodule') {
|
||||
$key = 'module_name';
|
||||
}
|
||||
|
||||
// This is mandatory again
|
||||
$rss_feed .= '</item>'."\n";
|
||||
}
|
||||
switch ($key) {
|
||||
case 'module_status':
|
||||
$value = events_translate_module_status(
|
||||
$row[$key]
|
||||
);
|
||||
break;
|
||||
|
||||
$rss_feed .= "</channel>\n</rss>\n";
|
||||
case 'event_type':
|
||||
$value = events_translate_event_type(
|
||||
$row[$key]
|
||||
);
|
||||
break;
|
||||
|
||||
echo $rss_feed;
|
||||
case 'criticity':
|
||||
$value = events_translate_event_criticity(
|
||||
$row[$key]
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
$value = $row[$key];
|
||||
break;
|
||||
}
|
||||
|
||||
function xml_entities($str)
|
||||
{
|
||||
if (!is_string($str)) {
|
||||
return '';
|
||||
}
|
||||
$rss .= xml_entry($key, $value);
|
||||
}
|
||||
|
||||
if (preg_match_all('/(&[^;]+;)/', $str, $matches) != 0) {
|
||||
$matches = $matches[0];
|
||||
|
||||
foreach ($matches as $entity) {
|
||||
$char = html_entity_decode($entity, (ENT_COMPAT | ENT_HTML401), 'UTF-8');
|
||||
|
||||
$html_entity_numeric = '&#'.uniord($char).';';
|
||||
|
||||
$str = str_replace($entity, $html_entity_numeric, $str);
|
||||
$rss .= '</item>';
|
||||
}
|
||||
} else {
|
||||
$rss .= '<item><guid>'.xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events')).'</guid><title>No results</title>';
|
||||
$rss .= '<description>There are no results. Click on the link to see all Pending events</description>';
|
||||
$rss .= '<link>'.xml_entities(io_safe_input($url.'/index.php?sec=eventos&sec2=operation/events/events')).'</link></item>'."\n";
|
||||
}
|
||||
|
||||
return $str;
|
||||
$rss .= "</channel>\n</rss>\n";
|
||||
|
||||
echo $rss;
|
||||
} catch (Exception $e) {
|
||||
echo rss_error_handler(200, 'Controlled error', '', '', $e->getMessage());
|
||||
}
|
||||
|
||||
|
||||
function uniord($u)
|
||||
{
|
||||
$k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8');
|
||||
$k1 = ord(substr($k, 0, 1));
|
||||
$k2 = ord(substr($k, 1, 1));
|
||||
|
||||
return ($k2 * 256 + $k1);
|
||||
if ($reset_session) {
|
||||
unset($config['id_user']);
|
||||
}
|
||||
|
@ -1,18 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Event CSV exporter.
|
||||
*
|
||||
* @category Event CSV export
|
||||
* @package Pandora FMS
|
||||
* @subpackage Community
|
||||
* @version 1.0.0
|
||||
* @license See below
|
||||
*
|
||||
* ______ ___ _______ _______ ________
|
||||
* | __ \.-----.--.--.--| |.-----.----.-----. | ___| | | __|
|
||||
* | __/| _ | | _ || _ | _| _ | | ___| |__ |
|
||||
* |___| |___._|__|__|_____||_____|__| |___._| |___| |__|_|__|_______|
|
||||
*
|
||||
* ============================================================================
|
||||
* Copyright (c) 2005-2019 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 for 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.
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
// Load global vars.
|
||||
global $config;
|
||||
|
||||
// Pandora FMS - http://pandorafms.com
|
||||
// ==================================================
|
||||
// Copyright (c) 2005-2009 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 for 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.
|
||||
// Don't start a session before this import.
|
||||
// The session is configured and started inside the config process.
|
||||
require_once '../../include/config.php';
|
||||
require_once '../../include/auth/mysql.php';
|
||||
require_once '../../include/functions.php';
|
||||
@ -23,134 +39,165 @@ require_once '../../include/functions_groups.php';
|
||||
|
||||
$config['id_user'] = $_SESSION['id_usuario'];
|
||||
|
||||
if (! check_acl($config['id_user'], 0, 'ER') && ! check_acl($config['id_user'], 0, 'EW') && ! check_acl($config['id_user'], 0, 'EM')) {
|
||||
if (! check_acl($config['id_user'], 0, 'ER')
|
||||
&& ! check_acl($config['id_user'], 0, 'EW')
|
||||
&& ! check_acl($config['id_user'], 0, 'EM')
|
||||
) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $config;
|
||||
|
||||
// loading l10n tables, because of being invoked not through index.php.
|
||||
// Loading l10n tables, because of being invoked not through index.php.
|
||||
$l10n = null;
|
||||
if (file_exists($config['homedir'].'/include/languages/'.$user_language.'.mo')) {
|
||||
$l10n = new gettext_reader(new CachedFileReader($config['homedir'].'/include/languages/'.$user_language.'.mo'));
|
||||
$cfr = new CachedFileReader(
|
||||
$config['homedir'].'/include/languages/'.$user_language.'.mo'
|
||||
);
|
||||
$l10n = new gettext_reader($cfr);
|
||||
$l10n->load_tables();
|
||||
}
|
||||
|
||||
$offset = (int) get_parameter('offset');
|
||||
$id_group = (int) get_parameter('id_group');
|
||||
// group
|
||||
$event_type = (string) get_parameter('event_type', 'all');
|
||||
// 0 all
|
||||
$severity = (int) get_parameter('severity', -1);
|
||||
// -1 all
|
||||
$status = (int) get_parameter('status', -1);
|
||||
// -1 all, 0 only red, 1 only green
|
||||
$id_agent = (int) get_parameter('id_agent', -1);
|
||||
$column_names = [
|
||||
'id_evento',
|
||||
'evento',
|
||||
'timestamp',
|
||||
'estado',
|
||||
'event_type',
|
||||
'utimestamp',
|
||||
'id_agente',
|
||||
'agent_name',
|
||||
'id_usuario',
|
||||
'id_grupo',
|
||||
'id_agentmodule',
|
||||
'id_alert_am',
|
||||
'criticity',
|
||||
'user_comment',
|
||||
'tags',
|
||||
'source',
|
||||
'id_extra',
|
||||
'critical_instructions',
|
||||
'warning_instructions',
|
||||
'unknown_instructions',
|
||||
'owner_user',
|
||||
'ack_utimestamp',
|
||||
'custom_data',
|
||||
'data',
|
||||
'module_status',
|
||||
];
|
||||
|
||||
$id_event = (int) get_parameter('id_event', -1);
|
||||
$event_view_hr = (int) get_parameter('event_view_hr', $config['event_view_hr']);
|
||||
$id_user_ack = get_parameter('id_user_ack', 0);
|
||||
$search = io_safe_output(preg_replace('/&([A-Za-z]{0,4}\w{2,3};|#[0-9]{2,3};)/', '&', rawurldecode(get_parameter('search'))));
|
||||
$text_agent = (string) get_parameter('text_agent', __('All'));
|
||||
|
||||
$tag_with_json = base64_decode(get_parameter('tag_with', ''));
|
||||
$tag_with_json_clean = io_safe_output($tag_with_json);
|
||||
$tag_with_base64 = base64_encode($tag_with_json_clean);
|
||||
$tag_with = json_decode($tag_with_json_clean, true);
|
||||
if (empty($tag_with)) {
|
||||
$tag_with = [];
|
||||
}
|
||||
|
||||
$tag_with = array_diff($tag_with, [0 => 0]);
|
||||
|
||||
$tag_without_json = base64_decode(get_parameter('tag_without', ''));
|
||||
$tag_without_json_clean = io_safe_output($tag_without_json);
|
||||
$tag_without_base64 = base64_encode($tag_without_json_clean);
|
||||
$tag_without = json_decode($tag_without_json_clean, true);
|
||||
if (empty($tag_without)) {
|
||||
$tag_without = [];
|
||||
}
|
||||
|
||||
$tag_without = array_diff($tag_without, [0 => 0]);
|
||||
|
||||
$filter_only_alert = (int) get_parameter('filter_only_alert', -1);
|
||||
|
||||
//
|
||||
// Build the condition of the events query
|
||||
$sql_post = '';
|
||||
$meta = false;
|
||||
|
||||
$id_user = $config['id_user'];
|
||||
|
||||
require 'events.build_query.php';
|
||||
|
||||
// Now $sql_post have all the where condition
|
||||
//
|
||||
switch ($config['dbtype']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
case 'oracle':
|
||||
$sql = 'SELECT *
|
||||
FROM tevento te
|
||||
LEFT JOIN tagent_secondary_group tasg
|
||||
ON te.id_grupo = tasg.id_group
|
||||
WHERE 1=1 '.$sql_post.'
|
||||
ORDER BY utimestamp DESC';
|
||||
break;
|
||||
}
|
||||
$fields = [
|
||||
'te.id_evento',
|
||||
'te.evento',
|
||||
'te.timestamp',
|
||||
'te.estado',
|
||||
'te.event_type',
|
||||
'te.utimestamp',
|
||||
'te.id_agente',
|
||||
'ta.alias as agent_name',
|
||||
'te.id_usuario',
|
||||
'te.id_grupo',
|
||||
'te.id_agentmodule',
|
||||
'am.nombre as module_name',
|
||||
'te.id_alert_am',
|
||||
'te.criticity',
|
||||
'te.user_comment',
|
||||
'te.tags',
|
||||
'te.source',
|
||||
'te.id_extra',
|
||||
'te.critical_instructions',
|
||||
'te.warning_instructions',
|
||||
'te.unknown_instructions',
|
||||
'te.owner_user',
|
||||
'te.ack_utimestamp',
|
||||
'te.custom_data',
|
||||
'te.data',
|
||||
'te.module_status',
|
||||
'tg.nombre as group_name',
|
||||
];
|
||||
|
||||
$now = date('Y-m-d');
|
||||
|
||||
// Show contentype header
|
||||
// Download header.
|
||||
header('Content-type: text/txt');
|
||||
header('Content-Disposition: attachment; filename="pandora_export_event'.$now.'.csv"');
|
||||
|
||||
echo 'timestamp';
|
||||
echo $config['csv_divider'];
|
||||
echo 'agent';
|
||||
echo $config['csv_divider'];
|
||||
echo 'group';
|
||||
echo $config['csv_divider'];
|
||||
echo 'event';
|
||||
echo $config['csv_divider'];
|
||||
echo 'status';
|
||||
echo $config['csv_divider'];
|
||||
echo 'user';
|
||||
echo $config['csv_divider'];
|
||||
echo 'event_type';
|
||||
echo $config['csv_divider'];
|
||||
echo 'severity';
|
||||
echo $config['csv_divider'];
|
||||
echo 'id';
|
||||
echo chr(13);
|
||||
|
||||
$new = true;
|
||||
while ($event = db_get_all_row_by_steps_sql($new, $result, $sql)) {
|
||||
$new = false;
|
||||
$alias = db_get_value('alias', 'tagente', 'id_agente', $event['id_agente']);
|
||||
if ((!check_acl($config['id_user'], $event['id_grupo'], 'ER')
|
||||
&& !check_acl($config['id_user'], $event['id_grupo'], 'EW') && !check_acl($config['id_user'], $event['id_grupo'], 'EM') )
|
||||
|| (!check_acl($config['id_user'], 0, 'PM') && $event['event_type'] == 'system')
|
||||
) {
|
||||
continue;
|
||||
try {
|
||||
$fb64 = get_parameter('fb64', null);
|
||||
$plain_filter = base64_decode($fb64);
|
||||
$filter = json_decode($plain_filter, true);
|
||||
if (json_last_error() != JSON_ERROR_NONE) {
|
||||
throw new Exception('Invalid filter. ['.$plain_filter.']');
|
||||
}
|
||||
|
||||
$names = events_get_column_names($column_names);
|
||||
|
||||
// Dump headers.
|
||||
foreach ($names as $n) {
|
||||
echo io_safe_output($n).$config['csv_divider'];
|
||||
}
|
||||
|
||||
echo date($config['date_format'], $event['utimestamp']);
|
||||
echo $config['csv_divider'];
|
||||
echo io_safe_output($alias);
|
||||
echo $config['csv_divider'];
|
||||
echo io_safe_output(groups_get_name($event['id_grupo']));
|
||||
echo $config['csv_divider'];
|
||||
echo io_safe_output($event['evento']);
|
||||
echo $config['csv_divider'];
|
||||
echo io_safe_output($event['estado']);
|
||||
echo $config['csv_divider'];
|
||||
echo io_safe_output($event['id_usuario']);
|
||||
echo $config['csv_divider'];
|
||||
echo io_safe_output($event['event_type']);
|
||||
echo $config['csv_divider'];
|
||||
echo $event['criticity'];
|
||||
echo $config['csv_divider'];
|
||||
echo $event['id_evento'];
|
||||
echo chr(13);
|
||||
|
||||
// Dump events.
|
||||
$events_per_step = 1000;
|
||||
$step = 0;
|
||||
while (1) {
|
||||
$events = events_get_all(
|
||||
$fields,
|
||||
$filter,
|
||||
(($step++) * $events_per_step),
|
||||
$events_per_step,
|
||||
'desc',
|
||||
'timestamp',
|
||||
$filter['history']
|
||||
);
|
||||
|
||||
if ($events === false) {
|
||||
break;
|
||||
}
|
||||
|
||||
foreach ($events as $row) {
|
||||
foreach ($column_names as $val) {
|
||||
$key = $val;
|
||||
if ($val == 'id_grupo') {
|
||||
$key = 'group_name';
|
||||
} else if ($val == 'id_agentmodule') {
|
||||
$key = 'module_name';
|
||||
}
|
||||
|
||||
switch ($key) {
|
||||
case 'module_status':
|
||||
echo events_translate_module_status(
|
||||
$row[$key]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'event_type':
|
||||
echo events_translate_event_type(
|
||||
$row[$key]
|
||||
);
|
||||
break;
|
||||
|
||||
case 'criticity':
|
||||
echo events_translate_event_criticity(
|
||||
$row[$key]
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
echo io_safe_output($row[$key]);
|
||||
break;
|
||||
}
|
||||
|
||||
echo $config['csv_divider'];
|
||||
}
|
||||
|
||||
echo chr(13);
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
echo 'ERROR'.chr(13);
|
||||
echo $e->getMessage();
|
||||
exit;
|
||||
}
|
||||
|
||||
exit;
|
||||
|
@ -373,10 +373,36 @@ if (check_acl($config['id_user'], 0, 'ER')
|
||||
$pss = get_user_info($config['id_user']);
|
||||
$hashup = md5($config['id_user'].$pss['password']);
|
||||
|
||||
$user_filter = db_get_row_sql(
|
||||
sprintf(
|
||||
'SELECT f.id_filter, f.id_name
|
||||
FROM tevent_filter f
|
||||
INNER JOIN tusuario u
|
||||
ON u.default_event_filter=f.id_filter
|
||||
WHERE u.id_user = "%s" ',
|
||||
$config['id_user']
|
||||
)
|
||||
);
|
||||
if ($user_filter !== false) {
|
||||
$filter = events_get_event_filter($user_filter['id_filter']);
|
||||
} else {
|
||||
// Default.
|
||||
$filter = [
|
||||
'status' => EVENT_NO_VALIDATED,
|
||||
'event_view_hr' => $config['event_view_hr'],
|
||||
'group_rep' => 1,
|
||||
'tag_with' => [],
|
||||
'tag_without' => [],
|
||||
'history' => false,
|
||||
];
|
||||
}
|
||||
|
||||
$fb64 = base64_encode(json_encode($filter));
|
||||
|
||||
// RSS.
|
||||
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0§ion=list&open_filter=0&pure=']['text'] = __('RSS');
|
||||
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0§ion=list&open_filter=0&pure=']['id'] = 'RSS';
|
||||
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&search=&event_type=&severity=-1&status=3&id_group=0&refr=0&id_agent=0&pagination=20&group_rep=1&event_view_hr=8&id_user_ack=0&tag_with=&tag_without=&filter_only_alert-1&offset=0&toogle_filter=no&filter_id=0&id_name=&id_group=0&history=0§ion=list&open_filter=0&pure=']['type'] = 'direct';
|
||||
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&fb64='.$fb64]['text'] = __('RSS');
|
||||
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&fb64='.$fb64]['id'] = 'RSS';
|
||||
$sub['operation/events/events_rss.php?user='.$config['id_user'].'&hashup='.$hashup.'&fb64='.$fb64]['type'] = 'direct';
|
||||
|
||||
// Marquee.
|
||||
$sub['operation/events/events_marquee.php']['text'] = __('Marquee');
|
||||
|
@ -15,6 +15,7 @@ global $config;
|
||||
|
||||
// Login check
|
||||
require_once $config['homedir'].'/include/functions_visual_map.php';
|
||||
ui_require_css_file('visual_maps');
|
||||
|
||||
check_login();
|
||||
|
||||
|
@ -83,7 +83,7 @@ echo '<div id="visual-console-container"></div>';
|
||||
echo '<div id="vc-controls" style="z-index:300;">';
|
||||
|
||||
echo '<div id="menu_tab">';
|
||||
echo '<ul class="mn">';
|
||||
echo '<ul class="mn white-box-content box-shadow flex-row">';
|
||||
|
||||
// QR code.
|
||||
echo '<li class="nomn">';
|
||||
|
@ -19,6 +19,8 @@ check_login();
|
||||
require_once $config['homedir'].'/vendor/autoload.php';
|
||||
require_once $config['homedir'].'/include/functions_visual_map.php';
|
||||
|
||||
ui_require_css_file('visual_maps');
|
||||
|
||||
// Query parameters.
|
||||
$visualConsoleId = (int) get_parameter(!is_metaconsole() ? 'id' : 'id_visualmap');
|
||||
// To hide the menus.
|
||||
@ -172,7 +174,7 @@ if ($pure === true) {
|
||||
echo '<div id="vc-controls" style="z-index: 999">';
|
||||
|
||||
echo '<div id="menu_tab">';
|
||||
echo '<ul class="mn">';
|
||||
echo '<ul class="mn white-box-content box-shadow flex-row">';
|
||||
|
||||
// Quit fullscreen.
|
||||
echo '<li class="nomn">';
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.735
|
||||
%define release 190624
|
||||
%define release 190626
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.735
|
||||
%define release 190624
|
||||
%define release 190626
|
||||
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name httpd
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_console
|
||||
%define version 7.0NG.735
|
||||
%define release 190624
|
||||
%define release 190626
|
||||
%define httpd_name httpd
|
||||
# User and Group under which Apache is running
|
||||
%define httpd_name apache2
|
||||
|
@ -693,6 +693,20 @@ CREATE TABLE IF NOT EXISTS `tgrupo` (
|
||||
KEY `parent_index` (`parent`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tcredential_store`
|
||||
-- ---------------------------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `tcredential_store` (
|
||||
`identifier` varchar(100) NOT NULL,
|
||||
`id_group` mediumint(4) unsigned NOT NULL DEFAULT 0,
|
||||
`product` enum('CUSTOM', 'AWS', 'AZURE', 'GOOGLE') default 'CUSTOM',
|
||||
`username` text,
|
||||
`password` text,
|
||||
`extra_1` text,
|
||||
`extra_2` text,
|
||||
PRIMARY KEY (`identifier`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
|
||||
-- ---------------------------------------------------------------------
|
||||
-- Table `tincidencia`
|
||||
-- ---------------------------------------------------------------------
|
||||
|
@ -1,5 +1,5 @@
|
||||
package: pandorafms-server
|
||||
Version: 7.0NG.735-190624
|
||||
Version: 7.0NG.735-190626
|
||||
Architecture: all
|
||||
Priority: optional
|
||||
Section: admin
|
||||
|
@ -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-190624"
|
||||
pandora_version="7.0NG.735-190626"
|
||||
|
||||
package_cpan=0
|
||||
package_pandora=1
|
||||
|
@ -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 = "190624";
|
||||
my $pandora_build = "190626";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
# Setup hash
|
||||
|
@ -185,6 +185,7 @@ our @EXPORT = qw(
|
||||
pandora_exec_forced_alerts
|
||||
pandora_generate_alerts
|
||||
pandora_get_config_value
|
||||
pandora_get_credential
|
||||
pandora_get_module_tags
|
||||
pandora_get_module_url_tags
|
||||
pandora_get_module_phone_tags
|
||||
@ -3122,6 +3123,19 @@ sub pandora_get_config_value ($$) {
|
||||
return (defined ($config_value) ? $config_value : "");
|
||||
}
|
||||
|
||||
|
||||
##########################################################################
|
||||
## Get credential from credential store
|
||||
##########################################################################
|
||||
sub pandora_get_credential ($$) {
|
||||
my ($dbh, $identifier) = @_;
|
||||
|
||||
my $key = get_db_single_row($dbh, 'SELECT * FROM tcredential_store WHERE identifier = ?', $identifier);
|
||||
|
||||
return $key;
|
||||
}
|
||||
|
||||
|
||||
##########################################################################
|
||||
=head2 C<< pandora_create_module_tags (I<$pa_config>, I<$dbh>, I<$id_agent_module>, I<$serialized_tags>) >>
|
||||
|
||||
@ -3866,7 +3880,7 @@ sub subst_alert_macros ($$;$$$$) {
|
||||
my $macro_regexp = join('|', keys %{$macros});
|
||||
|
||||
my $subst_func;
|
||||
if ($string =~ m/^(?:(")(?:.*)"|(')(?:.*)')$/) {
|
||||
if (defined($string) && $string =~ m/^(?:(")(?:.*)"|(')(?:.*)')$/) {
|
||||
my $quote = $1 ? $1 : $2;
|
||||
$subst_func = sub {
|
||||
my $macro = on_demand_macro($pa_config, $dbh, shift, $macros, $agent, $module);
|
||||
|
@ -113,10 +113,6 @@ sub run ($) {
|
||||
print_message ($pa_config, " [*] Starting " . $pa_config->{'rb_product_name'} . " Discovery Server.", 1);
|
||||
my $threads = $pa_config->{'recon_threads'};
|
||||
|
||||
# Prepare some environmental variables.
|
||||
$ENV{'AWS_ACCESS_KEY_ID'} = pandora_get_config_value($dbh, 'aws_access_key_id');
|
||||
$ENV{'AWS_SECRET_ACCESS_KEY'} = pandora_get_config_value($dbh, 'aws_secret_access_key');
|
||||
|
||||
# Use hightest value
|
||||
if ($pa_config->{'discovery_threads'} > $pa_config->{'recon_threads'}) {
|
||||
$threads = $pa_config->{'discovery_threads'};
|
||||
@ -141,12 +137,21 @@ sub data_producer ($) {
|
||||
# Manual tasks are "forced" like the other, setting the utimestamp to 1
|
||||
# By default, after create a tasks it takes the utimestamp to 0
|
||||
# Status -1 means "done".
|
||||
my @rows;
|
||||
if (pandora_is_master($pa_config) == 0) {
|
||||
@rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
||||
WHERE id_recon_server = ?
|
||||
AND disabled = 0
|
||||
AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
|
||||
OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
|
||||
} else {
|
||||
@rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
||||
WHERE (id_recon_server = ? OR id_recon_server = ANY(SELECT id_server FROM tserver WHERE status = 0 AND server_type = ?))
|
||||
AND disabled = 0
|
||||
AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
|
||||
OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id, DISCOVERYSERVER);
|
||||
}
|
||||
|
||||
my @rows = get_db_rows ($dbh, 'SELECT * FROM trecon_task
|
||||
WHERE id_recon_server = ?
|
||||
AND disabled = 0
|
||||
AND ((utimestamp = 0 AND interval_sweep != 0 OR status = 1)
|
||||
OR (status = -1 AND interval_sweep > 0 AND (utimestamp + interval_sweep) < UNIX_TIMESTAMP()))', $server_id);
|
||||
foreach my $row (@rows) {
|
||||
|
||||
# Update task status
|
||||
@ -193,42 +198,46 @@ sub data_consumer ($$) {
|
||||
my %cnf_extra;
|
||||
if ($task->{'type'} == DISCOVERY_CLOUD_AWS_EC2
|
||||
|| $task->{'type'} == DISCOVERY_CLOUD_AWS_RDS) {
|
||||
$cnf_extra{'aws_access_key_id'} = pandora_get_config_value($dbh, 'aws_access_key_id');
|
||||
$cnf_extra{'aws_secret_access_key'} = pandora_get_config_value($dbh, 'aws_secret_access_key');
|
||||
# auth_strings stores the crential identifier to be used.
|
||||
my $key = pandora_get_credential($dbh, $task->{'auth_strings'});
|
||||
|
||||
if (ref($key) eq "HASH") {
|
||||
$cnf_extra{'aws_access_key_id'} = $key->{'username'};
|
||||
$cnf_extra{'aws_secret_access_key'} = $key->{'password'};
|
||||
} else {
|
||||
# Invalid credential.
|
||||
return;
|
||||
}
|
||||
|
||||
$cnf_extra{'cloud_util_path'} = pandora_get_config_value($dbh, 'cloud_util_path');
|
||||
|
||||
if (!defined($ENV{'AWS_ACCESS_KEY_ID'}) || !defined($ENV{'AWS_SECRET_ACCESS_KEY'})
|
||||
|| $cnf_extra{'aws_secret_access_key'} ne $ENV{'AWS_ACCESS_KEY_ID'}
|
||||
|| $cnf_extra{'cloud_util_path'} ne $ENV{'AWS_SECRET_ACCESS_KEY'}) {
|
||||
# Environmental data is out of date. Create a tmp file to manage
|
||||
# credentials. Perl limitation. We cannot update ENV here.
|
||||
$cnf_extra{'creds_file'} = $pa_config->{'temporal'} . '/tmp_discovery.' . md5($task->{'id_rt'} . $task->{'name'} . time());
|
||||
eval {
|
||||
open(my $__file_cfg, '> '. $cnf_extra{'creds_file'}) or die($!);
|
||||
print $__file_cfg $cnf_extra{'aws_access_key_id'} . "\n";
|
||||
print $__file_cfg $cnf_extra{'aws_secret_access_key'} . "\n";
|
||||
close($__file_cfg);
|
||||
set_file_permissions(
|
||||
$pa_config,
|
||||
$cnf_extra{'creds_file'},
|
||||
"0600"
|
||||
);
|
||||
};
|
||||
if ($@) {
|
||||
logger(
|
||||
$pa_config,
|
||||
'Cannot instantiate configuration file for task: ' . safe_output($task->{'name'}),
|
||||
5
|
||||
);
|
||||
# A server restart will override ENV definition (see run)
|
||||
logger(
|
||||
$pa_config,
|
||||
'Cannot execute Discovery task: ' . safe_output($task->{'name'}) . '. Please restart the server.',
|
||||
1
|
||||
);
|
||||
# Skip this task.
|
||||
return;
|
||||
}
|
||||
# Pass credentials by file due Perl limitations. We cannot update ENV here.
|
||||
$cnf_extra{'creds_file'} = $pa_config->{'temporal'} . '/tmp_discovery.' . md5($task->{'id_rt'} . $task->{'name'} . time());
|
||||
eval {
|
||||
open(my $__file_cfg, '> '. $cnf_extra{'creds_file'}) or die($!);
|
||||
print $__file_cfg $cnf_extra{'aws_access_key_id'} . "\n";
|
||||
print $__file_cfg $cnf_extra{'aws_secret_access_key'} . "\n";
|
||||
close($__file_cfg);
|
||||
set_file_permissions(
|
||||
$pa_config,
|
||||
$cnf_extra{'creds_file'},
|
||||
"0600"
|
||||
);
|
||||
};
|
||||
if ($@) {
|
||||
logger(
|
||||
$pa_config,
|
||||
'Cannot instantiate configuration file for task: ' . safe_output($task->{'name'}),
|
||||
5
|
||||
);
|
||||
# A server restart will override ENV definition (see run)
|
||||
logger(
|
||||
$pa_config,
|
||||
'Cannot execute Discovery task: ' . safe_output($task->{'name'}) . '. Please restart the server.',
|
||||
1
|
||||
);
|
||||
# Skip this task.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 = "190624";
|
||||
my $pandora_build = "190626";
|
||||
our $VERSION = $pandora_version." ".$pandora_build;
|
||||
|
||||
our %EXPORT_TAGS = ( 'all' => [ qw() ] );
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.735
|
||||
%define release 190624
|
||||
%define release 190626
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -3,7 +3,7 @@
|
||||
#
|
||||
%define name pandorafms_server
|
||||
%define version 7.0NG.735
|
||||
%define release 190624
|
||||
%define release 190626
|
||||
|
||||
Summary: Pandora FMS Server
|
||||
Name: %{name}
|
||||
|
@ -9,7 +9,7 @@
|
||||
# **********************************************************************
|
||||
|
||||
PI_VERSION="7.0NG.735"
|
||||
PI_BUILD="190624"
|
||||
PI_BUILD="190626"
|
||||
|
||||
MODE=$1
|
||||
if [ $# -gt 1 ]; then
|
||||
|
@ -34,7 +34,7 @@ use PandoraFMS::Config;
|
||||
use PandoraFMS::DB;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.735 PS190624";
|
||||
my $version = "7.0NG.735 PS190626";
|
||||
|
||||
# Pandora server configuration
|
||||
my %conf;
|
||||
|
@ -36,7 +36,7 @@ use Encode::Locale;
|
||||
Encode::Locale::decode_argv;
|
||||
|
||||
# version: define current version
|
||||
my $version = "7.0NG.735 PS190624";
|
||||
my $version = "7.0NG.735 PS190626";
|
||||
|
||||
# save program name for logging
|
||||
my $progname = basename($0);
|
||||
|
@ -13,7 +13,10 @@ import {
|
||||
notEmptyStringOr,
|
||||
replaceMacros,
|
||||
humanDate,
|
||||
humanTime
|
||||
humanTime,
|
||||
addMovementListener,
|
||||
debounce,
|
||||
addResizementListener
|
||||
} from "./lib";
|
||||
import TypedEvent, { Listener, Disposable } from "./lib/TypedEvent";
|
||||
|
||||
@ -68,6 +71,18 @@ export interface ItemRemoveEvent<Props extends ItemProps> {
|
||||
data: AnyObject;
|
||||
}
|
||||
|
||||
export interface ItemMovedEvent {
|
||||
item: VisualConsoleItem<ItemProps>;
|
||||
prevPosition: Position;
|
||||
newPosition: Position;
|
||||
}
|
||||
|
||||
export interface ItemResizedEvent {
|
||||
item: VisualConsoleItem<ItemProps>;
|
||||
prevSize: Size;
|
||||
newSize: Size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract a valid enum value from a raw label positi9on value.
|
||||
* @param labelPosition Raw value.
|
||||
@ -133,6 +148,10 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
|
||||
protected readonly childElementRef: HTMLElement;
|
||||
// Event manager for click events.
|
||||
private readonly clickEventManager = new TypedEvent<ItemClickEvent<Props>>();
|
||||
// Event manager for moved events.
|
||||
private readonly movedEventManager = new TypedEvent<ItemMovedEvent>();
|
||||
// Event manager for resized events.
|
||||
private readonly resizedEventManager = new TypedEvent<ItemResizedEvent>();
|
||||
// Event manager for remove events.
|
||||
private readonly removeEventManager = new TypedEvent<
|
||||
ItemRemoveEvent<Props>
|
||||
@ -140,6 +159,137 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
|
||||
// List of references to clean the event listeners.
|
||||
private readonly disposables: Disposable[] = [];
|
||||
|
||||
// This function will only run the 2nd arg function after the time
|
||||
// of the first arg have passed after its last execution.
|
||||
private debouncedMovementSave = debounce(
|
||||
500, // ms.
|
||||
(x: Position["x"], y: Position["y"]) => {
|
||||
const prevPosition = {
|
||||
x: this.props.x,
|
||||
y: this.props.y
|
||||
};
|
||||
const newPosition = {
|
||||
x: x,
|
||||
y: y
|
||||
};
|
||||
|
||||
if (!this.positionChanged(prevPosition, newPosition)) return;
|
||||
|
||||
// Save the new position to the props.
|
||||
this.move(x, y);
|
||||
// Emit the movement event.
|
||||
this.movedEventManager.emit({
|
||||
item: this,
|
||||
prevPosition: prevPosition,
|
||||
newPosition: newPosition
|
||||
});
|
||||
}
|
||||
);
|
||||
// This property will store the function
|
||||
// to clean the movement listener.
|
||||
private removeMovement: Function | null = null;
|
||||
|
||||
/**
|
||||
* Start the movement funtionality.
|
||||
* @param element Element to move inside its container.
|
||||
*/
|
||||
private initMovementListener(element: HTMLElement): void {
|
||||
this.removeMovement = addMovementListener(
|
||||
element,
|
||||
(x: Position["x"], y: Position["y"]) => {
|
||||
// Move the DOM element.
|
||||
this.moveElement(x, y);
|
||||
// Run the save function.
|
||||
this.debouncedMovementSave(x, y);
|
||||
}
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Stop the movement fun
|
||||
*/
|
||||
private stopMovementListener(): void {
|
||||
if (this.removeMovement) {
|
||||
this.removeMovement();
|
||||
this.removeMovement = null;
|
||||
}
|
||||
}
|
||||
|
||||
// This function will only run the 2nd arg function after the time
|
||||
// of the first arg have passed after its last execution.
|
||||
private debouncedResizementSave = debounce(
|
||||
500, // ms.
|
||||
(width: Size["width"], height: Size["height"]) => {
|
||||
const prevSize = {
|
||||
width: this.props.width,
|
||||
height: this.props.height
|
||||
};
|
||||
const newSize = {
|
||||
width: width,
|
||||
height: height
|
||||
};
|
||||
|
||||
if (!this.sizeChanged(prevSize, newSize)) return;
|
||||
|
||||
// Save the new position to the props.
|
||||
this.resize(width, height);
|
||||
// Emit the resizement event.
|
||||
this.resizedEventManager.emit({
|
||||
item: this,
|
||||
prevSize: prevSize,
|
||||
newSize: newSize
|
||||
});
|
||||
}
|
||||
);
|
||||
// This property will store the function
|
||||
// to clean the resizement listener.
|
||||
private removeResizement: Function | null = null;
|
||||
|
||||
/**
|
||||
* Start the resizement funtionality.
|
||||
* @param element Element to move inside its container.
|
||||
*/
|
||||
protected initResizementListener(element: HTMLElement): void {
|
||||
this.removeResizement = addResizementListener(
|
||||
element,
|
||||
(width: Size["width"], height: Size["height"]) => {
|
||||
// The label it's outside the item's size, so we need
|
||||
// to get rid of its size to get the real size of the
|
||||
// item's content.
|
||||
if (this.props.label && this.props.label.length > 0) {
|
||||
const {
|
||||
width: labelWidth,
|
||||
height: labelHeight
|
||||
} = this.labelElementRef.getBoundingClientRect();
|
||||
|
||||
switch (this.props.labelPosition) {
|
||||
case "up":
|
||||
case "down":
|
||||
height -= labelHeight;
|
||||
break;
|
||||
case "left":
|
||||
case "right":
|
||||
width -= labelWidth;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Move the DOM element.
|
||||
this.resizeElement(width, height);
|
||||
// Run the save function.
|
||||
this.debouncedResizementSave(width, height);
|
||||
}
|
||||
);
|
||||
}
|
||||
/**
|
||||
* Stop the resizement functionality.
|
||||
*/
|
||||
private stopResizementListener(): void {
|
||||
if (this.removeResizement) {
|
||||
this.removeResizement();
|
||||
this.removeResizement = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* To create a new element which will be inside the item box.
|
||||
* @return Item.
|
||||
@ -182,18 +332,17 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
|
||||
private createContainerDomElement(): HTMLElement {
|
||||
let box;
|
||||
if (this.props.isLinkEnabled) {
|
||||
box = document.createElement("a");
|
||||
box as HTMLAnchorElement;
|
||||
box = document.createElement("a") as HTMLAnchorElement;
|
||||
if (this.props.link) box.href = this.props.link;
|
||||
} else {
|
||||
box = document.createElement("div");
|
||||
box as HTMLDivElement;
|
||||
box = document.createElement("div") as HTMLDivElement;
|
||||
}
|
||||
|
||||
box.className = "visual-console-item";
|
||||
box.style.zIndex = this.props.isOnTop ? "2" : "1";
|
||||
box.style.left = `${this.props.x}px`;
|
||||
box.style.top = `${this.props.y}px`;
|
||||
// Init the click listener.
|
||||
box.addEventListener("click", e => {
|
||||
if (this.meta.editMode) {
|
||||
e.preventDefault();
|
||||
@ -203,6 +352,21 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
|
||||
}
|
||||
});
|
||||
|
||||
// Metadata state.
|
||||
if (this.meta.editMode) {
|
||||
box.classList.add("is-editing");
|
||||
// Init the movement listener.
|
||||
this.initMovementListener(box);
|
||||
// Init the resizement listener.
|
||||
this.initResizementListener(box);
|
||||
}
|
||||
if (this.meta.isFetching) {
|
||||
box.classList.add("is-fetching");
|
||||
}
|
||||
if (this.meta.isUpdating) {
|
||||
box.classList.add("is-updating");
|
||||
}
|
||||
|
||||
return box;
|
||||
}
|
||||
|
||||
@ -344,6 +508,15 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
|
||||
* @param newProps
|
||||
*/
|
||||
public set meta(newMetadata: ItemMeta) {
|
||||
this.setMeta(newMetadata);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clasic and protected version of the setter of the `meta` property.
|
||||
* Useful to override it from children classes.
|
||||
* @param newProps
|
||||
*/
|
||||
protected setMeta(newMetadata: ItemMeta) {
|
||||
const prevMetadata = this._metadata;
|
||||
// Update the internal meta.
|
||||
this._metadata = newMetadata;
|
||||
@ -428,8 +601,12 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
|
||||
if (!prevMeta || prevMeta.editMode !== this.meta.editMode) {
|
||||
if (this.meta.editMode) {
|
||||
this.elementRef.classList.add("is-editing");
|
||||
this.initMovementListener(this.elementRef);
|
||||
this.initResizementListener(this.elementRef);
|
||||
} else {
|
||||
this.elementRef.classList.remove("is-editing");
|
||||
this.stopMovementListener();
|
||||
this.stopResizementListener();
|
||||
}
|
||||
}
|
||||
if (!prevMeta || prevMeta.isFetching !== this.meta.isFetching) {
|
||||
@ -569,6 +746,25 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
|
||||
// The most valuable size is the content size.
|
||||
this.childElementRef.style.width = width > 0 ? `${width}px` : null;
|
||||
this.childElementRef.style.height = height > 0 ? `${height}px` : null;
|
||||
|
||||
if (this.props.label && this.props.label.length > 0) {
|
||||
// Ugly table to show the label as its legacy counterpart.
|
||||
const tables = this.labelElementRef.getElementsByTagName("table");
|
||||
const table = tables.length > 0 ? tables.item(0) : null;
|
||||
|
||||
if (table) {
|
||||
switch (this.props.labelPosition) {
|
||||
case "up":
|
||||
case "down":
|
||||
table.style.width = width > 0 ? `${width}px` : null;
|
||||
break;
|
||||
case "left":
|
||||
case "right":
|
||||
table.style.height = height > 0 ? `${height}px` : null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -601,6 +797,38 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
|
||||
return disposable;
|
||||
}
|
||||
|
||||
/**
|
||||
* To add an event handler to the movement of visual console elements.
|
||||
* @param listener Function which is going to be executed when a linked console is moved.
|
||||
*/
|
||||
public onMoved(listener: Listener<ItemMovedEvent>): Disposable {
|
||||
/*
|
||||
* The '.on' function returns a function which will clean the event
|
||||
* listener when executed. We store all the 'dispose' functions to
|
||||
* call them when the item should be cleared.
|
||||
*/
|
||||
const disposable = this.movedEventManager.on(listener);
|
||||
this.disposables.push(disposable);
|
||||
|
||||
return disposable;
|
||||
}
|
||||
|
||||
/**
|
||||
* To add an event handler to the resizement of visual console elements.
|
||||
* @param listener Function which is going to be executed when a linked console is moved.
|
||||
*/
|
||||
public onResized(listener: Listener<ItemResizedEvent>): Disposable {
|
||||
/*
|
||||
* The '.on' function returns a function which will clean the event
|
||||
* listener when executed. We store all the 'dispose' functions to
|
||||
* call them when the item should be cleared.
|
||||
*/
|
||||
const disposable = this.resizedEventManager.on(listener);
|
||||
this.disposables.push(disposable);
|
||||
|
||||
return disposable;
|
||||
}
|
||||
|
||||
/**
|
||||
* To add an event handler to the removal of the item.
|
||||
* @param listener Function which is going to be executed when a item is removed.
|
||||
|
@ -10,7 +10,9 @@ import Item, {
|
||||
ItemType,
|
||||
ItemProps,
|
||||
ItemClickEvent,
|
||||
ItemRemoveEvent
|
||||
ItemRemoveEvent,
|
||||
ItemMovedEvent,
|
||||
ItemResizedEvent
|
||||
} from "./Item";
|
||||
import StaticGraph, { staticGraphPropsDecoder } from "./items/StaticGraph";
|
||||
import Icon, { iconPropsDecoder } from "./items/Icon";
|
||||
@ -204,6 +206,10 @@ export default class VisualConsole {
|
||||
private readonly clickEventManager = new TypedEvent<
|
||||
ItemClickEvent<ItemProps>
|
||||
>();
|
||||
// Event manager for move events.
|
||||
private readonly movedEventManager = new TypedEvent<ItemMovedEvent>();
|
||||
// Event manager for resize events.
|
||||
private readonly resizedEventManager = new TypedEvent<ItemResizedEvent>();
|
||||
// List of references to clean the event listeners.
|
||||
private readonly disposables: Disposable[] = [];
|
||||
|
||||
@ -216,6 +222,24 @@ export default class VisualConsole {
|
||||
// console.log(`Clicked element #${e.data.id}`, e);
|
||||
};
|
||||
|
||||
/**
|
||||
* React to a movement on an element.
|
||||
* @param e Event object.
|
||||
*/
|
||||
private handleElementMovement: (e: ItemMovedEvent) => void = e => {
|
||||
this.movedEventManager.emit(e);
|
||||
// console.log(`Moved element #${e.item.props.id}`, e);
|
||||
};
|
||||
|
||||
/**
|
||||
* React to a resizement on an element.
|
||||
* @param e Event object.
|
||||
*/
|
||||
private handleElementResizement: (e: ItemResizedEvent) => void = e => {
|
||||
this.resizedEventManager.emit(e);
|
||||
// console.log(`Resized element #${e.item.props.id}`, e);
|
||||
};
|
||||
|
||||
/**
|
||||
* Clear some element references.
|
||||
* @param e Event object.
|
||||
@ -264,6 +288,8 @@ export default class VisualConsole {
|
||||
this.elementIds.push(itemInstance.props.id);
|
||||
// Item event handlers.
|
||||
itemInstance.onClick(this.handleElementClick);
|
||||
itemInstance.onMoved(this.handleElementMovement);
|
||||
itemInstance.onResized(this.handleElementResizement);
|
||||
itemInstance.onRemove(this.handleElementRemove);
|
||||
// Add the item to the DOM.
|
||||
this.containerRef.append(itemInstance.elementRef);
|
||||
@ -552,7 +578,9 @@ export default class VisualConsole {
|
||||
* Add an event handler to the click of the linked visual console elements.
|
||||
* @param listener Function which is going to be executed when a linked console is clicked.
|
||||
*/
|
||||
public onClick(listener: Listener<ItemClickEvent<ItemProps>>): Disposable {
|
||||
public onItemClick(
|
||||
listener: Listener<ItemClickEvent<ItemProps>>
|
||||
): Disposable {
|
||||
/*
|
||||
* The '.on' function returns a function which will clean the event
|
||||
* listener when executed. We store all the 'dispose' functions to
|
||||
@ -564,6 +592,38 @@ export default class VisualConsole {
|
||||
return disposable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an event handler to the movement of the visual console elements.
|
||||
* @param listener Function which is going to be executed when a linked console is moved.
|
||||
*/
|
||||
public onItemMoved(listener: Listener<ItemMovedEvent>): Disposable {
|
||||
/*
|
||||
* The '.on' function returns a function which will clean the event
|
||||
* listener when executed. We store all the 'dispose' functions to
|
||||
* call them when the item should be cleared.
|
||||
*/
|
||||
const disposable = this.movedEventManager.on(listener);
|
||||
this.disposables.push(disposable);
|
||||
|
||||
return disposable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an event handler to the resizement of the visual console elements.
|
||||
* @param listener Function which is going to be executed when a linked console is moved.
|
||||
*/
|
||||
public onItemResized(listener: Listener<ItemResizedEvent>): Disposable {
|
||||
/*
|
||||
* The '.on' function returns a function which will clean the event
|
||||
* listener when executed. We store all the 'dispose' functions to
|
||||
* call them when the item should be cleared.
|
||||
*/
|
||||
const disposable = this.resizedEventManager.on(listener);
|
||||
this.disposables.push(disposable);
|
||||
|
||||
return disposable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the edition mode.
|
||||
*/
|
||||
@ -571,6 +631,7 @@ export default class VisualConsole {
|
||||
this.elements.forEach(item => {
|
||||
item.meta = { ...item.meta, editMode: true };
|
||||
});
|
||||
this.containerRef.classList.add("is-editing");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -580,5 +641,6 @@ export default class VisualConsole {
|
||||
this.elements.forEach(item => {
|
||||
item.meta = { ...item.meta, editMode: false };
|
||||
});
|
||||
this.containerRef.classList.remove("is-editing");
|
||||
}
|
||||
}
|
||||
|
@ -53,6 +53,10 @@ export default class ColorCloud extends Item<ColorCloudProps> {
|
||||
return container;
|
||||
}
|
||||
|
||||
protected resizeElement(width: number): void {
|
||||
super.resizeElement(width, width);
|
||||
}
|
||||
|
||||
public createSvgElement(): SVGSVGElement {
|
||||
const gradientId = `grad_${this.props.id}`;
|
||||
// SVG container.
|
||||
|
@ -83,10 +83,26 @@ export default class Line extends Item<LineProps> {
|
||||
...props,
|
||||
...Line.extractBoxSizeAndPosition(props)
|
||||
},
|
||||
meta
|
||||
{
|
||||
...meta,
|
||||
editMode: false
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clasic and protected version of the setter of the `meta` property.
|
||||
* Useful to override it from children classes.
|
||||
* @param newProps
|
||||
* @override Item.setMeta
|
||||
*/
|
||||
public setMeta(newMetadata: ItemMeta) {
|
||||
super.setMeta({
|
||||
...newMetadata,
|
||||
editMode: false
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @override
|
||||
* To create the item's DOM representation.
|
||||
|
@ -58,6 +58,15 @@ export default class ModuleGraph extends Item<ModuleGraphProps> {
|
||||
super.resizeElement(width, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @override Item.initResizementListener. To disable the functionality.
|
||||
* Start the resizement funtionality.
|
||||
* @param element Element to move inside its container.
|
||||
*/
|
||||
protected initResizementListener(): void {
|
||||
// No-Op. Disable the resizement functionality for this item.
|
||||
}
|
||||
|
||||
protected createDomElement(): HTMLElement {
|
||||
const element = document.createElement("div");
|
||||
element.className = "module-graph";
|
||||
|
@ -374,3 +374,376 @@ export function replaceMacros(macros: Macro[], text: string): string {
|
||||
text
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a function which will limit the rate of execution of
|
||||
* the selected function to one time for the selected interval.
|
||||
* @param delay Interval.
|
||||
* @param fn Function to be executed at a limited rate.
|
||||
*/
|
||||
export function throttle<T, R>(delay: number, fn: (...args: T[]) => R) {
|
||||
let last = 0;
|
||||
return (...args: T[]) => {
|
||||
const now = Date.now();
|
||||
if (now - last < delay) return;
|
||||
last = now;
|
||||
return fn(...args);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a function which will call the selected function only
|
||||
* after the interval time has passed after its last execution.
|
||||
* @param delay Interval.
|
||||
* @param fn Function to be executed after the last call.
|
||||
*/
|
||||
export function debounce<T>(delay: number, fn: (...args: T[]) => void) {
|
||||
let timerRef: number | null = null;
|
||||
return (...args: T[]) => {
|
||||
if (timerRef !== null) window.clearTimeout(timerRef);
|
||||
timerRef = window.setTimeout(() => {
|
||||
fn(...args);
|
||||
timerRef = null;
|
||||
}, delay);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the offset of an element relative to the page.
|
||||
* @param el Node used to calculate the offset.
|
||||
*/
|
||||
function getOffset(el: HTMLElement | null) {
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
while (el && !Number.isNaN(el.offsetLeft) && !Number.isNaN(el.offsetTop)) {
|
||||
x += el.offsetLeft - el.scrollLeft;
|
||||
y += el.offsetTop - el.scrollTop;
|
||||
el = el.offsetParent as HTMLElement | null;
|
||||
}
|
||||
return { top: y, left: x };
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the grab & move functionality to a certain element inside it's container.
|
||||
*
|
||||
* @param element Element to move.
|
||||
* @param onMoved Function to execute when the element moves.
|
||||
*
|
||||
* @return A function which will clean the event handlers when executed.
|
||||
*/
|
||||
export function addMovementListener(
|
||||
element: HTMLElement,
|
||||
onMoved: (x: Position["x"], y: Position["y"]) => void
|
||||
): Function {
|
||||
const container = element.parentElement as HTMLElement;
|
||||
// Store the initial draggable state.
|
||||
const isDraggable = element.draggable;
|
||||
// Init the coordinates.
|
||||
let lastX: Position["x"] = 0;
|
||||
let lastY: Position["y"] = 0;
|
||||
let lastMouseX: Position["x"] = 0;
|
||||
let lastMouseY: Position["y"] = 0;
|
||||
let mouseElementOffsetX: Position["x"] = 0;
|
||||
let mouseElementOffsetY: Position["y"] = 0;
|
||||
// Bounds.
|
||||
let containerBounds = container.getBoundingClientRect();
|
||||
let containerOffset = getOffset(container);
|
||||
let containerTop = containerOffset.top;
|
||||
let containerBottom = containerTop + containerBounds.height;
|
||||
let containerLeft = containerOffset.left;
|
||||
let containerRight = containerLeft + containerBounds.width;
|
||||
let elementBounds = element.getBoundingClientRect();
|
||||
let borderWidth = window.getComputedStyle(element).borderWidth || "0";
|
||||
let borderFix = Number.parseInt(borderWidth) * 2;
|
||||
|
||||
// Will run onMoved 32ms after its last execution.
|
||||
const debouncedMovement = debounce(32, (x: Position["x"], y: Position["y"]) =>
|
||||
onMoved(x, y)
|
||||
);
|
||||
// Will run onMoved one time max every 16ms.
|
||||
const throttledMovement = throttle(16, (x: Position["x"], y: Position["y"]) =>
|
||||
onMoved(x, y)
|
||||
);
|
||||
|
||||
const handleMove = (e: MouseEvent) => {
|
||||
// Calculate the new element coordinates.
|
||||
let x = 0;
|
||||
let y = 0;
|
||||
|
||||
const mouseX = e.pageX;
|
||||
const mouseY = e.pageY;
|
||||
const mouseDeltaX = mouseX - lastMouseX;
|
||||
const mouseDeltaY = mouseY - lastMouseY;
|
||||
|
||||
const minX = 0;
|
||||
const maxX = containerBounds.width - elementBounds.width + borderFix;
|
||||
const minY = 0;
|
||||
const maxY = containerBounds.height - elementBounds.height + borderFix;
|
||||
|
||||
const outOfBoundsLeft =
|
||||
mouseX < containerLeft ||
|
||||
(lastX === 0 &&
|
||||
mouseDeltaX > 0 &&
|
||||
mouseX < containerLeft + mouseElementOffsetX);
|
||||
const outOfBoundsRight =
|
||||
mouseX > containerRight ||
|
||||
mouseDeltaX + lastX + elementBounds.width - borderFix >
|
||||
containerBounds.width ||
|
||||
(lastX === maxX &&
|
||||
mouseDeltaX < 0 &&
|
||||
mouseX > containerLeft + maxX + mouseElementOffsetX);
|
||||
const outOfBoundsTop =
|
||||
mouseY < containerTop ||
|
||||
(lastY === 0 &&
|
||||
mouseDeltaY > 0 &&
|
||||
mouseY < containerTop + mouseElementOffsetY);
|
||||
const outOfBoundsBottom =
|
||||
mouseY > containerBottom ||
|
||||
mouseDeltaY + lastY + elementBounds.height - borderFix >
|
||||
containerBounds.height ||
|
||||
(lastY === maxY &&
|
||||
mouseDeltaY < 0 &&
|
||||
mouseY > containerTop + maxY + mouseElementOffsetY);
|
||||
|
||||
if (outOfBoundsLeft) x = minX;
|
||||
else if (outOfBoundsRight) x = maxX;
|
||||
else x = mouseDeltaX + lastX;
|
||||
|
||||
if (outOfBoundsTop) y = minY;
|
||||
else if (outOfBoundsBottom) y = maxY;
|
||||
else y = mouseDeltaY + lastY;
|
||||
|
||||
if (x < 0) x = minX;
|
||||
if (y < 0) y = minY;
|
||||
|
||||
// Store the last mouse coordinates.
|
||||
lastMouseX = mouseX;
|
||||
lastMouseY = mouseY;
|
||||
|
||||
if (x === lastX && y === lastY) return;
|
||||
|
||||
// Run the movement events.
|
||||
throttledMovement(x, y);
|
||||
debouncedMovement(x, y);
|
||||
|
||||
// Store the coordinates of the element.
|
||||
lastX = x;
|
||||
lastY = y;
|
||||
};
|
||||
const handleEnd = () => {
|
||||
// Reset the positions.
|
||||
lastX = 0;
|
||||
lastY = 0;
|
||||
lastMouseX = 0;
|
||||
lastMouseY = 0;
|
||||
// Remove the move event.
|
||||
document.removeEventListener("mousemove", handleMove);
|
||||
// Clean itself.
|
||||
document.removeEventListener("mouseup", handleEnd);
|
||||
// Reset the draggable property to its initial state.
|
||||
element.draggable = isDraggable;
|
||||
// Reset the body selection property to a default state.
|
||||
document.body.style.userSelect = "auto";
|
||||
};
|
||||
const handleStart = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
// Disable the drag temporarily.
|
||||
element.draggable = false;
|
||||
|
||||
// Store the difference between the cursor and
|
||||
// the initial coordinates of the element.
|
||||
lastX = element.offsetLeft;
|
||||
lastY = element.offsetTop;
|
||||
// Store the mouse position.
|
||||
lastMouseX = e.pageX;
|
||||
lastMouseY = e.pageY;
|
||||
// Store the relative position between the mouse and the element.
|
||||
mouseElementOffsetX = e.offsetX;
|
||||
mouseElementOffsetY = e.offsetY;
|
||||
|
||||
// Initialize the bounds.
|
||||
containerBounds = container.getBoundingClientRect();
|
||||
containerOffset = getOffset(container);
|
||||
containerTop = containerOffset.top;
|
||||
containerBottom = containerTop + containerBounds.height;
|
||||
containerLeft = containerOffset.left;
|
||||
containerRight = containerLeft + containerBounds.width;
|
||||
elementBounds = element.getBoundingClientRect();
|
||||
borderWidth = window.getComputedStyle(element).borderWidth || "0";
|
||||
borderFix = Number.parseInt(borderWidth) * 2;
|
||||
|
||||
// Listen to the mouse movement.
|
||||
document.addEventListener("mousemove", handleMove);
|
||||
// Listen to the moment when the mouse click is not pressed anymore.
|
||||
document.addEventListener("mouseup", handleEnd);
|
||||
// Limit the mouse selection of the body.
|
||||
document.body.style.userSelect = "none";
|
||||
};
|
||||
|
||||
// Event to listen the init of the movement.
|
||||
element.addEventListener("mousedown", handleStart);
|
||||
|
||||
// Returns a function to clean the event listeners.
|
||||
return () => {
|
||||
element.removeEventListener("mousedown", handleStart);
|
||||
handleEnd();
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the grab & resize functionality to a certain element.
|
||||
*
|
||||
* @param element Element to move.
|
||||
* @param onResized Function to execute when the element is resized.
|
||||
*
|
||||
* @return A function which will clean the event handlers when executed.
|
||||
*/
|
||||
export function addResizementListener(
|
||||
element: HTMLElement,
|
||||
onResized: (x: Position["x"], y: Position["y"]) => void
|
||||
): Function {
|
||||
const minWidth = 15;
|
||||
const minHeight = 15;
|
||||
|
||||
const resizeDraggable = document.createElement("div");
|
||||
resizeDraggable.className = "resize-draggable";
|
||||
element.appendChild(resizeDraggable);
|
||||
|
||||
// Container of the resizable element.
|
||||
const container = element.parentElement as HTMLElement;
|
||||
// Store the initial draggable state.
|
||||
const isDraggable = element.draggable;
|
||||
// Init the coordinates.
|
||||
let lastWidth: Size["width"] = 0;
|
||||
let lastHeight: Size["height"] = 0;
|
||||
let lastMouseX: Position["x"] = 0;
|
||||
let lastMouseY: Position["y"] = 0;
|
||||
let mouseElementOffsetX: Position["x"] = 0;
|
||||
let mouseElementOffsetY: Position["y"] = 0;
|
||||
// Init the bounds.
|
||||
let containerBounds = container.getBoundingClientRect();
|
||||
let containerOffset = getOffset(container);
|
||||
let containerTop = containerOffset.top;
|
||||
let containerBottom = containerTop + containerBounds.height;
|
||||
let containerLeft = containerOffset.left;
|
||||
let containerRight = containerLeft + containerBounds.width;
|
||||
let elementOffset = getOffset(element);
|
||||
let elementTop = elementOffset.top;
|
||||
let elementLeft = elementOffset.left;
|
||||
let borderWidth = window.getComputedStyle(element).borderWidth || "0";
|
||||
let borderFix = Number.parseInt(borderWidth);
|
||||
|
||||
// Will run onResized 32ms after its last execution.
|
||||
const debouncedResizement = debounce(
|
||||
32,
|
||||
(width: Size["width"], height: Size["height"]) => onResized(width, height)
|
||||
);
|
||||
// Will run onResized one time max every 16ms.
|
||||
const throttledResizement = throttle(
|
||||
16,
|
||||
(width: Size["width"], height: Size["height"]) => onResized(width, height)
|
||||
);
|
||||
|
||||
const handleResize = (e: MouseEvent) => {
|
||||
// Calculate the new element coordinates.
|
||||
let width = lastWidth + (e.pageX - lastMouseX);
|
||||
let height = lastHeight + (e.pageY - lastMouseY);
|
||||
|
||||
if (width === lastWidth && height === lastHeight) return;
|
||||
|
||||
if (
|
||||
width < lastWidth &&
|
||||
e.pageX > elementLeft + (lastWidth - mouseElementOffsetX)
|
||||
)
|
||||
return;
|
||||
|
||||
if (width < minWidth) {
|
||||
// Minimum value.
|
||||
width = minWidth;
|
||||
} else if (width + elementLeft - borderFix / 2 >= containerRight) {
|
||||
// Limit the size to the container.
|
||||
width = containerRight - elementLeft;
|
||||
}
|
||||
if (height < minHeight) {
|
||||
// Minimum value.
|
||||
height = minHeight;
|
||||
} else if (height + elementTop - borderFix / 2 >= containerBottom) {
|
||||
// Limit the size to the container.
|
||||
height = containerBottom - elementTop;
|
||||
}
|
||||
|
||||
// Run the movement events.
|
||||
throttledResizement(width, height);
|
||||
debouncedResizement(width, height);
|
||||
|
||||
// Store the coordinates of the element.
|
||||
lastWidth = width;
|
||||
lastHeight = height;
|
||||
// Store the last mouse coordinates.
|
||||
lastMouseX = e.pageX;
|
||||
lastMouseY = e.pageY;
|
||||
};
|
||||
const handleEnd = () => {
|
||||
// Reset the positions.
|
||||
lastWidth = 0;
|
||||
lastHeight = 0;
|
||||
lastMouseX = 0;
|
||||
lastMouseY = 0;
|
||||
mouseElementOffsetX = 0;
|
||||
mouseElementOffsetY = 0;
|
||||
// Remove the move event.
|
||||
document.removeEventListener("mousemove", handleResize);
|
||||
// Clean itself.
|
||||
document.removeEventListener("mouseup", handleEnd);
|
||||
// Reset the draggable property to its initial state.
|
||||
element.draggable = isDraggable;
|
||||
// Reset the body selection property to a default state.
|
||||
document.body.style.userSelect = "auto";
|
||||
};
|
||||
const handleStart = (e: MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
|
||||
// Disable the drag temporarily.
|
||||
element.draggable = false;
|
||||
|
||||
// Store the difference between the cursor and
|
||||
// the initial coordinates of the element.
|
||||
const { width, height } = element.getBoundingClientRect();
|
||||
lastWidth = width;
|
||||
lastHeight = height;
|
||||
// Store the mouse position.
|
||||
lastMouseX = e.pageX;
|
||||
lastMouseY = e.pageY;
|
||||
// Store the relative position between the mouse and the element.
|
||||
mouseElementOffsetX = e.offsetX;
|
||||
mouseElementOffsetY = e.offsetY;
|
||||
|
||||
// Initialize the bounds.
|
||||
containerBounds = container.getBoundingClientRect();
|
||||
containerOffset = getOffset(container);
|
||||
containerTop = containerOffset.top;
|
||||
containerBottom = containerTop + containerBounds.height;
|
||||
containerLeft = containerOffset.left;
|
||||
containerRight = containerLeft + containerBounds.width;
|
||||
elementOffset = getOffset(element);
|
||||
elementTop = elementOffset.top;
|
||||
elementLeft = elementOffset.left;
|
||||
|
||||
// Listen to the mouse movement.
|
||||
document.addEventListener("mousemove", handleResize);
|
||||
// Listen to the moment when the mouse click is not pressed anymore.
|
||||
document.addEventListener("mouseup", handleEnd);
|
||||
// Limit the mouse selection of the body.
|
||||
document.body.style.userSelect = "none";
|
||||
};
|
||||
|
||||
// Event to listen the init of the movement.
|
||||
resizeDraggable.addEventListener("mousedown", handleStart);
|
||||
|
||||
// Returns a function to clean the event listeners.
|
||||
return () => {
|
||||
resizeDraggable.remove();
|
||||
handleEnd();
|
||||
};
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user