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,
holding_area_dimensions: networkmap_holding_area_dimensions,
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_minimap();

View File

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

View File

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

View File

@ -104,6 +104,13 @@ class EventsListWidget extends Widget
*/
protected $gridWidth;
/**
* Public Link.
*
* @var boolean
*/
protected $publicLink;
/**
* Construct.
@ -114,6 +121,7 @@ class EventsListWidget extends Widget
* @param integer|null $width New width.
* @param integer|null $height New height.
* @param integer|null $gridWidth Grid width.
* @param boolean|null $publicLink Public Link.
*/
public function __construct(
int $cellId,
@ -121,7 +129,8 @@ class EventsListWidget extends Widget
int $widgetId=0,
?int $width=0,
?int $height=0,
?int $gridWidth=0
?int $gridWidth=0,
?bool $publicLink=false
) {
global $config;
@ -146,6 +155,9 @@ class EventsListWidget extends Widget
// Grid Width.
$this->gridWidth = $gridWidth;
// Grid Width.
$this->publicLink = $publicLink;
// Options.
$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);
if (strlen($event['evento']) > 150) {
$data[2] .= '...';
}
$data[2] .= '<a>';
if ($this->publicLink === false) {
$data[2] .= '<a>';
}
$data[3] = ui_print_timestamp($event['timestamp'], true);

View File

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

View File

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