mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
Merge branch 'ent-8697-13244-no-funcionan-acciones-de-eventos-a-traves-de-un-dashboard' into 'develop'
Fix dashboard events responses See merge request artica/pandorafms!4759
This commit is contained in:
commit
74e4461d8a
@ -26,6 +26,8 @@
|
||||
* ============================================================================
|
||||
*/
|
||||
|
||||
use PandoraFMS\Enterprise\Metaconsole\Node;
|
||||
|
||||
// Begin.
|
||||
global $config;
|
||||
|
||||
@ -86,6 +88,7 @@ $get_event_filters = get_parameter('get_event_filters', 0);
|
||||
$get_comments = (bool) get_parameter('get_comments', false);
|
||||
$get_events_fired = (bool) get_parameter('get_events_fired');
|
||||
$get_id_source_event = get_parameter('get_id_source_event');
|
||||
$node_id = (int) get_parameter('node_id', 0);
|
||||
if ($get_comments === true) {
|
||||
$event = get_parameter('event', false);
|
||||
$filter = get_parameter('filter', false);
|
||||
@ -195,7 +198,23 @@ if ($delete_event) {
|
||||
return;
|
||||
}
|
||||
|
||||
$r = events_delete($id_evento, $filter);
|
||||
if ($node_id > 0) {
|
||||
try {
|
||||
$node = new Node($node_id);
|
||||
$node->connect();
|
||||
$r = events_delete($id_evento, $filter, false, true);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
$node->disconnect();
|
||||
$success = false;
|
||||
echo 'owner_error';
|
||||
} finally {
|
||||
$node->disconnect();
|
||||
}
|
||||
} else {
|
||||
$r = events_delete($id_evento, $filter);
|
||||
}
|
||||
|
||||
if ($r === false) {
|
||||
echo 'Failed';
|
||||
} else {
|
||||
@ -1261,18 +1280,42 @@ if ($change_status) {
|
||||
$event_ids = get_parameter('event_ids');
|
||||
$new_status = get_parameter('new_status');
|
||||
|
||||
$return = events_change_status(
|
||||
explode(',', $event_ids),
|
||||
$new_status,
|
||||
$meta,
|
||||
$history
|
||||
);
|
||||
if ($node_id > 0) {
|
||||
try {
|
||||
$node = new Node($node_id);
|
||||
$node->connect();
|
||||
$return = events_change_status(
|
||||
explode(',', $event_ids),
|
||||
$new_status,
|
||||
$meta,
|
||||
$history
|
||||
);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
$node->disconnect();
|
||||
$success = false;
|
||||
echo 'owner_error';
|
||||
} finally {
|
||||
$node->disconnect();
|
||||
}
|
||||
} else {
|
||||
$return = events_change_status(
|
||||
explode(',', $event_ids),
|
||||
$new_status,
|
||||
$meta,
|
||||
$history
|
||||
);
|
||||
}
|
||||
|
||||
if ($return !== false) {
|
||||
$event_st = events_display_status($new_status);
|
||||
|
||||
echo json_encode(
|
||||
[
|
||||
'status' => 'status_ok',
|
||||
'user' => db_get_value(
|
||||
'status_title' => $event_st['title'],
|
||||
'status_img' => html_print_image($event_st['img'], true, false, true),
|
||||
'status' => 'status_ok',
|
||||
'user' => db_get_value(
|
||||
'fullname',
|
||||
'tusuario',
|
||||
'id_user',
|
||||
@ -1306,7 +1349,22 @@ if ($change_owner) {
|
||||
$new_owner = '';
|
||||
}
|
||||
|
||||
$return = events_change_owner($event_id, $new_owner, true, $meta, $history);
|
||||
if ($node_id > 0) {
|
||||
try {
|
||||
$node = new Node($node_id);
|
||||
$node->connect();
|
||||
$return = events_change_owner($event_id, $new_owner, true, $meta, $history);
|
||||
} catch (\Exception $e) {
|
||||
// Unexistent agent.
|
||||
$node->disconnect();
|
||||
$success = false;
|
||||
echo 'owner_error';
|
||||
} finally {
|
||||
$node->disconnect();
|
||||
}
|
||||
} else {
|
||||
$return = events_change_owner($event_id, $new_owner, true, $meta, $history);
|
||||
}
|
||||
|
||||
if ($return) {
|
||||
echo 'owner_ok';
|
||||
@ -1322,7 +1380,7 @@ if ($change_owner) {
|
||||
if ($get_extended_event) {
|
||||
global $config;
|
||||
|
||||
$event = get_parameter('event', false);
|
||||
$event = io_safe_output(get_parameter('event', false));
|
||||
$filter = get_parameter('filter', false);
|
||||
|
||||
if ($event === false) {
|
||||
@ -1411,6 +1469,9 @@ if ($get_extended_event) {
|
||||
|
||||
// Print group_rep in a hidden field to recover it from javascript.
|
||||
html_print_input_hidden('group_rep', (int) $group_rep);
|
||||
if ($node_id > 0) {
|
||||
html_print_input_hidden('node_id', (int) $node_id);
|
||||
}
|
||||
|
||||
if ($event === false) {
|
||||
return;
|
||||
@ -1578,14 +1639,16 @@ if ($get_extended_event) {
|
||||
|
||||
$comments = '<div id="extended_event_comments_page" class="extended_event_pages"></div>';
|
||||
|
||||
$notifications = '<div id="notification_comment_error" class="invisible">'.ui_print_error_message(__('Error adding comment'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_comment_success" class="invisible">'.ui_print_success_message(__('Comment added successfully'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_status_error" class="invisible">'.ui_print_error_message(__('Error changing event status'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_status_success" class="invisible">'.ui_print_success_message(__('Event status changed successfully'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_error" class="invisible">'.ui_print_error_message(__('Error changing event owner'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_success" class="invisible">'.ui_print_success_message(__('Event owner changed successfully'), '', true).'</div>';
|
||||
$notifications = '<div id="notification_comment_error" class="invisible_events">'.ui_print_error_message(__('Error adding comment'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_comment_success" class="invisible_events">'.ui_print_success_message(__('Comment added successfully'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_status_error" class="invisible_events">'.ui_print_error_message(__('Error changing event status'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_status_success" class="invisible_events">'.ui_print_success_message(__('Event status changed successfully'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_error" class="invisible_events">'.ui_print_error_message(__('Error changing event owner'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_owner_success" class="invisible_events">'.ui_print_success_message(__('Event owner changed successfully'), '', true).'</div>';
|
||||
$notifications .= '<div id="notification_delete_error" class="invisible_events">'.ui_print_error_message(__('Error deleting event'), '', true).'</div>';
|
||||
|
||||
$loading = '<div id="response_loading" class="invisible">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
|
||||
$loading = '<div id="response_loading" class="invisible_events">'.html_print_image('images/spinner.gif', true).'</div>';
|
||||
|
||||
$i = 0;
|
||||
$tab['general'] = $i++;
|
||||
|
@ -352,13 +352,14 @@ function events_get_column_names($fields, $table_alias=false)
|
||||
/**
|
||||
* Validates all events matching target filter.
|
||||
*
|
||||
* @param integer $id_evento Master event.
|
||||
* @param array $filter Optional. Filter options.
|
||||
* @param boolean $history Apply on historical table.
|
||||
* @param integer $id_evento Master event.
|
||||
* @param array $filter Optional. Filter options.
|
||||
* @param boolean $history Apply on historical table.
|
||||
* @param boolean $force_node Force node table.
|
||||
*
|
||||
* @return integer Events validated or false if error.
|
||||
*/
|
||||
function events_delete($id_evento, $filter=null, $history=false)
|
||||
function events_delete($id_evento, $filter=null, $history=false, $force_node=false)
|
||||
{
|
||||
if (!isset($id_evento) || $id_evento <= 0) {
|
||||
return false;
|
||||
@ -368,7 +369,10 @@ function events_delete($id_evento, $filter=null, $history=false)
|
||||
$filter = ['group_rep' => 0];
|
||||
}
|
||||
|
||||
$table = events_get_events_table(is_metaconsole(), $history);
|
||||
$table = events_get_events_table(
|
||||
($force_node === false) ? is_metaconsole() : false,
|
||||
$history
|
||||
);
|
||||
|
||||
switch ($filter['group_rep']) {
|
||||
case '0':
|
||||
@ -3752,7 +3756,7 @@ function events_page_responses($event, $childrens_ids=[])
|
||||
$data = [];
|
||||
$data[0] = __('Delete event');
|
||||
$data[1] = '';
|
||||
$data[2] = '<form method="post">';
|
||||
$data[2] = '<form id="event_responses_delete" method="post">';
|
||||
$data[2] .= html_print_button(
|
||||
__('Delete event'),
|
||||
'delete_button',
|
||||
@ -5043,6 +5047,8 @@ function events_page_general($event)
|
||||
$event_st = events_display_status($event['estado']);
|
||||
|
||||
$data = [];
|
||||
|
||||
$table_general->rowid[7] = 'general_status';
|
||||
$data[0] = __('Status');
|
||||
$data[1] = $event_st['title'];
|
||||
$data[2] = html_print_image($event_st['img'], true);
|
||||
|
@ -232,7 +232,6 @@ function fmModuleChange(uniqId, isMeta) {
|
||||
selection: showCommonModules
|
||||
},
|
||||
function(data) {
|
||||
debugger;
|
||||
$("#filtered-module-modules-" + uniqId).html("");
|
||||
if (data) {
|
||||
jQuery.each(data, function(id, value) {
|
||||
|
@ -1404,7 +1404,8 @@ function dashboardShowEventDialog(settings) {
|
||||
dialog_page: "",
|
||||
meta: 0,
|
||||
history: 0,
|
||||
filter: []
|
||||
filter: [],
|
||||
node_id: settings.node_id
|
||||
},
|
||||
dataType: "html",
|
||||
success: function(data) {
|
||||
@ -1417,9 +1418,58 @@ function dashboardShowEventDialog(settings) {
|
||||
resizable: true,
|
||||
draggable: true,
|
||||
modal: true,
|
||||
create: function() {
|
||||
$("#button-delete_button").removeAttr("onclick");
|
||||
$("#button-delete_button").click(function() {
|
||||
var confirm_message = $("#hidden-delete_confirm_message").val();
|
||||
if (confirm(confirm_message) == false) {
|
||||
return false;
|
||||
}
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: settings.ajaxUrl,
|
||||
data: {
|
||||
page: "include/ajax/events",
|
||||
delete_event: 1,
|
||||
node_id: settings.node_id,
|
||||
id_evento: settings.event.id_evento,
|
||||
filter: []
|
||||
},
|
||||
success: function() {
|
||||
$("#notification_delete_error").show();
|
||||
$("#event_details_window").dialog("close");
|
||||
},
|
||||
error: function(error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
close: function() {
|
||||
//$("#refrcounter").countdown("resume");
|
||||
//$("div.vc-countdown").countdown("resume");
|
||||
$.ajax({
|
||||
method: "post",
|
||||
url: settings.ajaxUrl,
|
||||
data: {
|
||||
page: "operation/dashboard/dashboard",
|
||||
method: "drawWidget",
|
||||
dashboardId: settings.dashboardId,
|
||||
cellId: settings.cellId,
|
||||
widgetId: settings.widgetId,
|
||||
redraw: 1
|
||||
},
|
||||
success: function(dataWidget) {
|
||||
// Widget empty and reload.
|
||||
$("#widget-" + settings.cellId + " .content-widget").empty();
|
||||
$("#widget-" + settings.cellId + " .content-widget").append(
|
||||
dataWidget
|
||||
);
|
||||
},
|
||||
error: function(error) {
|
||||
console.error(error);
|
||||
}
|
||||
});
|
||||
},
|
||||
overlay: {
|
||||
opacity: 0.5,
|
||||
|
@ -476,6 +476,7 @@ function event_change_status(event_ids) {
|
||||
var new_status = $("#estado").val();
|
||||
var meta = $("#hidden-meta").val();
|
||||
var history = $("#hidden-history").val();
|
||||
var node_id = $("#hidden-node_id").val();
|
||||
|
||||
$("#button-status_button").attr("disabled", "disabled");
|
||||
$("#response_loading").show();
|
||||
@ -487,6 +488,7 @@ function event_change_status(event_ids) {
|
||||
event_ids: event_ids,
|
||||
new_status: new_status,
|
||||
meta: meta,
|
||||
node_id: node_id,
|
||||
history: history
|
||||
},
|
||||
type: "POST",
|
||||
@ -519,6 +521,13 @@ function event_change_status(event_ids) {
|
||||
"N/A"
|
||||
);
|
||||
}
|
||||
|
||||
$("#general_status")
|
||||
.find(".general_status")
|
||||
.text(data.status_title);
|
||||
$("#general_status")
|
||||
.find("img")
|
||||
.attr("src", data.status_img);
|
||||
} else {
|
||||
$("#notification_status_error").show();
|
||||
}
|
||||
@ -533,6 +542,7 @@ function event_change_owner() {
|
||||
var new_owner = $("#id_owner").val();
|
||||
var meta = $("#hidden-meta").val();
|
||||
var history = $("#hidden-history").val();
|
||||
var node_id = $("#hidden-node_id").val();
|
||||
|
||||
$("#button-owner_button").attr("disabled", "disabled");
|
||||
$("#response_loading").show();
|
||||
@ -544,6 +554,7 @@ function event_change_owner() {
|
||||
event_id: event_id,
|
||||
new_owner: new_owner,
|
||||
meta: meta,
|
||||
node_id: node_id,
|
||||
history: history
|
||||
},
|
||||
type: "POST",
|
||||
|
@ -502,6 +502,7 @@ class EventsListWidget extends Widget
|
||||
|
||||
\ui_require_css_file('events', 'include/styles/', true);
|
||||
\ui_require_css_file('tables', 'include/styles/', true);
|
||||
\ui_require_javascript_file('pandora_events', 'include/javascript/', true);
|
||||
|
||||
$this->values['groupId'] = explode(',', $this->values['groupId'][0]);
|
||||
$this->values['tagsId'] = explode(',', $this->values['tagsId'][0]);
|
||||
@ -668,6 +669,18 @@ class EventsListWidget extends Widget
|
||||
true
|
||||
);
|
||||
|
||||
$output .= \html_print_input_hidden(
|
||||
'meta',
|
||||
is_metaconsole(),
|
||||
true
|
||||
);
|
||||
|
||||
$output .= \html_print_input_hidden(
|
||||
'delete_confirm_message',
|
||||
__('Are you sure?'),
|
||||
true
|
||||
);
|
||||
|
||||
$table = new \StdClass;
|
||||
$table->class = 'widget_groups_status databox';
|
||||
$table->cellspacing = '1';
|
||||
@ -717,16 +730,20 @@ class EventsListWidget extends Widget
|
||||
|
||||
$settings = json_encode(
|
||||
[
|
||||
'event' => $event,
|
||||
'page' => 'include/ajax/events',
|
||||
'cellId' => $this->cellId,
|
||||
'ajaxUrl' => \ui_get_full_url(
|
||||
'event' => $event,
|
||||
'page' => 'include/ajax/events',
|
||||
'cellId' => $this->cellId,
|
||||
'ajaxUrl' => \ui_get_full_url(
|
||||
'ajax.php',
|
||||
false,
|
||||
false,
|
||||
false
|
||||
),
|
||||
'result' => false,
|
||||
'result' => false,
|
||||
'dashboardId' => $this->dashboardId,
|
||||
'widgetId' => $this->widgetId,
|
||||
'cellId' => $this->cellId,
|
||||
'node_id' => $this->nodeId,
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -875,6 +875,9 @@ select:-internal-list-box {
|
||||
.invisible_important {
|
||||
display: none !important;
|
||||
}
|
||||
.invisible_events {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.visible {
|
||||
display: block;
|
||||
|
Loading…
x
Reference in New Issue
Block a user