Show empty gauges if not value

This commit is contained in:
2025-06-16 13:33:38 +05:30
parent 1c985ccd47
commit df23cc4a40
2 changed files with 27 additions and 23 deletions

View File

@@ -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();

View File

@@ -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
];
}
}
}
}