Files
laravel-llm-gateway/laravel-app/resources/views/api-keys/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

247 lines
15 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">
{{ __('API Key Details') }}
</h2>
<a href="{{ route('api-keys.index') }}"
class="inline-flex items-center px-4 py-2 bg-gray-800 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-gray-700">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"/>
</svg>
Back to List
</a>
</div>
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8 space-y-6">
<!-- Key Information Card -->
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<div class="flex justify-between items-start mb-6">
<div>
<h3 class="text-lg font-semibold text-gray-900">{{ $apiKey->key_name }}</h3>
<p class="mt-1 text-sm text-gray-500">Created {{ $apiKey->created_at->format('F d, Y \a\t H:i') }}</p>
</div>
<div>
@if($apiKey->is_active && !$apiKey->is_expired)
<span class="px-3 py-1 inline-flex text-sm leading-5 font-semibold rounded-full bg-green-100 text-green-800">
Active
</span>
@elseif($apiKey->is_expired)
<span class="px-3 py-1 inline-flex text-sm leading-5 font-semibold rounded-full bg-yellow-100 text-yellow-800">
Expired
</span>
@else
<span class="px-3 py-1 inline-flex text-sm leading-5 font-semibold rounded-full bg-red-100 text-red-800">
Revoked
</span>
@endif
</div>
</div>
<dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2 lg:grid-cols-3">
<!-- Masked Key -->
<div class="sm:col-span-2">
<dt class="text-sm font-medium text-gray-500">Masked Key</dt>
<dd class="mt-1">
<code class="text-sm text-gray-900 bg-gray-100 px-3 py-2 rounded inline-block">
{{ $apiKey->masked_key }}
</code>
</dd>
</div>
<!-- Associated User -->
<div>
<dt class="text-sm font-medium text-gray-500">Associated User</dt>
<dd class="mt-1 text-sm text-gray-900">
<a href="{{ route('gateway-users.show', $apiKey->user_id) }}"
class="text-blue-600 hover:text-blue-900">
{{ $apiKey->gatewayUser->alias ?? $apiKey->user_id }}
</a>
</dd>
</div>
<!-- Last Used -->
<div>
<dt class="text-sm font-medium text-gray-500">Last Used</dt>
<dd class="mt-1 text-sm text-gray-900">
{{ $apiKey->last_used_at ? $apiKey->last_used_at->format('Y-m-d H:i:s') : 'Never' }}
@if($apiKey->last_used_at)
<span class="text-gray-500">({{ $apiKey->last_used_at->diffForHumans() }})</span>
@endif
</dd>
</div>
<!-- Expires At -->
<div>
<dt class="text-sm font-medium text-gray-500">Expires At</dt>
<dd class="mt-1 text-sm text-gray-900">
{{ $apiKey->expires_at ? $apiKey->expires_at->format('Y-m-d H:i:s') : 'Never' }}
@if($apiKey->expires_at)
@if($apiKey->is_expired)
<span class="text-red-600">(Expired)</span>
@else
<span class="text-gray-500">({{ $apiKey->expires_at->diffForHumans() }})</span>
@endif
@endif
</dd>
</div>
<!-- Metadata -->
@if($apiKey->metadata)
<div class="sm:col-span-3">
<dt class="text-sm font-medium text-gray-500">Metadata</dt>
<dd class="mt-1 text-sm text-gray-900">
<pre class="bg-gray-100 p-3 rounded overflow-x-auto"><code>{{ json_encode($apiKey->metadata, JSON_PRETTY_PRINT) }}</code></pre>
</dd>
</div>
@endif
</dl>
<!-- Action Buttons -->
@if($apiKey->is_active && !$apiKey->is_expired)
<div class="mt-6 pt-6 border-t border-gray-200">
<form action="{{ route('api-keys.revoke', $apiKey->id) }}"
method="POST"
onsubmit="return confirm('Are you sure you want to revoke this API key? This action cannot be undone and all requests using this key will be rejected immediately.');">
@csrf
<button type="submit"
class="inline-flex items-center px-4 py-2 bg-red-600 border border-transparent rounded-md font-semibold text-xs text-white uppercase tracking-widest hover:bg-red-700 focus:bg-red-700 active:bg-red-900 focus:outline-none focus:ring-2 focus:ring-red-500 focus:ring-offset-2 transition ease-in-out duration-150">
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
Revoke This Key
</button>
</form>
</div>
@endif
</div>
</div>
<!-- Usage Statistics -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<dt class="text-sm font-medium text-gray-500 truncate">Total Requests</dt>
<dd class="mt-1 text-3xl font-semibold text-gray-900">
{{ number_format($stats['total_requests']) }}
</dd>
</div>
</div>
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<dt class="text-sm font-medium text-gray-500 truncate">Total Cost</dt>
<dd class="mt-1 text-3xl font-semibold text-green-600">
${{ number_format($stats['total_cost'], 4) }}
</dd>
</div>
</div>
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<dt class="text-sm font-medium text-gray-500 truncate">Total Tokens</dt>
<dd class="mt-1 text-3xl font-semibold text-purple-600">
{{ number_format($stats['total_tokens']) }}
</dd>
</div>
</div>
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<dt class="text-sm font-medium text-gray-500 truncate">Last 30 Days</dt>
<dd class="mt-1 text-3xl font-semibold text-blue-600">
{{ number_format($stats['last_30_days_requests']) }}
</dd>
<p class="mt-1 text-xs text-gray-500">requests</p>
</div>
</div>
</div>
<!-- Recent Activity -->
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6">
<h3 class="text-lg font-semibold text-gray-900 mb-4">Recent Activity</h3>
@if($recentLogs->count() > 0)
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Timestamp
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Model
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Provider
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Tokens
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Cost
</th>
<th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Status
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
@foreach($recentLogs as $log)
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{{ $log->timestamp->format('Y-m-d H:i:s') }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
{{ $log->model }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full
@if($log->provider === 'openai') bg-green-100 text-green-800
@elseif($log->provider === 'anthropic') bg-purple-100 text-purple-800
@else bg-gray-100 text-gray-800
@endif">
{{ ucfirst($log->provider) }}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ number_format($log->total_tokens) }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
${{ number_format($log->cost, 4) }}
</td>
<td class="px-6 py-4 whitespace-nowrap">
@if($log->status === 'success')
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
Success
</span>
@else
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
{{ ucfirst($log->status) }}
</span>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@else
<div class="text-center py-8">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"/>
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">No activity yet</h3>
<p class="mt-1 text-sm text-gray-500">This API key hasn't been used yet.</p>
</div>
@endif
</div>
</div>
</div>
</div>
</x-app-layout>