Changing routes on baseUrl changed

This commit is contained in:
Nikhil Kadam
2025-05-15 11:55:51 +05:30
parent 42ebc1d71c
commit ef90e65066
22 changed files with 469 additions and 31 deletions

View File

@@ -46,7 +46,7 @@ class AdminDashboardController extends Controller
$response = Http::withHeaders([
'Authorization' => "Bearer $token",
'Accept' => 'application/json',
])->get("$baseUrl/api/device/info/{$deviceId}");
])->get("{$baseUrl}api/device/info/{$deviceId}");
if ($response->successful()) {
$deviceInfo = $response->json();
@@ -59,7 +59,7 @@ class AdminDashboardController extends Controller
$alarmsResponse = Http::withHeaders([
'Authorization' => "Bearer $token",
'Accept' => 'application/json',
])->get("$baseUrl/api/v2/alarms", [
])->get("{$baseUrl}api/v2/alarms", [
'pageSize' => 1000,
'page' => 0,
'status' => 'ACTIVE'

View File

@@ -23,7 +23,7 @@ class CustomerDeviceInfoController extends Controller
$this->customerInfoService = $customerInfoService;
}
@@ -243,7 +243,7 @@ class CustomerDeviceInfoController extends Controller
$telemetryResponse = Http::withHeaders([
'accept' => 'application/json',
'Authorization' => 'Bearer ' . $bearerToken,
])->get("$apiBaseUrl/api/plugins/telemetry/DEVICE/{$device->id}/values/timeseries", [
])->get("{$apiBaseUrl}api/plugins/telemetry/DEVICE/{$device->id}/values/timeseries", [
'useStrictDataTypes' => 'false'
]);

View File

@@ -321,7 +321,7 @@ class TelemetryController extends Controller
$deviceInfoResponse = Http::withHeaders([
'Authorization' => "Bearer $deviceInfoToken",
'Accept' => 'application/json',
])->get("$baseUrl/api/device/info/{$device->id}");
])->get("{$baseUrl}api/device/info/{$device->id}");
if ($deviceInfoResponse->successful()) {
$deviceInfo = $deviceInfoResponse->json();
@@ -446,7 +446,7 @@ class TelemetryController extends Controller
$response = Http::withHeaders([
'Authorization' => "Bearer $token",
'Accept' => 'application/json',
])->get("$baseUrl/api/v2/alarms", [
])->get("{$baseUrl}api/v2/alarms", [
'statusList' => 'ACTIVE',
'severityList' => 'CRITICAL,MAJOR,MINOR,WARNING',
'pageSize' => $pageSize,
@@ -867,12 +867,12 @@ class TelemetryController extends Controller
$cacheKey = "user_assets_health_{$userId}";
// Cache for 1 hour
$formattedData = Cache::remember($cacheKey, now()->addHours(value: 1), function () use ($userId) {
// $formattedData = Cache::remember($cacheKey, now()->addHours(value: 1), function () use ($userId) {
$assetDeviceListing = UserAssetLink::with('asset.devices')
->where(['user_id' => $userId, 'active' => 1])
->get();
return $assetDeviceListing->map(function ($link) {
$formattedData = $assetDeviceListing->map(function ($link) {
$asset = $link->asset;
$deviceHealthStatuses = [];
@@ -895,7 +895,7 @@ class TelemetryController extends Controller
'devices' => $devicesData
];
});
});
// });
return response()->json(['success' => true, 'data' => $formattedData]);

View File

@@ -320,7 +320,7 @@ class UserAssetLinkController extends Controller
$deviceResponse = Http::withHeaders([
'accept' => 'application/json',
'Authorization' => 'Bearer ' . $bearerToken,
])->get("$apiBaseUrl/api/customer/{$device->customer_id}/deviceInfos", [
])->get("{$apiBaseUrl}api/customer/{$device->customer_id}/deviceInfos", [
'pageSize' => 100,
'page' => 0
]);
@@ -349,7 +349,7 @@ class UserAssetLinkController extends Controller
$dailyResponse = Http::withHeaders([
'accept' => 'application/json',
'Authorization' => 'Bearer ' . $bearerToken,
])->get("$apiBaseUrl/api/plugins/telemetry/DEVICE/{$device->id}/values/timeseries", [
])->get("{$apiBaseUrl}api/plugins/telemetry/DEVICE/{$device->id}/values/timeseries", [
'startTs' => $startOfDay->timestamp * 1000,
'endTs' => $endOfDay->timestamp * 1000,
'useStrictDataTypes' => 'false'
@@ -380,7 +380,7 @@ class UserAssetLinkController extends Controller
$telemetryResponse = Http::withHeaders([
'accept' => 'application/json',
'Authorization' => 'Bearer ' . $bearerToken,
])->get("$apiBaseUrl/api/plugins/telemetry/DEVICE/{$device->id}/values/timeseries");
])->get("{$apiBaseUrl}api/plugins/telemetry/DEVICE/{$device->id}/values/timeseries");
$telemetryData = $telemetryResponse->successful() ? $telemetryResponse->json() : [];

View File

@@ -108,7 +108,7 @@ class AlarmControllerCommon extends Controller
{
try {
$token = app('App\Services\AdminService')->getToken(); // Fetch cached token0
$url = env('THINGSBOARD_URL') . "/api/alarm/{$id}";
$url = env('THINGSBOARD_URL') . "api/alarm/{$id}";
$getResponse = Http::withHeaders([
'X-Authorization' => 'Bearer ' . $token,
@@ -130,7 +130,7 @@ class AlarmControllerCommon extends Controller
]);
}
$ackUrl = env('THINGSBOARD_URL') . "/api/alarm/{$id}/ack";
$ackUrl = env('THINGSBOARD_URL') . "api/alarm/{$id}/ack";
$ackResponse = Http::withHeaders([
'X-Authorization' => 'Bearer ' . $token,
@@ -160,7 +160,7 @@ class AlarmControllerCommon extends Controller
{
try {
$token = app(AdminService::class)->getToken(); // Fetch cached token
$url = env('THINGSBOARD_URL') . "/api/alarm/{$id}";
$url = env('THINGSBOARD_URL') . "api/alarm/{$id}";
// Fetch the alarm details first
$getResponse = Http::withHeaders([
@@ -184,7 +184,7 @@ class AlarmControllerCommon extends Controller
}
// Clear the alarm
$clearUrl = env('THINGSBOARD_URL') . "/api/alarm/{$id}/clear";
$clearUrl = env('THINGSBOARD_URL') . "api/alarm/{$id}/clear";
$clearResponse = Http::withHeaders([
'X-Authorization' => 'Bearer ' . $token,
'accept' => 'application/json',
@@ -277,7 +277,7 @@ class AlarmControllerCommon extends Controller
$response = Http::withHeaders([
'Authorization' => "Bearer $token",
'Accept' => 'application/json',
])->get("$baseUrl/api/v2/alarms", [
])->get("{$baseUrl}api/v2/alarms", [
'statusList' => 'ACTIVE',
'severityList' => 'CRITICAL,MAJOR,MINOR,WARNING',
'pageSize' => $pageSize,

View File

@@ -11,7 +11,10 @@ class AppServiceProvider extends ServiceProvider
*/
public function register(): void
{
//
if ($this->app->environment('local') && class_exists(\Laravel\Telescope\TelescopeServiceProvider::class)) {
$this->app->register(\Laravel\Telescope\TelescopeServiceProvider::class);
$this->app->register(TelescopeServiceProvider::class);
}
}
/**

View File

@@ -0,0 +1,64 @@
<?php
namespace App\Providers;
use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider
{
/**
* Register any application services.
*/
public function register(): void
{
// Telescope::night();
$this->hideSensitiveRequestDetails();
$isLocal = $this->app->environment('local');
Telescope::filter(function (IncomingEntry $entry) use ($isLocal) {
return $isLocal ||
$entry->isReportableException() ||
$entry->isFailedRequest() ||
$entry->isFailedJob() ||
$entry->isScheduledTask() ||
$entry->hasMonitoredTag();
});
}
/**
* Prevent sensitive request details from being logged by Telescope.
*/
protected function hideSensitiveRequestDetails(): void
{
if ($this->app->environment('local')) {
return;
}
Telescope::hideRequestParameters(['_token']);
Telescope::hideRequestHeaders([
'cookie',
'x-csrf-token',
'x-xsrf-token',
]);
}
/**
* Register the Telescope gate.
*
* This gate determines who can access Telescope in non-local environments.
*/
protected function gate(): void
{
Gate::define('viewTelescope', function ($user) {
return in_array($user->email, [
//
]);
});
}
}

View File

@@ -34,7 +34,7 @@ class AdminDeviceProfileMaster
// 'accept' => 'application/json',
'Content-Type' => 'application/json',
])
->post("{$this->baseUrl}/api/auth/login", [
->post("{$this->baseUrl}api/auth/login", [
'username' => $this->username,
'password' => $this->password,
]);
@@ -51,5 +51,5 @@ class AdminDeviceProfileMaster
}
}

View File

@@ -281,7 +281,7 @@ class AlarmService
$response = Http::withHeaders([
'Authorization' => "Bearer $token",
'Accept' => 'application/json'
])->get("$baseUrl/api/plugins/telemetry/DEVICE/{$deviceId}/values/timeseries", [
])->get("{$baseUrl}api/plugins/telemetry/DEVICE/{$deviceId}/values/timeseries", [
'keys' => $keys,
'startTs' => $startTs,
'interval' => $endTs,

View File

@@ -92,7 +92,7 @@ class CustomerInfoService
$response = Http::withHeaders([
'Authorization' => "Bearer $token",
'Accept' => 'application/json',
])->get("$baseUrl/api/plugins/telemetry/DEVICE/{$deviceId}/values/timeseries", $queryParams);
])->get("{$baseUrl}api/plugins/telemetry/DEVICE/{$deviceId}/values/timeseries", $queryParams);
// Check if the response was successful
if (!$response->successful()) {
@@ -153,7 +153,7 @@ class CustomerInfoService
$response = Http::withHeaders([
'Authorization' => "Bearer $token",
'Accept' => 'application/json',
])->get("$baseUrl/api/plugins/telemetry/DEVICE/{$deviceId}/values/timeseries", $queryParams);
])->get("{$baseUrl}api/plugins/telemetry/DEVICE/{$deviceId}/values/timeseries", $queryParams);
@@ -372,7 +372,7 @@ class CustomerInfoService
// 'accept' => 'application/json',
'Content-Type' => 'application/json',
])
->post("{$baseUrl}/api/auth/login", [
->post("{$baseUrl}api/auth/login", [
'username' => $username,
'password' => $password,
]);

View File

@@ -31,7 +31,7 @@ class DeviceService
'accept' => 'application/json',
'Content-Type' => 'application/json',
])
->post("{$this->baseUrl}/api/auth/login", [
->post("{$this->baseUrl}api/auth/login", [
'username' => $this->username,
'password' => $this->password,
]);
@@ -96,7 +96,7 @@ class DeviceService
$url = "{$this->baseUrl}/api/device";
$url = "{$this->baseUrl}api/device";
$method = 'post';
$response = Http::withHeaders([
@@ -122,7 +122,7 @@ class DeviceService
$token = $this->getToken();
$url = "{$this->baseUrl}/api/device/{$data['deviceId']}";
$url = "{$this->baseUrl}api/device/{$data['deviceId']}";
$response = Http::withHeaders([
'Authorization' => "Bearer $token",

View File

@@ -93,7 +93,7 @@ class RuleChainService
'accept' => 'application/json',
'Content-Type' => 'application/json',
'X-Authorization' => "Bearer {$token}",
])->get("{$this->baseUrl}/api/ruleChains/export", [
])->get("{$this->baseUrl}api/ruleChains/export", [
'limit' => $limit
]);

View File

@@ -3,4 +3,5 @@
return [
App\Providers\AppServiceProvider::class,
App\Providers\RouteServiceProvider::class,
// App\Providers\TelescopeServiceProvider::class,
];

View File

@@ -18,6 +18,7 @@
"laravel/pail": "^1.2.2",
"laravel/pint": "^1.13",
"laravel/sail": "^1.41",
"laravel/telescope": "^5.7",
"mockery/mockery": "^1.6",
"nunomaduro/collision": "^8.6",
"phpunit/phpunit": "^11.5.3"
@@ -61,7 +62,9 @@
},
"extra": {
"laravel": {
"dont-discover": []
"dont-discover": [
"laravel/telescope"
]
}
},
"config": {

73
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "1bba97d230b8ab68157468ff078d2d97",
"content-hash": "8d3d61a18d5d707559ad51cadb5c7248",
"packages": [
{
"name": "brick/math",
@@ -7058,6 +7058,75 @@
},
"time": "2025-01-24T15:45:36+00:00"
},
{
"name": "laravel/telescope",
"version": "v5.7.0",
"source": {
"type": "git",
"url": "https://github.com/laravel/telescope.git",
"reference": "440908cb856cfbef9323244f7978ad4bf8cd2daa"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/telescope/zipball/440908cb856cfbef9323244f7978ad4bf8cd2daa",
"reference": "440908cb856cfbef9323244f7978ad4bf8cd2daa",
"shasum": ""
},
"require": {
"ext-json": "*",
"laravel/framework": "^8.37|^9.0|^10.0|^11.0|^12.0",
"php": "^8.0",
"symfony/console": "^5.3|^6.0|^7.0",
"symfony/var-dumper": "^5.0|^6.0|^7.0"
},
"require-dev": {
"ext-gd": "*",
"guzzlehttp/guzzle": "^6.0|^7.0",
"laravel/octane": "^1.4|^2.0|dev-develop",
"orchestra/testbench": "^6.40|^7.37|^8.17|^9.0|^10.0",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9.0|^10.5|^11.5"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Laravel\\Telescope\\TelescopeServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Laravel\\Telescope\\": "src/",
"Laravel\\Telescope\\Database\\Factories\\": "database/factories/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Taylor Otwell",
"email": "taylor@laravel.com"
},
{
"name": "Mohamed Said",
"email": "mohamed@laravel.com"
}
],
"description": "An elegant debug assistant for the Laravel framework.",
"keywords": [
"debugging",
"laravel",
"monitoring"
],
"support": {
"issues": "https://github.com/laravel/telescope/issues",
"source": "https://github.com/laravel/telescope/tree/v5.7.0"
},
"time": "2025-03-27T17:25:52+00:00"
},
{
"name": "mockery/mockery",
"version": "1.6.12",
@@ -8951,5 +9020,5 @@
"php": "^8.2"
},
"platform-dev": [],
"plugin-api-version": "2.6.0"
"plugin-api-version": "2.2.0"
}

206
config/telescope.php Normal file
View File

@@ -0,0 +1,206 @@
<?php
use Laravel\Telescope\Http\Middleware\Authorize;
use Laravel\Telescope\Watchers;
return [
/*
|--------------------------------------------------------------------------
| Telescope Master Switch
|--------------------------------------------------------------------------
|
| This option may be used to disable all Telescope watchers regardless
| of their individual configuration, which simply provides a single
| and convenient way to enable or disable Telescope data storage.
|
*/
'enabled' => env('TELESCOPE_ENABLED', true),
/*
|--------------------------------------------------------------------------
| Telescope Domain
|--------------------------------------------------------------------------
|
| This is the subdomain where Telescope will be accessible from. If the
| setting is null, Telescope will reside under the same domain as the
| application. Otherwise, this value will be used as the subdomain.
|
*/
'domain' => env('TELESCOPE_DOMAIN'),
/*
|--------------------------------------------------------------------------
| Telescope Path
|--------------------------------------------------------------------------
|
| This is the URI path where Telescope will be accessible from. Feel free
| to change this path to anything you like. Note that the URI will not
| affect the paths of its internal API that aren't exposed to users.
|
*/
'path' => env('TELESCOPE_PATH', 'telescope'),
/*
|--------------------------------------------------------------------------
| Telescope Storage Driver
|--------------------------------------------------------------------------
|
| This configuration options determines the storage driver that will
| be used to store Telescope's data. In addition, you may set any
| custom options as needed by the particular driver you choose.
|
*/
'driver' => env('TELESCOPE_DRIVER', 'database'),
'storage' => [
'database' => [
'connection' => env('DB_CONNECTION', 'mysql'),
'chunk' => 1000,
],
],
/*
|--------------------------------------------------------------------------
| Telescope Queue
|--------------------------------------------------------------------------
|
| This configuration options determines the queue connection and queue
| which will be used to process ProcessPendingUpdate jobs. This can
| be changed if you would prefer to use a non-default connection.
|
*/
'queue' => [
'connection' => env('TELESCOPE_QUEUE_CONNECTION', null),
'queue' => env('TELESCOPE_QUEUE', null),
'delay' => env('TELESCOPE_QUEUE_DELAY', 10),
],
/*
|--------------------------------------------------------------------------
| Telescope Route Middleware
|--------------------------------------------------------------------------
|
| These middleware will be assigned to every Telescope route, giving you
| the chance to add your own middleware to this list or change any of
| the existing middleware. Or, you can simply stick with this list.
|
*/
'middleware' => [
'web',
Authorize::class,
],
/*
|--------------------------------------------------------------------------
| Allowed / Ignored Paths & Commands
|--------------------------------------------------------------------------
|
| The following array lists the URI paths and Artisan commands that will
| not be watched by Telescope. In addition to this list, some Laravel
| commands, like migrations and queue commands, are always ignored.
|
*/
'only_paths' => [
// 'api/*'
],
'ignore_paths' => [
'livewire*',
'nova-api*',
'pulse*',
],
'ignore_commands' => [
//
],
/*
|--------------------------------------------------------------------------
| Telescope Watchers
|--------------------------------------------------------------------------
|
| The following array lists the "watchers" that will be registered with
| Telescope. The watchers gather the application's profile data when
| a request or task is executed. Feel free to customize this list.
|
*/
'watchers' => [
Watchers\BatchWatcher::class => env('TELESCOPE_BATCH_WATCHER', true),
Watchers\CacheWatcher::class => [
'enabled' => env('TELESCOPE_CACHE_WATCHER', true),
'hidden' => [],
],
Watchers\ClientRequestWatcher::class => env('TELESCOPE_CLIENT_REQUEST_WATCHER', true),
Watchers\CommandWatcher::class => [
'enabled' => env('TELESCOPE_COMMAND_WATCHER', true),
'ignore' => [],
],
Watchers\DumpWatcher::class => [
'enabled' => env('TELESCOPE_DUMP_WATCHER', true),
'always' => env('TELESCOPE_DUMP_WATCHER_ALWAYS', false),
],
Watchers\EventWatcher::class => [
'enabled' => env('TELESCOPE_EVENT_WATCHER', true),
'ignore' => [],
],
Watchers\ExceptionWatcher::class => env('TELESCOPE_EXCEPTION_WATCHER', true),
Watchers\GateWatcher::class => [
'enabled' => env('TELESCOPE_GATE_WATCHER', true),
'ignore_abilities' => [],
'ignore_packages' => true,
'ignore_paths' => [],
],
Watchers\JobWatcher::class => env('TELESCOPE_JOB_WATCHER', true),
Watchers\LogWatcher::class => [
'enabled' => env('TELESCOPE_LOG_WATCHER', true),
'level' => 'error',
],
Watchers\MailWatcher::class => env('TELESCOPE_MAIL_WATCHER', true),
Watchers\ModelWatcher::class => [
'enabled' => env('TELESCOPE_MODEL_WATCHER', true),
'events' => ['eloquent.*'],
'hydrations' => true,
],
Watchers\NotificationWatcher::class => env('TELESCOPE_NOTIFICATION_WATCHER', true),
Watchers\QueryWatcher::class => [
'enabled' => env('TELESCOPE_QUERY_WATCHER', true),
'ignore_packages' => true,
'ignore_paths' => [],
'slow' => 100,
],
Watchers\RedisWatcher::class => env('TELESCOPE_REDIS_WATCHER', true),
Watchers\RequestWatcher::class => [
'enabled' => env('TELESCOPE_REQUEST_WATCHER', true),
'size_limit' => env('TELESCOPE_RESPONSE_SIZE_LIMIT', 64),
'ignore_http_methods' => [],
'ignore_status_codes' => [],
],
Watchers\ScheduleWatcher::class => env('TELESCOPE_SCHEDULE_WATCHER', true),
Watchers\ViewWatcher::class => env('TELESCOPE_VIEW_WATCHER', true),
],
];

View File

@@ -0,0 +1,70 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Get the migration connection name.
*/
public function getConnection(): ?string
{
return config('telescope.storage.database.connection');
}
/**
* Run the migrations.
*/
public function up(): void
{
$schema = Schema::connection($this->getConnection());
$schema->create('telescope_entries', function (Blueprint $table) {
$table->bigIncrements('sequence');
$table->uuid('uuid');
$table->uuid('batch_id');
$table->string('family_hash')->nullable();
$table->boolean('should_display_on_index')->default(true);
$table->string('type', 20);
$table->longText('content');
$table->dateTime('created_at')->nullable();
$table->unique('uuid');
$table->index('batch_id');
$table->index('family_hash');
$table->index('created_at');
$table->index(['type', 'should_display_on_index']);
});
$schema->create('telescope_entries_tags', function (Blueprint $table) {
$table->uuid('entry_uuid');
$table->string('tag');
$table->primary(['entry_uuid', 'tag']);
$table->index('tag');
$table->foreign('entry_uuid')
->references('uuid')
->on('telescope_entries')
->onDelete('cascade');
});
$schema->create('telescope_monitoring', function (Blueprint $table) {
$table->string('tag')->primary();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
$schema = Schema::connection($this->getConnection());
$schema->dropIfExists('telescope_entries_tags');
$schema->dropIfExists('telescope_entries');
$schema->dropIfExists('telescope_monitoring');
}
};

8
public/vendor/telescope/app-dark.css vendored Normal file

File diff suppressed because one or more lines are too long

7
public/vendor/telescope/app.css vendored Normal file

File diff suppressed because one or more lines are too long

2
public/vendor/telescope/app.js vendored Normal file

File diff suppressed because one or more lines are too long

BIN
public/vendor/telescope/favicon.ico vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

View File

@@ -0,0 +1,5 @@
{
"/app.js": "/app.js?id=99e99836705c54c9dc04352a9907bc7f",
"/app-dark.css": "/app-dark.css?id=1ea407db56c5163ae29311f1f38eb7b9",
"/app.css": "/app.css?id=de4c978567bfd90b38d186937dee5ccf"
}