Fix S3 permissions and things
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Add Club - HKFC Men's C Team</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-4">
|
||||
@@ -43,7 +44,12 @@
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.logo_url.label(class="form-label") }}
|
||||
{{ form.logo_url(class="form-control", id="logoUrl", onchange="previewLogo()") }}
|
||||
<div class="input-group">
|
||||
{{ form.logo_url(class="form-control", id="logoUrl", onchange="previewLogo()") }}
|
||||
<button type="button" class="btn btn-outline-secondary" onclick="browseS3()" title="Browse S3 Storage">
|
||||
<i class="fas fa-cloud"></i> Browse S3
|
||||
</button>
|
||||
</div>
|
||||
{% if form.logo_url.errors %}
|
||||
<div class="text-danger">
|
||||
{% for error in form.logo_url.errors %}
|
||||
@@ -51,7 +57,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<small class="form-text text-muted">Enter the full URL to the club's logo image</small>
|
||||
<small class="form-text text-muted">Enter the full URL to the club's logo image or use the S3 browser to select from your configured storage.</small>
|
||||
|
||||
<!-- Logo Preview -->
|
||||
<div id="logoPreview" class="mt-2" style="display: none;">
|
||||
@@ -71,6 +77,32 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- S3 Browser Modal -->
|
||||
<div class="modal fade" id="s3BrowserModal" tabindex="-1" aria-labelledby="s3BrowserModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="s3BrowserModalLabel">Browse S3 Storage</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="s3BrowserContent">
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<p>Loading S3 contents...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="selectS3FileBtn" onclick="selectS3File()" disabled>Select File</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<a href="/admin/clubs" class="btn btn-outline-secondary">Back to Club Management</a>
|
||||
</div>
|
||||
@@ -93,6 +125,205 @@
|
||||
previewDiv.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// S3 Browser functionality
|
||||
let selectedS3File = null;
|
||||
let currentS3Path = '';
|
||||
|
||||
function browseS3() {
|
||||
// Reset state
|
||||
selectedS3File = null;
|
||||
currentS3Path = '';
|
||||
|
||||
// Show loading state
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<p>Loading S3 contents...</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Show modal
|
||||
const s3BrowserModal = new bootstrap.Modal(document.getElementById('s3BrowserModal'));
|
||||
s3BrowserModal.show();
|
||||
|
||||
// Load S3 contents from root of assets folder
|
||||
loadS3Contents('');
|
||||
}
|
||||
|
||||
function loadS3Contents(path) {
|
||||
fetch(`/admin/api/s3-browser?path=${encodeURIComponent(path)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
displayS3Contents(data);
|
||||
} else {
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error:</strong> ${data.message}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error:</strong> Failed to load S3 contents. Please try again.
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
function displayS3Contents(data) {
|
||||
currentS3Path = data.path;
|
||||
|
||||
let html = `
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="#" onclick="loadS3Contents('')">assets</a>
|
||||
</li>
|
||||
`;
|
||||
|
||||
// Build breadcrumb
|
||||
if (data.path !== '') {
|
||||
const pathParts = data.path.split('/').filter(p => p);
|
||||
let currentPath = '';
|
||||
|
||||
pathParts.forEach((part, index) => {
|
||||
currentPath += part + '/';
|
||||
const isLast = index === pathParts.length - 1;
|
||||
html += `<li class="breadcrumb-item ${isLast ? 'active' : ''}">`;
|
||||
|
||||
if (!isLast) {
|
||||
html += `<a href="#" onclick="loadS3Contents('${currentPath}')">${part}</a>`;
|
||||
} else {
|
||||
html += part;
|
||||
}
|
||||
html += '</li>';
|
||||
});
|
||||
}
|
||||
|
||||
html += `
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
`;
|
||||
|
||||
// Display folders
|
||||
if (data.folders.length > 0) {
|
||||
data.folders.forEach(folder => {
|
||||
html += `
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card h-100 folder-card" onclick="loadS3Contents('${folder.path}')" style="cursor: pointer;">
|
||||
<div class="card-body text-center">
|
||||
<i class="fas fa-folder fa-3x text-warning mb-2"></i>
|
||||
<h6 class="card-title">${folder.name}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
// Display files
|
||||
if (data.files.length > 0) {
|
||||
data.files.forEach(file => {
|
||||
const isImage = /\.(jpg|jpeg|png|gif|svg|webp)$/i.test(file.name);
|
||||
const fileSize = formatFileSize(file.size);
|
||||
|
||||
html += `
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card h-100 file-card" onclick="selectS3FileItem('${file.path}', '${file.url}')" style="cursor: pointer;">
|
||||
<div class="card-body text-center">
|
||||
`;
|
||||
|
||||
if (isImage) {
|
||||
html += `
|
||||
<img src="${file.url}" alt="${file.name}" class="img-fluid mb-2" style="max-height: 100px; max-width: 100%; object-fit: contain;">
|
||||
`;
|
||||
} else {
|
||||
html += `
|
||||
<i class="fas fa-file fa-3x text-primary mb-2"></i>
|
||||
`;
|
||||
}
|
||||
|
||||
html += `
|
||||
<h6 class="card-title">${file.name}</h6>
|
||||
<small class="text-muted">${fileSize}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.folders.length === 0 && data.files.length === 0) {
|
||||
html += `
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info text-center">
|
||||
<i class="fas fa-info-circle"></i> No files or folders found in this directory.
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
html += `
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.getElementById('s3BrowserContent').innerHTML = html;
|
||||
}
|
||||
|
||||
function selectS3FileItem(filePath, fileUrl) {
|
||||
// Remove previous selection
|
||||
document.querySelectorAll('.file-card').forEach(card => {
|
||||
card.classList.remove('border-primary');
|
||||
});
|
||||
|
||||
// Add selection to clicked card
|
||||
event.currentTarget.classList.add('border-primary');
|
||||
|
||||
// Store selected file
|
||||
selectedS3File = {
|
||||
path: filePath,
|
||||
url: fileUrl
|
||||
};
|
||||
|
||||
// Enable select button
|
||||
document.getElementById('selectS3FileBtn').disabled = false;
|
||||
}
|
||||
|
||||
function selectS3File() {
|
||||
if (selectedS3File) {
|
||||
// Update the logo URL field
|
||||
const logoUrlField = document.getElementById('logoUrl');
|
||||
if (logoUrlField) {
|
||||
logoUrlField.value = selectedS3File.path;
|
||||
// Trigger preview update
|
||||
previewLogo();
|
||||
}
|
||||
|
||||
// Close modal
|
||||
const s3BrowserModal = bootstrap.Modal.getInstance(document.getElementById('s3BrowserModal'));
|
||||
s3BrowserModal.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function formatFileSize(bytes) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
const k = 1024;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
// Preview logo on page load if URL is already filled
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
@@ -178,7 +178,7 @@
|
||||
<h3>System Management</h3>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-3">
|
||||
<div class="list-group card-custom">
|
||||
<a href="/admin/database-setup" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Database Setup</h4>
|
||||
@@ -186,7 +186,7 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="col-md-3">
|
||||
<div class="list-group card-custom">
|
||||
<a href="/admin/database-status" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">Database Status</h4>
|
||||
@@ -194,6 +194,22 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="list-group card-custom">
|
||||
<a href="/admin/s3-config" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">S3 Configuration</h4>
|
||||
<p class="list-group-item-text">Configure S3/MinIO storage</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<div class="list-group card-custom">
|
||||
<a href="/admin/s3-status" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">S3 Status</h4>
|
||||
<p class="list-group-item-text">View S3/MinIO status</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -54,6 +54,32 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- S3 Browser Modal -->
|
||||
<div class="modal fade" id="s3BrowserModal" tabindex="-1" aria-labelledby="s3BrowserModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="s3BrowserModalLabel">Browse S3 Storage</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="s3BrowserContent">
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<p>Loading S3 contents...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="selectS3FileBtn" onclick="selectS3File()" disabled>Select File</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
@@ -89,7 +115,7 @@
|
||||
<td>{{ club.hockey_club }}</td>
|
||||
<td>
|
||||
{% if club.logo_url %}
|
||||
<img src="{{ club.logo_url }}" alt="{{ club.hockey_club }} logo" style="max-height: 40px; max-width: 60px;" onerror="this.style.display='none'">
|
||||
<img src="{{ s3_asset_service.get_logo_url(club.logo_url, club.hockey_club) }}" alt="{{ club.hockey_club }} logo" style="max-height: 40px; max-width: 60px;" onerror="this.style.display='none'">
|
||||
{% else %}
|
||||
<span class="text-muted">No logo</span>
|
||||
{% endif %}
|
||||
@@ -142,6 +168,206 @@
|
||||
statusDiv.classList.add('d-none');
|
||||
}, 5000);
|
||||
}
|
||||
|
||||
// S3 Browser functionality
|
||||
let selectedS3File = null;
|
||||
let currentS3Path = '';
|
||||
|
||||
function browseS3() {
|
||||
// Reset state
|
||||
selectedS3File = null;
|
||||
currentS3Path = '';
|
||||
|
||||
// Show loading state
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<p>Loading S3 contents...</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Show modal
|
||||
const s3BrowserModal = new bootstrap.Modal(document.getElementById('s3BrowserModal'));
|
||||
s3BrowserModal.show();
|
||||
|
||||
// Load S3 contents from root of assets folder
|
||||
loadS3Contents('');
|
||||
}
|
||||
|
||||
function loadS3Contents(path) {
|
||||
fetch(`/admin/api/s3-browser?path=${encodeURIComponent(path)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
displayS3Contents(data);
|
||||
} else {
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error:</strong> ${data.message}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error:</strong> Failed to load S3 contents. Please try again.
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
function displayS3Contents(data) {
|
||||
currentS3Path = data.path;
|
||||
|
||||
let html = `
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="#" onclick="loadS3Contents('')">assets</a>
|
||||
</li>
|
||||
`;
|
||||
|
||||
// Build breadcrumb
|
||||
if (data.path !== '') {
|
||||
const pathParts = data.path.split('/').filter(p => p);
|
||||
let currentPath = '';
|
||||
|
||||
pathParts.forEach((part, index) => {
|
||||
currentPath += part + '/';
|
||||
const isLast = index === pathParts.length - 1;
|
||||
html += `<li class="breadcrumb-item ${isLast ? 'active' : ''}">`;
|
||||
|
||||
if (!isLast) {
|
||||
html += `<a href="#" onclick="loadS3Contents('${currentPath}')">${part}</a>`;
|
||||
} else {
|
||||
html += part;
|
||||
}
|
||||
html += '</li>';
|
||||
});
|
||||
}
|
||||
|
||||
html += `
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
`;
|
||||
|
||||
// Display folders
|
||||
if (data.folders.length > 0) {
|
||||
data.folders.forEach(folder => {
|
||||
html += `
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card h-100 folder-card" onclick="loadS3Contents('${folder.path}')" style="cursor: pointer;">
|
||||
<div class="card-body text-center">
|
||||
<i class="fas fa-folder fa-3x text-warning mb-2"></i>
|
||||
<h6 class="card-title">${folder.name}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
// Display files
|
||||
if (data.files.length > 0) {
|
||||
data.files.forEach(file => {
|
||||
const isImage = /\.(jpg|jpeg|png|gif|svg|webp)$/i.test(file.name);
|
||||
const fileSize = formatFileSize(file.size);
|
||||
|
||||
html += `
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card h-100 file-card" onclick="selectS3FileItem('${file.path}', '${file.url}')" style="cursor: pointer;">
|
||||
<div class="card-body text-center">
|
||||
`;
|
||||
|
||||
if (isImage) {
|
||||
html += `
|
||||
<img src="${file.url}" alt="${file.name}" class="img-fluid mb-2" style="max-height: 100px; max-width: 100%; object-fit: contain;">
|
||||
`;
|
||||
} else {
|
||||
html += `
|
||||
<i class="fas fa-file fa-3x text-primary mb-2"></i>
|
||||
`;
|
||||
}
|
||||
|
||||
html += `
|
||||
<h6 class="card-title">${file.name}</h6>
|
||||
<small class="text-muted">${fileSize}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.folders.length === 0 && data.files.length === 0) {
|
||||
html += `
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info text-center">
|
||||
<i class="fas fa-info-circle"></i> No files or folders found in this directory.
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
html += `
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.getElementById('s3BrowserContent').innerHTML = html;
|
||||
}
|
||||
|
||||
function selectS3FileItem(filePath, fileUrl) {
|
||||
// Remove previous selection
|
||||
document.querySelectorAll('.file-card').forEach(card => {
|
||||
card.classList.remove('border-primary');
|
||||
});
|
||||
|
||||
// Add selection to clicked card
|
||||
event.currentTarget.classList.add('border-primary');
|
||||
|
||||
// Store selected file
|
||||
selectedS3File = {
|
||||
path: filePath,
|
||||
url: fileUrl
|
||||
};
|
||||
|
||||
// Enable select button
|
||||
document.getElementById('selectS3FileBtn').disabled = false;
|
||||
}
|
||||
|
||||
function selectS3File() {
|
||||
if (selectedS3File) {
|
||||
// Update the logo URL field in the add club form
|
||||
const logoUrlField = document.querySelector('input[name="logo_url"]');
|
||||
if (logoUrlField) {
|
||||
logoUrlField.value = selectedS3File.path;
|
||||
}
|
||||
|
||||
// Close modal
|
||||
const s3BrowserModal = bootstrap.Modal.getInstance(document.getElementById('s3BrowserModal'));
|
||||
s3BrowserModal.hide();
|
||||
|
||||
// Show success message
|
||||
showStatus('Logo selected successfully!', 'success');
|
||||
}
|
||||
}
|
||||
|
||||
function formatFileSize(bytes) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
const k = 1024;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
function previewClubs() {
|
||||
const modal = new bootstrap.Modal(document.getElementById('previewModal'));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Edit Club - HKFC Men's C Team</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-4">
|
||||
@@ -43,7 +44,12 @@
|
||||
|
||||
<div class="mb-3">
|
||||
{{ form.logo_url.label(class="form-label") }}
|
||||
{{ form.logo_url(class="form-control", id="logoUrl", onchange="previewLogo()") }}
|
||||
<div class="input-group">
|
||||
{{ form.logo_url(class="form-control", id="logoUrl", onchange="previewLogo()") }}
|
||||
<button type="button" class="btn btn-outline-secondary" onclick="browseS3()" title="Browse S3 Storage">
|
||||
<i class="fas fa-cloud"></i> Browse S3
|
||||
</button>
|
||||
</div>
|
||||
{% if form.logo_url.errors %}
|
||||
<div class="text-danger">
|
||||
{% for error in form.logo_url.errors %}
|
||||
@@ -51,7 +57,7 @@
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endif %}
|
||||
<small class="form-text text-muted">Enter the full URL to the club's logo image</small>
|
||||
<small class="form-text text-muted">Enter the full URL to the club's logo image or use the S3 browser to select from your configured storage.</small>
|
||||
|
||||
<!-- Logo Preview -->
|
||||
<div id="logoPreview" class="mt-2" style="display: none;">
|
||||
@@ -71,6 +77,32 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- S3 Browser Modal -->
|
||||
<div class="modal fade" id="s3BrowserModal" tabindex="-1" aria-labelledby="s3BrowserModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-xl">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="s3BrowserModalLabel">Browse S3 Storage</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="s3BrowserContent">
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<p>Loading S3 contents...</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<button type="button" class="btn btn-primary" id="selectS3FileBtn" onclick="selectS3File()" disabled>Select File</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-3">
|
||||
<a href="/admin/clubs" class="btn btn-outline-secondary">Back to Club Management</a>
|
||||
</div>
|
||||
@@ -93,6 +125,205 @@
|
||||
previewDiv.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// S3 Browser functionality
|
||||
let selectedS3File = null;
|
||||
let currentS3Path = '';
|
||||
|
||||
function browseS3() {
|
||||
// Reset state
|
||||
selectedS3File = null;
|
||||
currentS3Path = '';
|
||||
|
||||
// Show loading state
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="text-center">
|
||||
<div class="spinner-border" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<p>Loading S3 contents...</p>
|
||||
</div>
|
||||
`;
|
||||
|
||||
// Show modal
|
||||
const s3BrowserModal = new bootstrap.Modal(document.getElementById('s3BrowserModal'));
|
||||
s3BrowserModal.show();
|
||||
|
||||
// Load S3 contents from root of assets folder
|
||||
loadS3Contents('');
|
||||
}
|
||||
|
||||
function loadS3Contents(path) {
|
||||
fetch(`/admin/api/s3-browser?path=${encodeURIComponent(path)}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
displayS3Contents(data);
|
||||
} else {
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error:</strong> ${data.message}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Error:', error);
|
||||
document.getElementById('s3BrowserContent').innerHTML = `
|
||||
<div class="alert alert-danger" role="alert">
|
||||
<strong>Error:</strong> Failed to load S3 contents. Please try again.
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
function displayS3Contents(data) {
|
||||
currentS3Path = data.path;
|
||||
|
||||
let html = `
|
||||
<div class="row mb-3">
|
||||
<div class="col-12">
|
||||
<nav aria-label="breadcrumb">
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="#" onclick="loadS3Contents('')">assets</a>
|
||||
</li>
|
||||
`;
|
||||
|
||||
// Build breadcrumb
|
||||
if (data.path !== '') {
|
||||
const pathParts = data.path.split('/').filter(p => p);
|
||||
let currentPath = '';
|
||||
|
||||
pathParts.forEach((part, index) => {
|
||||
currentPath += part + '/';
|
||||
const isLast = index === pathParts.length - 1;
|
||||
html += `<li class="breadcrumb-item ${isLast ? 'active' : ''}">`;
|
||||
|
||||
if (!isLast) {
|
||||
html += `<a href="#" onclick="loadS3Contents('${currentPath}')">${part}</a>`;
|
||||
} else {
|
||||
html += part;
|
||||
}
|
||||
html += '</li>';
|
||||
});
|
||||
}
|
||||
|
||||
html += `
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
`;
|
||||
|
||||
// Display folders
|
||||
if (data.folders.length > 0) {
|
||||
data.folders.forEach(folder => {
|
||||
html += `
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card h-100 folder-card" onclick="loadS3Contents('${folder.path}')" style="cursor: pointer;">
|
||||
<div class="card-body text-center">
|
||||
<i class="fas fa-folder fa-3x text-warning mb-2"></i>
|
||||
<h6 class="card-title">${folder.name}</h6>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
// Display files
|
||||
if (data.files.length > 0) {
|
||||
data.files.forEach(file => {
|
||||
const isImage = /\.(jpg|jpeg|png|gif|svg|webp)$/i.test(file.name);
|
||||
const fileSize = formatFileSize(file.size);
|
||||
|
||||
html += `
|
||||
<div class="col-md-3 mb-3">
|
||||
<div class="card h-100 file-card" onclick="selectS3FileItem('${file.path}', '${file.url}')" style="cursor: pointer;">
|
||||
<div class="card-body text-center">
|
||||
`;
|
||||
|
||||
if (isImage) {
|
||||
html += `
|
||||
<img src="${file.url}" alt="${file.name}" class="img-fluid mb-2" style="max-height: 100px; max-width: 100%; object-fit: contain;">
|
||||
`;
|
||||
} else {
|
||||
html += `
|
||||
<i class="fas fa-file fa-3x text-primary mb-2"></i>
|
||||
`;
|
||||
}
|
||||
|
||||
html += `
|
||||
<h6 class="card-title">${file.name}</h6>
|
||||
<small class="text-muted">${fileSize}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
}
|
||||
|
||||
if (data.folders.length === 0 && data.files.length === 0) {
|
||||
html += `
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info text-center">
|
||||
<i class="fas fa-info-circle"></i> No files or folders found in this directory.
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
||||
html += `
|
||||
</div>
|
||||
`;
|
||||
|
||||
document.getElementById('s3BrowserContent').innerHTML = html;
|
||||
}
|
||||
|
||||
function selectS3FileItem(filePath, fileUrl) {
|
||||
// Remove previous selection
|
||||
document.querySelectorAll('.file-card').forEach(card => {
|
||||
card.classList.remove('border-primary');
|
||||
});
|
||||
|
||||
// Add selection to clicked card
|
||||
event.currentTarget.classList.add('border-primary');
|
||||
|
||||
// Store selected file
|
||||
selectedS3File = {
|
||||
path: filePath,
|
||||
url: fileUrl
|
||||
};
|
||||
|
||||
// Enable select button
|
||||
document.getElementById('selectS3FileBtn').disabled = false;
|
||||
}
|
||||
|
||||
function selectS3File() {
|
||||
if (selectedS3File) {
|
||||
// Update the logo URL field
|
||||
const logoUrlField = document.getElementById('logoUrl');
|
||||
if (logoUrlField) {
|
||||
logoUrlField.value = selectedS3File.path;
|
||||
// Trigger preview update
|
||||
previewLogo();
|
||||
}
|
||||
|
||||
// Close modal
|
||||
const s3BrowserModal = bootstrap.Modal.getInstance(document.getElementById('s3BrowserModal'));
|
||||
s3BrowserModal.hide();
|
||||
}
|
||||
}
|
||||
|
||||
function formatFileSize(bytes) {
|
||||
if (bytes === 0) return '0 Bytes';
|
||||
const k = 1024;
|
||||
const sizes = ['Bytes', 'KB', 'MB', 'GB'];
|
||||
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
||||
return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
// Preview logo on page load if URL is already filled
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if is_admin %}
|
||||
<div class="col-md-6">
|
||||
<h3>Admin Section</h3>
|
||||
<div class="list-group">
|
||||
@@ -87,8 +88,25 @@
|
||||
<h4 class="list-group-item-heading">Database Status</h4>
|
||||
<p class="list-group-item-text">View current database configuration and status</p>
|
||||
</a>
|
||||
<a href="/admin/s3-config" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">S3 Configuration</h4>
|
||||
<p class="list-group-item-text">Configure AWS S3 storage for logos and assets</p>
|
||||
</a>
|
||||
<a href="/admin/s3-status" class="list-group-item">
|
||||
<h4 class="list-group-item-heading">S3 Status</h4>
|
||||
<p class="list-group-item-text">View current S3 configuration and connection status</p>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="col-md-6">
|
||||
<h3>Admin Access</h3>
|
||||
<div class="alert alert-info">
|
||||
<h4 class="alert-heading">Authentication Required</h4>
|
||||
<p>Admin functions require authentication. Please contact the system administrator for access.</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>S3 Configuration - HKFC Men's C Team</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
<style>
|
||||
.config-section {
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 0.375rem;
|
||||
padding: 1rem;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.help-text {
|
||||
font-size: 0.875rem;
|
||||
color: #6c757d;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-4">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>S3 Configuration</h1>
|
||||
<p class="lead">Configure AWS S3 storage for logos and assets</p>
|
||||
|
||||
<div class="mb-3">
|
||||
<a href="/admin" class="btn btn-secondary">Back to Admin</a>
|
||||
</div>
|
||||
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
<div class="alert alert-{{ 'danger' if category == 'error' else 'success' }} alert-dismissible fade show" role="alert">
|
||||
{{ message }}
|
||||
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
|
||||
<form method="POST">
|
||||
{{ form.hidden_tag() }}
|
||||
|
||||
<!-- Enable S3 Section -->
|
||||
<div class="config-section">
|
||||
<h4>Storage Configuration</h4>
|
||||
<div class="form-check form-switch mb-3">
|
||||
{{ form.enable_s3(class="form-check-input") }}
|
||||
{{ form.enable_s3.label(class="form-check-label") }}
|
||||
<div class="help-text">When enabled, logos and assets will be served from S3. When disabled, local static files will be used.</div>
|
||||
</div>
|
||||
|
||||
<div class="form-check form-switch mb-3">
|
||||
{{ form.fallback_to_static(class="form-check-input") }}
|
||||
{{ form.fallback_to_static.label(class="form-check-label") }}
|
||||
<div class="help-text">If S3 is unavailable, fallback to local static files.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Storage Provider Section -->
|
||||
<div class="config-section">
|
||||
<h4>Storage Provider</h4>
|
||||
<div class="mb-3">
|
||||
{{ form.storage_provider.label(class="form-label") }}
|
||||
{{ form.storage_provider(class="form-select") }}
|
||||
<div class="help-text">Choose between AWS S3 or MinIO (self-hosted S3-compatible storage).</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Credentials Section -->
|
||||
<div class="config-section">
|
||||
<h4>Access Credentials</h4>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
{{ form.aws_access_key_id.label(class="form-label") }}
|
||||
{{ form.aws_access_key_id(class="form-control", placeholder="AKIA...") }}
|
||||
<div class="help-text">Your Access Key ID (AWS or MinIO)</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
{{ form.aws_secret_access_key.label(class="form-label") }}
|
||||
{{ form.aws_secret_access_key(class="form-control", placeholder="Enter secret key") }}
|
||||
<div class="help-text">Your Secret Access Key (AWS or MinIO)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
{{ form.aws_region.label(class="form-label") }}
|
||||
{{ form.aws_region(class="form-control") }}
|
||||
<div class="help-text">Region (AWS) or leave default for MinIO</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- MinIO Configuration Section -->
|
||||
<div class="config-section" id="minio-config" style="display: none;">
|
||||
<h4>MinIO Configuration</h4>
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<div class="mb-3">
|
||||
{{ form.minio_endpoint.label(class="form-label") }}
|
||||
{{ form.minio_endpoint(class="form-control", placeholder="minio.example.com:9000") }}
|
||||
<div class="help-text">MinIO server endpoint (hostname:port)</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="mb-3">
|
||||
<div class="form-check form-switch">
|
||||
{{ form.minio_use_ssl(class="form-check-input") }}
|
||||
{{ form.minio_use_ssl.label(class="form-check-label") }}
|
||||
</div>
|
||||
<div class="help-text">Enable SSL/TLS for MinIO connection</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- S3 Bucket Configuration -->
|
||||
<div class="config-section">
|
||||
<h4>S3 Bucket Configuration</h4>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
{{ form.bucket_name.label(class="form-label") }}
|
||||
{{ form.bucket_name(class="form-control", placeholder="my-motm-assets") }}
|
||||
<div class="help-text">Name of your S3 bucket</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
{{ form.bucket_prefix.label(class="form-label") }}
|
||||
{{ form.bucket_prefix(class="form-control") }}
|
||||
<div class="help-text">Prefix for objects in the bucket (e.g., motm-assets/)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- URL Configuration -->
|
||||
<div class="config-section">
|
||||
<h4>URL Configuration</h4>
|
||||
<div class="form-check form-switch mb-3">
|
||||
{{ form.use_signed_urls(class="form-check-input") }}
|
||||
{{ form.use_signed_urls.label(class="form-check-label") }}
|
||||
<div class="help-text">Use signed URLs for secure access to private objects. If disabled, objects must be public.</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
{{ form.signed_url_expiry.label(class="form-label") }}
|
||||
{{ form.signed_url_expiry(class="form-control") }}
|
||||
<div class="help-text">How long signed URLs remain valid (in seconds)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="d-flex gap-2">
|
||||
{{ form.test_connection(class="btn btn-info") }}
|
||||
{{ form.save_config(class="btn btn-primary") }}
|
||||
{{ form.cancel(class="btn btn-secondary") }}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Current Configuration Display -->
|
||||
<div class="config-section mt-4">
|
||||
<h4>Current Configuration</h4>
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<strong>S3 Status:</strong>
|
||||
<span class="badge bg-{{ 'success' if current_config.get('enable_s3') else 'secondary' }}">
|
||||
{{ 'Enabled' if current_config.get('enable_s3') else 'Disabled' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<strong>Bucket:</strong> {{ current_config.get('bucket_name', 'Not configured') }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mt-2">
|
||||
<div class="col-md-6">
|
||||
<strong>Region:</strong> {{ current_config.get('aws_region', 'Not configured') }}
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<strong>Signed URLs:</strong>
|
||||
<span class="badge bg-{{ 'success' if current_config.get('use_signed_urls') else 'secondary' }}">
|
||||
{{ 'Enabled' if current_config.get('use_signed_urls') else 'Disabled' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Help Section -->
|
||||
<div class="config-section mt-4">
|
||||
<h4>Setup Instructions</h4>
|
||||
<ol>
|
||||
<li><strong>Create S3 Bucket:</strong> Create an S3 bucket in your AWS account</li>
|
||||
<li><strong>Set Permissions:</strong> Configure bucket permissions for your access key</li>
|
||||
<li><strong>Upload Assets:</strong> Upload your logos and assets to the bucket</li>
|
||||
<li><strong>Configure Here:</strong> Enter your credentials and bucket details above</li>
|
||||
<li><strong>Test Connection:</strong> Use the "Test S3 Connection" button to verify</li>
|
||||
<li><strong>Save Configuration:</strong> Save your settings to enable S3 storage</li>
|
||||
</ol>
|
||||
|
||||
<div class="alert alert-info">
|
||||
<h6>Asset Organization</h6>
|
||||
<p>Organize your assets in the S3 bucket as follows:</p>
|
||||
<ul class="mb-0">
|
||||
<li><code>assets/images/clubs/</code> - Club logos</li>
|
||||
<li><code>assets/images/</code> - General images</li>
|
||||
<li><code>assets/logos/</code> - Alternative logo location</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
<script>
|
||||
// Show/hide MinIO configuration based on storage provider selection
|
||||
function toggleMinioConfig() {
|
||||
const storageProvider = document.getElementById('storage_provider');
|
||||
const minioConfig = document.getElementById('minio-config');
|
||||
|
||||
if (storageProvider.value === 'minio') {
|
||||
minioConfig.style.display = 'block';
|
||||
} else {
|
||||
minioConfig.style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize on page load
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
toggleMinioConfig();
|
||||
|
||||
// Add event listener for storage provider changes
|
||||
const storageProviderSelect = document.getElementById('storage_provider');
|
||||
if (storageProviderSelect) {
|
||||
storageProviderSelect.addEventListener('change', toggleMinioConfig);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,154 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>S3 Status - HKFC Men's C Team</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<div class="container mt-4">
|
||||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<h1>S3 Storage Status</h1>
|
||||
<p class="lead">Current S3 configuration and connection status</p>
|
||||
|
||||
<div class="mb-3">
|
||||
<a href="/admin/s3-config" class="btn btn-primary">Configure S3</a>
|
||||
<a href="/admin" class="btn btn-secondary">Back to Admin</a>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5>Configuration Status</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td><strong>S3 Storage:</strong></td>
|
||||
<td>
|
||||
<span class="badge bg-{{ 'success' if s3_info.enabled else 'secondary' }}">
|
||||
{{ 'Enabled' if s3_info.enabled else 'Disabled' }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Provider:</strong></td>
|
||||
<td>{{ s3_info.storage_provider.title() if s3_info.get('storage_provider') else 'AWS S3' }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Bucket Name:</strong></td>
|
||||
<td>{{ s3_info.bucket_name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Region:</strong></td>
|
||||
<td>{{ s3_info.aws_region }}</td>
|
||||
</tr>
|
||||
{% if s3_info.get('storage_provider') == 'minio' %}
|
||||
<tr>
|
||||
<td><strong>MinIO Endpoint:</strong></td>
|
||||
<td>{{ s3_info.get('minio_endpoint', 'Not configured') }}</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<table class="table table-borderless">
|
||||
<tr>
|
||||
<td><strong>Signed URLs:</strong></td>
|
||||
<td>
|
||||
<span class="badge bg-{{ 'success' if s3_info.use_signed_urls else 'secondary' }}">
|
||||
{{ 'Enabled' if s3_info.use_signed_urls else 'Disabled' }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Fallback:</strong></td>
|
||||
<td>
|
||||
<span class="badge bg-{{ 'success' if s3_info.fallback_enabled else 'warning' }}">
|
||||
{{ 'Enabled' if s3_info.fallback_enabled else 'Disabled' }}
|
||||
</span>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5>Connection Status</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="alert alert-{{ 'success' if s3_info.connection_success else 'danger' }}" role="alert">
|
||||
<h6 class="alert-heading">
|
||||
{{ '✅ Connection Successful' if s3_info.connection_success else '❌ Connection Failed' }}
|
||||
</h6>
|
||||
<p class="mb-0">{{ s3_info.connection_status }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if s3_info.enabled and s3_info.connection_success %}
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5>Asset Management</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>S3 storage is properly configured and connected. Assets will be served from S3.</p>
|
||||
<div class="alert alert-info">
|
||||
<h6>Asset Locations</h6>
|
||||
<ul class="mb-0">
|
||||
<li><strong>Club Logos:</strong> <code>{{ s3_info.bucket_name }}/assets/images/clubs/</code></li>
|
||||
<li><strong>General Images:</strong> <code>{{ s3_info.bucket_name }}/assets/images/</code></li>
|
||||
<li><strong>Player Images:</strong> <code>{{ s3_info.bucket_name }}/assets/images/players/</code></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% elif s3_info.enabled and not s3_info.connection_success %}
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5>Troubleshooting</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="alert alert-warning">
|
||||
<h6>S3 is enabled but connection failed</h6>
|
||||
<p>Check the following:</p>
|
||||
<ul>
|
||||
<li>Verify AWS credentials are correct</li>
|
||||
<li>Ensure the bucket name exists</li>
|
||||
<li>Check bucket permissions</li>
|
||||
<li>Verify AWS region is correct</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="card mt-4">
|
||||
<div class="card-header">
|
||||
<h5>Static File Storage</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p>S3 storage is disabled. Assets are being served from local static files.</p>
|
||||
<div class="alert alert-info">
|
||||
<h6>Local Asset Locations</h6>
|
||||
<ul class="mb-0">
|
||||
<li><strong>Club Logos:</strong> <code>/static/images/clubs/</code></li>
|
||||
<li><strong>General Images:</strong> <code>/static/images/</code></li>
|
||||
<li><strong>Player Images:</strong> <code>/static/images/players/</code></li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user