281 lines
18 KiB
PHP
281 lines
18 KiB
PHP
<x-app-layout>
|
|
<x-slot name="header">
|
|
<div class="flex items-center justify-between">
|
|
<h2 class="text-xl font-semibold leading-tight text-gray-800">
|
|
{{ $document->title }}
|
|
</h2>
|
|
<div class="flex items-center space-x-2">
|
|
<a href="{{ route('admin.documents.edit', $document) }}" class="inline-flex items-center rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50">
|
|
編輯資訊
|
|
</a>
|
|
@if($document->status === 'active')
|
|
<form action="{{ route('admin.documents.archive', $document) }}" method="POST" class="inline">
|
|
@csrf
|
|
<button type="submit" class="inline-flex items-center rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50">
|
|
封存
|
|
</button>
|
|
</form>
|
|
@else
|
|
<form action="{{ route('admin.documents.restore', $document) }}" method="POST" class="inline">
|
|
@csrf
|
|
<button type="submit" class="inline-flex items-center rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50">
|
|
恢復
|
|
</button>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</x-slot>
|
|
|
|
<div class="py-12">
|
|
<div class="mx-auto max-w-7xl sm:px-6 lg:px-8 space-y-6">
|
|
@if (session('status'))
|
|
<div class="rounded-md bg-green-50 p-4">
|
|
<p class="text-sm font-medium text-green-800">{{ session('status') }}</p>
|
|
</div>
|
|
@endif
|
|
|
|
@if (session('error'))
|
|
<div class="rounded-md bg-red-50 p-4">
|
|
<p class="text-sm font-medium text-red-800">{{ session('error') }}</p>
|
|
</div>
|
|
@endif
|
|
|
|
<!-- Document Info -->
|
|
<div class="bg-white shadow sm:rounded-lg">
|
|
<div class="px-6 py-5">
|
|
<h3 class="text-lg font-medium leading-6 text-gray-900">文件資訊</h3>
|
|
</div>
|
|
<div class="border-t border-gray-200 px-6 py-5">
|
|
<dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-2">
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">類別</dt>
|
|
<dd class="mt-1 text-sm text-gray-900">{{ $document->category->icon }} {{ $document->category->name }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">文件編號</dt>
|
|
<dd class="mt-1 text-sm text-gray-900">{{ $document->document_number ?? '—' }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">存取權限</dt>
|
|
<dd class="mt-1">
|
|
<span class="inline-flex rounded-full px-2 py-1 text-xs font-semibold
|
|
@if($document->access_level === 'public') bg-green-100 text-green-800
|
|
@elseif($document->access_level === 'members') bg-blue-100 text-blue-800
|
|
@elseif($document->access_level === 'admin') bg-purple-100 text-purple-800
|
|
@else bg-gray-100 text-gray-800
|
|
@endif">
|
|
{{ $document->getAccessLevelLabel() }}
|
|
</span>
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">狀態</dt>
|
|
<dd class="mt-1">
|
|
<span class="inline-flex rounded-full px-2 py-1 text-xs font-semibold
|
|
{{ $document->status === 'active' ? 'bg-green-100 text-green-800' : 'bg-gray-100 text-gray-800' }}">
|
|
{{ $document->getStatusLabel() }}
|
|
</span>
|
|
</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">當前版本</dt>
|
|
<dd class="mt-1 text-sm text-gray-900">v{{ $document->currentVersion->version_number }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">總版本數</dt>
|
|
<dd class="mt-1 text-sm text-gray-900">{{ $document->version_count }} 個版本</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">檢視 / 下載次數</dt>
|
|
<dd class="mt-1 text-sm text-gray-900">{{ $document->view_count }} / {{ $document->download_count }}</dd>
|
|
</div>
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">公開連結</dt>
|
|
<dd class="mt-1 text-sm">
|
|
<a href="{{ $document->getPublicUrl() }}" target="_blank" class="text-indigo-600 hover:text-indigo-900">
|
|
{{ $document->getPublicUrl() }}
|
|
</a>
|
|
</dd>
|
|
</div>
|
|
@if($document->description)
|
|
<div class="sm:col-span-2">
|
|
<dt class="text-sm font-medium text-gray-500">說明</dt>
|
|
<dd class="mt-1 text-sm text-gray-900">{{ $document->description }}</dd>
|
|
</div>
|
|
@endif
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">建立者</dt>
|
|
<dd class="mt-1 text-sm text-gray-900">{{ $document->createdBy->name }} · {{ $document->created_at->format('Y-m-d H:i') }}</dd>
|
|
</div>
|
|
@if($document->lastUpdatedBy)
|
|
<div>
|
|
<dt class="text-sm font-medium text-gray-500">最後更新</dt>
|
|
<dd class="mt-1 text-sm text-gray-900">{{ $document->lastUpdatedBy->name }} · {{ $document->updated_at->format('Y-m-d H:i') }}</dd>
|
|
</div>
|
|
@endif
|
|
</dl>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Upload New Version -->
|
|
<div class="bg-white shadow sm:rounded-lg">
|
|
<div class="px-6 py-5">
|
|
<h3 class="text-lg font-medium leading-6 text-gray-900">上傳新版本</h3>
|
|
</div>
|
|
<div class="border-t border-gray-200 px-6 py-5">
|
|
<form action="{{ route('admin.documents.upload-version', $document) }}" method="POST" enctype="multipart/form-data" class="space-y-4">
|
|
@csrf
|
|
<div>
|
|
<label for="file" class="block text-sm font-medium text-gray-700">選擇檔案 <span class="text-red-500">*</span></label>
|
|
<input type="file" name="file" id="file" required
|
|
class="mt-1 block w-full text-sm text-gray-500
|
|
file:mr-4 file:py-2 file:px-4
|
|
file:rounded-md file:border-0
|
|
file:text-sm file:font-semibold
|
|
file:bg-indigo-50 file:text-indigo-700
|
|
hover:file:bg-indigo-100">
|
|
<p class="mt-1 text-sm text-gray-500">最大 10MB</p>
|
|
</div>
|
|
<div>
|
|
<label for="version_notes" class="block text-sm font-medium text-gray-700">版本說明 <span class="text-red-500">*</span></label>
|
|
<textarea name="version_notes" id="version_notes" rows="2" required placeholder="說明此版本的變更內容"
|
|
class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500"></textarea>
|
|
</div>
|
|
<div class="flex justify-end">
|
|
<button type="submit" class="rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white hover:bg-indigo-700">
|
|
上傳新版本
|
|
</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Version History -->
|
|
<div class="bg-white shadow sm:rounded-lg">
|
|
<div class="px-6 py-5">
|
|
<h3 class="text-lg font-medium leading-6 text-gray-900">版本歷史</h3>
|
|
<p class="mt-1 text-sm text-gray-600">所有版本永久保留,無法刪除</p>
|
|
</div>
|
|
<div class="border-t border-gray-200">
|
|
<ul class="divide-y divide-gray-200">
|
|
@foreach($versionHistory as $history)
|
|
@php $version = $history['version']; @endphp
|
|
<li class="px-6 py-5">
|
|
<div class="flex items-center justify-between">
|
|
<div class="flex-1">
|
|
<div class="flex items-center space-x-3">
|
|
<span class="text-2xl">{{ $version->getFileIcon() }}</span>
|
|
<div>
|
|
<div class="flex items-center space-x-2">
|
|
<span class="text-sm font-medium text-gray-900">版本 {{ $version->version_number }}</span>
|
|
@if($version->is_current)
|
|
<span class="inline-flex rounded-full bg-green-100 px-2 py-1 text-xs font-semibold text-green-800">
|
|
當前版本
|
|
</span>
|
|
@endif
|
|
</div>
|
|
<div class="mt-1 text-sm text-gray-900">{{ $version->original_filename }}</div>
|
|
<div class="mt-1 flex items-center space-x-4 text-xs text-gray-500">
|
|
<span>{{ $version->getFileSizeHuman() }}</span>
|
|
<span>{{ $version->uploadedBy->name }}</span>
|
|
<span>{{ $version->uploaded_at->format('Y-m-d H:i') }}</span>
|
|
@if($history['days_since_previous'])
|
|
<span>({{ $history['days_since_previous'] }} 天前)</span>
|
|
@endif
|
|
</div>
|
|
@if($version->version_notes)
|
|
<div class="mt-2 text-sm text-gray-600">
|
|
<span class="font-medium">變更說明:</span>{{ $version->version_notes }}
|
|
</div>
|
|
@endif
|
|
<div class="mt-2 flex items-center space-x-2 text-xs text-gray-500">
|
|
<span>檔案雜湊:</span>
|
|
<code class="px-2 py-1 bg-gray-100 rounded">{{ substr($version->file_hash, 0, 16) }}...</code>
|
|
@if($version->verifyIntegrity())
|
|
<span class="text-green-600">✓ 完整</span>
|
|
@else
|
|
<span class="text-red-600">✗ 損壞</span>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="ml-6 flex flex-col space-y-2">
|
|
<a href="{{ route('admin.documents.download-version', [$document, $version]) }}"
|
|
class="inline-flex items-center rounded-md border border-gray-300 bg-white px-3 py-2 text-sm font-medium text-gray-700 hover:bg-gray-50">
|
|
下載
|
|
</a>
|
|
@if(!$version->is_current)
|
|
<form action="{{ route('admin.documents.promote-version', [$document, $version]) }}" method="POST">
|
|
@csrf
|
|
<button type="submit" class="w-full inline-flex items-center justify-center rounded-md border border-indigo-300 bg-indigo-50 px-3 py-2 text-sm font-medium text-indigo-700 hover:bg-indigo-100"
|
|
onclick="return confirm('確定要將此版本設為當前版本嗎?');">
|
|
設為當前
|
|
</button>
|
|
</form>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
</li>
|
|
@endforeach
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Access Logs -->
|
|
<div class="bg-white shadow sm:rounded-lg">
|
|
<div class="px-6 py-5">
|
|
<h3 class="text-lg font-medium leading-6 text-gray-900">存取記錄</h3>
|
|
<p class="mt-1 text-sm text-gray-600">最近 20 筆</p>
|
|
</div>
|
|
<div class="border-t border-gray-200">
|
|
<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 uppercase tracking-wider text-gray-500">時間</th>
|
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">使用者</th>
|
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">動作</th>
|
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">IP</th>
|
|
<th scope="col" class="px-6 py-3 text-left text-xs font-medium uppercase tracking-wider text-gray-500">瀏覽器</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-gray-200 bg-white">
|
|
@forelse($document->accessLogs->take(20) as $log)
|
|
<tr>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
{{ $log->accessed_at->format('Y-m-d H:i:s') }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-900">
|
|
{{ $log->getUserDisplay() }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm">
|
|
<span class="inline-flex rounded-full px-2 py-1 text-xs font-semibold
|
|
{{ $log->action === 'view' ? 'bg-blue-100 text-blue-800' : 'bg-green-100 text-green-800' }}">
|
|
{{ $log->getActionLabel() }}
|
|
</span>
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
{{ $log->ip_address }}
|
|
</td>
|
|
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
|
|
{{ $log->getBrowser() }}
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="5" class="px-6 py-4 text-center text-sm text-gray-500">
|
|
尚無存取記錄
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</x-app-layout>
|