Deploy Ladill POS / deploy (push) Successful in 42s
Register tills, customer displays, kitchen screens, printers, scanners, and tablets per branch. Customer displays share the branch display token and mark online when the public screen polls; stale devices go offline on a schedule.
97 lines
5.6 KiB
PHP
97 lines
5.6 KiB
PHP
<x-app-layout title="Edit device">
|
|
<div class="mx-auto max-w-lg space-y-6">
|
|
<div>
|
|
<a href="{{ route('pos.devices.index') }}" class="text-sm font-medium text-slate-500 hover:text-slate-800">← Devices</a>
|
|
<h1 class="mt-2 text-2xl font-semibold text-slate-900">Edit device</h1>
|
|
<p class="mt-1 text-sm text-slate-500">{{ $deviceTypes[$device->type] ?? $device->type }} · {{ $device->location?->name ?? 'No branch' }}</p>
|
|
</div>
|
|
|
|
@if (session('success'))
|
|
<div class="rounded-xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-800">{{ session('success') }}</div>
|
|
@endif
|
|
|
|
<form method="POST" action="{{ route('pos.devices.update', $device) }}"
|
|
class="space-y-4 rounded-2xl border border-slate-200 bg-white p-6"
|
|
x-data="{ type: @js(old('type', $device->type)), hints: @js($hints) }">
|
|
@csrf
|
|
@method('PUT')
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Name</label>
|
|
<input type="text" name="name" value="{{ old('name', $device->name) }}" required
|
|
class="mt-1.5 w-full rounded-xl border-slate-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Type</label>
|
|
<select name="type" required x-model="type"
|
|
class="mt-1.5 w-full rounded-xl border-slate-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
@foreach ($deviceTypes as $key => $label)
|
|
<option value="{{ $key }}">{{ $label }}</option>
|
|
@endforeach
|
|
</select>
|
|
<p class="mt-2 text-xs text-slate-500" x-text="hints[type] || ''"></p>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Status</label>
|
|
<select name="status"
|
|
class="mt-1.5 w-full rounded-xl border-slate-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
@foreach (['online', 'offline', 'maintenance'] as $status)
|
|
<option value="{{ $status }}" @selected(old('status', $device->status) === $status)>{{ ucfirst($status) }}</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label class="block text-sm font-medium text-slate-700">Branch</label>
|
|
<select name="location_id"
|
|
class="mt-1.5 w-full rounded-xl border-slate-300 text-sm shadow-sm focus:border-indigo-500 focus:ring-indigo-500">
|
|
<option value="">— Optional / all branches —</option>
|
|
@foreach ($locations as $location)
|
|
<option value="{{ $location->id }}" @selected((string) old('location_id', $device->location_id) === (string) $location->id)>
|
|
{{ $location->name }}
|
|
</option>
|
|
@endforeach
|
|
</select>
|
|
</div>
|
|
|
|
@if ($device->device_token)
|
|
<div class="rounded-xl border border-slate-100 bg-slate-50 p-4">
|
|
<p class="text-xs font-semibold uppercase tracking-wide text-slate-500">Device token</p>
|
|
<code class="mt-2 block break-all text-xs text-slate-700">{{ $device->device_token }}</code>
|
|
@if ($openUrl)
|
|
<a href="{{ $openUrl }}" target="_blank" rel="noopener"
|
|
class="mt-3 inline-flex text-sm font-semibold text-indigo-600 hover:text-indigo-800">
|
|
Open device URL →
|
|
</a>
|
|
@endif
|
|
<p class="mt-2 text-xs text-slate-500">Last online: {{ $device->last_online_at?->diffForHumans() ?? 'Never' }}</p>
|
|
</div>
|
|
@endif
|
|
|
|
<div class="flex gap-3 pt-1">
|
|
<a href="{{ route('pos.devices.index') }}" class="inline-flex flex-1 items-center justify-center rounded-xl border border-slate-200 px-4 py-2.5 text-sm font-medium text-slate-700 hover:bg-slate-50">Back</a>
|
|
<button type="submit" class="btn-primary flex-1">Save</button>
|
|
</div>
|
|
</form>
|
|
|
|
<div class="space-y-3 rounded-2xl border border-rose-100 bg-white p-5">
|
|
<p class="text-sm font-semibold text-slate-900">Device actions</p>
|
|
@if ($device->device_token)
|
|
<form method="POST" action="{{ route('pos.devices.regenerate-token', $device) }}"
|
|
onsubmit="return confirm('Regenerate token? Existing display sessions will stop until reopened.');">
|
|
@csrf
|
|
<button type="submit" class="w-full rounded-xl border border-amber-200 bg-amber-50 px-4 py-2.5 text-sm font-medium text-amber-900 hover:bg-amber-100">
|
|
Regenerate token
|
|
</button>
|
|
</form>
|
|
@endif
|
|
<form method="POST" action="{{ route('pos.devices.destroy', $device) }}"
|
|
onsubmit="return confirm('Remove this device?');">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="w-full rounded-xl border border-rose-200 bg-rose-50 px-4 py-2.5 text-sm font-medium text-rose-800 hover:bg-rose-100">
|
|
Remove device
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</x-app-layout>
|