mirror of
https://github.com/Dvorinka/ClubLogos.git
synced 2026-06-03 19:42:58 +00:00
bgbg
This commit is contained in:
+22
-9
@@ -433,26 +433,39 @@ func uploadLogo(c *gin.Context) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get club name from form (required)
|
// Read metadata from form
|
||||||
clubName := c.PostForm("club_name")
|
clubName := c.PostForm("club_name")
|
||||||
if clubName == "" {
|
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "club_name is required"})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// Optional fields
|
|
||||||
clubCity := c.PostForm("club_city")
|
clubCity := c.PostForm("club_city")
|
||||||
clubType := c.PostForm("club_type")
|
clubType := c.PostForm("club_type")
|
||||||
clubWebsite := c.PostForm("club_website")
|
clubWebsite := c.PostForm("club_website")
|
||||||
|
|
||||||
|
// Derive metadata if missing
|
||||||
|
if clubName == "" {
|
||||||
|
if club, err := facrClient.GetClub(id); err == nil && club != nil {
|
||||||
|
if club.Name != "" {
|
||||||
|
clubName = club.Name
|
||||||
|
}
|
||||||
|
if clubType == "" && club.Type != "" {
|
||||||
|
clubType = club.Type
|
||||||
|
}
|
||||||
|
if clubCity == "" && club.City != "" {
|
||||||
|
clubCity = club.City
|
||||||
|
}
|
||||||
|
if clubWebsite == "" && club.Website != "" {
|
||||||
|
clubWebsite = club.Website
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if clubName == "" {
|
||||||
|
clubName = "Club " + id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Get uploaded file
|
// Get uploaded file
|
||||||
file, err := c.FormFile("file")
|
file, err := c.FormFile("file")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "no file provided"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "no file provided"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate file type
|
|
||||||
ext := strings.ToLower(filepath.Ext(file.Filename))
|
ext := strings.ToLower(filepath.Ext(file.Filename))
|
||||||
if ext != ".svg" && ext != ".png" && ext != ".pdf" {
|
if ext != ".svg" && ext != ".png" && ext != ".pdf" {
|
||||||
c.JSON(http.StatusBadRequest, gin.H{"error": "only .svg, .png and .pdf files are allowed"})
|
c.JSON(http.StatusBadRequest, gin.H{"error": "only .svg, .png and .pdf files are allowed"})
|
||||||
|
|||||||
+4
-5
@@ -72,19 +72,18 @@
|
|||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Club Name (Required) -->
|
<!-- Club Name (Optional) -->
|
||||||
<div>
|
<div>
|
||||||
<label class="block text-sm font-medium text-gray-400 mb-2">
|
<label class="block text-sm font-medium text-gray-400 mb-2">
|
||||||
Název Klubu <span class="text-red-500">*</span>
|
Název Klubu <span class="text-gray-500 text-xs">(volitelné)</span>
|
||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
id="clubName"
|
id="clubName"
|
||||||
required
|
|
||||||
placeholder="AC Sparta Praha"
|
placeholder="AC Sparta Praha"
|
||||||
class="w-full bg-dark-bg border border-dark-border rounded-lg px-4 py-3 text-white focus:outline-none focus:border-accent-blue transition-smooth"
|
class="w-full bg-dark-bg border border-dark-border rounded-lg px-4 py-3 text-white focus:outline-none focus:border-accent-blue transition-smooth"
|
||||||
>
|
>
|
||||||
<p class="text-xs text-gray-500 mt-1">Povinné: Nahrání bude zamítnuto bez názvu klubu</p>
|
<p class="text-xs text-gray-500 mt-1">Volitelné: Pokud název neuvedete, doplníme jej automaticky dle FAČR (podle UUID)</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Club Type -->
|
<!-- Club Type -->
|
||||||
@@ -178,7 +177,7 @@
|
|||||||
<div class="bg-red-900/20 border border-red-800 rounded-lg p-4 text-sm">
|
<div class="bg-red-900/20 border border-red-800 rounded-lg p-4 text-sm">
|
||||||
<p class="font-semibold text-red-400 mb-2">⚠️ Požadavky na nahrání:</p>
|
<p class="font-semibold text-red-400 mb-2">⚠️ Požadavky na nahrání:</p>
|
||||||
<ul class="list-disc list-inside space-y-1 text-red-300/80">
|
<ul class="list-disc list-inside space-y-1 text-red-300/80">
|
||||||
<li>Název klubu je povinný (automatické zamítnutí bez něj)</li>
|
<li>Název klubu je volitelný (doplníme dle FAČR podle UUID)</li>
|
||||||
<li>UUID klubu musí být platné</li>
|
<li>UUID klubu musí být platné</li>
|
||||||
<li>Akceptovány pouze SVG, PNG a PDF soubory</li>
|
<li>Akceptovány pouze SVG, PNG a PDF soubory</li>
|
||||||
<li>Doporučeno průhledné pozadí</li>
|
<li>Doporučeno průhledné pozadí</li>
|
||||||
|
|||||||
+1
-1
@@ -52,7 +52,7 @@
|
|||||||
<h1 id="clubName" class="text-4xl font-bold gradient-text mb-2"></h1>
|
<h1 id="clubName" class="text-4xl font-bold gradient-text mb-2"></h1>
|
||||||
<p id="clubMeta" class="text-gray-400"></p>
|
<p id="clubMeta" class="text-gray-400"></p>
|
||||||
</div>
|
</div>
|
||||||
<a href="/admin.html" class="px-4 py-2 bg-accent-blue rounded-lg hover:bg-blue-600 transition-smooth">
|
<a id="editButton" href="/admin.html" class="px-4 py-2 bg-accent-blue rounded-lg hover:bg-blue-600 transition-smooth">
|
||||||
✏️ Upravit
|
✏️ Upravit
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+32
-5
@@ -385,11 +385,6 @@ uploadForm.addEventListener('submit', async (e) => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!clubName) {
|
|
||||||
showNotification('Název klubu je povinný', 'error')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if (selectedFiles.length === 0) {
|
if (selectedFiles.length === 0) {
|
||||||
showNotification('Vyberte prosím soubor loga', 'error')
|
showNotification('Vyberte prosím soubor loga', 'error')
|
||||||
return
|
return
|
||||||
@@ -508,6 +503,38 @@ console.log('🇨🇿 České Kluby Loga API - Administrace')
|
|||||||
console.log('Backend API:', API_BASE_URL)
|
console.log('Backend API:', API_BASE_URL)
|
||||||
console.log('FAČR API:', FACR_API_URL)
|
console.log('FAČR API:', FACR_API_URL)
|
||||||
|
|
||||||
|
// Prefill editing when navigated with ?id=<uuid>
|
||||||
|
try {
|
||||||
|
const params = new URLSearchParams(window.location.search)
|
||||||
|
const editId = params.get('id')
|
||||||
|
if (editId) {
|
||||||
|
// Fill UUID and show upload section
|
||||||
|
const uuidInput = document.getElementById('clubUuid')
|
||||||
|
uuidInput.value = editId
|
||||||
|
uploadSection.classList.remove('hidden')
|
||||||
|
uploadSection.scrollIntoView({ behavior: 'smooth', block: 'start' })
|
||||||
|
showNotification('Režim úprav pro existující logo', 'info')
|
||||||
|
|
||||||
|
// Load metadata to prefill fields
|
||||||
|
;(async () => {
|
||||||
|
try {
|
||||||
|
const resp = await fetch(`${API_BASE_URL}/logos/${editId}/json`)
|
||||||
|
if (resp.ok) {
|
||||||
|
const contentType = resp.headers.get('content-type') || ''
|
||||||
|
if (contentType.includes('application/json')) {
|
||||||
|
const data = await resp.json()
|
||||||
|
if (data.club_name) document.getElementById('clubName').value = data.club_name
|
||||||
|
if (data.club_type) document.getElementById('clubType').value = data.club_type
|
||||||
|
if (data.club_website) document.getElementById('clubWebsite').value = data.club_website
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
// Non-fatal
|
||||||
|
}
|
||||||
|
})()
|
||||||
|
}
|
||||||
|
} catch (_) {}
|
||||||
|
|
||||||
// Load from URL functionality
|
// Load from URL functionality
|
||||||
const loadFromUrlBtn = document.getElementById('loadFromUrl')
|
const loadFromUrlBtn = document.getElementById('loadFromUrl')
|
||||||
const logoUrlInput = document.getElementById('logoUrl')
|
const logoUrlInput = document.getElementById('logoUrl')
|
||||||
|
|||||||
@@ -43,6 +43,8 @@ function displayLogoDetails(logo) {
|
|||||||
logoDetail.classList.remove('hidden')
|
logoDetail.classList.remove('hidden')
|
||||||
|
|
||||||
// Club Info
|
// Club Info
|
||||||
|
const editBtn = document.getElementById('editButton')
|
||||||
|
if (editBtn) editBtn.href = `/admin.html?id=${logoId}`
|
||||||
document.getElementById('clubName').textContent = logo.club_name
|
document.getElementById('clubName').textContent = logo.club_name
|
||||||
document.getElementById('clubMeta').textContent = `${logo.club_type || 'fotbal'}`
|
document.getElementById('clubMeta').textContent = `${logo.club_type || 'fotbal'}`
|
||||||
|
|
||||||
@@ -137,7 +139,7 @@ function displayLogoDetails(logo) {
|
|||||||
document.getElementById('uploadDate').textContent = formatDate(logo.created_at)
|
document.getElementById('uploadDate').textContent = formatDate(logo.created_at)
|
||||||
|
|
||||||
// API URLs
|
// API URLs
|
||||||
const baseUrl = window.location.origin
|
const baseUrl = API_BASE_URL
|
||||||
document.getElementById('apiUrlDefault').textContent = `${baseUrl}/logos/${logo.id}`
|
document.getElementById('apiUrlDefault').textContent = `${baseUrl}/logos/${logo.id}`
|
||||||
document.getElementById('apiUrlJson').textContent = `${baseUrl}/logos/${logo.id}/json`
|
document.getElementById('apiUrlJson').textContent = `${baseUrl}/logos/${logo.id}/json`
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user