Files
laravel-llm-gateway/laravel-app/resources/views/budgets/show.blade.php
wtrinkl b1363aeab9 Initial commit: Any-LLM Gateway with Laravel Admin Interface
- Any-LLM Gateway setup with Docker Compose
- Laravel 11 admin interface with Livewire
- Dashboard with usage statistics and charts
- Gateway Users management with budget tracking
- API Keys management with revocation
- Budget templates with assignment
- Usage Logs with filtering and CSV export
- Model Pricing management with calculator
- PostgreSQL database integration
- Complete authentication system for admins
2025-11-16 12:38:05 +01:00

165 lines
9.6 KiB
PHP

<x-app-layout>
<x-slot name="header">
<div class="flex justify-between items-center">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
Budget Details
</h2>
<div class="flex gap-2">
<a href="{{ route('budgets.edit', $budget->budget_id) }}"
class="bg-indigo-500 hover:bg-indigo-700 text-white font-bold py-2 px-4 rounded">
Edit Budget
</a>
<form action="{{ route('budgets.destroy', $budget->budget_id) }}" method="POST"
onsubmit="return confirm('Are you sure? This will delete the budget.');" class="inline">
@csrf
@method('DELETE')
<button type="submit" class="bg-red-500 hover:bg-red-700 text-white font-bold py-2 px-4 rounded">
Delete
</button>
</form>
</div>
</div>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
@if(session('success'))
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded">
{{ session('success') }}
</div>
@endif
<!-- Budget Info Card -->
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<h3 class="text-lg font-semibold mb-4">Budget Information</h3>
<dl class="grid grid-cols-1 md:grid-cols-3 gap-6">
<div>
<dt class="text-sm font-medium text-gray-500">Budget ID</dt>
<dd class="mt-1 text-sm text-gray-900 font-mono">{{ $budget->budget_id }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Maximum Budget</dt>
<dd class="mt-1 text-2xl font-bold text-green-600">{{ $budget->max_budget_formatted }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Duration</dt>
<dd class="mt-1 text-sm text-gray-900">{{ $budget->duration_human }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Assigned Users</dt>
<dd class="mt-1 text-2xl font-bold text-blue-600">{{ $budget->gatewayUsers()->count() }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Created</dt>
<dd class="mt-1 text-sm text-gray-900">{{ $budget->created_at->format('M d, Y H:i') }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Last Updated</dt>
<dd class="mt-1 text-sm text-gray-900">{{ $budget->updated_at->format('M d, Y H:i') }}</dd>
</div>
</dl>
</div>
</div>
<!-- Assigned Users Table -->
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<h3 class="text-lg font-semibold mb-4">Assigned Users ({{ $budget->gatewayUsers()->count() }})</h3>
@if($budget->gatewayUsers()->count() > 0)
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">User ID</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Alias</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Current Spend</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Budget Started</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase">Next Reset</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase">Actions</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@foreach($budget->gatewayUsers as $user)
<tr>
<td class="px-6 py-4 whitespace-nowrap text-sm font-mono text-gray-900">
{{ $user->user_id }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{{ $user->alias ?? '-' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm">
<span class="font-semibold {{ $user->spend >= $budget->max_budget ? 'text-red-600' : 'text-green-600' }}">
{{ $user->spend_formatted }}
</span>
<span class="text-gray-500">/ {{ $budget->max_budget_formatted }}</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $user->budget_started_at?->format('M d, Y') ?? '-' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ $user->next_budget_reset_at?->format('M d, Y') ?? 'Never' }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
<a href="{{ route('gateway-users.show', $user->user_id) }}" class="text-blue-600 hover:text-blue-900">View</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p class="text-gray-500 text-center py-8">No users assigned to this budget yet.</p>
@endif
</div>
</div>
<!-- Assign Users Form -->
@if($availableUsers->count() > 0)
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<h3 class="text-lg font-semibold mb-4">Assign Users to Budget</h3>
<form action="{{ route('budgets.assign-users', $budget->budget_id) }}" method="POST">
@csrf
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700 mb-2">Select Users</label>
<div class="border rounded-lg p-4 max-h-64 overflow-y-auto">
@foreach($availableUsers as $user)
<div class="flex items-center mb-2">
<input type="checkbox" name="user_ids[]" value="{{ $user->user_id }}"
id="user_{{ $user->user_id }}"
class="rounded border-gray-300 text-blue-600 focus:ring-blue-500">
<label for="user_{{ $user->user_id }}" class="ml-2 text-sm text-gray-900 cursor-pointer">
<span class="font-mono">{{ $user->user_id }}</span>
@if($user->alias)
<span class="text-gray-500">({{ $user->alias }})</span>
@endif
</label>
</div>
@endforeach
</div>
@error('user_ids')
<p class="text-red-500 text-xs mt-1">{{ $message }}</p>
@enderror
</div>
<div class="flex items-center justify-end">
<button type="submit" class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Assign Selected Users
</button>
</div>
</form>
</div>
</div>
@else
<div class="bg-gray-50 overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 text-center text-gray-500">
All users are currently assigned to budgets. No available users to assign.
</div>
</div>
@endif
</div>
</div>
</x-app-layout>