diff --git a/dashboard/index.html b/dashboard/index.html index 0bfede6..1ceefa5 100644 --- a/dashboard/index.html +++ b/dashboard/index.html @@ -73,12 +73,12 @@
Changer
- +
-
- Cliquer sur l'icône pour personnaliser · SVG JPG PNG WEBP · max 128×128 px +
+ Cliquer sur l'icône pour personnaliser · JPG PNG WEBP · max 128×128 px
diff --git a/dashboard/js/popups.js b/dashboard/js/popups.js index 7bba143..1b5f42f 100644 --- a/dashboard/js/popups.js +++ b/dashboard/js/popups.js @@ -30,8 +30,27 @@ const Popups = (() => { document.getElementById('icon-upload').onchange = async (e) => { const file = e.target.files[0]; if (!file) return; - await API.uploadIcon(agentId, file); - img.src = API.iconUrl(agentId) + '?t=' + Date.now(); + const hint = document.getElementById('icon-hint'); + try { + await API.uploadIcon(agentId, file); + const ts = '?t=' + Date.now(); + img.src = API.iconUrl(agentId) + ts; + img.style.display = 'block'; + document.getElementById('pop-icon-fa').style.display = 'none'; + const tileImg = document.querySelector(`#tile-${CSS.escape(agentId)} .t-icon img`); + if (tileImg) tileImg.src = API.iconUrl(agentId) + ts; + } catch (err) { + if (hint) { + hint.style.color = 'var(--err)'; + hint.textContent = 'Erreur : ' + (err.message || 'téléversement échoué'); + setTimeout(() => { + hint.style.color = ''; + hint.textContent = 'Cliquer sur l\'icône pour personnaliser · JPG PNG WEBP · max 128×128 px'; + }, 4000); + } + } finally { + e.target.value = ''; + } }; // Uptime diff --git a/server/handlers/icons.go b/server/handlers/icons.go index 97e01a0..8185773 100644 --- a/server/handlers/icons.go +++ b/server/handlers/icons.go @@ -3,6 +3,7 @@ package handlers import ( "bytes" "image" + _ "image/gif" _ "image/jpeg" "image/png" "io" @@ -11,6 +12,7 @@ import ( "github.com/disintegration/imaging" "github.com/user/nanometrics/server/db" + _ "golang.org/x/image/webp" ) const maxIconSize = 128 diff --git a/server/nginx/nginx.conf b/server/nginx/nginx.conf index b585da6..98f4e33 100644 --- a/server/nginx/nginx.conf +++ b/server/nginx/nginx.conf @@ -2,6 +2,7 @@ server { listen 80; root /usr/share/nginx/html; index index.html; + client_max_body_size 10m; location /api/ { proxy_pass http://server:8080;