Ent 6177 mejoras para el public link de dashboards

This commit is contained in:
Manuel Montes 2020-09-24 16:20:13 +02:00 committed by Daniel Rodriguez
parent 04215ba582
commit f78ae89a99
6 changed files with 112 additions and 71 deletions

View File

@ -3346,7 +3346,8 @@ class NetworkMap
node_radius: node_radius, node_radius: node_radius,
holding_area_dimensions: networkmap_holding_area_dimensions, holding_area_dimensions: networkmap_holding_area_dimensions,
url_background_grid: url_background_grid, url_background_grid: url_background_grid,
font_size: '.$this->mapOptions['font_size'].' font_size: '.$this->mapOptions['font_size'].',
base_url_homedir: "'.ui_get_full_url(false).'"
}); });
init_drag_and_drop(); init_drag_and_drop();
init_minimap(); init_minimap();

View File

@ -159,7 +159,7 @@ function set_center(id) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php" url: window.base_url_homedir + "/ajax.php"
}); });
} }
@ -208,7 +208,7 @@ function delete_link(
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
var found = -1; var found = -1;
@ -266,7 +266,7 @@ function update_fictional_node(id_db_node) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
$("#dialog_node_edit").dialog("close"); $("#dialog_node_edit").dialog("close");
@ -306,7 +306,7 @@ function update_node_name(id_db_node) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
$("#dialog_node_edit").dialog("close"); $("#dialog_node_edit").dialog("close");
@ -352,7 +352,7 @@ function change_shape(id_db_node) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
$("#shape_icon_in_progress").css("display", "none"); $("#shape_icon_in_progress").css("display", "none");
if (data["correct"]) { if (data["correct"]) {
@ -629,7 +629,7 @@ function update_link(row_index, id_link) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
$(".edit_icon_progress_" + row_index).css("display", "none"); $(".edit_icon_progress_" + row_index).css("display", "none");
@ -756,7 +756,7 @@ function move_to_networkmap(node) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
window.location = window.location =
@ -831,7 +831,7 @@ function edit_node(data_node, dblClick) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
$("#node_details-0-1").html( $("#node_details-0-1").html(
'<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' + '<a href="index.php?sec=estado&sec2=operation/agentes/ver_agente&id_agente=' +
@ -920,7 +920,7 @@ function get_interface_data_to_table(node_selected, selected_links) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data.length == 0) { if (data.length == 0) {
$("#interface_information") $("#interface_information")
@ -1008,7 +1008,7 @@ function load_interfaces(selected_links) {
type: "POST", type: "POST",
async: true, async: true,
cache: false, cache: false,
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
$( $(
@ -1175,7 +1175,7 @@ function add_agent_node(agents) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
$("#agent_name").val(""); $("#agent_name").val("");
@ -1374,7 +1374,7 @@ function delete_nodes() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
var found = -1; var found = -1;
@ -1712,7 +1712,7 @@ function update_networkmap() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
d3.select( d3.select(
"#id_node_" + d.id + networkmap_id + " .node_shape" "#id_node_" + d.id + networkmap_id + " .node_shape"
@ -1733,7 +1733,7 @@ function update_networkmap() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
d3.selectAll(".id_module_start_" + d.id_module_start).attr( d3.selectAll(".id_module_start_" + d.id_module_start).attr(
"marker-start", "marker-start",
@ -1756,7 +1756,7 @@ function update_networkmap() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
d3.selectAll(".id_module_end_" + d.id_module_end).attr( d3.selectAll(".id_module_end_" + d.id_module_end).attr(
"marker-end", "marker-end",
@ -2284,7 +2284,7 @@ function add_interface_link(data_parent) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
var parent_name = data_parent.text; var parent_name = data_parent.text;
var child_name = child_data.text; var child_name = child_data.text;
@ -2350,7 +2350,7 @@ function add_interface_link_js() {
}, },
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
var temp_link = {}; var temp_link = {};
@ -2423,7 +2423,7 @@ function refresh_holding_area() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
window.holding_area = data["holding_area"]; window.holding_area = data["holding_area"];
@ -2639,7 +2639,7 @@ function proceed_to_restart_map() {
data: params.join("&"), data: params.join("&"),
dataType: "html", dataType: "html",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
$("#restart_map_form") $("#restart_map_form")
.html(data) .html(data)
@ -2657,7 +2657,7 @@ function reset_map_from_form(new_elements) {
data: data, data: data,
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(d) { success: function(d) {
window.location = window.location =
"index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap=" + "index.php?sec=network&sec2=operation/agentes/pandora_networkmap&tab=view&id_networkmap=" +
@ -2722,7 +2722,7 @@ function set_parent(parent_data) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
var child_index = -1; var child_index = -1;
@ -2838,7 +2838,7 @@ function init_drag_and_drop() {
jQuery.ajax({ jQuery.ajax({
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
data: { data: {
node: JSON.stringify(d), node: JSON.stringify(d),
x: holding_pos_x, x: holding_pos_x,
@ -2879,7 +2879,7 @@ function init_drag_and_drop() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
$("#open_version_dialog").dialog(); $("#open_version_dialog").dialog();
@ -2945,7 +2945,7 @@ function add_fictional_node() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
$("#dialog_node_add").dialog("close"); $("#dialog_node_add").dialog("close");
@ -3066,6 +3066,7 @@ function init_graph(parameter_object) {
window.show_minimap = false; window.show_minimap = false;
window.show_labels = true; window.show_labels = true;
window.context_minimap; window.context_minimap;
window.base_url_homedir = parameter_object.base_url_homedir;
window.holding_area_dimensions = [200, 200]; window.holding_area_dimensions = [200, 200];
if (typeof parameter_object.holding_area_dimensions != "undefined") { if (typeof parameter_object.holding_area_dimensions != "undefined") {
@ -4123,7 +4124,7 @@ function choose_group_for_show_agents() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
$("#agents_filter_group").html(""); $("#agents_filter_group").html("");
@ -4189,7 +4190,7 @@ function get_status_node() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "../../../ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
color_status_node = data["status_agent"]; color_status_node = data["status_agent"];
@ -4211,7 +4212,7 @@ function get_status_module() {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "../../../ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
modules[data["id"]].status_color = data["status_color"]; modules[data["id"]].status_color = data["status_color"];
@ -4309,7 +4310,7 @@ function show_tooltip_content(id) {
data: params.join("&"), data: params.join("&"),
dataType: "json", dataType: "json",
type: "POST", type: "POST",
url: "../../../ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
if (data["correct"]) { if (data["correct"]) {
$("#tooltip").html(data["content"]); $("#tooltip").html(data["content"]);
@ -4329,7 +4330,7 @@ function show_tooltip(id, x, y) {
jQuery.ajax({ jQuery.ajax({
data: params1.join("&"), data: params1.join("&"),
type: "POST", type: "POST",
url: "../../../ajax.php", url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
$("#tooltip").html(data); $("#tooltip").html(data);
$("#tooltip").css("display", ""); $("#tooltip").css("display", "");
@ -4577,17 +4578,6 @@ function move_to_networkmap_widget(networkmap_id, id_cell) {
$("#body_cell").empty(); $("#body_cell").empty();
}); });
var pathname = window.location.pathname;
var path;
if (
pathname == "/pandora_console/enterprise/dashboard/public_dashboard.php"
) {
path = "../../ajax.php";
} else {
path = "ajax.php";
}
params.push("networkmap=true"); params.push("networkmap=true");
params.push("networkmap_id=" + networkmap_id); params.push("networkmap_id=" + networkmap_id);
@ -4596,7 +4586,7 @@ function move_to_networkmap_widget(networkmap_id, id_cell) {
data: params.join("&"), data: params.join("&"),
dataType: "html", dataType: "html",
type: "POST", type: "POST",
url: path, url: window.base_url_homedir + "/ajax.php",
success: function(data) { success: function(data) {
$(".widget_content").each(function(i) { $(".widget_content").each(function(i) {
$("#body_cell").append(data); $("#body_cell").append(data);

View File

@ -152,6 +152,13 @@ class Manager
*/ */
private $refr; private $refr;
/**
* Public Link.
*
* @var boolean
*/
private $publicLink;
/** /**
* Allowed methods to be called using AJAX request. * Allowed methods to be called using AJAX request.
* *
@ -185,6 +192,7 @@ class Manager
// Check ACL. // Check ACL.
$hash = get_parameter('hash', false); $hash = get_parameter('hash', false);
$this->publicLink = false;
// Check user access. // Check user access.
if ($hash === false) { if ($hash === false) {
check_login(); check_login();
@ -201,6 +209,12 @@ class Manager
include 'general/noaccess.php'; include 'general/noaccess.php';
exit; exit;
} }
$this->publicLink = true;
}
if (empty(get_parameter('auth_hash', '')) === false) {
$this->publicLink = true;
} }
// User is admin. // User is admin.
@ -411,7 +425,8 @@ class Manager
$this->widgetId, $this->widgetId,
$width, $width,
$height, $height,
$gridWidth $gridWidth,
$this->publicLink
); );
return $instance; return $instance;
@ -992,6 +1007,7 @@ class Manager
'url' => $this->url, 'url' => $this->url,
'dashboardName' => $this->dashboardFields['name'], 'dashboardName' => $this->dashboardFields['name'],
'hash' => self::generatePublicHash(), 'hash' => self::generatePublicHash(),
'publicLink' => $this->publicLink,
] ]
); );
} else { } else {
@ -1185,6 +1201,7 @@ class Manager
$cellData = $cellClass->get(); $cellData = $cellClass->get();
$instance = ''; $instance = '';
if ((int) $cellData['id_widget'] !== 0 || $this->widgetId !== 0) { if ((int) $cellData['id_widget'] !== 0 || $this->widgetId !== 0) {
$instance = $this->instanceWidget( $instance = $this->instanceWidget(
$newWidth, $newWidth,

View File

@ -104,6 +104,13 @@ class EventsListWidget extends Widget
*/ */
protected $gridWidth; protected $gridWidth;
/**
* Public Link.
*
* @var boolean
*/
protected $publicLink;
/** /**
* Construct. * Construct.
@ -114,6 +121,7 @@ class EventsListWidget extends Widget
* @param integer|null $width New width. * @param integer|null $width New width.
* @param integer|null $height New height. * @param integer|null $height New height.
* @param integer|null $gridWidth Grid width. * @param integer|null $gridWidth Grid width.
* @param boolean|null $publicLink Public Link.
*/ */
public function __construct( public function __construct(
int $cellId, int $cellId,
@ -121,7 +129,8 @@ class EventsListWidget extends Widget
int $widgetId=0, int $widgetId=0,
?int $width=0, ?int $width=0,
?int $height=0, ?int $height=0,
?int $gridWidth=0 ?int $gridWidth=0,
?bool $publicLink=false
) { ) {
global $config; global $config;
@ -146,6 +155,9 @@ class EventsListWidget extends Widget
// Grid Width. // Grid Width.
$this->gridWidth = $gridWidth; $this->gridWidth = $gridWidth;
// Grid Width.
$this->publicLink = $publicLink;
// Options. // Options.
$this->values = $this->decoders($this->getOptionsWidget()); $this->values = $this->decoders($this->getOptionsWidget());
@ -564,13 +576,18 @@ class EventsListWidget extends Widget
] ]
); );
$data[2] = '<a href="javascript:"onclick="dashboardShowEventDialog(\''.base64_encode($settings).'\');">'; if ($this->publicLink === false) {
$data[2] = '<a href="javascript:"onclick="dashboardShowEventDialog(\''.base64_encode($settings).'\');">';
}
$data[2] .= substr(io_safe_output($event['evento']), 0, 150); $data[2] .= substr(io_safe_output($event['evento']), 0, 150);
if (strlen($event['evento']) > 150) { if (strlen($event['evento']) > 150) {
$data[2] .= '...'; $data[2] .= '...';
} }
$data[2] .= '<a>'; if ($this->publicLink === false) {
$data[2] .= '<a>';
}
$data[3] = ui_print_timestamp($event['timestamp'], true); $data[3] = ui_print_timestamp($event['timestamp'], true);

View File

@ -380,12 +380,7 @@ class NetworkMapWidget extends Widget
[ [
'cellId' => $this->cellId, 'cellId' => $this->cellId,
'page' => 'enterprise/include/ajax/map_enterprise.ajax', 'page' => 'enterprise/include/ajax/map_enterprise.ajax',
'url' => ui_get_full_url( 'url' => ui_get_full_url('ajax.php'),
'ajax.php',
false,
false,
false
),
'networkmap_id' => $id_networkmap, 'networkmap_id' => $id_networkmap,
'x_offset' => $x_offset, 'x_offset' => $x_offset,
'y_offset' => $y_offset, 'y_offset' => $y_offset,

View File

@ -130,8 +130,8 @@ if ($config['public_dashboard'] === true) {
$urlRefresh = $url.'&'.http_build_query($queryRefresh); $urlRefresh = $url.'&'.http_build_query($queryRefresh);
} }
$comboRefresh['text'] = '<div class="dashboard-countdown" style="display: inline;"></div>'; $comboRefreshCountdown['text'] = '<div class="dashboard-countdown" style="display: inline;"></div>';
$comboRefresh['text'] .= '<form id="refr-form" method="post" action="'.$urlRefresh.'">'; $comboRefresh['text'] = '<form id="refr-form" method="post" style="margin-top: 13px;" action="'.$urlRefresh.'">';
$comboRefresh['text'] .= __('Refresh').':'; $comboRefresh['text'] .= __('Refresh').':';
$comboRefresh['text'] .= html_print_select( $comboRefresh['text'] .= html_print_select(
\get_refresh_time_array(), \get_refresh_time_array(),
@ -191,7 +191,7 @@ $newWidget['text'] .= '</a>';
if ($config['public_dashboard'] === true) { if ($config['public_dashboard'] === true) {
$buttons = [ $buttons = [
'combo_refresh_one_dashboard' => $comboRefresh, 'combo_refresh_one_dashboard' => $comboRefresh,
// 'slides' => $slides, 'combo_refresh_countdown' => $comboRefreshCountdown,
]; ];
} else if ($config['pure']) { } else if ($config['pure']) {
if (check_acl($config['id_user'], 0, 'RW') === 0) { if (check_acl($config['id_user'], 0, 'RW') === 0) {
@ -200,16 +200,25 @@ if ($config['public_dashboard'] === true) {
'normalscreen' => $normalscreen, 'normalscreen' => $normalscreen,
'combo_refresh_one_dashboard' => $comboRefresh, 'combo_refresh_one_dashboard' => $comboRefresh,
'slides' => $slides, 'slides' => $slides,
'combo_refresh_countdown' => $comboRefreshCountdown,
]; ];
} else { } else {
$buttons = [ if ($publicLink === true) {
'back_to_dashboard_list' => $back_to_dashboard_list, $buttons = [
'save_layout' => $save_layout_dashboard, 'combo_refresh_one_dashboard' => $comboRefresh,
'normalscreen' => $normalscreen, 'combo_refresh_countdown' => $comboRefreshCountdown,
'combo_refresh_one_dashboard' => $comboRefresh, ];
'slides' => $slides, } else {
'options' => $options, $buttons = [
]; 'back_to_dashboard_list' => $back_to_dashboard_list,
'save_layout' => $save_layout_dashboard,
'normalscreen' => $normalscreen,
'combo_refresh_one_dashboard' => $comboRefresh,
'slides' => $slides,
'options' => $options,
'combo_refresh_countdown' => $comboRefreshCountdown,
];
}
} }
} else { } else {
if (check_acl($config['id_user'], 0, 'RW') === 0) { if (check_acl($config['id_user'], 0, 'RW') === 0) {
@ -235,11 +244,23 @@ if ($config['public_dashboard'] === true) {
} }
} }
ui_print_page_header( if ($publicLink === false) {
$dashboardName, ui_print_page_header(
'', $dashboardName,
false, '',
'', false,
false, '',
$buttons false,
); $buttons
);
} else {
$output = '<div id="dashboard-controls">';
foreach ($buttons as $key => $value) {
$output .= '<div>';
$output .= $value['text'];
$output .= '</div>';
}
$output .= '</div>';
echo $output;
}