From ba6a56b9fc63a9710b39af1992493899b7e440e9 Mon Sep 17 00:00:00 2001 From: Luis Date: Mon, 21 Mar 2022 18:15:58 +0100 Subject: [PATCH] WIP: event dashboard responses --- pandora_console/include/ajax/events.php | 8 ++++-- pandora_console/include/functions_events.php | 2 ++ .../include/javascript/pandora_dashboards.js | 25 ++++++++++++++++++- .../include/javascript/pandora_events.js | 9 ++++++- .../lib/Dashboard/Widgets/events_list.php | 13 ++++++---- 5 files changed, 48 insertions(+), 9 deletions(-) diff --git a/pandora_console/include/ajax/events.php b/pandora_console/include/ajax/events.php index 8446748cd4..988c458a1c 100644 --- a/pandora_console/include/ajax/events.php +++ b/pandora_console/include/ajax/events.php @@ -1269,10 +1269,14 @@ if ($change_status) { ); 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', diff --git a/pandora_console/include/functions_events.php b/pandora_console/include/functions_events.php index 26f41a2589..1861134e3f 100644 --- a/pandora_console/include/functions_events.php +++ b/pandora_console/include/functions_events.php @@ -5008,6 +5008,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); diff --git a/pandora_console/include/javascript/pandora_dashboards.js b/pandora_console/include/javascript/pandora_dashboards.js index aacf542cbb..104073ef84 100644 --- a/pandora_console/include/javascript/pandora_dashboards.js +++ b/pandora_console/include/javascript/pandora_dashboards.js @@ -651,7 +651,7 @@ function initialiceLayout(data) { url: data.url, data: { page: data.page, - method: "drawWidget", + method: "drawCell", dashboardId: data.dashboardId, cellId: cellId, newWidth: newWidth, @@ -1329,6 +1329,29 @@ function dashboardShowEventDialog(settings) { close: function() { //$("#refrcounter").countdown("resume"); //$("div.vc-countdown").countdown("resume"); + debugger; + $.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, diff --git a/pandora_console/include/javascript/pandora_events.js b/pandora_console/include/javascript/pandora_events.js index 357e22318c..6826eb3eed 100644 --- a/pandora_console/include/javascript/pandora_events.js +++ b/pandora_console/include/javascript/pandora_events.js @@ -504,7 +504,7 @@ function event_change_status(event_ids) { if ($("#notification_status_error").length) { $("#notification_status_error").hide(); } - + debugger; if (data.status == "status_ok") { if (typeof dt_events !== "undefined") { dt_events.draw(false); @@ -519,6 +519,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(); } diff --git a/pandora_console/include/lib/Dashboard/Widgets/events_list.php b/pandora_console/include/lib/Dashboard/Widgets/events_list.php index ebd4dfb09f..c3b01a177e 100644 --- a/pandora_console/include/lib/Dashboard/Widgets/events_list.php +++ b/pandora_console/include/lib/Dashboard/Widgets/events_list.php @@ -718,16 +718,19 @@ 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, ] );