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,6 +213,11 @@ if ($config['menu_type'] == 'classic') {
$select[0]['autorefresh_white_list']
);
if ($config['legacy_vc']
|| ($_GET['sec2'] !== 'operation/visual_console/render_view')
|| (($_GET['sec2'] !== 'operation/visual_console/render_view')
&& $config['legacy_vc'])
) {
if ($autorefresh_list !== null
&& array_search($_GET['sec2'], $autorefresh_list) !== false
) {
@ -332,6 +337,7 @@ if ($config['menu_type'] == 'classic') {
$header_autorefresh_counter .= $autorefresh_link_close;
$header_autorefresh_counter .= $autorefresh_additional;
$header_autorefresh_counter .= '</div>';
}
// Button for feedback pandora.
if (enterprise_installed()) {

View File

@ -783,10 +783,13 @@ $buttons['wizard'] = [
'active' => false,
'text' => '<a href="'.$url_base.$action.'&tab=wizard&id_visual_console='.$idVisualConsole.'">'.html_print_image('images/wand.png', true, ['title' => __('Wizard')]).'</a>',
];
if ($config['legacy_vc']) {
$buttons['editor'] = [
'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'] = [
'active' => false,
'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['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
&& $data['module_input'] === true
) {
@ -3755,12 +3761,18 @@ function html_print_input($data, $wrapper='div', $input_only=false)
0 => __('Select an Agent first'),
];
} 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(
'SELECT id_agente_modulo, nombre
FROM tagente_modulo
WHERE id_agente = %d
AND delete_pending = 0',
$data['agent_id']
AND delete_pending = 0 %s',
$data['agent_id'],
$string_filter
);
if (is_metaconsole() === true) {

View File

@ -1,8 +1,9 @@
/* globals d3 */
(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/
d3.bullet = function() {
var orient = "right", // TODO top & bottom
reverse = false,
@ -17,18 +18,31 @@ d3.bullet = function() {
// For each small multiple…
function bullet(g) {
g.each(function(d, i) {
var rangez = ranges.call(this, d, i).slice().sort(d3.descending),
markerz = markers.call(this, d, i).slice().sort(d3.descending),
measurez = measures.call(this, d, i).slice().sort(d3.descending),
var rangez = ranges
.call(this, d, i)
.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);
// 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])])
.range(reverse ? [width, 0] : [0, width - 160]);
// Retrieve the old x-scale, if this is an update.
var x0 = this.__chart__ || d3.scale.linear()
var x0 =
this.__chart__ ||
d3.scale
.linear()
.domain([0, Infinity])
.range(x1.range());
@ -40,11 +54,14 @@ d3.bullet = function() {
w1 = bulletWidth(x1);
// Update the range rects.
var range = g.selectAll("rect.range")
.data(rangez);
var range = g.selectAll("rect.range").data(rangez);
range.enter().append("rect")
.attr("class", function(d, i) { return "range s" + i; })
range
.enter()
.append("rect")
.attr("class", function(d, i) {
return "range s" + i;
})
.attr("width", w0)
.attr("height", height)
.attr("x", reverse ? x0 : 0)
@ -53,18 +70,22 @@ d3.bullet = function() {
.attr("width", w1)
.attr("x", reverse ? x1 : 0);
range.transition()
range
.transition()
.duration(duration)
.attr("x", reverse ? x1 : 0)
.attr("width", w1)
.attr("height", height);
// Update the measure rects.
var measure = g.selectAll("rect.measure")
.data(measurez);
var measure = g.selectAll("rect.measure").data(measurez);
measure.enter().append("rect")
.attr("class", function(d, i) { return "measure s" + i; })
measure
.enter()
.append("rect")
.attr("class", function(d, i) {
return "measure s" + i;
})
.attr("width", w0)
.attr("height", height / 3)
.attr("x", reverse ? x0 : 0)
@ -74,7 +95,8 @@ d3.bullet = function() {
.attr("width", w1)
.attr("x", reverse ? x1 : 0);
measure.transition()
measure
.transition()
.duration(duration)
.attr("width", w1)
.attr("height", height / 3)
@ -82,73 +104,84 @@ d3.bullet = function() {
.attr("y", height / 3);
// Update the marker lines.
var marker = g.selectAll("line.marker")
.data(markerz);
var marker = g.selectAll("line.marker").data(markerz);
marker.enter().append("line")
.attr("class", function(d, i) { return "marker s" + i; })
marker
.enter()
.append("line")
.attr("class", function(d, i) {
return "marker s" + i;
})
.attr("x1", x0)
.attr("x2", x0)
.attr("y1", height / 6)
.attr("y2", height * 5 / 6)
.attr("y2", (height * 5) / 6)
.transition()
.duration(duration)
.attr("x1", x1)
.attr("x2", x1);
marker.transition()
marker
.transition()
.duration(duration)
.attr("x1", x1)
.attr("x2", x1)
.attr("y1", height / 6)
.attr("y2", height * 5 / 6);
.attr("y2", (height * 5) / 6);
// Compute the tick format.
var format = tickFormat || x1.tickFormat(8);
// Update the tick groups.
var tick = g.selectAll("g.tick")
.data(x1.ticks(8), function(d) {
var tick = g.selectAll("g.tick").data(x1.ticks(8), function(d) {
return this.textContent || format(d);
});
// Initialize the ticks with the old scale, x0.
var tickEnter = tick.enter().append("g")
var tickEnter = tick
.enter()
.append("g")
.attr("class", "tick")
.attr("transform", bulletTranslate(x0))
.style("opacity", 1e-6);
tickEnter.append("line")
tickEnter
.append("line")
.attr("y1", height)
.attr("y2", height * 7 / 6);
.attr("y2", (height * 7) / 6);
tickEnter.append("text")
tickEnter
.append("text")
.attr("text-anchor", "middle")
.attr("dy", "1em")
.attr("y", height * 7 / 6)
.attr("y", (height * 7) / 6)
.text(format);
// Transition the entering ticks to the new scale, x1.
tickEnter.transition()
tickEnter
.transition()
.duration(duration)
.attr("transform", bulletTranslate(x1))
.style("opacity", 1);
// Transition the updating ticks to the new scale, x1.
var tickUpdate = tick.transition()
var tickUpdate = tick
.transition()
.duration(duration)
.attr("transform", bulletTranslate(x1))
.style("opacity", 1);
tickUpdate.select("line")
tickUpdate
.select("line")
.attr("y1", height)
.attr("y2", height + 7);
tickUpdate.select("text")
.attr("y", height + 7);
tickUpdate.select("text").attr("y", height + 7);
// Transition the exiting ticks to the new scale, x1.
tick.exit().transition()
tick
.exit()
.transition()
.duration(duration)
.attr("transform", bulletTranslate(x1))
.style("opacity", 1e-6)
@ -237,5 +270,4 @@ function bulletWidth(x) {
return Math.abs(x(d) - x0);
};
}
})();

View File

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

View File

@ -45,6 +45,21 @@ function createVisualConsole(
visualConsoleId,
function(error, data) {
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(
"[ERROR]",
"[VISUAL-CONSOLE-CLIENT]",

View File

@ -75,39 +75,26 @@ abstract class CachedModel extends Model
public static function fromDB(array $filter): Model
{
global $config;
// TODO: Remove references to the VC items. This class should be usable with any resource.
$save_cache = false;
if ($filter['cache_expiration'] > 0) {
// Obtain the item's data from cache.
$cachedData = static::fetchCachedData($filter);
if ($cachedData === null) {
$userId = (static::$indexCacheByUser === true) ? $config['id_user'] : null;
// Delete expired data cache.
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;
$data = static::fetchCachedData($filter);
$save_cache = true;
}
} else {
if (isset($data) === false) {
$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);

View File

@ -413,7 +413,7 @@ final class Container extends Model
try {
array_push($items, $class::fromDB($data));
} 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;
/**
* 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
@ -815,6 +822,14 @@ class Item extends CachedModel
);
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;
}
@ -835,14 +850,19 @@ class Item extends CachedModel
*/
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(
'tvisual_console_elements_cache',
[
'vc_id' => $filter['vc_id'],
'vc_item_id' => $filter['vc_item_id'],
'vc_id' => $data['id_layout'],
'vc_item_id' => $data['id'],
'user_id' => $filter['user_id'],
'data' => base64_encode(json_encode($data)),
'expiration' => $filter['expiration'],
'expiration' => $data['cache_expiration'],
]
) > 0;
}
@ -1052,6 +1072,19 @@ class Item extends CachedModel
// The layout can be from another node.
$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()) {
/*
* A Visual Console from this console.
@ -1885,6 +1918,7 @@ class Item extends CachedModel
],
];
if ($values['type'] !== LABEL) {
// Link enabled.
$inputs[] = [
'label' => __('Link enabled'),
@ -1895,6 +1929,7 @@ class Item extends CachedModel
'value' => $values['isLinkEnabled'],
],
];
}
// Show on top.
$inputs[] = [
@ -2232,7 +2267,19 @@ class Item extends CachedModel
{
// LinkConsoleInputGroup.
$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'];
if (\is_metaconsole() === true) {
@ -2252,6 +2299,8 @@ class Item extends CachedModel
'selected' => $getAllVisualConsoleValue,
'script' => 'linkedVisualConsoleChange()',
'return' => true,
'nothing' => __('None'),
'nothing_value' => 0,
],
];

View File

@ -340,6 +340,15 @@ final class BarsGraph extends Item
$height = (int) $data['height'];
}
if (empty($moduleData) === true) {
$image = ui_get_full_url(
'images/image_problem_area.png',
false,
false,
false
);
$graph = base64_encode(file_get_contents($image));
} else {
if ($typeGraph === 'horizontal') {
$graph = \hbar_graph(
$moduleData,
@ -392,6 +401,7 @@ final class BarsGraph extends Item
true
);
}
}
// Restore connection.
if ($nodeConnected === true) {
@ -493,6 +503,7 @@ final class BarsGraph extends Item
'module_input' => true,
'module_name' => 'moduleId',
'module_none' => false,
'get_only_string_modules' => true,
],
];
@ -508,6 +519,7 @@ final class BarsGraph extends Item
'sort' => false,
'agent_id' => $values['agentId'],
'metaconsole_id' => $values['metaconsoleId'],
'get_only_string_modules' => true,
],
];
}

View File

@ -220,6 +220,7 @@ final class DonutGraph extends Item
'module_input' => true,
'module_name' => 'moduleId',
'module_none' => false,
'get_only_string_modules' => true,
],
];
@ -235,6 +236,7 @@ final class DonutGraph extends Item
'sort' => false,
'agent_id' => $values['agentId'],
'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');
}
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.
$html = \graph_graphic_moduleevents(
$agentId,
@ -111,7 +124,7 @@ final class EventsHistory extends Item
static::extractMaxTime($data),
'',
true,
2
1
);
$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;
}
@ -75,10 +85,6 @@ final class Label extends Item
*/
public function getDefaultGeneralValues(array $values): array
{
if (isset($values['isLinkEnabled']) === false) {
$values['isLinkEnabled'] = false;
}
// Retrieve global - common inputs.
$values = parent::getDefaultGeneralValues($values);

View File

@ -276,7 +276,7 @@ final class ModuleGraph extends Item
\enterprise_include_once('include/functions_metaconsole.php');
}
$imageOnly = true;
$imageOnly = false;
$backgroundType = static::extractBackgroundType($data);
$period = static::extractPeriod($data);
@ -344,7 +344,10 @@ final class ModuleGraph extends Item
'modules_series' => $customGraph['modules_series'],
];
if ($imageOnly !== false) {
$imgbase64 = 'data:image/jpg;base64,';
}
$imgbase64 .= \graphic_combined_module(
false,
$params,
@ -376,7 +379,10 @@ final class ModuleGraph extends Item
'show_title' => false,
];
if ($imageOnly !== false) {
$imgbase64 = 'data:image/jpg;base64,';
}
$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;
}
if (isset($values['showLegend']) === false) {
$values['showLegend'] = true;
}
// Background color.
$fields = [
'white' => __('White'),
@ -559,6 +576,8 @@ final class ModuleGraph extends Item
'name' => 'customGraphId',
'selected' => $values['customGraphId'],
'return' => true,
'nothing' => __('None'),
'nothing_value' => 0,
],
];

View File

@ -81,19 +81,6 @@ class View extends \HTML
$activetabs = 2;
if ($type === LABEL) {
$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) {
$activetabs = 0;
$tabs = [
@ -501,6 +488,9 @@ class View extends \HTML
break;
case LABEL:
$data['isLinkEnabled'] = true;
break;
default:
// Not posible.
break;

View File

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

View File

@ -200,7 +200,13 @@ if (!is_metaconsole()) {
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 ($edit_capable === true) {
echo '<div id ="edit-vc">';
echo '<div id ="edit-controls" class="visual-console-edit-controls" style="visibility:hidden">';
echo '<div>';
@ -297,6 +303,7 @@ if ($pure === false) {
echo html_print_checkbox_switch('edit-mode', 1, false, true);
echo '</div>';
}
}
echo '<div id="visual-console-container"></div>';
@ -502,6 +509,9 @@ ui_require_css_file('form');
handleUpdate
);
<?php
if ($edit_capable === true) {
?>
// Enable/disable the edition mode.
$('input[name=edit-mode]').change(function(event) {
if ($(this).prop('checked')) {
@ -510,10 +520,14 @@ ui_require_css_file('form');
$('#edit-controls').css('visibility', '');
} else {
visualConsoleManager.visualConsole.disableEditMode();
visualConsoleManager.visualConsole.unSelectItems();
visualConsoleManager.changeUpdateInterval(<?php echo ($refr * 1000); ?>); // To ms.
$('#edit-controls').css('visibility', 'hidden');
}
});
<?php
}
?>
// Update the data fetch interval.
$('select#vc-refr').change(function(event) {

View File

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

View File

@ -88,21 +88,72 @@ export function moduleGraphPropsDecoder(
export default class ModuleGraph extends Item<ModuleGraphProps> {
protected createDomElement(): HTMLElement {
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.style.backgroundImage = `url(${this.props.html})`;
element.style.backgroundRepeat = "no-repeat";
element.style.backgroundSize = `${this.props.width}px ${
this.props.height
}px`;
// 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) {
setTimeout(() => {
try {
eval(scripts[i].innerHTML.trim());
} catch (ignored) {} // eslint-disable-line no-empty
}, 0);
}
}
// element.innerHTML = this.props.html;
return element;
}
protected updateDomElement(element: HTMLElement): void {
element.style.backgroundImage = `url(${this.props.html})`;
element.style.backgroundRepeat = "no-repeat";
element.style.backgroundSize = `${this.props.width}px ${
this.props.height
}px`;
//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;
// 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-size: 100% 100%;
background-position: center;
margin-top: 5px;
}
.visual-console-item {
@ -525,8 +526,13 @@ li#li-timeZone-item > select:not(:first-child) {
}
div.label,
div.simple-value {
div.simple-value,
div.module-graph {
display: inline-table;
min-width: fit-content;
min-height: fit-content;
}
.textDecorationNone:hover {
text-decoration: none;
}