From 0852bcc68039682dacb69599b2146a0ccc2e3200 Mon Sep 17 00:00:00 2001 From: Nikhil Kadam Date: Fri, 16 May 2025 11:30:06 +0530 Subject: [PATCH] Setting health status color for global indicators & fixing max value key --- .../APIS/AdminApi/UsersController.php | 4 +++- app/Services/TelemetryService.php | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/APIS/AdminApi/UsersController.php b/app/Http/Controllers/APIS/AdminApi/UsersController.php index eb5b9c3..6454e0a 100644 --- a/app/Http/Controllers/APIS/AdminApi/UsersController.php +++ b/app/Http/Controllers/APIS/AdminApi/UsersController.php @@ -257,7 +257,7 @@ class UsersController extends Controller 'default_dashboard_fullscreen' => $request->default_dashboard_fullscreen ?? false, 'home_dashboard_id' => $request->home_dashboard_id ?? null, 'home_dashboard_hide_toolbar' => $request->home_dashboard_hide_toolbar ?? false, - 'user_credentials_enabled' => $request->user_credentials_enabled ?? false, + 'user_credentials_enabled' => 0, 'failed_login_attempts' => $request->failed_login_attempts ?? 0, 'last_login_ts' => $request->last_login_ts, 'version' => $request->version ?? 0, @@ -335,6 +335,7 @@ class UsersController extends Controller if (!empty($users)) { return response()->json([ 'message' => 'Users fetched successfully', + 'count' => $users->count(), 'users' => $users ], 200); } @@ -506,6 +507,7 @@ class UsersController extends Controller // Update password in Laravel $user->password = Hash::make('password'); + $user->user_credentials_enabled = 1; $user->save(); Log::info("Password updated for User ID: {$id} in Laravel."); diff --git a/app/Services/TelemetryService.php b/app/Services/TelemetryService.php index c48e6b5..68e3b5c 100644 --- a/app/Services/TelemetryService.php +++ b/app/Services/TelemetryService.php @@ -89,22 +89,22 @@ class TelemetryService { return [ 'ChannelSpeed' => [ - ['min' => 0, 'color' => 50000] + ['min' => 0, 'max' => 50000] ], 'PowerLoss_value' => [ - ['min' => 0, 'color' => 10] + ['min' => 0, 'max' => 10] ], 'GlobalLevel_value' => [ - ['min' => 0, 'color' => 10] + ['min' => 0, 'max' => 10] ], 'StaticTorque_value' => [ - ['min' => 0, 'color' => 50000] + ['min' => 0, 'max' => 50000] ], 'StaticPower_value' => [ - ['min' => 0, 'color' => 500000] + ['min' => 0, 'max' => 500000] ], 'default' => [ - ['min' => 0, 'color' => 100] + ['min' => 0, 'max' => 100] ] ]; } @@ -139,11 +139,17 @@ class TelemetryService $thresholdLimits = $this->getThresholdLimit()[$key] ?? $this->getThresholdLimit()['default']; $status = $this->getHealthStatus($value, $thresholds); + $statusColor = match($status) { + 'Alert' => 'red', + 'Attention' => 'orange', + 'Stable' => 'green' + }; $transformedTelemetry[] = [ 'display_name' => $displayNameMap[$key] ?? $key, 'value' => number_format((float)$value, 2), 'health_status' => $status, + 'status_color' => $statusColor, 'thresholds' => $thresholds, 'limit' => $thresholdLimits ];