Merge branch 'visual-console-refactor' of https://brutus.artica.lan:8081/artica/pandorafms into visual-console-refactor
Former-commit-id: cae1d1fbf8efb664d5042877d63584c4699801ab
This commit is contained in:
commit
eb1e505a79
|
@ -158,8 +158,8 @@ class Item extends Model
|
|||
|
||||
// The item uses HTML output.
|
||||
if (static::$useHtmlOutput === true) {
|
||||
if (static::notEmptyStringOr($data['encodedHtml'], null) === null
|
||||
&& static::notEmptyStringOr($data['html'], null) === null
|
||||
if (static::notEmptyStringOr(static::issetInArray($data, ['encodedHtml']), null) === null
|
||||
&& static::notEmptyStringOr(static::issetInArray($data, ['html']), null) === null
|
||||
) {
|
||||
throw new \InvalidArgumentException(
|
||||
'the html property is required and should be a not empty string'
|
||||
|
|
|
@ -44,7 +44,7 @@ final class ColorCloud extends Item
|
|||
$decodedData['label'] = null;
|
||||
$decodedData['defaultColor'] = static::extractDefaultColor($data);
|
||||
$decodedData['colorRanges'] = static::extractColorRanges($data);
|
||||
$decodedData['color'] = static::notEmptyStringOr($data['color'], null);
|
||||
$decodedData['color'] = static::notEmptyStringOr(static::issetInArray($data, ['color']), null);
|
||||
|
||||
return $decodedData;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@ final class Label extends Item
|
|||
protected function validateData(array $data): void
|
||||
{
|
||||
parent::validateData($data);
|
||||
if (static::notEmptyStringOr($data['label'], null) === null) {
|
||||
if (static::notEmptyStringOr(static::issetInArray($data, ['label']), null) === null) {
|
||||
throw new \InvalidArgumentException(
|
||||
'the label property is required and should be a not empty string'
|
||||
);
|
||||
|
|
|
@ -43,16 +43,22 @@ final class Percentile extends Item
|
|||
$return['type'] = PERCENTILE_BAR;
|
||||
$return['percentileType'] = static::extractPercentileType($data);
|
||||
$return['valueType'] = static::extractValueType($data);
|
||||
$return['minValue'] = static::parseFloatOr($data['minValue'], null);
|
||||
$return['minValue'] = static::parseFloatOr(
|
||||
static::issetInArray($data, ['minValue']),
|
||||
null
|
||||
);
|
||||
$return['maxValue'] = static::parseFloatOr(
|
||||
static::issetInArray($data, ['maxValue', 'height']),
|
||||
null
|
||||
);
|
||||
$return['color'] = static::extractColor($data);
|
||||
$return['labelColor'] = static::extractLabelColor($data);
|
||||
$return['value'] = static::parseFloatOr($data['value'], null);
|
||||
$return['displayValue'] = static::notEmptyStringOr(
|
||||
$data['displayValue'],
|
||||
$return['value'] = static::parseFloatOr(
|
||||
static::issetInArray($data, ['value']),
|
||||
null
|
||||
);
|
||||
$return['unit'] = static::notEmptyStringOr(
|
||||
static::issetInArray($data, ['unit']),
|
||||
null
|
||||
);
|
||||
return $return;
|
||||
|
|
|
@ -86,15 +86,31 @@ final class SimpleValue extends Item
|
|||
*/
|
||||
private static function extractProcessValue(array $data): string
|
||||
{
|
||||
switch ($data['processValue']) {
|
||||
case 'none':
|
||||
case 'avg':
|
||||
case 'max':
|
||||
case 'min':
|
||||
return $data['processValue'];
|
||||
if (isset($data['processValue'])) {
|
||||
switch ($data['processValue']) {
|
||||
case 'none':
|
||||
case 'avg':
|
||||
case 'max':
|
||||
case 'min':
|
||||
return $data['processValue'];
|
||||
|
||||
default:
|
||||
return 'none';
|
||||
default:
|
||||
return 'none';
|
||||
}
|
||||
} else {
|
||||
switch ($data['type']) {
|
||||
case SIMPLE_VALUE_MAX:
|
||||
return 'max';
|
||||
|
||||
case SIMPLE_VALUE_MIN:
|
||||
return 'min';
|
||||
|
||||
case SIMPLE_VALUE_AVG:
|
||||
return 'avg';
|
||||
|
||||
default:
|
||||
return 'none';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,7 +124,10 @@ final class SimpleValue extends Item
|
|||
*/
|
||||
private static function extractPeriod(array $data): int
|
||||
{
|
||||
$period = static::parseIntOr($data['period'], 0);
|
||||
$period = static::parseIntOr(
|
||||
static::issetInArray($data, ['period']),
|
||||
0
|
||||
);
|
||||
return ($period >= 0) ? $period : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ final class StaticGraph extends Item
|
|||
$return['imageSrc'] = $this->extractImageSrc($data);
|
||||
$return['showLastValueTooltip'] = $this->extractShowLastValueTooltip($data);
|
||||
$return['statusImageSrc'] = static::notEmptyStringOr(
|
||||
$data['statusImageSrc'],
|
||||
static::issetInArray($data, ['statusImageSrc']),
|
||||
null
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue