feat: stages module, mobility frontend, theme toggle, employeeOnly access control

- Add stages module with full CRUD API and admin overview island
- Add mobility overview island (Liste, Kanban, Detail CRUD views)
- Add contract PDF upload/download endpoints for mobilites
- Add light/dark theme toggle in header
- Add employeeOnly flag to hide entire modules from students (admin, students, stages)
- Add read-only GET endpoints for modules/ues/ue-modules in notes module
- Add [slug].tsx catch-all routes for direct URL navigation
- Replace old mobility table with mobilites + stages schema (migration 0004)
- Allow students to create mobilites and upload contracts
- Redirect authenticated users from / to /apps catalog
This commit is contained in:
2026-05-01 12:47:23 +02:00
parent df3957741d
commit 9a4c6863d1
65 changed files with 2597 additions and 681 deletions
+11 -4
View File
@@ -273,9 +273,9 @@ export default function ImportNotes() {
Promise.all([
fetch("/students/api/students").then((r) => r.json()),
fetch("/notes/api/notes").then((r) => r.json()),
fetch("/admin/api/modules").then((r) => r.json()),
fetch("/admin/api/ue-modules").then((r) => r.json()),
fetch("/admin/api/ues").then((r) => r.json()),
fetch("/notes/api/modules").then((r) => r.json()),
fetch("/notes/api/ue-modules").then((r) => r.json()),
fetch("/notes/api/ues").then((r) => r.json()),
]).then(
([
studentsData,
@@ -450,7 +450,10 @@ export default function ImportNotes() {
const ws2 = XLSX.utils.aoa_to_sheet([headerRow, coeffRow, ...s2Rows]);
XLSX.utils.book_append_sheet(wb, ws2, "Session 2");
const buf = XLSX.write(wb, { bookType: "xlsx", type: "array" });
const blob = new Blob([buf], { type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" });
const blob = new Blob([buf], {
type:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
});
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
@@ -600,6 +603,8 @@ export default function ImportNotes() {
>
Telecharger Modele
</button>
{
/* TODO: fix blob download in Fresh
<button
type="button"
class="btn btn-secondary"
@@ -607,6 +612,8 @@ export default function ImportNotes() {
>
Exporter Notes
</button>
*/
}
</div>
<p class="upload-format">
+3 -3
View File
@@ -66,11 +66,11 @@ export default function NoteRecap({ numEtud }: Props) {
setStudent(s);
const [uesRes, umRes, mRes, notesRes, ajustRes] = await Promise.all([
fetch("/admin/api/ues"),
fetch("/notes/api/ues"),
fetch(
`/admin/api/ue-modules?idPromo=${encodeURIComponent(s.idPromo)}`,
`/notes/api/ue-modules?idPromo=${encodeURIComponent(s.idPromo)}`,
),
fetch("/admin/api/modules"),
fetch("/notes/api/modules"),
fetch(`/notes/api/notes?numEtud=${numEtud}`),
fetch(`/notes/api/ajustements?numEtud=${numEtud}`),
]);
+3 -3
View File
@@ -62,9 +62,9 @@ export default function NotesView({ numEtud, prenom }: Props) {
try {
const [notesRes, uesRes, ueModRes, modRes, ajRes] = await Promise.all([
fetch(`/notes/api/notes?numEtud=${numEtud}`),
fetch("/admin/api/ues"),
fetch("/admin/api/ue-modules"),
fetch("/admin/api/modules"),
fetch("/notes/api/ues"),
fetch("/notes/api/ue-modules"),
fetch("/notes/api/modules"),
fetch(`/notes/api/ajustements?numEtud=${numEtud}`),
]);
+2
View File
@@ -0,0 +1,2 @@
import makeSlug from "$root/defaults/makeSlug.ts";
export default makeSlug(import.meta.dirname!);
+12
View File
@@ -0,0 +1,12 @@
import { Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { modules } from "$root/databases/schema.ts";
export const handler: Handlers = {
async GET() {
const rows = await db.select().from(modules);
return new Response(JSON.stringify(rows), {
headers: { "content-type": "application/json" },
});
},
};
+28
View File
@@ -0,0 +1,28 @@
import { Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { ueModules } from "$root/databases/schema.ts";
import { and, eq } from "npm:drizzle-orm@0.45.2";
export const handler: Handlers = {
async GET(request) {
const url = new URL(request.url);
const idPromo = url.searchParams.get("idPromo");
const idUEParam = url.searchParams.get("idUE");
const idUE = idUEParam ? parseInt(idUEParam) : null;
if (idUEParam && isNaN(idUE!)) {
return new Response("Paramètre idUE invalide", { status: 400 });
}
const rows = await db.select().from(ueModules).where(
and(
idPromo ? eq(ueModules.idPromo, idPromo) : undefined,
idUE ? eq(ueModules.idUE, idUE) : undefined,
),
);
return new Response(JSON.stringify(rows), {
headers: { "content-type": "application/json" },
});
},
};
+12
View File
@@ -0,0 +1,12 @@
import { Handlers } from "$fresh/server.ts";
import { db } from "$root/databases/db.ts";
import { ues } from "$root/databases/schema.ts";
export const handler: Handlers = {
async GET() {
const rows = await db.select().from(ues);
return new Response(JSON.stringify(rows), {
headers: { "content-type": "application/json" },
});
},
};
@@ -11,5 +11,6 @@ async function Courses(_request: Request, _context: FreshContext<State>) {
return <AdminConsultNotes />;
}
export { Courses as Page };
export const config = getPartialsConfig();
export default makePartials(Courses);
@@ -19,5 +19,6 @@ async function ImportNotesPage(
);
}
export { ImportNotesPage as Page };
export const config = getPartialsConfig();
export default makePartials(ImportNotesPage);
+1
View File
@@ -54,5 +54,6 @@ async function Notes(
);
}
export { Notes as Page };
export const config = getPartialsConfig();
export default makePartials(Notes);