Fixed Line class

Former-commit-id: 639649f4d65340ff25ecc1e956298705f5d13a05
This commit is contained in:
Daniel Maya 2019-04-16 12:18:53 +02:00
parent fa1bf821e2
commit 9be6029e1a
4 changed files with 10 additions and 24 deletions

View File

@ -376,7 +376,7 @@ final class Container extends Model
$class = static::getItemClass($itemType);
try {
\array_push($items, $class::fromDBWithId($itemId));
\array_push($items, $class::fromDB(['id' => $itemId]));
} catch (\Throwable $e) {
// TODO: Log this?
}

View File

@ -1073,18 +1073,4 @@ class Item extends Model
}
/**
* Obtain a vc item instance from the database using an identifier.
*
* @param integer $id Identifier of the Visual Console Item.
*
* @return mixed The Visual Console Item data structure stored into the DB.
* @throws \Exception When the data cannot be retrieved from the DB.
*/
public static function fromDBWithId(int $id)
{
return static::fromDB(['id' => $id]);
}
}

View File

@ -191,7 +191,7 @@ final class StaticGraph extends Item
// Get last value.
if (isset($data['show_last_value']) && $data['show_last_value'] !== 2) {
$img_style_title = '';
$imgTitle = '';
$unit_text = \trim(\io_safe_output(\modules_get_unit($moduleId)));
@ -201,17 +201,17 @@ final class StaticGraph extends Item
|| (\modules_is_boolean($moduleId) && $data['show_last_value'] != 0)
) {
if (\is_numeric($value)) {
$img_style_title .= __('Last value: ').remove_right_zeros($value);
$imgTitle .= __('Last value: ').remove_right_zeros($value);
} else {
$img_style_title .= __('Last value: ').$value;
$imgTitle .= __('Last value: ').$value;
}
}
if (empty($unit_text) === false && empty($img_style_title) === false) {
$img_style_title .= ' '.$unit_text;
if (empty($unit_text) === false && empty($imgTitle) === false) {
$imgTitle .= ' '.$unit_text;
}
$data['lastValue'] = $img_style_title;
$data['lastValue'] = $imgTitle;
}
// Restore connection.

View File

@ -27,7 +27,7 @@ interface LineProps extends ItemProps {
*/
export function linePropsDecoder(data: UnknownObject): LineProps | never {
return {
...itemBasePropsDecoder(data), // Object spread. It will merge the properties of the two objects.
...itemBasePropsDecoder({ ...data, width: 1, height: 1 }), // Object spread. It will merge the properties of the two objects.
type: ItemType.LINE_ITEM,
label: null,
isLinkEnabled: false,
@ -47,8 +47,8 @@ export function linePropsDecoder(data: UnknownObject): LineProps | never {
x: parseIntOr(data.endX, 0),
y: parseIntOr(data.endY, 0)
},
lineWidth: parseIntOr(data.lineWidth, 1),
color: notEmptyStringOr(data.color, null)
lineWidth: parseIntOr(data.borderWidth, 1),
color: notEmptyStringOr(data.borderColor, null)
};
}