Vision éditable — contenu chargé depuis NocoDB
- Nouvelle table NocoDB Vision (9 sections : trois-mots, phrase, synopsis, tags, listes, inspirations) - Routes API /api/vision GET + PATCH dans server.js - Frontend : contenteditable sur les champs texte, sauvegarde auto au blur - Tags, listes et inspirations : ajout/suppression/édition en place - Indicateur "Enregistré" discret en bas à droite - Variable NOCODB_VISION_TABLE_ID ajoutée Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,6 +14,7 @@ const NOCODB_URL = process.env.NOCODB_URL || 'https://nocodb.hub.delvarre.net';
|
||||
const NOCODB_TOKEN = process.env.NOCODB_TOKEN || '';
|
||||
const NOCODB_BASE_ID = process.env.NOCODB_BASE_ID || '';
|
||||
const NOCODB_TABLE_ID = process.env.NOCODB_TABLE_ID || '';
|
||||
const NOCODB_VISION_TABLE_ID = process.env.NOCODB_VISION_TABLE_ID || '';
|
||||
|
||||
// Auth
|
||||
function makeToken(ts) {
|
||||
@@ -142,6 +143,36 @@ app.post('/api/reorder', requireAuth, async (req, res) => {
|
||||
}
|
||||
});
|
||||
|
||||
// ── Vision API ──
|
||||
|
||||
// List all vision sections
|
||||
app.get('/api/vision', requireAuth, async (req, res) => {
|
||||
try {
|
||||
const url = `${NOCODB_URL}/api/v1/db/data/noco/${NOCODB_BASE_ID}/${NOCODB_VISION_TABLE_ID}?limit=50&sort=Ordre`;
|
||||
const r = await fetch(url, { headers: { 'xc-token': NOCODB_TOKEN } });
|
||||
const data = await r.json();
|
||||
res.json(data);
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Update a vision section
|
||||
app.patch('/api/vision/:id', requireAuth, async (req, res) => {
|
||||
try {
|
||||
const url = `${NOCODB_URL}/api/v1/db/data/noco/${NOCODB_BASE_ID}/${NOCODB_VISION_TABLE_ID}/${req.params.id}`;
|
||||
const r = await fetch(url, {
|
||||
method: 'PATCH',
|
||||
headers: { 'xc-token': NOCODB_TOKEN, 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify(req.body),
|
||||
});
|
||||
const data = await r.json();
|
||||
res.status(r.status).json(data);
|
||||
} catch (e) {
|
||||
res.status(500).json({ error: e.message });
|
||||
}
|
||||
});
|
||||
|
||||
// Auth gate — redirect to login page if not authenticated
|
||||
app.get('/', (req, res) => {
|
||||
if (isAuth(req)) {
|
||||
|
||||
Reference in New Issue
Block a user