120 lines
8.3 KiB
PHP
120 lines
8.3 KiB
PHP
<x-layouts.admin>
|
|
<x-slot name="title">数据库管理</x-slot>
|
|
|
|
<x-slot name="content">
|
|
<div class="my-6">
|
|
@include('system_settings.partials.navigation')
|
|
|
|
@if ($errors->any())
|
|
<div class="mb-5 rounded-lg bg-red-50 px-4 py-3 text-sm text-red-700" role="alert">
|
|
@foreach ($errors->all() as $error)<p>{{ $error }}</p>@endforeach
|
|
</div>
|
|
@endif
|
|
|
|
<section aria-labelledby="system-database-heading">
|
|
<div class="mb-3">
|
|
<h2 id="system-database-heading" class="font-semibold text-gray-900">系统数据库</h2>
|
|
<p class="mt-1 text-xs leading-5 text-gray-600">固定一条,不可删除。系统用户、侧边栏权限、系统设置和云数据库配置都保存在这里。</p>
|
|
</div>
|
|
|
|
<div class="overflow-x-auto rounded-xl border border-[#D8D2C7] bg-white">
|
|
<table class="min-w-full divide-y divide-[#D8D2C7] text-sm">
|
|
<thead class="bg-[#F7F0DE] text-left text-gray-700">
|
|
<tr>
|
|
<th class="px-5 py-3 font-semibold">名称</th>
|
|
<th class="px-5 py-3 font-semibold">地址</th>
|
|
<th class="px-5 py-3 font-semibold">数据库</th>
|
|
<th class="px-5 py-3 font-semibold">传输加密</th>
|
|
<th class="px-5 py-3 text-right font-semibold">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
<tr data-system-database="fixed">
|
|
<td class="px-5 py-4 font-semibold text-gray-900">
|
|
<div class="flex flex-wrap items-center gap-2">
|
|
<span>{{ $systemDatabase['name'] }}</span>
|
|
<span class="inline-flex rounded-full bg-[#F7F0DE] px-2.5 py-1 text-xs font-semibold text-[#856632]">固定 · 不可删除</span>
|
|
</div>
|
|
<p class="mt-1 text-xs font-normal text-gray-500">{{ strtoupper($systemDatabase['driver']) }} 系统数据库</p>
|
|
</td>
|
|
<td class="px-5 py-4 text-gray-600">{{ $systemDatabase['host'] }}{{ $systemDatabase['port'] ? ':' . $systemDatabase['port'] : '' }}</td>
|
|
<td class="px-5 py-4 text-gray-600">{{ $systemDatabase['database'] ?: $systemDatabase['connection'] }}</td>
|
|
<td class="px-5 py-4">
|
|
<span @class([
|
|
'inline-flex rounded-full px-2.5 py-1 text-xs font-semibold',
|
|
'bg-green-100 text-green-700' => $systemDatabase['tls_required'],
|
|
'bg-yellow-100 text-yellow-800' => ! $systemDatabase['tls_required'],
|
|
])>{{ $systemDatabase['tls_required'] ? 'TLS 已启用' : '未启用 TLS' }}</span>
|
|
</td>
|
|
<td class="px-5 py-4 text-right whitespace-nowrap">
|
|
<a href="{{ route('system-settings.databases.system.edit') }}" class="font-semibold text-[#856632] hover:text-[#6A5129] hover:underline">修改连接</a>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
|
|
<section class="mt-7" aria-labelledby="cloud-databases-heading">
|
|
<div class="mb-3 flex flex-wrap items-end justify-between gap-3">
|
|
<div>
|
|
<h2 id="cloud-databases-heading" class="font-semibold text-gray-900">云数据库</h2>
|
|
<p class="mt-1 text-xs leading-5 text-gray-600">可以添加多个。每条密码均加密保存到上方的财务系统配置数据库。</p>
|
|
</div>
|
|
@if ($editable)
|
|
<a href="{{ route('system-settings.databases.create') }}" class="inline-flex items-center gap-2 rounded-lg bg-[#856632] px-4 py-2 text-sm font-semibold text-white hover:bg-[#6A5129] focus:outline-none focus:ring-2 focus:ring-[#856632] focus:ring-offset-2">
|
|
<span class="material-icons-outlined text-lg" aria-hidden="true">add</span>添加云数据库
|
|
</a>
|
|
@endif
|
|
</div>
|
|
|
|
<div class="overflow-x-auto rounded-xl border border-[#D8D2C7] bg-white">
|
|
<table class="min-w-full divide-y divide-[#D8D2C7] text-sm">
|
|
<thead class="bg-[#F7F0DE] text-left text-gray-700">
|
|
<tr>
|
|
<th class="px-5 py-3 font-semibold">名称</th>
|
|
<th class="px-5 py-3 font-semibold">地址</th>
|
|
<th class="px-5 py-3 font-semibold">数据库</th>
|
|
<th class="px-5 py-3 font-semibold">业务绑定</th>
|
|
<th class="px-5 py-3 font-semibold">状态</th>
|
|
<th class="px-5 py-3 text-right font-semibold">操作</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-100">
|
|
@forelse ($connections as $connection)
|
|
<tr>
|
|
<td class="px-5 py-4 font-semibold text-gray-900">{{ $connection->name }}</td>
|
|
<td class="px-5 py-4 text-gray-600">{{ $connection->host }}:{{ $connection->port }}</td>
|
|
<td class="px-5 py-4 text-gray-600">{{ $connection->database_name }}</td>
|
|
<td class="px-5 py-4 text-gray-600">{{ $sourceLabels[$connection->source_key] ?? '未绑定' }}</td>
|
|
<td class="px-5 py-4">
|
|
<span @class([
|
|
'inline-flex rounded-full px-2.5 py-1 text-xs font-semibold',
|
|
'bg-green-100 text-green-700' => $connection->enabled,
|
|
'bg-gray-100 text-gray-600' => ! $connection->enabled,
|
|
])>{{ $connection->enabled ? '启用' : '停用' }}</span>
|
|
</td>
|
|
<td class="px-5 py-4 text-right whitespace-nowrap">
|
|
<form method="POST" action="{{ route('system-settings.databases.test', $connection->id) }}" class="inline">
|
|
@csrf
|
|
<button type="submit" class="font-semibold text-gray-600 hover:text-[#856632] hover:underline">测试</button>
|
|
</form>
|
|
<a href="{{ route('system-settings.databases.edit', $connection->id) }}" class="ml-4 font-semibold text-[#856632] hover:text-[#6A5129] hover:underline">修改</a>
|
|
<form method="POST" action="{{ route('system-settings.databases.destroy', $connection->id) }}" class="ml-4 inline" onsubmit="return confirm('确定删除这个数据库配置吗?')">
|
|
@csrf
|
|
@method('DELETE')
|
|
<button type="submit" class="font-semibold text-red-600 hover:underline">删除</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr><td colspan="6" class="px-5 py-12 text-center text-gray-500">还没有云数据库。点击“添加云数据库”开始配置。</td></tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</x-slot>
|
|
</x-layouts.admin>
|