332 lines
22 KiB
PHP
Executable File
332 lines
22 KiB
PHP
Executable File
@extends("layouts.app")
|
|
|
|
@section("title", __("System Management"))
|
|
|
|
@section("header")
|
|
<div class="flex justify-between items-center">
|
|
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
|
|
{{ __("System Management") }}
|
|
</h2>
|
|
</div>
|
|
@endsection
|
|
|
|
@section("content")
|
|
<div class="py-6">
|
|
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
|
@if(session("success"))
|
|
<div class="bg-green-100 border border-green-400 text-green-700 px-4 py-3 rounded-lg mb-6">
|
|
{{ session("success") }}
|
|
</div>
|
|
@endif
|
|
|
|
<!-- Statistics -->
|
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-5 gap-6 mb-6">
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
|
|
<p class="text-sm font-medium text-gray-500">{{ __("Total Users") }}</p>
|
|
<p class="text-3xl font-bold text-gray-900 mt-1">{{ $stats["total_users"] }}</p>
|
|
</div>
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
|
|
<p class="text-sm font-medium text-gray-500">{{ __("Active Users") }}</p>
|
|
<p class="text-3xl font-bold text-green-600 mt-1">{{ $stats["active_users"] }}</p>
|
|
</div>
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
|
|
<p class="text-sm font-medium text-gray-500">{{ __("Pending Users") }}</p>
|
|
<p class="text-3xl font-bold text-yellow-600 mt-1">{{ $stats["pending_users"] }}</p>
|
|
</div>
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
|
|
<p class="text-sm font-medium text-gray-500">{{ __("Total Subjects") }}</p>
|
|
<p class="text-3xl font-bold text-indigo-600 mt-1">{{ $stats["total_subjects"] }}</p>
|
|
</div>
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
|
|
<p class="text-sm font-medium text-gray-500">{{ __("Total Insights") }}</p>
|
|
<p class="text-3xl font-bold text-purple-600 mt-1">{{ $stats["total_insights"] }}</p>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- System Subjects Management -->
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 mb-6">
|
|
<div class="flex justify-between items-center mb-6">
|
|
<div>
|
|
<h3 class="text-xl font-semibold text-gray-900">{{ __("System Subjects") }}</h3>
|
|
<p class="text-sm text-gray-500 mt-1">{{ __("Manage global subjects available to all users") }}</p>
|
|
</div>
|
|
<button onclick="document.getElementById('createSubjectModal').classList.remove('hidden')"
|
|
class="inline-flex items-center px-4 py-2 bg-indigo-600 text-white text-sm font-medium rounded-lg hover:bg-indigo-700 transition">
|
|
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4v16m8-8H4"/>
|
|
</svg>
|
|
{{ __("Create System Subject") }}
|
|
</button>
|
|
</div>
|
|
|
|
<div class="overflow-x-auto">
|
|
<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 tracking-wider">{{ __("Name") }}</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Description") }}</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Subscribers") }}</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Status") }}</th>
|
|
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">{{ __("Actions") }}</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="bg-white divide-y divide-gray-200">
|
|
@foreach($subjects as $subject)
|
|
<tr class="hover:bg-gray-50">
|
|
<td class="px-6 py-4 whitespace-nowrap font-medium text-gray-900">{{ $subject->name }}</td>
|
|
<td class="px-6 py-4 text-sm text-gray-500 max-w-xs truncate">{{ $subject->description ?? '-' }}</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
{{ $subject->userSubjects()->count() }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap">
|
|
@if($subject->is_active)
|
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-green-100 text-green-800">
|
|
{{ __("Active") }}
|
|
</span>
|
|
@else
|
|
<span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full bg-red-100 text-red-800">
|
|
{{ __("Inactive") }}
|
|
</span>
|
|
@endif
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium">
|
|
<button onclick="openEditSubjectModal({{ $subject->id }}, '{{ addslashes($subject->name) }}', '{{ addslashes($subject->description ?? '') }}', '{{ addslashes($subject->introduction ?? '') }}', {{ $subject->is_active ? 'true' : 'false' }})"
|
|
class="text-indigo-600 hover:text-indigo-900 mr-3">
|
|
{{ __("Edit") }}
|
|
</button>
|
|
<form action="{{ route("superadmin.system.subjects.destroy", $subject) }}" method="POST" class="inline"
|
|
onsubmit="return confirm('{{ __("Delete this subject? This action cannot be undone.") }}')">
|
|
@csrf
|
|
@method("DELETE")
|
|
<button type="submit" class="text-red-600 hover:text-red-900">
|
|
{{ __("Delete") }}
|
|
</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
@endforeach
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Quick Actions -->
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6">
|
|
<h3 class="text-lg font-semibold text-gray-900 mb-4">{{ __("Quick Actions") }}</h3>
|
|
<div class="grid grid-cols-1 md:grid-cols-3 gap-4">
|
|
<a href="{{ route('superadmin.users.index') }}"
|
|
class="flex items-center gap-3 p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition">
|
|
<div class="w-10 h-10 bg-indigo-100 rounded-lg flex items-center justify-center">
|
|
<svg class="w-5 h-5 text-indigo-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 4.354a4 4 0 110 5.292M15 21H3v-1a6 6 0 0112 0v1zm0 0h6v-1a6 6 0 00-9-5.197m13.5-9a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z"/>
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<p class="text-sm font-medium text-gray-900">{{ __("Manage Users") }}</p>
|
|
<p class="text-xs text-gray-500">{{ __("Approve, reject, or manage users") }}</p>
|
|
</div>
|
|
</a>
|
|
<a href="{{ route('superadmin.billing.index') }}"
|
|
class="flex items-center gap-3 p-4 border border-gray-200 rounded-lg hover:bg-gray-50 transition">
|
|
<div class="w-10 h-10 bg-green-100 rounded-lg flex items-center justify-center">
|
|
<svg class="w-5 h-5 text-green-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
|
</svg>
|
|
</div>
|
|
<div>
|
|
<p class="text-sm font-medium text-gray-900">{{ __("Billing") }}</p>
|
|
<p class="text-xs text-gray-500">{{ __("Manage plans, subscriptions and invoices") }}</p>
|
|
</div>
|
|
</a>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- AI Settings -->
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 mb-6">
|
|
<div class="mb-6">
|
|
<h3 class="text-xl font-semibold text-gray-900">{{ __("AI Settings") }}</h3>
|
|
<p class="text-sm text-gray-500 mt-1">{{ __("Configure the default AI provider and model, except for Chat.
|
|
") }}</p>
|
|
</div>
|
|
<form action="{{ route('superadmin.system.ai-settings.update') }}" method="POST">
|
|
@csrf
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div>
|
|
<label for="ai_default_provider" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Default Provider") }}</label>
|
|
<select name="ai_default_provider" id="ai_default_provider" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
|
<option value="openrouter" {{ (old('ai_default_provider', $aiDefaultProvider) === 'openrouter') ? 'selected' : '' }}>OpenRouter.ai</option>
|
|
<option value="openai" {{ (old('ai_default_provider', $aiDefaultProvider) === 'openai') ? 'selected' : '' }}>OpenAI</option>
|
|
<option value="stepfun" {{ (old('ai_default_provider', $aiDefaultProvider) === 'stepfun') ? 'selected' : '' }}>StepFun</option>
|
|
<option value="llamacpp" {{ (old('ai_default_provider', $aiDefaultProvider) === 'llamacpp') ? 'selected' : '' }}>llama.cpp (Local)</option>
|
|
<option value="qwen" {{ (old('ai_default_provider', $aiDefaultProvider) === 'qwen') ? 'selected' : '' }}>QwenCloud</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="ai_default_model" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Default Model") }}</label>
|
|
<input type="text" name="ai_default_model" id="ai_default_model" value="{{ old('ai_default_model', $aiDefaultModel) }}" required
|
|
placeholder="e.g., deepseek/deepseek-v4-flash-0731"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
|
</div>
|
|
</div>
|
|
<div class="flex justify-end gap-2 mt-6">
|
|
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition font-medium">
|
|
{{ __("Save AI Settings") }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<!-- Chat Settings -->
|
|
<div class="bg-white rounded-xl shadow-sm border border-gray-100 p-6 mb-6">
|
|
<div class="mb-6">
|
|
<h3 class="text-xl font-semibold text-gray-900">{{ __("Chat AI Settings") }}</h3>
|
|
<p class="text-sm text-gray-500 mt-1">{{ __("Configure default AI provider and model for chat conversations") }}</p>
|
|
</div>
|
|
<form action="{{ route('superadmin.system.chat-settings.update') }}" method="POST">
|
|
@csrf
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
|
<div>
|
|
<label for="chat_default_provider" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Default Chat Provider") }}</label>
|
|
<select name="chat_default_provider" id="chat_default_provider" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
|
<option value="openrouter" {{ (old('chat_default_provider', $chatDefaultProvider) === 'openrouter') ? 'selected' : '' }}>OpenRouter.ai</option>
|
|
<option value="openai" {{ (old('chat_default_provider', $chatDefaultProvider) === 'openai') ? 'selected' : '' }}>OpenAI</option>
|
|
<option value="stepfun" {{ (old('chat_default_provider', $chatDefaultProvider) === 'stepfun') ? 'selected' : '' }}>StepFun</option>
|
|
<option value="llamacpp" {{ (old('chat_default_provider', $chatDefaultProvider) === 'llamacpp') ? 'selected' : '' }}>llama.cpp (Local)</option>
|
|
<option value="qwen" {{ (old('chat_default_provider', $chatDefaultProvider) === 'qwen') ? 'selected' : '' }}>QwenCloud</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="chat_default_model" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Default Chat Model") }}</label>
|
|
<input type="text" name="chat_default_model" id="chat_default_model" value="{{ old('chat_default_model', $chatDefaultModel) }}" required
|
|
placeholder="e.g., gpt-4o-mini"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
|
</div>
|
|
</div>
|
|
<div class="flex justify-end gap-2 mt-6">
|
|
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition font-medium">
|
|
{{ __("Save Chat Settings") }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Create Subject Modal -->
|
|
<div id="createSubjectModal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
|
|
<div class="relative top-20 mx-auto p-5 border w-full max-w-md shadow-lg rounded-xl bg-white">
|
|
<div class="mt-3">
|
|
<div class="flex justify-between items-center mb-4">
|
|
<h3 class="text-lg font-medium text-gray-900">{{ __("Create System Subject") }}</h3>
|
|
<button onclick="document.getElementById('createSubjectModal').classList.add('hidden')" class="text-gray-400 hover:text-gray-600">
|
|
<svg class="w-5 h-5" 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>
|
|
</button>
|
|
</div>
|
|
<form action="{{ route("superadmin.system.subjects.store") }}" method="POST">
|
|
@csrf
|
|
<div class="mb-4">
|
|
<label for="name" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Name") }} *</label>
|
|
<input type="text" name="name" id="name" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
|
</div>
|
|
<div class="mb-4">
|
|
<label for="description" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Description") }}</label>
|
|
<textarea name="description" id="description" rows="3"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"></textarea>
|
|
</div>
|
|
<div class="mb-4">
|
|
<label for="introduction" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Introduction") }}</label>
|
|
<textarea name="introduction" id="introduction" rows="3"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"></textarea>
|
|
</div>
|
|
<div class="flex justify-end gap-2 mt-6">
|
|
<button type="button" onclick="document.getElementById('createSubjectModal').classList.add('hidden')"
|
|
class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition font-medium">
|
|
{{ __("Cancel") }}
|
|
</button>
|
|
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition font-medium">
|
|
{{ __("Create") }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Edit Subject Modal -->
|
|
<div id="editSubjectModal" class="hidden fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
|
|
<div class="relative top-20 mx-auto p-5 border w-full max-w-md shadow-lg rounded-xl bg-white">
|
|
<div class="mt-3">
|
|
<div class="flex justify-between items-center mb-4">
|
|
<h3 class="text-lg font-medium text-gray-900">{{ __("Edit System Subject") }}</h3>
|
|
<button onclick="document.getElementById('editSubjectModal').classList.add('hidden')" class="text-gray-400 hover:text-gray-600">
|
|
<svg class="w-5 h-5" 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>
|
|
</button>
|
|
</div>
|
|
<form id="editSubjectForm" method="POST">
|
|
@csrf
|
|
@method("PUT")
|
|
<div class="mb-4">
|
|
<label for="edit_name" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Name") }} *</label>
|
|
<input type="text" name="name" id="edit_name" required
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500">
|
|
</div>
|
|
<div class="mb-4">
|
|
<label for="edit_description" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Description") }}</label>
|
|
<textarea name="description" id="edit_description" rows="3"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"></textarea>
|
|
</div>
|
|
<div class="mb-4">
|
|
<label for="edit_introduction" class="block text-sm font-medium text-gray-700 mb-2">{{ __("Introduction") }}</label>
|
|
<textarea name="introduction" id="edit_introduction" rows="3"
|
|
class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500"></textarea>
|
|
</div>
|
|
<div class="mb-4">
|
|
<label class="flex items-center">
|
|
<input type="checkbox" name="is_active" id="edit_is_active" value="1"
|
|
class="rounded border-gray-300 text-indigo-600 shadow-sm focus:ring-indigo-500">
|
|
<span class="ml-2 text-sm text-gray-700">{{ __("Active") }}</span>
|
|
</label>
|
|
</div>
|
|
<div class="flex justify-end gap-2 mt-6">
|
|
<button type="button" onclick="document.getElementById('editSubjectModal').classList.add('hidden')"
|
|
class="px-4 py-2 bg-gray-100 text-gray-700 rounded-lg hover:bg-gray-200 transition font-medium">
|
|
{{ __("Cancel") }}
|
|
</button>
|
|
<button type="submit" class="px-4 py-2 bg-indigo-600 text-white rounded-lg hover:bg-indigo-700 transition font-medium">
|
|
{{ __("Update") }}
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@endsection
|
|
|
|
@push("scripts")
|
|
<script>
|
|
function openEditSubjectModal(id, name, description, introduction, isActive) {
|
|
document.getElementById('edit_name').value = name;
|
|
document.getElementById('edit_description').value = description;
|
|
document.getElementById('edit_introduction').value = introduction;
|
|
document.getElementById('edit_is_active').checked = isActive;
|
|
document.getElementById('editSubjectForm').action = '{{ url("superadmin/system/subjects") }}/' + id;
|
|
document.getElementById('editSubjectModal').classList.remove('hidden');
|
|
}
|
|
|
|
// Close modals on Escape key
|
|
document.addEventListener('keydown', function(event) {
|
|
if (event.key === 'Escape') {
|
|
document.getElementById('createSubjectModal').classList.add('hidden');
|
|
document.getElementById('editSubjectModal').classList.add('hidden');
|
|
}
|
|
});
|
|
</script>
|
|
@endpush
|