Ajoute la V1 fonctionnelle : upload invité, galerie admin, QR code, backend Supabase
Schéma dédié `photobooth` (jamais exposé via PostgREST, accès exclusivement via fonctions SECURITY DEFINER dans public) avec RLS, policies Storage sur bucket privé event-photos, Edge Functions admin-gallery et expire-events, et job pg_cron d'expiration J+7. Le tout déployé et testé en conditions réelles sur le projet Supabase kevin-lecou-hub avant relecture sécurité (faille d'abus sur insert_public_photo corrigée en cours de route). Côté front : page upload invité (compression + HEIC + RGPD), galerie admin avec export ZIP, générateur de QR code autonome. Workflow n8n de purge Storage J+7 fourni (à activer manuellement côté n8n).
This commit is contained in:
@@ -0,0 +1,218 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Générateur de QR code — photobooth-qr (admin)</title>
|
||||
<meta name="robots" content="noindex, nofollow" />
|
||||
<style>
|
||||
:root {
|
||||
color-scheme: light;
|
||||
--border: #d8d8d8;
|
||||
--text: #1a1a1a;
|
||||
--muted: #666;
|
||||
--accent: #1a1a1a;
|
||||
}
|
||||
* { box-sizing: border-box; }
|
||||
body {
|
||||
margin: 0;
|
||||
padding: 1.25rem;
|
||||
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
|
||||
color: var(--text);
|
||||
background: #fafafa;
|
||||
max-width: 480px;
|
||||
margin-inline: auto;
|
||||
}
|
||||
h1 {
|
||||
font-size: 1.1rem;
|
||||
margin: 0 0 0.25rem;
|
||||
}
|
||||
p.hint {
|
||||
color: var(--muted);
|
||||
font-size: 0.85rem;
|
||||
margin-top: 0;
|
||||
margin-bottom: 1.25rem;
|
||||
}
|
||||
label {
|
||||
display: block;
|
||||
font-size: 0.85rem;
|
||||
margin-bottom: 0.25rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
input, select {
|
||||
width: 100%;
|
||||
padding: 0.6rem;
|
||||
font-size: 1rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
}
|
||||
.preview {
|
||||
margin-top: 1.5rem;
|
||||
padding: 1rem;
|
||||
border: 1px solid var(--border);
|
||||
border-radius: 8px;
|
||||
background: #fff;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
}
|
||||
.preview svg {
|
||||
width: 100%;
|
||||
max-width: 280px;
|
||||
height: auto;
|
||||
}
|
||||
.preview .url {
|
||||
font-size: 0.8rem;
|
||||
color: var(--muted);
|
||||
word-break: break-all;
|
||||
text-align: center;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 0.5rem;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
button {
|
||||
flex: 1;
|
||||
padding: 0.7rem;
|
||||
font-size: 0.95rem;
|
||||
border: 1px solid var(--accent);
|
||||
border-radius: 6px;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
}
|
||||
button.secondary {
|
||||
background: #fff;
|
||||
color: var(--accent);
|
||||
}
|
||||
button:disabled {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
.error {
|
||||
color: #b00020;
|
||||
font-size: 0.85rem;
|
||||
margin-top: 0.5rem;
|
||||
min-height: 1.2em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Générateur de QR code — événement</h1>
|
||||
<p class="hint">
|
||||
Outil admin autonome : saisir le slug d'un événement et le domaine de
|
||||
l'app pour générer et exporter le QR code (PNG / SVG) à imprimer.
|
||||
Ne fait aucun appel à Supabase.
|
||||
</p>
|
||||
|
||||
<label for="slug">Slug de l'événement</label>
|
||||
<input id="slug" type="text" placeholder="mariage-julie-marc" autocomplete="off" />
|
||||
|
||||
<label for="baseUrl">Domaine de base de l'app</label>
|
||||
<input id="baseUrl" type="text" placeholder="https://photobooth.mondomaine.fr" autocomplete="off" />
|
||||
|
||||
<label for="ecLevel">Niveau de correction d'erreur</label>
|
||||
<select id="ecLevel">
|
||||
<option value="L">L — bas (fichier le plus léger)</option>
|
||||
<option value="M" selected>M — moyen (par défaut)</option>
|
||||
<option value="Q">Q — élevé (recommandé si affiché en extérieur)</option>
|
||||
<option value="H">H — maximal (support très exposé/manipulé)</option>
|
||||
</select>
|
||||
|
||||
<div class="preview" id="preview" hidden>
|
||||
<div id="svgContainer"></div>
|
||||
<div class="url" id="urlDisplay"></div>
|
||||
</div>
|
||||
|
||||
<div class="error" id="error" role="alert"></div>
|
||||
|
||||
<div class="actions">
|
||||
<button id="downloadSvg" disabled>Télécharger SVG</button>
|
||||
<button id="downloadPng" class="secondary" disabled>Télécharger PNG</button>
|
||||
</div>
|
||||
|
||||
<script type="module">
|
||||
import {
|
||||
DEFAULT_BASE_URL,
|
||||
buildEventUrl,
|
||||
generateEventQrSvg,
|
||||
downloadEventQrSvg,
|
||||
downloadEventQrPng,
|
||||
} from './qrcode.js';
|
||||
|
||||
const slugInput = document.getElementById('slug');
|
||||
const baseUrlInput = document.getElementById('baseUrl');
|
||||
const ecLevelSelect = document.getElementById('ecLevel');
|
||||
const preview = document.getElementById('preview');
|
||||
const svgContainer = document.getElementById('svgContainer');
|
||||
const urlDisplay = document.getElementById('urlDisplay');
|
||||
const errorEl = document.getElementById('error');
|
||||
const btnSvg = document.getElementById('downloadSvg');
|
||||
const btnPng = document.getElementById('downloadPng');
|
||||
|
||||
// Champ laissé vide par défaut : si non renseigné, le module résout le
|
||||
// domaine via window.__PHOTOBOOTH_CONFIG__.APP_BASE_URL (si présent,
|
||||
// voir src/e/config.example.js) puis via DEFAULT_BASE_URL en secours.
|
||||
baseUrlInput.placeholder = DEFAULT_BASE_URL;
|
||||
|
||||
function currentOptions() {
|
||||
const baseUrl = baseUrlInput.value.trim() || undefined;
|
||||
const errorCorrectionLevel = ecLevelSelect.value;
|
||||
return { baseUrl, errorCorrectionLevel };
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
errorEl.textContent = '';
|
||||
const slug = slugInput.value.trim();
|
||||
|
||||
if (!slug) {
|
||||
preview.hidden = true;
|
||||
btnSvg.disabled = true;
|
||||
btnPng.disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const options = currentOptions();
|
||||
const svg = generateEventQrSvg(slug, options);
|
||||
svgContainer.innerHTML = svg;
|
||||
urlDisplay.textContent = buildEventUrl(slug, options.baseUrl);
|
||||
preview.hidden = false;
|
||||
btnSvg.disabled = false;
|
||||
btnPng.disabled = false;
|
||||
} catch (err) {
|
||||
preview.hidden = true;
|
||||
btnSvg.disabled = true;
|
||||
btnPng.disabled = true;
|
||||
errorEl.textContent = err.message;
|
||||
}
|
||||
}
|
||||
|
||||
slugInput.addEventListener('input', refresh);
|
||||
baseUrlInput.addEventListener('input', refresh);
|
||||
ecLevelSelect.addEventListener('change', refresh);
|
||||
|
||||
btnSvg.addEventListener('click', () => {
|
||||
const slug = slugInput.value.trim();
|
||||
if (!slug) return;
|
||||
downloadEventQrSvg(slug, { ...currentOptions(), filename: `qr-${slug}.svg` });
|
||||
});
|
||||
|
||||
btnPng.addEventListener('click', async () => {
|
||||
const slug = slugInput.value.trim();
|
||||
if (!slug) return;
|
||||
btnPng.disabled = true;
|
||||
try {
|
||||
await downloadEventQrPng(slug, { ...currentOptions(), filename: `qr-${slug}.png` });
|
||||
} catch (err) {
|
||||
errorEl.textContent = err.message;
|
||||
} finally {
|
||||
btnPng.disabled = false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user