diff --git a/backend/handlers.go b/backend/handlers.go
index 41db220..4056c6c 100644
--- a/backend/handlers.go
+++ b/backend/handlers.go
@@ -407,7 +407,7 @@ func listLogos(c *gin.Context) {
logo.HasSVG = hasSVG == 1
logo.HasPNG = hasPNG == 1
-
+
if logo.HasPNG {
logo.LogoURL = fmt.Sprintf("%s/logos/%s?format=png", baseURL, logo.ID)
} else if logo.HasSVG {
@@ -433,26 +433,39 @@ func uploadLogo(c *gin.Context) {
return
}
- // Get club name from form (required)
+ // Read metadata from form
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")
clubType := c.PostForm("club_type")
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
file, err := c.FormFile("file")
if err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "no file provided"})
return
}
-
- // Validate file type
ext := strings.ToLower(filepath.Ext(file.Filename))
if ext != ".svg" && ext != ".png" && ext != ".pdf" {
c.JSON(http.StatusBadRequest, gin.H{"error": "only .svg, .png and .pdf files are allowed"})
diff --git a/frontend/admin.html b/frontend/admin.html
index 20ad543..4fd3dfc 100644
--- a/frontend/admin.html
+++ b/frontend/admin.html
@@ -72,19 +72,18 @@
>
-
+
-
Povinné: Nahrání bude zamítnuto bez názvu klubu
+
Volitelné: Pokud název neuvedete, doplníme jej automaticky dle FAČR (podle UUID)
@@ -178,7 +177,7 @@
⚠️ Požadavky na nahrání:
- - Název klubu je povinný (automatické zamítnutí bez něj)
+ - Název klubu je volitelný (doplníme dle FAČR podle UUID)
- UUID klubu musí být platné
- Akceptovány pouze SVG, PNG a PDF soubory
- Doporučeno průhledné pozadí
diff --git a/frontend/logo.html b/frontend/logo.html
index 0c326bd..4928f0f 100644
--- a/frontend/logo.html
+++ b/frontend/logo.html
@@ -52,7 +52,7 @@
-
+
✏️ Upravit
diff --git a/frontend/src/admin.js b/frontend/src/admin.js
index 43198ee..8c5762e 100644
--- a/frontend/src/admin.js
+++ b/frontend/src/admin.js
@@ -385,11 +385,6 @@ uploadForm.addEventListener('submit', async (e) => {
return
}
- if (!clubName) {
- showNotification('Název klubu je povinný', 'error')
- return
- }
-
if (selectedFiles.length === 0) {
showNotification('Vyberte prosím soubor loga', 'error')
return
@@ -508,6 +503,38 @@ console.log('🇨🇿 České Kluby Loga API - Administrace')
console.log('Backend API:', API_BASE_URL)
console.log('FAČR API:', FACR_API_URL)
+// Prefill editing when navigated with ?id=
+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
const loadFromUrlBtn = document.getElementById('loadFromUrl')
const logoUrlInput = document.getElementById('logoUrl')
diff --git a/frontend/src/logo.js b/frontend/src/logo.js
index a047882..4adbde6 100644
--- a/frontend/src/logo.js
+++ b/frontend/src/logo.js
@@ -43,6 +43,8 @@ function displayLogoDetails(logo) {
logoDetail.classList.remove('hidden')
// Club Info
+ const editBtn = document.getElementById('editButton')
+ if (editBtn) editBtn.href = `/admin.html?id=${logoId}`
document.getElementById('clubName').textContent = logo.club_name
document.getElementById('clubMeta').textContent = `${logo.club_type || 'fotbal'}`
@@ -137,7 +139,7 @@ function displayLogoDetails(logo) {
document.getElementById('uploadDate').textContent = formatDate(logo.created_at)
// API URLs
- const baseUrl = window.location.origin
+ const baseUrl = API_BASE_URL
document.getElementById('apiUrlDefault').textContent = `${baseUrl}/logos/${logo.id}`
document.getElementById('apiUrlJson').textContent = `${baseUrl}/logos/${logo.id}/json`