From ba097b2c5ed4ecf785e695ea6d7d332dc67a13eb Mon Sep 17 00:00:00 2001 From: Nikhil Date: Thu, 17 Jul 2025 12:41:39 +0530 Subject: [PATCH] Fixing graphs of scale --- app/Http/Controllers/APIS/AdminApi/DeviceController.php | 4 +++- app/Http/Controllers/APIS/CustomerApi/TelemetryController.php | 4 ++-- app/Services/DeviceService.php | 2 +- app/Services/TelemetryService.php | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/Http/Controllers/APIS/AdminApi/DeviceController.php b/app/Http/Controllers/APIS/AdminApi/DeviceController.php index 7351a81..7b910b9 100644 --- a/app/Http/Controllers/APIS/AdminApi/DeviceController.php +++ b/app/Http/Controllers/APIS/AdminApi/DeviceController.php @@ -42,10 +42,12 @@ class DeviceController extends Controller return jsonResponseWithErrorMessage('Name already exists', 400); } + $deviceProfileName = DeviceProfileMaster::where('id',$request->deviceProfileId)->first(); + dd($deviceProfileName['name']); $deviceData = [ 'id' => $request->id ?? null, 'name' => $request->name ?? null, - 'type' => $request->type ?? null, + 'type' => $deviceProfileName['name'] ?? null, 'label' => $request->label ?? null, 'version' => $request->version ?? 1, 'customerId' => $request->customerId ?? 1, diff --git a/app/Http/Controllers/APIS/CustomerApi/TelemetryController.php b/app/Http/Controllers/APIS/CustomerApi/TelemetryController.php index 9812bba..42d02af 100644 --- a/app/Http/Controllers/APIS/CustomerApi/TelemetryController.php +++ b/app/Http/Controllers/APIS/CustomerApi/TelemetryController.php @@ -1456,11 +1456,11 @@ class TelemetryController extends Controller $getLimit = Device::where('id', $deviceId)->select('speed_limit','torque_limit','power_limit')->first(); - $graph1['y1'] = count($key1) === 3 ? ['name' => [$x1[0]['display_name'], $x1[1]['display_name']], 'min' => $min1, 'max' => $getLimit['torque_limit'] ?? 50000] : ['name' => [$x1['display_name']], 'min' => $min1, 'max' => $getLimit['torque_limit'] ?? 50000]; + $graph1['y1'] = count($key1) === 3 ? ['name' => [$x1[0]['display_name'], $x1[1]['display_name']], 'min' => $min1, 'max' => $getLimit['torque_limit'] ?? 50000] : ['name' => [$x1['display_name']], 'min' => $min1, 'max' => $max1 ]; $graph1['y2'] = $x2 ? ['name' => [$x2['display_name']], 'min' => 0, 'max' => $getLimit['speed_limit'] ?? 50000] : null; $graph1[$date] = $value1; - $graph2['y1'] = count($key2) === 3 ? ['name' => [$y1[0]['display_name'], $y1[1]['display_name']], 'min' => $min2, 'max' => $getLimit['power_limit'] ?? 500000] : ['name' => [$y1['display_name']], 'min' => $min2, 'max' => $getLimit['power_limit'] ?? 500000]; + $graph2['y1'] = count($key2) === 3 ? ['name' => [$y1[0]['display_name'], $y1[1]['display_name']], 'min' => $min2, 'max' => $getLimit['power_limit'] ?? 500000] : ['name' => [$y1['display_name']], 'min' => $min2, 'max' => $max2 ]; $graph2['y2'] = $y2 ? ['name' => [$y2['display_name']], 'min' => 0, 'max' => $getLimit['speed_limit'] ?? 50000] : null; $graph2[$date] = $value2; } diff --git a/app/Services/DeviceService.php b/app/Services/DeviceService.php index 99cadf7..5ed0ddb 100644 --- a/app/Services/DeviceService.php +++ b/app/Services/DeviceService.php @@ -50,7 +50,7 @@ class DeviceService public function createOrUpdateDevice(array $data) { - + dd($data); $token = $this->getToken(); $payload = [ diff --git a/app/Services/TelemetryService.php b/app/Services/TelemetryService.php index 16bd28a..c3ad187 100644 --- a/app/Services/TelemetryService.php +++ b/app/Services/TelemetryService.php @@ -243,8 +243,8 @@ class TelemetryService 'value' => $this->getTypeWiseValue($key, $value), 'health_status' => !$isActive ? 'Offline' - : (in_array($displayNameMap[$key], ['Speed', 'RPM']) ? 'Offline' : $status), - // 'health_status' => $status, + : (in_array($displayNameMap[$key], ['Speed', 'RPM']) ? '' : $status), + // 'health_status' => in_array($displayNameMap[$key], ['Speed', 'RPM']) ? '' : $status, 'status_color' => !$isActive ? 'gray' : $statusColor, 'thresholds' => $thresholds, 'limit' => $thresholdLimits