diff --git a/pandora_console/include/rest-api/models/VisualConsole/Item.php b/pandora_console/include/rest-api/models/VisualConsole/Item.php index c99dc02e9d..55b6387946 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Item.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Item.php @@ -1586,12 +1586,35 @@ class Item extends CachedModel $result['timezone'] = $timezone; } - $show_last_value = static::parseIntOr( - static::issetInArray($data, ['show_last_value', 'showLastValue']), + $show_last_value = static::notEmptyStringOr( + static::issetInArray($data, ['showLastValueTooltip']), null ); + if ($show_last_value === null) { + $show_last_value = static::parseIntOr( + static::issetInArray($data, ['show_last_value', 'showLastValue']), + null + ); + } + if ($show_last_value !== null) { - $result['show_last_value'] = $show_last_value; + if (\is_numeric($show_last_value) === true) { + $result['show_last_value'] = $show_last_value; + } else { + switch ($show_last_value) { + case 'enabled': + $result['show_last_value'] = 1; + break; + + case 'disabled': + $result['show_last_value'] = 2; + break; + + default: + $result['show_last_value'] = 0; + break; + } + } } $cacheExpiration = static::extractCacheExpiration($data); diff --git a/visual_console_client/src/items/StaticGraph.ts b/visual_console_client/src/items/StaticGraph.ts index 0a504be48b..a00d9f4419 100644 --- a/visual_console_client/src/items/StaticGraph.ts +++ b/visual_console_client/src/items/StaticGraph.ts @@ -94,7 +94,8 @@ class ShowLastValueInputGroup extends InputGroup> { const showLastValueSelect = document.createElement("select"); showLastValueSelect.required = true; - showLastValueSelect.value = + + const currentValue = this.currentData.showLastValueTooltip || this.initialData.showLastValueTooltip || "default"; @@ -103,6 +104,9 @@ class ShowLastValueInputGroup extends InputGroup> { const optionElement = document.createElement("option"); optionElement.value = option.value; optionElement.textContent = option.text; + if (currentValue == optionElement.value) { + optionElement.selected = true; + } showLastValueSelect.appendChild(optionElement); });