Ajout du script de base de données scheme_clean.sql pour initialiser les tables, types, fonctions et commentaires.

This commit is contained in:
mathis committed 2026-08-25 16:35:40 +02:00
1 parent 3eaca9c72b
commit bbeac5af86
10 files changed
+1881 -83

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
module.exports = {
apps: [
{
name: "ferrovia-panel",
cwd: "/var/www/ferrovia-panel",
script: "npm",
args: "run start",
instances: 1,
exec_mode: "fork",
autorestart: true,
watch: false,
max_memory_restart: "1G",
env: {
NODE_ENV: "production",
HOST: "127.0.0.1",
PORT: 3000
},
time: true,
merge_logs: true,
out_file: "/var/www/ferrovia-panel/logs/out.log",
error_file: "/var/www/ferrovia-panel/logs/error.log"
}
]
};
+4 -1
View File
@@ -4,7 +4,10 @@
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/logos/logo-sncf.svg" />
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logos/logo-sncf.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="mobile-web-app-capable" content="yes" />
<meta name="theme-color" content="#000000" />
<meta name="description" content="Interface d'administration pour la gestion de l'exploitation régionale de la SNCF." />
<meta name="keywords" content="administration, régions, horaires, perturbations, gestion, SNCF" />
+9 -5
View File
@@ -1,6 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"short_name": "Admin Régions",
"name": "SNCF Admin - Gestion des régions",
"icons": [
{
"src": "favicon.ico",
@@ -10,16 +10,20 @@
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
"sizes": "192x192",
"purpose": "any maskable"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
"sizes": "512x512",
"purpose": "any maskable"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
"background_color": "#ffffff",
"orientation": "portrait-primary",
"description": "Interface d'administration pour la gestion de l'exploitation régionale de la SNCF."
}
+1624
View File
File diff suppressed because it is too large. Load diff
+6
View File
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import * as serviceWorkerRegistration from './serviceWorkerRegistration';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
@@ -15,3 +16,8 @@ root.render(
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://cra.link/PWA
serviceWorkerRegistration.register();
+3 -3
View File
@@ -917,7 +917,7 @@ export default function Gares() {
data-field="nom"
value={formData.nom}
placeholder="Ex: Paris Gare de Lyon"
onWcsChange={(e) => updateField('nom', e.detail?.value || '')}
onInput={(e) => updateField('nom', e.target.value || '')}
/>
</div>
@@ -977,7 +977,7 @@ export default function Gares() {
data-quai-id={quai.clientId}
value={quai.nom}
placeholder="Nom du quai (ex: Voie A)"
onWcsChange={(e) => updateQuai(quai.clientId, 'nom', e.detail?.value || '')}
onInput={(e) => updateQuai(quai.clientId, 'nom', e.target.value || '')}
/>
<wcs-input
data-field="quai-distance"
@@ -985,7 +985,7 @@ export default function Gares() {
type="number"
value={quai.distance_metres}
placeholder="Distance (m)"
onWcsChange={(e) => updateQuai(quai.clientId, 'distance_metres', parseInt(e.detail?.value, 10) || 0)}
onInput={(e) => updateQuai(quai.clientId, 'distance_metres', parseInt(e.target.value, 10) || 0)}
/>
<div style={{ alignSelf: 'center', minWidth: '80px', color: '#666', fontSize: '13px' }}>
{quaisCounts[quai.nom] ? `${quaisCounts[quai.nom]} horaire(s)` : '0 horaire'}
-37
View File
@@ -166,43 +166,6 @@
}
/* ── Mock / debug banner ── */
.admin-login-mock-banner {
margin-top: 16px;
padding: 10px 14px;
background: #fffbeb;
border: 1px solid #f59e0b;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
flex-wrap: wrap;
}
.admin-login-mock-banner span {
font-size: 12px;
color: #92400e;
font-weight: 500;
}
.admin-login-mock-btn {
background: #f59e0b;
color: #1c1917;
border: none;
border-radius: 6px;
padding: 5px 12px;
font-size: 12px;
font-weight: 700;
cursor: pointer;
transition: background 0.15s;
white-space: nowrap;
}
.admin-login-mock-btn:hover {
background: #d97706;
color: #fff;
}
/* ── Responsive ── */
@media (max-width: 900px) {
.admin-login-page {
+4 -37
View File
@@ -2,23 +2,6 @@ import React, { useRef, useState, useEffect } from 'react';
import supabase, { isSupabaseConfigured } from '../../supabaseClient';
import './Login.css';
// ─── Compte mocké pour debug ────────────────────────────────────────────────
// Désactiver en production en passant REACT_APP_ENABLE_MOCK_LOGIN=false
const MOCK_LOGIN_ENABLED = process.env.REACT_APP_ENABLE_MOCK_LOGIN !== 'false';
const MOCK_USER = {
id: 'mock-admin-001',
email: 'mock@ferrovia.dev',
nom: 'Mock',
prenom: 'Admin',
name: 'Mock Admin',
role: 'admin',
permissions: {},
region_admin: true,
region_id: null,
region_nom: null,
};
// ────────────────────────────────────────────────────────────────────────────
async function tryFallbackAuth(email, password) {
try {
@@ -64,13 +47,7 @@ export default function Login({ onLogin }) {
// nothing for now
}, []);
// ── Login mocké (debug uniquement) ──────────────────────────────────────
const handleMockLogin = () => {
console.info('[Mock Login] Connexion avec le compte de debug', MOCK_USER);
try { window.localStorage.setItem('app_user', JSON.stringify(MOCK_USER)); } catch (_) {}
onLogin(MOCK_USER);
};
// ────────────────────────────────────────────────────────────────────────
const handleSubmit = async (e) => {
if (e && e.preventDefault) e.preventDefault();
@@ -125,6 +102,9 @@ export default function Login({ onLogin }) {
const user = Array.isArray(effectiveData) ? (effectiveData.length ? effectiveData[0] : null) : effectiveData;
if (user && user.id) {
// S'assurer que permissions est au moins un objet vide pour que le RBAC applique les templates de base
user.permissions = user.permissions || {};
// Complète le profil avec les infos régionales nécessaires au RBAC front.
try {
const { data: profile } = await supabase
@@ -221,19 +201,6 @@ export default function Login({ onLogin }) {
<a className="admin-login-link" href="/activer-compte">Activer mon Compte</a>
</div>
{/* ── Bannière de debug (mock login) ── */}
{MOCK_LOGIN_ENABLED && (
<div className="admin-login-mock-banner">
<span>🛠 Mode debug — connexion instantanée sans Supabase</span>
<button
type="button"
className="admin-login-mock-btn"
onClick={handleMockLogin}
>
Connexion mock
</button>
</div>
)}
</div>
</form>
</section>
+70
View File
@@ -0,0 +1,70 @@
/* eslint-disable no-restricted-globals */
// This service worker can be customized!
// See https://developers.google.com/web/tools/workbox/modules
// for the list of available Workbox modules, or add any other
// code you'd like.
// You can also remove this file if you'd prefer not to use a
// service worker, and the Workbox build step will be skipped.
import { clientsClaim } from 'workbox-core';
import { ExpirationPlugin } from 'workbox-expiration';
import { precacheAndRoute, createHandlerBoundToURL } from 'workbox-precaching';
import { registerRoute } from 'workbox-routing';
import { StaleWhileRevalidate } from 'workbox-strategies';
clientsClaim();
// Precache all of the assets generated by your build process.
// Their URLs are injected into the manifest variable below.
// This variable must be present somewhere in your service worker file,
// even if you decide not to use precaching. See https://cra.link/PWA
precacheAndRoute(self.__WB_MANIFEST);
// Set up App Shell-style routing, so that all navigation requests
// are fulfilled with your index.html shell. Learn more at
// https://developers.google.com/web/fundamentals/architecture/app-shell
const fileExtensionRegexp = new RegExp('/[^/?]+\\.[^/]+$');
registerRoute(
// Return false to exempt requests from being fulfilled by index.html.
({ request, url }) => {
// If this isn't a navigation, skip.
if (request.mode !== 'navigate') {
return false;
} // If this is a URL that starts with /_, skip.
if (url.pathname.startsWith('/_')) {
return false;
} // If this looks like a URL for a resource, because it contains // a file extension, skip.
if (url.pathname.match(fileExtensionRegexp)) {
return false;
} // Return true to signal that we want to use the handler.
return true;
},
createHandlerBoundToURL(process.env.PUBLIC_URL + '/index.html')
);
// An example runtime caching route for requests that aren't handled by the
// precache, in this case same-origin .png requests like those from in public/
registerRoute(
// Add in any other file extensions or routing criteria as needed.
({ url }) => url.origin === self.location.origin && url.pathname.endsWith('.png'), // Customize this strategy as needed, e.g., by changing to CacheFirst.
new StaleWhileRevalidate({
cacheName: 'images',
plugins: [
// Ensure that once this runtime cache reaches a maximum size the
// least-recently used images are removed.
new ExpirationPlugin({ maxEntries: 50 }),
],
})
);
// This allows the web app to trigger skipWaiting via
// registration.waiting.postMessage({type: 'SKIP_WAITING'})
self.addEventListener('message', (event) => {
if (event.data && event.data.type === 'SKIP_WAITING') {
self.skipWaiting();
}
});
+132
View File
@@ -0,0 +1,132 @@
// This optional code is used to register a service worker.
// register() is not called by default.
const isLocalhost = Boolean(
window.location.hostname === 'localhost' ||
// [::1] is the IPv6 localhost address.
window.location.hostname === '[::1]' ||
// 127.0.0.0/8 are considered localhost for IPv4.
window.location.hostname.match(
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
)
);
export function register(config) {
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
// The URL constructor is available in all browsers that support SW.
const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);
if (publicUrl.origin !== window.location.origin) {
// Our service worker won't work if PUBLIC_URL is on a different origin
// from what our page is served on. This might happen if a CDN is used to
// serve assets; see https://github.com/facebook/create-react-app/issues/2374
return;
}
window.addEventListener('load', () => {
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
if (isLocalhost) {
// This is running on localhost. Let's check if a service worker still exists or not.
checkValidServiceWorker(swUrl, config);
// Add some additional logging to localhost, pointing developers to the
// service worker/PWA documentation.
navigator.serviceWorker.ready.then(() => {
console.log(
'This web app is being served cache-first by a service ' +
'worker. To learn more, visit https://cra.link/PWA'
);
});
} else {
// Is not localhost. Just register service worker
registerValidSW(swUrl, config);
}
});
}
}
function registerValidSW(swUrl, config) {
navigator.serviceWorker
.register(swUrl)
.then((registration) => {
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker == null) {
return;
}
installingWorker.onstatechange = () => {
if (installingWorker.state === 'installed') {
if (navigator.serviceWorker.controller) {
// At this point, the updated precached content has been fetched,
// but the previous service worker will still serve the older
// content until all client tabs are closed.
console.log(
'New content is available and will be used when all ' +
'tabs for this page are closed. See https://cra.link/PWA.'
);
// Execute callback
if (config && config.onUpdate) {
config.onUpdate(registration);
}
} else {
// At this point, everything has been precached.
// It's the perfect time to display a
// "Content is cached for offline use." message.
console.log('Content is cached for offline use.');
// Execute callback
if (config && config.onSuccess) {
config.onSuccess(registration);
}
}
}
};
};
})
.catch((error) => {
console.error('Error during service worker registration:', error);
});
}
function checkValidServiceWorker(swUrl, config) {
// Check if the service worker can be found. If it can't reload the page.
fetch(swUrl, {
headers: { 'Service-Worker': 'script' },
})
.then((response) => {
// Ensure service worker exists, and that we really are getting a JS file.
const contentType = response.headers.get('content-type');
if (
response.status === 404 ||
(contentType != null && contentType.indexOf('javascript') === -1)
) {
// No service worker found. Probably a different app. Reload the page.
navigator.serviceWorker.ready.then((registration) => {
registration.unregister().then(() => {
window.location.reload();
});
});
} else {
// Service worker found. Proceed as normal.
registerValidSW(swUrl, config);
}
})
.catch(() => {
console.log(
'No internet connection found. App is running in offline mode.'
);
});
}
export function unregister() {
if ('serviceWorker' in navigator) {
navigator.serviceWorker.ready
.then((registration) => {
registration.unregister();
})
.catch((error) => {
console.error(error.message);
});
}
}