Merge branch 'ent-5408-consola-visual-nueva-bugs' into 'develop'

Module graph paint direct

See merge request artica/pandorafms!3044
This commit is contained in:
Daniel Rodriguez 2020-02-20 17:10:32 +01:00
commit 433ee4b43b
25 changed files with 704 additions and 477 deletions

View File

@ -213,85 +213,109 @@ if ($config['menu_type'] == 'classic') {
$select[0]['autorefresh_white_list'] $select[0]['autorefresh_white_list']
); );
if ($autorefresh_list !== null if ($config['legacy_vc']
&& array_search($_GET['sec2'], $autorefresh_list) !== false || ($_GET['sec2'] !== 'operation/visual_console/render_view')
|| (($_GET['sec2'] !== 'operation/visual_console/render_view')
&& $config['legacy_vc'])
) { ) {
$do_refresh = true; if ($autorefresh_list !== null
if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') { && array_search($_GET['sec2'], $autorefresh_list) !== false
if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) { ) {
$do_refresh = false; $do_refresh = true;
if ($_GET['sec2'] == 'operation/agentes/pandora_networkmap') {
if ((!isset($_GET['tab'])) || ($_GET['tab'] != 'view')) {
$do_refresh = false;
}
} }
}
if ($do_refresh) { if ($do_refresh) {
$autorefresh_img = html_print_image(
'images/header_refresh_gray.png',
true,
[
'class' => 'bot',
'alt' => 'lightning',
'title' => __('Configure autorefresh'),
]
);
if ((isset($select[0]['time_autorefresh']) === true)
&& $select[0]['time_autorefresh'] !== 0
&& $config['refr'] === null
) {
$config['refr'] = $select[0]['time_autorefresh'];
$autorefresh_txt .= ' (<span id="refrcounter">';
$autorefresh_txt .= date(
'i:s',
$config['refr']
);
$autorefresh_txt .= '</span>)';
} else if ($_GET['refr']) {
$autorefresh_txt .= ' (<span id="refrcounter">';
$autorefresh_txt .= date('i:s', $config['refr']);
$autorefresh_txt .= '</span>)';
}
$ignored_params['refr'] = '';
$values = get_refresh_time_array();
$autorefresh_additional = '<span id="combo_refr" style="display: none;">';
$autorefresh_additional .= html_print_select(
$values,
'ref',
'',
'',
__('Select'),
'0',
true,
false,
false
);
$autorefresh_additional .= '</span>';
unset($values);
if ($home_page != '') {
$autorefresh_link_open_img = '<a class="white autorefresh" href="index.php?refr=">';
} else {
$autorefresh_link_open_img = '<a class="white autorefresh" href="'.ui_get_url_refresh($ignored_params).'">';
}
if ($_GET['refr']
|| ((isset($select[0]['time_autorefresh']) === true)
&& $select[0]['time_autorefresh'] !== 0)
) {
if ($home_page != '') {
$autorefresh_link_open_txt = '<a class="autorefresh autorefresh_txt" href="index.php?refr=">';
} else {
$autorefresh_link_open_txt = '<a class="autorefresh autorefresh_txt" href="'.ui_get_url_refresh($ignored_params).'">';
}
} else {
$autorefresh_link_open_txt = '<a>';
}
$autorefresh_link_close = '</a>';
$display_counter = 'display:block';
} else {
$autorefresh_img = html_print_image('images/header_refresh_disabled_gray.png', true, ['class' => 'bot autorefresh_disabled', 'alt' => 'lightning', 'title' => __('Disabled autorefresh')]);
$ignored_params['refr'] = false;
$autorefresh_link_open_img = '';
$autorefresh_link_open_txt = '';
$autorefresh_link_close = '';
$display_counter = 'display:none';
}
} else {
$autorefresh_img = html_print_image( $autorefresh_img = html_print_image(
'images/header_refresh_gray.png', 'images/header_refresh_disabled_gray.png',
true, true,
[ [
'class' => 'bot', 'class' => 'bot autorefresh_disabled',
'alt' => 'lightning', 'alt' => 'lightning',
'title' => __('Configure autorefresh'), 'title' => __('Disabled autorefresh'),
] ]
); );
if ((isset($select[0]['time_autorefresh']) === true)
&& $select[0]['time_autorefresh'] !== 0
&& $config['refr'] === null
) {
$config['refr'] = $select[0]['time_autorefresh'];
$autorefresh_txt .= ' (<span id="refrcounter">';
$autorefresh_txt .= date(
'i:s',
$config['refr']
);
$autorefresh_txt .= '</span>)';
} else if ($_GET['refr']) {
$autorefresh_txt .= ' (<span id="refrcounter">';
$autorefresh_txt .= date('i:s', $config['refr']);
$autorefresh_txt .= '</span>)';
}
$ignored_params['refr'] = '';
$values = get_refresh_time_array();
$autorefresh_additional = '<span id="combo_refr" style="display: none;">';
$autorefresh_additional .= html_print_select(
$values,
'ref',
'',
'',
__('Select'),
'0',
true,
false,
false
);
$autorefresh_additional .= '</span>';
unset($values);
if ($home_page != '') {
$autorefresh_link_open_img = '<a class="white autorefresh" href="index.php?refr=">';
} else {
$autorefresh_link_open_img = '<a class="white autorefresh" href="'.ui_get_url_refresh($ignored_params).'">';
}
if ($_GET['refr']
|| ((isset($select[0]['time_autorefresh']) === true)
&& $select[0]['time_autorefresh'] !== 0)
) {
if ($home_page != '') {
$autorefresh_link_open_txt = '<a class="autorefresh autorefresh_txt" href="index.php?refr=">';
} else {
$autorefresh_link_open_txt = '<a class="autorefresh autorefresh_txt" href="'.ui_get_url_refresh($ignored_params).'">';
}
} else {
$autorefresh_link_open_txt = '<a>';
}
$autorefresh_link_close = '</a>';
$display_counter = 'display:block';
} else {
$autorefresh_img = html_print_image('images/header_refresh_disabled_gray.png', true, ['class' => 'bot autorefresh_disabled', 'alt' => 'lightning', 'title' => __('Disabled autorefresh')]);
$ignored_params['refr'] = false; $ignored_params['refr'] = false;
$autorefresh_link_open_img = ''; $autorefresh_link_open_img = '';
@ -300,39 +324,21 @@ if ($config['menu_type'] == 'classic') {
$display_counter = 'display:none'; $display_counter = 'display:none';
} }
} else {
$autorefresh_img = html_print_image(
'images/header_refresh_disabled_gray.png',
true,
[
'class' => 'bot autorefresh_disabled',
'alt' => 'lightning',
'title' => __('Disabled autorefresh'),
]
);
$ignored_params['refr'] = false; $header_autorefresh = '<div id="header_autorefresh">';
$header_autorefresh .= $autorefresh_link_open_img;
$header_autorefresh .= $autorefresh_img;
$header_autorefresh .= $autorefresh_link_close;
$header_autorefresh .= '</div>';
$autorefresh_link_open_img = ''; $header_autorefresh_counter = '<div id="header_autorefresh_counter" style="'.$display_counter.'">';
$autorefresh_link_open_txt = ''; $header_autorefresh_counter .= $autorefresh_link_open_txt;
$autorefresh_link_close = ''; $header_autorefresh_counter .= $autorefresh_txt;
$header_autorefresh_counter .= $autorefresh_link_close;
$display_counter = 'display:none'; $header_autorefresh_counter .= $autorefresh_additional;
$header_autorefresh_counter .= '</div>';
} }
$header_autorefresh = '<div id="header_autorefresh">';
$header_autorefresh .= $autorefresh_link_open_img;
$header_autorefresh .= $autorefresh_img;
$header_autorefresh .= $autorefresh_link_close;
$header_autorefresh .= '</div>';
$header_autorefresh_counter = '<div id="header_autorefresh_counter" style="'.$display_counter.'">';
$header_autorefresh_counter .= $autorefresh_link_open_txt;
$header_autorefresh_counter .= $autorefresh_txt;
$header_autorefresh_counter .= $autorefresh_link_close;
$header_autorefresh_counter .= $autorefresh_additional;
$header_autorefresh_counter .= '</div>';
// Button for feedback pandora. // Button for feedback pandora.
if (enterprise_installed()) { if (enterprise_installed()) {
$header_feedback = '<div id="feedback-icon-header">'; $header_feedback = '<div id="feedback-icon-header">';

View File

@ -783,10 +783,13 @@ $buttons['wizard'] = [
'active' => false, 'active' => false,
'text' => '<a href="'.$url_base.$action.'&tab=wizard&id_visual_console='.$idVisualConsole.'">'.html_print_image('images/wand.png', true, ['title' => __('Wizard')]).'</a>', 'text' => '<a href="'.$url_base.$action.'&tab=wizard&id_visual_console='.$idVisualConsole.'">'.html_print_image('images/wand.png', true, ['title' => __('Wizard')]).'</a>',
]; ];
$buttons['editor'] = [ if ($config['legacy_vc']) {
'active' => false, $buttons['editor'] = [
'text' => '<a href="'.$url_base.$action.'&tab=editor&id_visual_console='.$idVisualConsole.'">'.html_print_image('images/builder.png', true, ['title' => __('Builder')]).'</a>', 'active' => false,
]; 'text' => '<a href="'.$url_base.$action.'&tab=editor&id_visual_console='.$idVisualConsole.'">'.html_print_image('images/builder.png', true, ['title' => __('Builder')]).'</a>',
];
}
$buttons['view'] = [ $buttons['view'] = [
'active' => false, 'active' => false,
'text' => '<a href="'.$url_view.'">'.html_print_image('images/operation.png', true, ['title' => __('View')]).'</a>', 'text' => '<a href="'.$url_view.'">'.html_print_image('images/operation.png', true, ['title' => __('View')]).'</a>',

View File

@ -3714,6 +3714,12 @@ function html_print_input($data, $wrapper='div', $input_only=false)
$params['value'] = $agent_name; $params['value'] = $agent_name;
$params['javascript_is_function_select'] = true; $params['javascript_is_function_select'] = true;
if (isset($data['get_only_string_modules']) === true
&& $data['get_only_string_modules'] === true
) {
$params['get_only_string_modules'] = $data['get_only_string_modules'];
}
if (isset($data['module_input']) === true if (isset($data['module_input']) === true
&& $data['module_input'] === true && $data['module_input'] === true
) { ) {
@ -3755,12 +3761,18 @@ function html_print_input($data, $wrapper='div', $input_only=false)
0 => __('Select an Agent first'), 0 => __('Select an Agent first'),
]; ];
} else { } else {
$string_filter .= '';
if ($data['get_only_string_modules'] === true) {
$string_filter = 'AND id_tipo_modulo IN (17,23,3,10,33,36)';
}
$sql = sprintf( $sql = sprintf(
'SELECT id_agente_modulo, nombre 'SELECT id_agente_modulo, nombre
FROM tagente_modulo FROM tagente_modulo
WHERE id_agente = %d WHERE id_agente = %d
AND delete_pending = 0', AND delete_pending = 0 %s',
$data['agent_id'] $data['agent_id'],
$string_filter
); );
if (is_metaconsole() === true) { if (is_metaconsole() === true) {

View File

@ -1,10 +1,11 @@
/* globals d3 */
(function() { (function() {
// Chart design based on the recommendations of Stephen Few. Implementation
// based on the work of Clint Ivy, Jamie Love, and Jason Davies.
// http://projects.instantcognition.com/protovis/bulletchart/
// Chart design based on the recommendations of Stephen Few. Implementation d3.bullet = function() {
// based on the work of Clint Ivy, Jamie Love, and Jason Davies. var orient = "right", // TODO top & bottom
// http://projects.instantcognition.com/protovis/bulletchart/
d3.bullet = function() {
var orient = "right", // TODO top & bottom
reverse = false, reverse = false,
duration = 0, duration = 0,
ranges = bulletRanges, ranges = bulletRanges,
@ -14,228 +15,259 @@ d3.bullet = function() {
height = 30, height = 30,
tickFormat = null; tickFormat = null;
// For each small multiple… // For each small multiple…
function bullet(g) { function bullet(g) {
g.each(function(d, i) { g.each(function(d, i) {
var rangez = ranges.call(this, d, i).slice().sort(d3.descending), var rangez = ranges
markerz = markers.call(this, d, i).slice().sort(d3.descending), .call(this, d, i)
measurez = measures.call(this, d, i).slice().sort(d3.descending), .slice()
.sort(d3.descending),
markerz = markers
.call(this, d, i)
.slice()
.sort(d3.descending),
measurez = measures
.call(this, d, i)
.slice()
.sort(d3.descending),
g = d3.select(this); g = d3.select(this);
// Compute the new x-scale. // Compute the new x-scale.
var x1 = d3.scale.linear() var x1 = d3.scale
.linear()
.domain([0, Math.max(rangez[0], markerz[0], measurez[0])]) .domain([0, Math.max(rangez[0], markerz[0], measurez[0])])
.range(reverse ? [width, 0] : [0, width-160]); .range(reverse ? [width, 0] : [0, width - 160]);
// Retrieve the old x-scale, if this is an update. // Retrieve the old x-scale, if this is an update.
var x0 = this.__chart__ || d3.scale.linear() var x0 =
.domain([0, Infinity]) this.__chart__ ||
.range(x1.range()); d3.scale
.linear()
.domain([0, Infinity])
.range(x1.range());
// Stash the new scale. // Stash the new scale.
this.__chart__ = x1; this.__chart__ = x1;
// Derive width-scales from the x-scales. // Derive width-scales from the x-scales.
var w0 = bulletWidth(x0), var w0 = bulletWidth(x0),
w1 = bulletWidth(x1); w1 = bulletWidth(x1);
// Update the range rects. // Update the range rects.
var range = g.selectAll("rect.range") var range = g.selectAll("rect.range").data(rangez);
.data(rangez);
range.enter().append("rect") range
.attr("class", function(d, i) { return "range s" + i; }) .enter()
.append("rect")
.attr("class", function(d, i) {
return "range s" + i;
})
.attr("width", w0) .attr("width", w0)
.attr("height", height) .attr("height", height)
.attr("x", reverse ? x0 : 0) .attr("x", reverse ? x0 : 0)
.transition() .transition()
.duration(duration) .duration(duration)
.attr("width", w1) .attr("width", w1)
.attr("x", reverse ? x1 : 0); .attr("x", reverse ? x1 : 0);
range.transition() range
.transition()
.duration(duration) .duration(duration)
.attr("x", reverse ? x1 : 0) .attr("x", reverse ? x1 : 0)
.attr("width", w1) .attr("width", w1)
.attr("height", height); .attr("height", height);
// Update the measure rects. // Update the measure rects.
var measure = g.selectAll("rect.measure") var measure = g.selectAll("rect.measure").data(measurez);
.data(measurez);
measure.enter().append("rect") measure
.attr("class", function(d, i) { return "measure s" + i; }) .enter()
.append("rect")
.attr("class", function(d, i) {
return "measure s" + i;
})
.attr("width", w0) .attr("width", w0)
.attr("height", height / 3) .attr("height", height / 3)
.attr("x", reverse ? x0 : 0) .attr("x", reverse ? x0 : 0)
.attr("y", height / 3) .attr("y", height / 3)
.transition() .transition()
.duration(duration) .duration(duration)
.attr("width", w1) .attr("width", w1)
.attr("x", reverse ? x1 : 0); .attr("x", reverse ? x1 : 0);
measure.transition() measure
.transition()
.duration(duration) .duration(duration)
.attr("width", w1) .attr("width", w1)
.attr("height", height / 3) .attr("height", height / 3)
.attr("x", reverse ? x1 : 0) .attr("x", reverse ? x1 : 0)
.attr("y", height / 3); .attr("y", height / 3);
// Update the marker lines. // Update the marker lines.
var marker = g.selectAll("line.marker") var marker = g.selectAll("line.marker").data(markerz);
.data(markerz);
marker.enter().append("line") marker
.attr("class", function(d, i) { return "marker s" + i; }) .enter()
.append("line")
.attr("class", function(d, i) {
return "marker s" + i;
})
.attr("x1", x0) .attr("x1", x0)
.attr("x2", x0) .attr("x2", x0)
.attr("y1", height / 6) .attr("y1", height / 6)
.attr("y2", height * 5 / 6) .attr("y2", (height * 5) / 6)
.transition() .transition()
.duration(duration) .duration(duration)
.attr("x1", x1) .attr("x1", x1)
.attr("x2", x1); .attr("x2", x1);
marker.transition() marker
.transition()
.duration(duration) .duration(duration)
.attr("x1", x1) .attr("x1", x1)
.attr("x2", x1) .attr("x2", x1)
.attr("y1", height / 6) .attr("y1", height / 6)
.attr("y2", height * 5 / 6); .attr("y2", (height * 5) / 6);
// Compute the tick format. // Compute the tick format.
var format = tickFormat || x1.tickFormat(8); var format = tickFormat || x1.tickFormat(8);
// Update the tick groups. // Update the tick groups.
var tick = g.selectAll("g.tick") var tick = g.selectAll("g.tick").data(x1.ticks(8), function(d) {
.data(x1.ticks(8), function(d) { return this.textContent || format(d);
return this.textContent || format(d); });
});
// Initialize the ticks with the old scale, x0. // Initialize the ticks with the old scale, x0.
var tickEnter = tick.enter().append("g") var tickEnter = tick
.enter()
.append("g")
.attr("class", "tick") .attr("class", "tick")
.attr("transform", bulletTranslate(x0)) .attr("transform", bulletTranslate(x0))
.style("opacity", 1e-6); .style("opacity", 1e-6);
tickEnter.append("line") tickEnter
.append("line")
.attr("y1", height) .attr("y1", height)
.attr("y2", height * 7 / 6); .attr("y2", (height * 7) / 6);
tickEnter.append("text") tickEnter
.append("text")
.attr("text-anchor", "middle") .attr("text-anchor", "middle")
.attr("dy", "1em") .attr("dy", "1em")
.attr("y", height * 7 / 6) .attr("y", (height * 7) / 6)
.text(format); .text(format);
// Transition the entering ticks to the new scale, x1. // Transition the entering ticks to the new scale, x1.
tickEnter.transition() tickEnter
.transition()
.duration(duration) .duration(duration)
.attr("transform", bulletTranslate(x1)) .attr("transform", bulletTranslate(x1))
.style("opacity", 1); .style("opacity", 1);
// Transition the updating ticks to the new scale, x1. // Transition the updating ticks to the new scale, x1.
var tickUpdate = tick.transition() var tickUpdate = tick
.transition()
.duration(duration) .duration(duration)
.attr("transform", bulletTranslate(x1)) .attr("transform", bulletTranslate(x1))
.style("opacity", 1); .style("opacity", 1);
tickUpdate.select("line") tickUpdate
.select("line")
.attr("y1", height) .attr("y1", height)
.attr("y2", height + 7); .attr("y2", height + 7);
tickUpdate.select("text") tickUpdate.select("text").attr("y", height + 7);
.attr("y", height + 7);
// Transition the exiting ticks to the new scale, x1. // Transition the exiting ticks to the new scale, x1.
tick.exit().transition() tick
.exit()
.transition()
.duration(duration) .duration(duration)
.attr("transform", bulletTranslate(x1)) .attr("transform", bulletTranslate(x1))
.style("opacity", 1e-6) .style("opacity", 1e-6)
.remove(); .remove();
}); });
d3.timer.flush(); d3.timer.flush();
}
// left, right, top, bottom
bullet.orient = function(x) {
if (!arguments.length) return orient;
orient = x;
reverse = orient == "right" || orient == "bottom";
return bullet;
};
// ranges (bad, satisfactory, good)
bullet.ranges = function(x) {
if (!arguments.length) return ranges;
ranges = x;
return bullet;
};
// markers (previous, goal)
bullet.markers = function(x) {
if (!arguments.length) return markers;
markers = x;
return bullet;
};
// measures (actual, forecast)
bullet.measures = function(x) {
if (!arguments.length) return measures;
measures = x;
return bullet;
};
bullet.width = function(x) {
if (!arguments.length) return width;
width = x;
return bullet;
};
bullet.height = function(x) {
if (!arguments.length) return height;
height = x;
return bullet;
};
bullet.tickFormat = function(x) {
if (!arguments.length) return tickFormat;
tickFormat = x;
return bullet;
};
bullet.duration = function(x) {
if (!arguments.length) return duration;
duration = x;
return bullet;
};
return bullet;
};
function bulletRanges(d) {
return d.ranges;
} }
// left, right, top, bottom function bulletMarkers(d) {
bullet.orient = function(x) { return d.markers;
if (!arguments.length) return orient; }
orient = x;
reverse = orient == "right" || orient == "bottom";
return bullet;
};
// ranges (bad, satisfactory, good) function bulletMeasures(d) {
bullet.ranges = function(x) { return d.measures;
if (!arguments.length) return ranges; }
ranges = x;
return bullet;
};
// markers (previous, goal) function bulletTranslate(x) {
bullet.markers = function(x) { return function(d) {
if (!arguments.length) return markers; return "translate(" + x(d) + ",0)";
markers = x; };
return bullet; }
};
// measures (actual, forecast)
bullet.measures = function(x) {
if (!arguments.length) return measures;
measures = x;
return bullet;
};
bullet.width = function(x) {
if (!arguments.length) return width;
width = x;
return bullet;
};
bullet.height = function(x) {
if (!arguments.length) return height;
height = x;
return bullet;
};
bullet.tickFormat = function(x) {
if (!arguments.length) return tickFormat;
tickFormat = x;
return bullet;
};
bullet.duration = function(x) {
if (!arguments.length) return duration;
duration = x;
return bullet;
};
return bullet;
};
function bulletRanges(d) {
return d.ranges;
}
function bulletMarkers(d) {
return d.markers;
}
function bulletMeasures(d) {
return d.measures;
}
function bulletTranslate(x) {
return function(d) {
return "translate(" + x(d) + ",0)";
};
}
function bulletWidth(x) {
var x0 = x(0);
return function(d) {
return Math.abs(x(d) - x0);
};
}
function bulletWidth(x) {
var x0 = x(0);
return function(d) {
return Math.abs(x(d) - x0);
};
}
})(); })();

View File

@ -175,12 +175,15 @@ function d3_bullet_chart(
$output = ''; $output = '';
$output .= include_javascript_d3(true); $output .= include_javascript_d3(true);
$output .= '<script language="javascript" type="text/javascript">';
$output .= file_get_contents($homeurl.'include/graphs/bullet.js');
$output .= '</script>';
$id_bullet = uniqid(); $id_bullet = uniqid();
$font = array_shift(explode('.', array_pop(explode('/', $font)))); $font = array_shift(explode('.', array_pop(explode('/', $font))));
$output .= '<div id="bullet_graph_'.$id_bullet.'" class="bullet" style="overflow: hidden; width: '.$width.'px; margin-left: auto; margin-right: auto;"></div> $output .= '<div id="bullet_graph_'.$id_bullet.'" class="bullet" style="overflow: hidden; width: '.$width.'px; margin-left: auto; margin-right: auto;"></div>
<style> <style>
.bullet_graph { .bullet_graph {
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
margin: auto; margin: auto;
@ -204,13 +207,12 @@ function d3_bullet_chart(
.bullet g text { font-size:'.$font_size.'pt;} .bullet g text { font-size:'.$font_size.'pt;}
</style> </style>
<script src="'.$homeurl.'include/graphs/bullet.js"></script>
<script language="javascript" type="text/javascript"> <script language="javascript" type="text/javascript">
var margin = {top: 5, right: 40, bottom: 20, left: 120}; var margin = {top: 5, right: 40, bottom: 20, left: 120};
width = ('.$width.'+10); var width = ('.$width.'+10);
height = '.$height.'- margin.top - margin.bottom; var height = '.$height.'- margin.top - margin.bottom;
var chart = d3.bullet() var chart = d3.bullet()
.width(width) .width(width)
@ -240,7 +242,6 @@ function d3_bullet_chart(
$output .= 'var data = ['.implode(',', $temp).']; $output .= 'var data = ['.implode(',', $temp).'];
'; ';
$output .= ' $output .= '
var svg = d3.select("#bullet_graph_'.$id_bullet.'").selectAll("svg") var svg = d3.select("#bullet_graph_'.$id_bullet.'").selectAll("svg")
.data(data) .data(data)
.enter().append("svg") .enter().append("svg")
@ -251,7 +252,6 @@ function d3_bullet_chart(
.attr("transform", "translate(" + (margin.left) + "," + margin.top + ")") .attr("transform", "translate(" + (margin.left) + "," + margin.top + ")")
.call(chart); .call(chart);
var title = svg.append("g") var title = svg.append("g")
.style("text-anchor", "end") .style("text-anchor", "end")
.attr("transform", "translate(-10, 15)"); .attr("transform", "translate(-10, 15)");
@ -261,22 +261,20 @@ function d3_bullet_chart(
.text(function(d) { return d.title; }); .text(function(d) { return d.title; });
title.append("text") title.append("text")
.attr("class", "subtitle") .attr("class", "subtitle")
.attr("dy", "1em") .attr("dy", "1em")
.text(function(d) { return d.subtitle; }); .text(function(d) { return d.subtitle; });
$(".tick>text").each(function() { $(".tick>text").each(function() {
var label = $(this).text().replace(/,/g,"");
label = $(this).text().replace(/,/g,"");
label = parseFloat(label); label = parseFloat(label);
text = label.toLocaleString(); var text = label.toLocaleString();
if ( label >= 1000000) if ( label >= 1000000)
text = text.substring(0,3) + "M"; text = text.substring(0,3) + "M";
else if (label >= 100000) else if (label >= 100000)
text = text.substring(0,3) + "K"; text = text.substring(0,3) + "K";
else if (label >= 1000) else if (label >= 1000)
text = text.substring(0,2) + "K"; text = text.substring(0,2) + "K";
$(this).text(text); $(this).text(text);
}); });
</script>'; </script>';

View File

@ -45,6 +45,21 @@ function createVisualConsole(
visualConsoleId, visualConsoleId,
function(error, data) { function(error, data) {
if (error) { if (error) {
//Remove spinner change VC.
document
.getElementById("visual-console-container")
.classList.remove("is-updating");
var div = document
.getElementById("visual-console-container")
.querySelector(".div-visual-console-spinner");
if (div !== null) {
var parent = div.parentElement;
if (parent !== null) {
parent.removeChild(div);
}
}
console.log( console.log(
"[ERROR]", "[ERROR]",
"[VISUAL-CONSOLE-CLIENT]", "[VISUAL-CONSOLE-CLIENT]",

View File

@ -75,39 +75,26 @@ abstract class CachedModel extends Model
public static function fromDB(array $filter): Model public static function fromDB(array $filter): Model
{ {
global $config; global $config;
$save_cache = false;
// TODO: Remove references to the VC items. This class should be usable with any resource.
if ($filter['cache_expiration'] > 0) { if ($filter['cache_expiration'] > 0) {
// Obtain the item's data from cache. $data = static::fetchCachedData($filter);
$cachedData = static::fetchCachedData($filter); $save_cache = true;
if ($cachedData === null) { }
$userId = (static::$indexCacheByUser === true) ? $config['id_user'] : null;
// Delete expired data cache. if (isset($data) === false) {
static::clearCachedData(
[
'vc_item_id' => $filter['id'],
'vc_id' => $filter['id_layout'],
'user_id' => $userId,
]
);
// Obtain the item's data from the database.
$data = static::fetchDataFromDB($filter);
// Save the item's data in cache.
static::saveCachedData(
[
'vc_item_id' => $filter['id'],
'vc_id' => $filter['id_layout'],
'user_id' => $userId,
'expiration' => $filter['cache_expiration'],
],
$data
);
} else {
$data = $cachedData;
}
} else {
$data = static::fetchDataFromDB($filter); $data = static::fetchDataFromDB($filter);
} else {
// Retrieved from cache.
$save_cache = false;
}
if ($save_cache === true) {
// Rebuild cache.
if (static::saveCachedData($filter, $data) !== true) {
throw new \Exception(
$config['dbconnection']->error
);
}
} }
return static::fromArray($data); return static::fromArray($data);

View File

@ -413,7 +413,7 @@ final class Container extends Model
try { try {
array_push($items, $class::fromDB($data)); array_push($items, $class::fromDB($data));
} catch (\Throwable $e) { } catch (\Throwable $e) {
// TODO: Log this? error_log('VC[Container]: '.$e->getMessage());
} }
} }

View File

@ -41,6 +41,13 @@ class Item extends CachedModel
*/ */
protected static $useHtmlOutput = false; protected static $useHtmlOutput = false;
/**
* Enable the cache index by user id.
*
* @var boolean
*/
protected static $indexCacheByUser = true;
/** /**
* Validate the received data structure to ensure if we can extract the * Validate the received data structure to ensure if we can extract the
@ -815,6 +822,14 @@ class Item extends CachedModel
); );
if ($data === false) { if ($data === false) {
// Invalid entry, clean it.
self::clearCachedData(
[
'vc_id' => $filter['vc_id'],
'vc_item_id' => $filter['vc_item_id'],
'user_id' => $filter['user_id'],
]
);
return null; return null;
} }
@ -835,14 +850,19 @@ class Item extends CachedModel
*/ */
protected static function saveCachedData(array $filter, array $data): bool protected static function saveCachedData(array $filter, array $data): bool
{ {
global $config;
if (static::$indexCacheByUser === true) {
$filter['user_id'] = $config['id_user'];
}
return \db_process_sql_insert( return \db_process_sql_insert(
'tvisual_console_elements_cache', 'tvisual_console_elements_cache',
[ [
'vc_id' => $filter['vc_id'], 'vc_id' => $data['id_layout'],
'vc_item_id' => $filter['vc_item_id'], 'vc_item_id' => $data['id'],
'user_id' => $filter['user_id'], 'user_id' => $filter['user_id'],
'data' => base64_encode(json_encode($data)), 'data' => base64_encode(json_encode($data)),
'expiration' => $filter['expiration'], 'expiration' => $data['cache_expiration'],
] ]
) > 0; ) > 0;
} }
@ -1052,6 +1072,19 @@ class Item extends CachedModel
// The layout can be from another node. // The layout can be from another node.
$linkedLayoutNodeId = $linkedVisualConsole['linkedLayoutNodeId']; $linkedLayoutNodeId = $linkedVisualConsole['linkedLayoutNodeId'];
// Check ACL.
$visualConsole = VC::fromDB(['id' => $vcId]);
$visualConsoleData = $visualConsole->toArray();
$vcGroupId = $visualConsoleData['groupId'];
$aclRead = \check_acl($config['id_user'], $vcGroupId, 'VR');
// To build the link to another visual console
// you must have read permissions of the visual console
// with which it is linked.
if ($aclRead === 0) {
return null;
}
if (empty($linkedLayoutNodeId) === true && \is_metaconsole()) { if (empty($linkedLayoutNodeId) === true && \is_metaconsole()) {
/* /*
* A Visual Console from this console. * A Visual Console from this console.
@ -1885,16 +1918,18 @@ class Item extends CachedModel
], ],
]; ];
// Link enabled. if ($values['type'] !== LABEL) {
$inputs[] = [ // Link enabled.
'label' => __('Link enabled'), $inputs[] = [
'arguments' => [ 'label' => __('Link enabled'),
'name' => 'isLinkEnabled', 'arguments' => [
'id' => 'isLinkEnabled', 'name' => 'isLinkEnabled',
'type' => 'switch', 'id' => 'isLinkEnabled',
'value' => $values['isLinkEnabled'], 'type' => 'switch',
], 'value' => $values['isLinkEnabled'],
]; ],
];
}
// Show on top. // Show on top.
$inputs[] = [ $inputs[] = [
@ -2232,7 +2267,19 @@ class Item extends CachedModel
{ {
// LinkConsoleInputGroup. // LinkConsoleInputGroup.
$fields = self::getAllVisualConsole($values['vCId']); $fields = self::getAllVisualConsole($values['vCId']);
\array_unshift($fields, ['id' => 0, 'name' => __('None')]);
if ($fields === false) {
$fields = [];
} else {
$fields = \array_reduce(
$fields,
function ($carry, $item) {
$carry[$item['id']] = $item['name'];
return $carry;
},
[]
);
}
$getAllVisualConsoleValue = $values['linkedLayoutId']; $getAllVisualConsoleValue = $values['linkedLayoutId'];
if (\is_metaconsole() === true) { if (\is_metaconsole() === true) {
@ -2246,12 +2293,14 @@ class Item extends CachedModel
$inputs[] = [ $inputs[] = [
'label' => __('Linked visual console'), 'label' => __('Linked visual console'),
'arguments' => [ 'arguments' => [
'type' => 'select', 'type' => 'select',
'fields' => $fields, 'fields' => $fields,
'name' => 'getAllVisualConsole', 'name' => 'getAllVisualConsole',
'selected' => $getAllVisualConsoleValue, 'selected' => $getAllVisualConsoleValue,
'script' => 'linkedVisualConsoleChange()', 'script' => 'linkedVisualConsoleChange()',
'return' => true, 'return' => true,
'nothing' => __('None'),
'nothing_value' => 0,
], ],
]; ];

View File

@ -340,57 +340,67 @@ final class BarsGraph extends Item
$height = (int) $data['height']; $height = (int) $data['height'];
} }
if ($typeGraph === 'horizontal') { if (empty($moduleData) === true) {
$graph = \hbar_graph( $image = ui_get_full_url(
$moduleData,
$width,
$height,
$color,
[],
[],
'images/image_problem_area.png', 'images/image_problem_area.png',
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
$gridColor,
null,
null,
true
);
} else {
$graph = \vbar_graph(
$moduleData,
$width,
$height,
$color,
[],
[],
\ui_get_full_url(
'images/image_problem_area.png',
false,
false,
false
),
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
true,
false, false,
$gridColor, false,
true false
); );
$graph = base64_encode(file_get_contents($image));
} else {
if ($typeGraph === 'horizontal') {
$graph = \hbar_graph(
$moduleData,
$width,
$height,
$color,
[],
[],
'images/image_problem_area.png',
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
$gridColor,
null,
null,
true
);
} else {
$graph = \vbar_graph(
$moduleData,
$width,
$height,
$color,
[],
[],
\ui_get_full_url(
'images/image_problem_area.png',
false,
false,
false
),
'',
'',
$waterMark,
$config['fontpath'],
$config['fontsize'],
'',
2,
$config['homeurl'],
$backGroundColor,
true,
false,
$gridColor,
true
);
}
} }
// Restore connection. // Restore connection.
@ -483,16 +493,17 @@ final class BarsGraph extends Item
$inputs[] = [ $inputs[] = [
'label' => __('Agent'), 'label' => __('Agent'),
'arguments' => [ 'arguments' => [
'type' => 'autocomplete_agent', 'type' => 'autocomplete_agent',
'name' => 'agentAlias', 'name' => 'agentAlias',
'id_agent_hidden' => $values['agentId'], 'id_agent_hidden' => $values['agentId'],
'name_agent_hidden' => 'agentId', 'name_agent_hidden' => 'agentId',
'server_id_hidden' => $values['metaconsoleId'], 'server_id_hidden' => $values['metaconsoleId'],
'name_server_hidden' => 'metaconsoleId', 'name_server_hidden' => 'metaconsoleId',
'return' => true, 'return' => true,
'module_input' => true, 'module_input' => true,
'module_name' => 'moduleId', 'module_name' => 'moduleId',
'module_none' => false, 'module_none' => false,
'get_only_string_modules' => true,
], ],
]; ];
@ -500,14 +511,15 @@ final class BarsGraph extends Item
$inputs[] = [ $inputs[] = [
'label' => __('Module'), 'label' => __('Module'),
'arguments' => [ 'arguments' => [
'type' => 'autocomplete_module', 'type' => 'autocomplete_module',
'fields' => $fields, 'fields' => $fields,
'name' => 'moduleId', 'name' => 'moduleId',
'selected' => $values['moduleId'], 'selected' => $values['moduleId'],
'return' => true, 'return' => true,
'sort' => false, 'sort' => false,
'agent_id' => $values['agentId'], 'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'], 'metaconsole_id' => $values['metaconsoleId'],
'get_only_string_modules' => true,
], ],
]; ];
} }

View File

@ -210,16 +210,17 @@ final class DonutGraph extends Item
$inputs[] = [ $inputs[] = [
'label' => __('Agent'), 'label' => __('Agent'),
'arguments' => [ 'arguments' => [
'type' => 'autocomplete_agent', 'type' => 'autocomplete_agent',
'name' => 'agentAlias', 'name' => 'agentAlias',
'id_agent_hidden' => $values['agentId'], 'id_agent_hidden' => $values['agentId'],
'name_agent_hidden' => 'agentId', 'name_agent_hidden' => 'agentId',
'server_id_hidden' => $values['metaconsoleId'], 'server_id_hidden' => $values['metaconsoleId'],
'name_server_hidden' => 'metaconsoleId', 'name_server_hidden' => 'metaconsoleId',
'return' => true, 'return' => true,
'module_input' => true, 'module_input' => true,
'module_name' => 'moduleId', 'module_name' => 'moduleId',
'module_none' => false, 'module_none' => false,
'get_only_string_modules' => true,
], ],
]; ];
@ -227,14 +228,15 @@ final class DonutGraph extends Item
$inputs[] = [ $inputs[] = [
'label' => __('Module'), 'label' => __('Module'),
'arguments' => [ 'arguments' => [
'type' => 'autocomplete_module', 'type' => 'autocomplete_module',
'fields' => $fields, 'fields' => $fields,
'name' => 'moduleId', 'name' => 'moduleId',
'selected' => $values['moduleId'], 'selected' => $values['moduleId'],
'return' => true, 'return' => true,
'sort' => false, 'sort' => false,
'agent_id' => $values['agentId'], 'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'], 'metaconsole_id' => $values['metaconsoleId'],
'get_only_string_modules' => true,
], ],
]; ];

View File

@ -102,6 +102,19 @@ final class EventsHistory extends Item
throw new \InvalidArgumentException('missing agent Id'); throw new \InvalidArgumentException('missing agent Id');
} }
if ((int) $data['width'] === 0 && (int) $data['height'] === 0) {
$data['width'] = 420;
$data['height'] = 80;
}
if ((int) $data['width'] < 11) {
$data['width'] = 11;
}
if ((int) $data['height'] < 11) {
$data['height'] = 11;
}
// Use the same HTML output as the old VC. // Use the same HTML output as the old VC.
$html = \graph_graphic_moduleevents( $html = \graph_graphic_moduleevents(
$agentId, $agentId,
@ -111,7 +124,7 @@ final class EventsHistory extends Item
static::extractMaxTime($data), static::extractMaxTime($data),
'', '',
true, true,
2 1
); );
$data['html'] = $html; $data['html'] = $html;

View File

@ -60,6 +60,16 @@ final class Label extends Item
); );
} }
if ($values['tabSelected'] === 'specific') {
// Inputs LinkedVisualConsole.
$inputsLinkedVisualConsole = self::inputsLinkedVisualConsole(
$values
);
foreach ($inputsLinkedVisualConsole as $key => $value) {
$inputs[] = $value;
}
}
return $inputs; return $inputs;
} }
@ -75,10 +85,6 @@ final class Label extends Item
*/ */
public function getDefaultGeneralValues(array $values): array public function getDefaultGeneralValues(array $values): array
{ {
if (isset($values['isLinkEnabled']) === false) {
$values['isLinkEnabled'] = false;
}
// Retrieve global - common inputs. // Retrieve global - common inputs.
$values = parent::getDefaultGeneralValues($values); $values = parent::getDefaultGeneralValues($values);

View File

@ -276,7 +276,7 @@ final class ModuleGraph extends Item
\enterprise_include_once('include/functions_metaconsole.php'); \enterprise_include_once('include/functions_metaconsole.php');
} }
$imageOnly = true; $imageOnly = false;
$backgroundType = static::extractBackgroundType($data); $backgroundType = static::extractBackgroundType($data);
$period = static::extractPeriod($data); $period = static::extractPeriod($data);
@ -344,7 +344,10 @@ final class ModuleGraph extends Item
'modules_series' => $customGraph['modules_series'], 'modules_series' => $customGraph['modules_series'],
]; ];
$imgbase64 = 'data:image/jpg;base64,'; if ($imageOnly !== false) {
$imgbase64 = 'data:image/jpg;base64,';
}
$imgbase64 .= \graphic_combined_module( $imgbase64 .= \graphic_combined_module(
false, false,
$params, $params,
@ -376,7 +379,10 @@ final class ModuleGraph extends Item
'show_title' => false, 'show_title' => false,
]; ];
$imgbase64 = 'data:image/jpg;base64,'; if ($imageOnly !== false) {
$imgbase64 = 'data:image/jpg;base64,';
}
$imgbase64 .= \grafico_modulo_sparse($params); $imgbase64 .= \grafico_modulo_sparse($params);
} }
@ -411,9 +417,16 @@ final class ModuleGraph extends Item
); );
} }
$data[0] = __('None'); $data = array_reduce(
$data,
function ($carry, $item) {
$carry[$item['id_graph']] = $item['name'];
return $carry;
},
[]
);
return array_reverse($data); return $data;
} }
@ -446,6 +459,10 @@ final class ModuleGraph extends Item
$values['period'] = 3600; $values['period'] = 3600;
} }
if (isset($values['showLegend']) === false) {
$values['showLegend'] = true;
}
// Background color. // Background color.
$fields = [ $fields = [
'white' => __('White'), 'white' => __('White'),
@ -554,11 +571,13 @@ final class ModuleGraph extends Item
'hidden' => $hiddenCustom, 'hidden' => $hiddenCustom,
'label' => __('Custom graph'), 'label' => __('Custom graph'),
'arguments' => [ 'arguments' => [
'type' => 'select', 'type' => 'select',
'fields' => $fields, 'fields' => $fields,
'name' => 'customGraphId', 'name' => 'customGraphId',
'selected' => $values['customGraphId'], 'selected' => $values['customGraphId'],
'return' => true, 'return' => true,
'nothing' => __('None'),
'nothing_value' => 0,
], ],
]; ];

View File

@ -81,19 +81,6 @@ class View extends \HTML
$activetabs = 2; $activetabs = 2;
if ($type === LABEL) { if ($type === LABEL) {
$activetabs = 0; $activetabs = 0;
$tabs = [
[
'name' => __('Label settings'),
'id' => 'tab-label',
'href' => $url.'&tabSelected=label',
'img' => 'zoom.png',
],[
'name' => __('General settings'),
'id' => 'tab-general',
'href' => $url.'&tabSelected=general',
'img' => 'pencil.png',
],
];
} else if ($type === LINE_ITEM) { } else if ($type === LINE_ITEM) {
$activetabs = 0; $activetabs = 0;
$tabs = [ $tabs = [
@ -501,6 +488,9 @@ class View extends \HTML
break; break;
case LABEL: case LABEL:
$data['isLinkEnabled'] = true;
break;
default: default:
// Not posible. // Not posible.
break; break;

View File

@ -4,6 +4,7 @@
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
background-position: center; background-position: center;
margin-top: 5px;
} }
.visual-console-item { .visual-console-item {
@ -699,7 +700,8 @@ li#li-timeZone-item > select:not(:first-child) {
} }
div.label, div.label,
div.simple-value { div.simple-value,
div.module-graph {
display: inline-table; display: inline-table;
min-width: -webkit-fit-content; min-width: -webkit-fit-content;
min-width: -moz-fit-content; min-width: -moz-fit-content;
@ -709,6 +711,10 @@ div.simple-value {
min-height: fit-content; min-height: fit-content;
} }
.textDecorationNone:hover {
text-decoration: none;
}
/* Styles for the solid icons */ /* Styles for the solid icons */
.fa { .fa {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -685,7 +685,7 @@ if (is_ajax()) {
); );
if ($get_only_string_modules) { if ($get_only_string_modules) {
$filter['tagente_modulo.id_tipo_modulo IN'] = '(17,23,3,10,33)'; $filter['tagente_modulo.id_tipo_modulo IN'] = '(17,23,3,10,33,36)';
} }
// Status selector. // Status selector.

View File

@ -200,10 +200,16 @@ if (!is_metaconsole()) {
html_print_input_hidden('metaconsole', 1); html_print_input_hidden('metaconsole', 1);
} }
$edit_capable = (bool) (
check_acl($config['id_user'], 0, 'VM')
|| check_acl($config['id_user'], 0, 'VW')
);
if ($pure === false) { if ($pure === false) {
echo '<div id ="edit-vc">'; if ($edit_capable === true) {
echo '<div id ="edit-controls" class="visual-console-edit-controls" style="visibility:hidden">'; echo '<div id ="edit-vc">';
echo '<div>'; echo '<div id ="edit-controls" class="visual-console-edit-controls" style="visibility:hidden">';
echo '<div>';
visual_map_print_button_editor_refactor( visual_map_print_button_editor_refactor(
'STATIC_GRAPH', 'STATIC_GRAPH',
__('Static Image'), __('Static Image'),
@ -278,24 +284,25 @@ if ($pure === false) {
enterprise_hook( enterprise_hook(
'enterprise_visual_map_editor_print_toolbox_refactor' 'enterprise_visual_map_editor_print_toolbox_refactor'
); );
echo '</div>'; echo '</div>';
echo '<div class="visual-console-copy-delete">'; echo '<div class="visual-console-copy-delete">';
visual_map_print_button_editor_refactor( visual_map_print_button_editor_refactor(
'button_delete', 'button_delete',
__('Delete Item'), __('Delete Item'),
'delete_item delete_min', 'delete_item delete_min',
true true
); );
visual_map_print_button_editor_refactor( visual_map_print_button_editor_refactor(
'button_copy', 'button_copy',
__('Copy Item'), __('Copy Item'),
'copy_item', 'copy_item',
true true
); );
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';
echo html_print_checkbox_switch('edit-mode', 1, false, true); echo html_print_checkbox_switch('edit-mode', 1, false, true);
echo '</div>'; echo '</div>';
}
} }
echo '<div id="visual-console-container"></div>'; echo '<div id="visual-console-container"></div>';
@ -502,6 +509,9 @@ ui_require_css_file('form');
handleUpdate handleUpdate
); );
<?php
if ($edit_capable === true) {
?>
// Enable/disable the edition mode. // Enable/disable the edition mode.
$('input[name=edit-mode]').change(function(event) { $('input[name=edit-mode]').change(function(event) {
if ($(this).prop('checked')) { if ($(this).prop('checked')) {
@ -510,10 +520,14 @@ ui_require_css_file('form');
$('#edit-controls').css('visibility', ''); $('#edit-controls').css('visibility', '');
} else { } else {
visualConsoleManager.visualConsole.disableEditMode(); visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.visualConsole.unSelectItems();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms. visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
$('#edit-controls').css('visibility', 'hidden'); $('#edit-controls').css('visibility', 'hidden');
} }
}); });
<?php
}
?>
// Update the data fetch interval. // Update the data fetch interval.
$('select#vc-refr').change(function(event) { $('select#vc-refr').change(function(event) {

View File

@ -486,12 +486,18 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
let box; let box;
if (this.props.isLinkEnabled) { if (this.props.isLinkEnabled) {
box = document.createElement("a") as HTMLAnchorElement; box = document.createElement("a") as HTMLAnchorElement;
if (this.props.link) box.href = this.props.link;
if (this.props.link) {
box.href = this.props.link;
} else {
box.className = "textDecorationNone";
}
} else { } else {
box = document.createElement("div") as HTMLDivElement; box = document.createElement("div") as HTMLDivElement;
box.className = "textDecorationNone";
} }
box.className = "visual-console-item"; box.classList.add("visual-console-item");
if (this.props.isOnTop) { if (this.props.isOnTop) {
box.classList.add("is-on-top"); box.classList.add("is-on-top");
} }
@ -516,7 +522,7 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
e.stopPropagation(); e.stopPropagation();
} else { } else {
// Add loading click item. // Add loading click item.
if (this.itemProps.isLinkEnabled) { if (this.itemProps.isLinkEnabled && this.itemProps.link != null) {
const divParent = document.createElement("div"); const divParent = document.createElement("div");
divParent.className = "div-visual-console-spinner"; divParent.className = "div-visual-console-spinner";
const divSpinner = document.createElement("div"); const divSpinner = document.createElement("div");

View File

@ -88,21 +88,72 @@ export function moduleGraphPropsDecoder(
export default class ModuleGraph extends Item<ModuleGraphProps> { export default class ModuleGraph extends Item<ModuleGraphProps> {
protected createDomElement(): HTMLElement { protected createDomElement(): HTMLElement {
const element = document.createElement("div"); const element = document.createElement("div");
//element.className = "module-graph";
//element.style.backgroundImage = `url(${this.props.html})`;
//element.style.backgroundRepeat = "no-repeat";
//element.style.backgroundSize = `${this.props.width}px ${
// this.props.height
//}px`;
element.innerHTML = this.props.html;
element.className = "module-graph"; element.className = "module-graph";
element.style.backgroundImage = `url(${this.props.html})`;
element.style.backgroundRepeat = "no-repeat"; // Remove the overview graph.
element.style.backgroundSize = `${this.props.width}px ${ const legendP = element.getElementsByTagName("p");
this.props.height for (let i = 0; i < legendP.length; i++) {
}px`; legendP[i].style.margin = "0px";
}
// Remove the overview graph.
const overviewGraphs = element.getElementsByClassName("overview_graph");
for (let i = 0; i < overviewGraphs.length; i++) {
overviewGraphs[i].remove();
}
// Hack to execute the JS after the HTML is added to the DOM.
const scripts = element.getElementsByTagName("script");
for (let i = 0; i < scripts.length; i++) {
if (scripts[i].src.length === 0) {
setTimeout(() => {
try {
eval(scripts[i].innerHTML.trim());
} catch (ignored) {} // eslint-disable-line no-empty
}, 0);
}
}
// element.innerHTML = this.props.html;
return element; return element;
} }
protected updateDomElement(element: HTMLElement): void { protected updateDomElement(element: HTMLElement): void {
element.style.backgroundImage = `url(${this.props.html})`; //element.style.backgroundImage = `url(${this.props.html})`;
element.style.backgroundRepeat = "no-repeat"; //element.style.backgroundRepeat = "no-repeat";
element.style.backgroundSize = `${this.props.width}px ${ //element.style.backgroundSize = `${this.props.width}px ${
this.props.height // this.props.height
}px`; //}px`;
element.innerHTML = this.props.html;
// Remove the overview graph.
const legendP = element.getElementsByTagName("p");
for (let i = 0; i < legendP.length; i++) {
legendP[i].style.margin = "0px";
}
// Remove the overview graph.
const overviewGraphs = element.getElementsByClassName("overview_graph");
for (let i = 0; i < overviewGraphs.length; i++) {
overviewGraphs[i].remove();
}
// Hack to execute the JS after the HTML is added to the DOM.
const scripts = element.getElementsByTagName("script");
for (let i = 0; i < scripts.length; i++) {
if (scripts[i].src.length === 0) {
eval(scripts[i].innerHTML.trim());
}
}
} }
} }

View File

@ -4,6 +4,7 @@
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: 100% 100%; background-size: 100% 100%;
background-position: center; background-position: center;
margin-top: 5px;
} }
.visual-console-item { .visual-console-item {
@ -525,8 +526,13 @@ li#li-timeZone-item > select:not(:first-child) {
} }
div.label, div.label,
div.simple-value { div.simple-value,
div.module-graph {
display: inline-table; display: inline-table;
min-width: fit-content; min-width: fit-content;
min-height: fit-content; min-height: fit-content;
} }
.textDecorationNone:hover {
text-decoration: none;
}