Show empty gauges if not value
This commit is contained in:
@@ -1297,13 +1297,6 @@ class TelemetryController extends Controller
|
||||
$cachedData = Cache::remember($cacheKey, now()->addSeconds(value: 60), function () use ($deviceId) {
|
||||
$deviceParams = $this->getPopupTimeseriesKeys($deviceId);
|
||||
|
||||
if ($deviceParams->isEmpty()) {
|
||||
return [
|
||||
'success' => false,
|
||||
'error' => 'No indicator parameters found for this device'
|
||||
];
|
||||
}
|
||||
|
||||
$keyNameList = $deviceParams->pluck('key_name')->implode(',');
|
||||
$displayNameMap = $deviceParams->pluck('display_name', 'key_name')->toArray();
|
||||
|
||||
|
||||
@@ -220,23 +220,34 @@ class TelemetryService
|
||||
$thresholds = $this->getThresholdMap()[$key] ?? $this->getThresholdMap()['default'];
|
||||
$thresholdLimits = $this->getThresholdLimit($deviceId)[$key] ?? $this->getThresholdLimit($deviceId)['default'];
|
||||
|
||||
$status = $this->getHealthStatus($value, $thresholds);
|
||||
$statusColor = match($status) {
|
||||
'Alert' => 'red',
|
||||
'Attention' => 'orange',
|
||||
'Stable' => 'green'
|
||||
};
|
||||
if(!$value){
|
||||
$transformedTelemetry[] = [
|
||||
'display_name' => $displayNameMap[$key] ?? $key,
|
||||
'value' => "",
|
||||
'health_status' => "",
|
||||
'status_color' => "",
|
||||
'thresholds' => $thresholds,
|
||||
'limit' => $thresholdLimits
|
||||
];
|
||||
} else {
|
||||
$status = $this->getHealthStatus($value, $thresholds);
|
||||
$statusColor = match($status) {
|
||||
'Alert' => 'red',
|
||||
'Attention' => 'orange',
|
||||
'Stable' => 'green'
|
||||
};
|
||||
|
||||
$transformedTelemetry[] = [
|
||||
'display_name' => $displayNameMap[$key] ?? $key,
|
||||
'value' => $this->getTypeWiseValue($key, $value),
|
||||
'health_status' => !$isActive
|
||||
? 'Offline'
|
||||
: (in_array($displayNameMap[$key], ['Speed', 'RPM']) ? 'Offline' : $status),
|
||||
'status_color' => !$isActive ? 'gray' : $statusColor,
|
||||
'thresholds' => $thresholds,
|
||||
'limit' => $thresholdLimits
|
||||
];
|
||||
$transformedTelemetry[] = [
|
||||
'display_name' => $displayNameMap[$key] ?? $key,
|
||||
'value' => $this->getTypeWiseValue($key, $value),
|
||||
'health_status' => !$isActive
|
||||
? 'Offline'
|
||||
: (in_array($displayNameMap[$key], ['Speed', 'RPM']) ? 'Offline' : $status),
|
||||
'status_color' => !$isActive ? 'gray' : $statusColor,
|
||||
'thresholds' => $thresholds,
|
||||
'limit' => $thresholdLimits
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user