christhompsontldr/fluxui-devices
FluxUI front-end for diego-ninja/laravel-devices: manage user devices and active sessions with Livewire Volt. View device details, session locations, and remotely sign out of specific devices or all others. Designed for Laravel Livewire Starter Kit + Flux UI.
Installation
composer require christhompsontldr/fluxui-devices
npm install @fluxui/devices
Publish assets and config:
php artisan vendor:publish --provider="FluxUI\Devices\DevicesServiceProvider" --tag="fluxui-devices-config"
php artisan vendor:publish --provider="FluxUI\Devices\DevicesServiceProvider" --tag="fluxui-devices-assets"
First Use Case
Register the package in resources/js/app.js:
import FluxUIDevices from '@fluxui/devices';
FluxUIDevices.init();
Add the Blade directive in a view (e.g., resources/views/layouts/app.blade.php):
@fluxui_devices
Key Configuration
Update .env with your Diego-Ninja Devices API endpoint:
DEVICES_API_URL=http://your-app.test/api/devices
Device Management
@fluxui_devices directive in Blade to auto-generate a dashboard for devices, sessions, and connections.DeviceCreated, SessionTerminated) to trigger UI updates:
use FluxUI\Devices\Events\DeviceCreated;
event(new DeviceCreated($device));
Session Handling
import Echo from 'laravel-echo';
const echo = new Echo({ broadcaster: 'pusher' });
echo.channel('devices.sessions')
.listen('DeviceSessionUpdated', (data) => {
FluxUIDevices.updateSession(data);
});
Integration with Existing UI
@fluxui_devices::device-card or @fluxui_devices::session-list to embed specific widgets:
@fluxui_devices::device-card({{ $device }})
API-Driven Customization
config/fluxui-devices.php:
'api' => [
'devices' => 'api/custom/devices',
'sessions' => 'api/custom/sessions',
],
Asset Conflicts
@fluxui/devices is imported after Vue/Laravel Mix in app.js to avoid duplicate IDs or hooks.ready callback:
document.addEventListener('DOMContentLoaded', () => {
FluxUIDevices.init();
});
CSRF Token Mismatch
X-CSRF-TOKEN header is included in API requests. FluxUI auto-injects it for Blade views but not for direct AJAX calls.axios.defaults.headers.common['X-CSRF-TOKEN'] = document.querySelector('meta[name="csrf-token"]').content;
Real-Time Lag
DEVICES_API_URL points to a slow endpoint.broadcastOn to filter events:
broadcast(new DeviceSessionUpdated($session))->toOthers();
?fluxui=debug to your URL to bypass Vue’s runtime caching.config/fluxui-devices.php:
'debug' => [
'log_api_calls' => true,
],
Custom Fields Add extra device attributes via a trait:
use FluxUI\Devices\Concerns\HasFluxUIFields;
class CustomDevice extends Device {
use HasFluxUIFields;
public function fluxUIFields(): array {
return [
'custom_field' => 'Custom Attribute',
];
}
}
Theming
Override SCSS variables in resources/sass/fluxui/_devices.scss:
$fluxui-devices-primary: #2d3748;
Localization
Extend translations in resources/lang/en/fluxui-devices.php:
return [
'device' => [
'attributes' => [
'name' => 'Device Name (Custom)',
],
],
];
How can I help you explore Laravel packages today?