Merge branch 'ent-6583-Bug-estado-de-elementos-consola-visual' into 'develop'

Mode ghost for disabled modules and agents

See merge request artica/pandorafms!3889
This commit is contained in:
Daniel Rodriguez 2021-03-22 14:10:14 +00:00
commit 6294910e29
16 changed files with 157 additions and 58 deletions

View File

@ -3272,12 +3272,6 @@ function visual_map_get_status_element($layoutData)
}
}
$module_value = db_get_sql(
'SELECT datos
FROM tagente_estado
WHERE id_agente_modulo = '.$layoutData['id_agente_modulo']
);
// Linked to other layout ?? - Only if not module defined
if (!empty($layoutData['id_layout_linked'])) {
if (!empty($layoutData['linked_layout_node_id'])) {
@ -3379,6 +3373,11 @@ function visual_map_get_status_element($layoutData)
case PERCENTILE_BUBBLE:
case CIRCULAR_PROGRESS_BAR:
case CIRCULAR_INTERIOR_PROGRESS_BAR:
$module_value = db_get_sql(
'SELECT datos
FROM tagente_estado
WHERE id_agente_modulo = '.$layoutData['id_agente_modulo']
);
if (empty($module_value) || $module_value == '') {
return VISUAL_MAP_STATUS_UNKNOWN;
@ -3907,9 +3906,19 @@ function visual_map_get_layout_status($layout_id, $status_data=[], $depth=0)
return VISUAL_MAP_STATUS_UNKNOWN;
}
$layout_items = db_get_all_rows_filter(
'tlayout_data',
['id_layout' => $layout_id]
$layout_items = db_get_all_rows_sql(
sprintf(
'SELECT tld.*
FROM tlayout_data tld
LEFT JOIN tagente ta
ON ta.id_agente=tld.id_agent
LEFT JOIN tagente_modulo tam
ON tam.id_agente_modulo = tld.id_agente_modulo
WHERE tld.id_layout = %d
AND (ta.disabled = 0 OR ta.disabled is null)
AND (tam.disabled = 0 OR tam.disabled is null)',
$layout_id
)
);
if ($layout_items === false) {

View File

@ -455,7 +455,6 @@ function createVisualConsole(
},
createItem: function(typeString) {
var type;
console.log(typeString);
switch (typeString) {
case "STATIC_GRAPH":
type = 0;

View File

@ -242,6 +242,13 @@ class Item extends CachedModel
);
}
$decodedData['agentDisabled'] = static::parseBool(
$data['agentDisabled']
);
$decodedData['moduleDisabled'] = static::parseBool(
$data['moduleDisabled']
);
return $decodedData;
}
@ -939,7 +946,7 @@ class Item extends CachedModel
if (\is_metaconsole()) {
$sql = sprintf(
'SELECT nombre, alias, direccion, comentarios
'SELECT nombre, alias, direccion, comentarios, `disabled`
FROM tmetaconsole_agent
WHERE id_tagente = %s and id_tmetaconsole_setup = %s',
$agentId,
@ -947,7 +954,7 @@ class Item extends CachedModel
);
} else {
$sql = sprintf(
'SELECT nombre, alias, direccion, comentarios
'SELECT nombre, alias, direccion, comentarios, `disabled`
FROM tagente
WHERE id_agente = %s',
$agentId
@ -966,6 +973,7 @@ class Item extends CachedModel
$agentData['agentAlias'] = $agent['alias'];
$agentData['agentDescription'] = $agent['comentarios'];
$agentData['agentAddress'] = $agent['direccion'];
$agentData['agentDisabled'] = $agent['disabled'];
return \io_safe_output($agentData);
}
@ -1026,7 +1034,7 @@ class Item extends CachedModel
}
$sql = sprintf(
'SELECT nombre, descripcion
'SELECT nombre, descripcion, `disabled`
FROM tagente_modulo
WHERE id_agente_modulo = %s',
$moduleId
@ -1046,6 +1054,7 @@ class Item extends CachedModel
$moduleData['moduleName'] = $moduleName['nombre'];
$moduleData['moduleDescription'] = $moduleName['descripcion'];
$moduleData['moduleDisabled'] = $moduleName['disabled'];
return \io_safe_output($moduleData);
}
@ -1076,6 +1085,12 @@ class Item extends CachedModel
$baseUrl = \ui_get_full_url('index.php');
if ((bool) $data['agentDisabled'] === true
|| (bool) $data['moduleDisabled'] === true
) {
return null;
}
// TODO: There's a feature to get the link from the label.
if (static::$useLinkedVisualConsole === true
&& $linkedVisualConsole['linkedLayoutId'] !== null

View File

@ -134,6 +134,7 @@ final class StaticGraph extends Item
* Fetch a vc item data structure from the database using a filter.
*
* @param array $filter Filter of the Visual Console Item.
* @param float|null $ratio Ratio.
*
* @return array The Visual Console Item data structure stored into the DB.
* @throws \InvalidArgumentException When an agent Id cannot be found.
@ -171,9 +172,12 @@ final class StaticGraph extends Item
throw new \InvalidArgumentException('missing module Id');
}
if ((bool) $data['agentDisabled'] === false
&& (bool) $data['moduleDisabled'] === false
) {
// Get the img src.
// There's no need to connect to the metaconsole before searching for
// the image status cause the function itself does that for us.
// There's no need to connect to the metaconsole before searching
// for the image status cause the function itself does that for us.
$imagePath = \visual_map_get_image_status_element($data);
$data['statusImageSrc'] = \ui_get_full_url(
$imagePath,
@ -210,6 +214,16 @@ final class StaticGraph extends Item
$data['colorStatus'] = COL_UNKNOWN;
break;
}
} else {
$data['colorStatus'] = COL_UNKNOWN;
$imagePath = 'images/console/icons/'.$data['image'].'.png';
$data['statusImageSrc'] = \ui_get_full_url(
$imagePath,
false,
false,
false
);
}
// If the width or the height are equal to 0 we will extract them
// from the real image size.
@ -359,7 +373,6 @@ final class StaticGraph extends Item
'label' => __('Module'),
'arguments' => [
'type' => 'autocomplete_module',
'fields' => $fields,
'name' => 'moduleId',
'selected' => $values['moduleId'],
'return' => true,

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -75,9 +75,14 @@ export default class BarsGraph extends Item<BarsGraphProps> {
element.className = "bars-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.style.backgroundSize = `${this.props.width}px ${this.props.height}px`;
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
element.style.opacity = "0.2";
}
return element;
}
@ -85,8 +90,13 @@ export default class BarsGraph extends Item<BarsGraphProps> {
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.backgroundSize = `${this.props.width}px ${this.props.height}px`;
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
element.style.opacity = "0.2";
}
}
}

View File

@ -410,6 +410,13 @@ export default class ColorCloud extends Item<ColorCloudProps> {
defs.append(radialGradient);
svg.append(defs, circle);
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
svg.setAttribute("opacity", "0.2");
}
return svg;
}

View File

@ -56,6 +56,13 @@ export default class DonutGraph extends Item<DonutGraphProps> {
element.className = "donut-graph";
element.innerHTML = this.props.html;
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
element.style.opacity = "0.2";
}
// 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++) {

View File

@ -48,6 +48,13 @@ export default class EventsHistory extends Item<EventsHistoryProps> {
element.className = "events-history";
element.innerHTML = this.props.html;
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
element.style.opacity = "0.2";
}
// 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++) {

View File

@ -97,6 +97,12 @@ export default class ModuleGraph extends Item<ModuleGraphProps> {
element.innerHTML = this.props.html;
element.className = "module-graph";
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
element.style.opacity = "0.2";
}
// Remove the overview graph.
const legendP = element.getElementsByTagName("p");

View File

@ -261,6 +261,13 @@ export default class Percentile extends Item<PercentileProps> {
break;
}
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
svg.setAttribute("opacity", "0.2");
}
if (svg !== null) element.append(svg);
return element;

View File

@ -22,7 +22,8 @@ export type SimpleValueProps = {
| {
processValue: "avg" | "max" | "min";
period: number;
}) &
}
) &
ItemProps &
WithModuleProps &
LinkedVisualConsoleProps;
@ -95,6 +96,13 @@ export default class SimpleValue extends Item<SimpleValueProps> {
const element = document.createElement("div");
element.className = "simple-value";
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
element.style.opacity = "0.2";
}
if (this.props.valueType === "image") {
const img = document.createElement("img");
img.src = this.props.value;

View File

@ -78,6 +78,13 @@ export default class StaticGraph extends Item<StaticGraphProps> {
element.style.backgroundSize = "contain";
element.style.backgroundPosition = "center";
if (
this.props.agentDisabled === true ||
this.props.moduleDisabled === true
) {
element.style.opacity = "0.2";
}
// Show last value in a tooltip.
if (
this.props.lastValue !== null &&

View File

@ -177,7 +177,8 @@ export function agentPropsDecoder(data: AnyObject): WithAgentProps {
agentName: notEmptyStringOr(data.agentName, null),
agentAlias: notEmptyStringOr(data.agentAlias, null),
agentDescription: notEmptyStringOr(data.agentDescription, null),
agentAddress: notEmptyStringOr(data.agentAddress, null)
agentAddress: notEmptyStringOr(data.agentAddress, null),
agentDisabled: parseBoolean(data.agentDisabled)
};
return data.metaconsoleId != null
@ -198,6 +199,7 @@ export function modulePropsDecoder(data: AnyObject): WithModuleProps {
moduleId: parseIntOr(data.moduleId, null),
moduleName: notEmptyStringOr(data.moduleName, null),
moduleDescription: notEmptyStringOr(data.moduleDescription, null),
moduleDisabled: parseBoolean(data.moduleDisabled),
...agentPropsDecoder(data) // Object spread: http://es6-features.org/#SpreadOperator
};
}

View File

@ -23,12 +23,14 @@ export interface WithAgentProps {
agentAlias: string | null;
agentDescription: string | null;
agentAddress: string | null;
agentDisabled: boolean;
}
export interface WithModuleProps extends WithAgentProps {
moduleId: number | null;
moduleName: string | null;
moduleDescription: string | null;
moduleDisabled: boolean;
}
export type LinkedVisualConsolePropsStatus =