fix error cv item module graph periodicity mode pandora_enterprise#9640

This commit is contained in:
daniel 2023-12-14 11:03:45 +01:00
parent cc12c77008
commit 27d76a0890
8 changed files with 41 additions and 29 deletions

View File

@ -13,6 +13,10 @@ SET @sqlstmt = IF (@exist>0, 'ALTER TABLE `tagente` DROP COLUMN `transactional_a
prepare stmt from @sqlstmt;
execute stmt;
ALTER TABLE `tlayout_template_data` ADD COLUMN `title` TEXT default '';
ALTER TABLE `tlayout_data` ADD COLUMN `period_chart_options` TEXT default '';
ALTER TABLE `tlayout_template_data` ADD COLUMN `period_chart_options` TEXT default '';
ALTER TABLE `tdashboard`
ADD COLUMN `date_range` TINYINT NOT NULL DEFAULT 0 AFTER `cells_slideshow`,
ADD COLUMN `date_from` INT NOT NULL DEFAULT 0 AFTER `date_range`,

View File

@ -81,7 +81,7 @@ final class ModuleGraph extends Item
$return['show_statistics'] = static::parseBool($show_legend);
}
$return['label'] = json_encode(
$return['period_chart_options'] = json_encode(
[
'periodicityChart' => static::extractPeriodicityChart($data),
'periodMaximum' => static::extractPeriodMaximum($data),
@ -160,14 +160,14 @@ final class ModuleGraph extends Item
$return['period'] = static::extractPeriod($data);
$return['showLegend'] = static::extractShowLegend($data);
$return['label'] = static::extractDynamicData($data);
$return['periodicityChart'] = static::extractPeriodicityChart($return['label']);
$return['periodMaximum'] = static::extractPeriodMaximum($return['label']);
$return['periodMinimum'] = static::extractPeriodMinimum($return['label']);
$return['periodAverage'] = static::extractPeriodAverage($return['label']);
$return['periodSummatory'] = static::extractPeriodSummatory($return['label']);
$return['periodSliceChart'] = static::extractPeriodSliceChart($return['label']);
$return['periodMode'] = static::extractPeriodMode($return['label']);
$return['periodChartOptions'] = static::extractPeriodChartOptions($data);
$return['periodicityChart'] = static::extractPeriodicityChart($return['periodChartOptions']);
$return['periodMaximum'] = static::extractPeriodMaximum($return['periodChartOptions']);
$return['periodMinimum'] = static::extractPeriodMinimum($return['periodChartOptions']);
$return['periodAverage'] = static::extractPeriodAverage($return['periodChartOptions']);
$return['periodSummatory'] = static::extractPeriodSummatory($return['periodChartOptions']);
$return['periodSliceChart'] = static::extractPeriodSliceChart($return['periodChartOptions']);
$return['periodMode'] = static::extractPeriodMode($return['periodChartOptions']);
$customGraphId = static::extractCustomGraphId($data);
@ -182,20 +182,20 @@ final class ModuleGraph extends Item
/**
* Extract a dynamic data structure from the 'label' field.
* Extract a dynamic data structure from the 'periodChartOptions' field.
*
* @param array $data Unknown input data structure.
*
* @return array Dynamic data structure.
* @throws \InvalidArgumentException If the structure cannot be built.
*/
private static function extractDynamicData(array $data): array
private static function extractPeriodChartOptions(array $data): array
{
$sliceMode = static::notEmptyStringOr($data['label'], null);
$periodChartOptions = static::notEmptyStringOr($data['period_chart_options'], null);
$result = [];
if ($sliceMode !== null) {
if ($periodChartOptions !== null) {
try {
$result = \json_decode($sliceMode, true);
$result = \json_decode($periodChartOptions, true);
} catch (\Throwable $e) {
throw new \InvalidArgumentException('invalid dynamic data');
}
@ -444,14 +444,15 @@ final class ModuleGraph extends Item
$backgroundType = static::extractBackgroundType($data);
$period = static::extractPeriod($data);
$showLegend = static::extractShowLegend($data);
$label = static::extractDynamicData($data);
$periodicityChart = static::extractPeriodicityChart($label);
$periodMaximum = static::extractPeriodMaximum($label);
$periodMinimum = static::extractPeriodMinimum($label);
$periodAverage = static::extractPeriodAverage($label);
$periodSummatory = static::extractPeriodSummatory($label);
$periodSliceChart = static::extractPeriodSliceChart($label);
$periodMode = static::extractPeriodMode($label);
$periodChartOptions = static::extractPeriodChartOptions($data);
$periodicityChart = static::extractPeriodicityChart($periodChartOptions);
$periodMaximum = static::extractPeriodMaximum($periodChartOptions);
$periodMinimum = static::extractPeriodMinimum($periodChartOptions);
$periodAverage = static::extractPeriodAverage($periodChartOptions);
$periodSummatory = static::extractPeriodSummatory($periodChartOptions);
$periodSliceChart = static::extractPeriodSliceChart($periodChartOptions);
$periodMode = static::extractPeriodMode($periodChartOptions);
$customGraphId = static::extractCustomGraphId($data);
$graphType = static::extractGraphType($data);

View File

@ -746,6 +746,7 @@ p {
strong {
font-size: inherit;
}
/* 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

@ -1746,7 +1746,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_data` (
`timezone` VARCHAR(60) NOT NULL DEFAULT 'Europe/Madrid',
`show_last_value` TINYINT UNSIGNED NULL DEFAULT 0,
`cache_expiration` INT UNSIGNED NOT NULL DEFAULT 0,
`title` TEXT ,
`title` TEXT,
`period_chart_options` TEXT,
PRIMARY KEY(`id`),
INDEX `tlayout_data_layout` (`id_layout`)
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;
@ -3822,6 +3823,8 @@ CREATE TABLE IF NOT EXISTS `tlayout_template_data` (
`timezone` VARCHAR(60) NOT NULL DEFAULT 'Europe/Madrid',
`show_last_value` TINYINT UNSIGNED NULL DEFAULT 0,
`cache_expiration` INT UNSIGNED NOT NULL DEFAULT 0,
`title` TEXT,
`period_chart_options` TEXT,
PRIMARY KEY(`id`),
FOREIGN KEY (`id_layout_template`) REFERENCES tlayout_template(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=UTF8MB4;

View File

@ -869,8 +869,6 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
// Change link.
if (prevProps && prevProps.isLinkEnabled !== this.props.isLinkEnabled) {
const container = this.createContainerDomElement();
// Add the children of the old element.
container.innerHTML = this.elementRef.innerHTML;
// Copy the attributes.
const attrs = this.elementRef.attributes;
for (let i = 0; i < attrs.length; i++) {
@ -879,7 +877,8 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
attrs[i].nodeName
);
if (cloneIsNeeded !== null) {
container.setAttributeNode(<any>cloneIsNeeded.cloneNode());
let cloneAttr = cloneIsNeeded.cloneNode(true) as Attr;
container.setAttributeNode(cloneAttr);
}
}
}
@ -890,6 +889,10 @@ abstract class VisualConsoleItem<Props extends ItemProps> {
// Changed the reference to the main element. It's ugly, but needed.
this.elementRef = container;
// Insert the elements into the container.
this.elementRef.appendChild(this.childElementRef);
this.elementRef.appendChild(this.labelElementRef);
}
if (