Resolving health status color issue
This commit is contained in:
@@ -24,28 +24,64 @@ class TelemetryService
|
||||
{
|
||||
$hasRed = false;
|
||||
$hasOrange = false;
|
||||
$hasBlue = false;
|
||||
|
||||
foreach ($values as $value) {
|
||||
if ($value['key_name'] == 'PowerLoss_value') {
|
||||
if ($value['value'] > 5 && $value['value'] < 10) {
|
||||
$hasRed = true;
|
||||
$key = $value['key_name'];
|
||||
$val = $value['value'];
|
||||
|
||||
switch ($key) {
|
||||
case 'PowerLoss_value':
|
||||
if ($val > 5 && $val < 10) {
|
||||
return 'red';
|
||||
} elseif ($val > 2.5 && $val < 6) {
|
||||
$hasOrange = true;
|
||||
}
|
||||
break;
|
||||
} elseif ($value['value'] > 2.5 && $value['value'] < 5) {
|
||||
$hasOrange = true;
|
||||
}
|
||||
} else {
|
||||
if ($value['value'] > 0 && $value['value'] < 31) {
|
||||
$hasRed = true;
|
||||
|
||||
case 'GlobalLevel_value':
|
||||
if ($val > 6 && $val < 10) {
|
||||
return 'red';
|
||||
} elseif ($val > 3 && $val < 7) {
|
||||
$hasOrange = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'PropellerEfficiency_value':
|
||||
if ($val > 5 && $val < 10) {
|
||||
return 'red';
|
||||
} elseif ($val > 3 && $val < 6) {
|
||||
$hasOrange = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'OT':
|
||||
case 'AT':
|
||||
$val > 50 ? $hasBlue = true : $hasRed = true;
|
||||
break;
|
||||
|
||||
case 'TDN':
|
||||
if ($val > 0 && $val < 401) {
|
||||
return 'red';
|
||||
} elseif ($val < 701) {
|
||||
$hasOrange = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if ($val > 0 && $val < 31) {
|
||||
return 'red';
|
||||
} elseif ($val < 71) {
|
||||
$hasOrange = true;
|
||||
}
|
||||
break;
|
||||
} elseif ($value['value'] < 71) {
|
||||
$hasOrange = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $hasRed ? 'red' : ($hasOrange ? 'orange' : 'green');
|
||||
}
|
||||
|
||||
|
||||
public function getAssetHealth(array $deviceHealthStatuses): string
|
||||
{
|
||||
if (in_array('red', $deviceHealthStatuses)) {
|
||||
|
||||
Reference in New Issue
Block a user