feat(ui): visionneuse et vignettes, retrait du popup identifiants, en-tete fige (#7)
CD — Déploiement / deploy (push) Successful in 20s
CD — Déploiement / deploy (push) Successful in 20s
- MediaViewer (image/video/audio/pdf/texte) et MediaThumb (vignette video 1re frame, icones audio/archive) - Gallery/Browser cables sur le viewer et les vignettes ; lib/media.ts + previewUrl - Admin: bandeau de succes au lieu du popup "Identifiants generes" - AppShell/PageHeader: hauteur fixe du viewport + en-tete de page sticky (filtres, recherche, stats figes) --------- Co-authored-by: xEsiah <[email protected]> Reviewed-on: #7 Reviewed-by: Esiah <[email protected]> Co-authored-by: Gitea Actions <-[email protected]>
This commit was merged in pull request #7.
This commit is contained in:
@@ -47,7 +47,7 @@ export const AdminUsers = () => {
|
||||
const [busy, setBusy] = useState<string | null>(null);
|
||||
const [createOpen, setCreateOpen] = useState(false);
|
||||
const [edit, setEdit] = useState<AdminUser | null>(null);
|
||||
const [credentials, setCredentials] = useState<{ email: string; password: string } | null>(null);
|
||||
const [notice, setNotice] = useState<string | null>(null);
|
||||
const termRef = useRef("");
|
||||
|
||||
const load = async (term: string) => {
|
||||
@@ -86,9 +86,10 @@ export const AdminUsers = () => {
|
||||
const resetPassword = async (user: AdminUser) => {
|
||||
setBusy(user.id);
|
||||
setError(null);
|
||||
setNotice(null);
|
||||
try {
|
||||
const { password } = await api.adminResetPassword(user.id);
|
||||
setCredentials({ email: user.email, password });
|
||||
await api.adminResetPassword(user.id);
|
||||
setNotice(`Mot de passe réinitialisé. Les identifiants ont été envoyés à ${user.email}.`);
|
||||
} catch (caught) {
|
||||
setError(messageOf(caught, "Réinitialisation impossible."));
|
||||
} finally {
|
||||
@@ -135,38 +136,42 @@ export const AdminUsers = () => {
|
||||
Nouveau membre
|
||||
</Button>
|
||||
}
|
||||
toolbar={
|
||||
<>
|
||||
{stats ? (
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<StatCard label="Membres" value={String(stats.users)} />
|
||||
<StatCard label="Fichiers" value={String(stats.files)} />
|
||||
<StatCard label="Stockage" value={`${toGb(stats.usedBytes)} Go`} />
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<form
|
||||
className="flex items-end gap-2"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void load(q);
|
||||
}}
|
||||
>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
label="Rechercher"
|
||||
type="search"
|
||||
placeholder="nom ou e-mail"
|
||||
value={q}
|
||||
onChange={(event) => setQ(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" size="md" variant="secondary">
|
||||
Filtrer
|
||||
</Button>
|
||||
</form>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
|
||||
{stats ? (
|
||||
<div className="grid grid-cols-3 gap-3">
|
||||
<StatCard label="Membres" value={String(stats.users)} />
|
||||
<StatCard label="Fichiers" value={String(stats.files)} />
|
||||
<StatCard label="Stockage" value={`${toGb(stats.usedBytes)} Go`} />
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<form
|
||||
className="flex items-end gap-2"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void load(q);
|
||||
}}
|
||||
>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
label="Rechercher"
|
||||
type="search"
|
||||
placeholder="nom ou e-mail"
|
||||
value={q}
|
||||
onChange={(event) => setQ(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" size="md" variant="secondary">
|
||||
Filtrer
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
{notice ? <Alert tone="success">{notice}</Alert> : null}
|
||||
|
||||
{users === null ? (
|
||||
<div className="flex justify-center py-16">
|
||||
@@ -227,9 +232,9 @@ export const AdminUsers = () => {
|
||||
{createOpen ? (
|
||||
<CreateUserDialog
|
||||
onClose={() => setCreateOpen(false)}
|
||||
onCreated={(email, password) => {
|
||||
onCreated={(email) => {
|
||||
setCreateOpen(false);
|
||||
setCredentials({ email, password });
|
||||
setNotice(`Compte créé. Les identifiants ont été envoyés à ${email}.`);
|
||||
void load(termRef.current);
|
||||
}}
|
||||
/>
|
||||
@@ -245,52 +250,16 @@ export const AdminUsers = () => {
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<CredentialsModal credentials={credentials} onClose={() => setCredentials(null)} />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const CredentialsModal = ({
|
||||
credentials,
|
||||
onClose,
|
||||
}: {
|
||||
credentials: { email: string; password: string } | null;
|
||||
onClose: () => void;
|
||||
}) => {
|
||||
if (!credentials) return null;
|
||||
return (
|
||||
<Modal open title="Identifiants générés" onClose={onClose}>
|
||||
<div className="flex flex-col gap-4">
|
||||
<Alert tone="success">
|
||||
Transmettez ces informations par un canal sûr : le mot de passe ne sera plus affiché.
|
||||
</Alert>
|
||||
<dl className="flex flex-col gap-2 text-xs">
|
||||
<div>
|
||||
<dt className="text-subtle-foreground">Adresse</dt>
|
||||
<dd className="font-medium text-foreground">{credentials.email}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-subtle-foreground">Mot de passe</dt>
|
||||
<dd className="break-all font-mono text-foreground">{credentials.password}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<div className="flex justify-end">
|
||||
<Button size="md" onClick={onClose}>
|
||||
Terminé
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
const CreateUserDialog = ({
|
||||
onClose,
|
||||
onCreated,
|
||||
}: {
|
||||
onClose: () => void;
|
||||
onCreated: (email: string, password: string) => void;
|
||||
onCreated: (email: string) => void;
|
||||
}) => {
|
||||
const [email, setEmail] = useState("");
|
||||
const [firstName, setFirstName] = useState("");
|
||||
@@ -306,7 +275,7 @@ const CreateUserDialog = ({
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const { user, password } = await api.adminCreateUser({
|
||||
const { user } = await api.adminCreateUser({
|
||||
email: email.trim(),
|
||||
first_name: firstName.trim(),
|
||||
last_name: lastName.trim(),
|
||||
@@ -314,7 +283,7 @@ const CreateUserDialog = ({
|
||||
quota_bytes: quotaGb ? Math.round(Number(quotaGb) * GB) : null,
|
||||
max_file_bytes: maxFileMb ? Math.round(Number(maxFileMb) * MB) : null,
|
||||
});
|
||||
onCreated(user.email, password);
|
||||
onCreated(user.email);
|
||||
} catch (caught) {
|
||||
setError(messageOf(caught, "Création impossible."));
|
||||
} finally {
|
||||
@@ -696,27 +665,31 @@ export const AdminAudit = () => {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-5">
|
||||
<PageHeader title="Journal d'activité" description="Dernières actions enregistrées." />
|
||||
|
||||
<form
|
||||
className="flex items-end gap-2"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void load(action);
|
||||
}}
|
||||
>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
label="Filtrer par action"
|
||||
placeholder="auth.login, file.upload…"
|
||||
value={action}
|
||||
onChange={(event) => setAction(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" variant="secondary" size="md">
|
||||
Filtrer
|
||||
</Button>
|
||||
</form>
|
||||
<PageHeader
|
||||
title="Journal d'activité"
|
||||
description="Dernières actions enregistrées."
|
||||
toolbar={
|
||||
<form
|
||||
className="flex items-end gap-2"
|
||||
onSubmit={(event) => {
|
||||
event.preventDefault();
|
||||
void load(action);
|
||||
}}
|
||||
>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
label="Filtrer par action"
|
||||
placeholder="auth.login, file.upload…"
|
||||
value={action}
|
||||
onChange={(event) => setAction(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button type="submit" variant="secondary" size="md">
|
||||
Filtrer
|
||||
</Button>
|
||||
</form>
|
||||
}
|
||||
/>
|
||||
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
|
||||
|
||||
@@ -10,6 +10,8 @@ import {
|
||||
import { useSession } from "../lib/session.js";
|
||||
import { Alert, Badge, EmptyState, PageHeader } from "../components/feedback.js";
|
||||
import { useConfirm } from "../components/confirm.js";
|
||||
import { MediaViewer } from "../components/MediaViewer.js";
|
||||
import { MediaThumb } from "../components/MediaThumb.js";
|
||||
import { IconAction } from "../components/IconAction.js";
|
||||
import {
|
||||
CreateFolderDialog,
|
||||
@@ -20,7 +22,6 @@ import {
|
||||
import {
|
||||
ArrowLeftIcon,
|
||||
DownloadIcon,
|
||||
FileIcon,
|
||||
FolderIcon,
|
||||
MoveIcon,
|
||||
PenIcon,
|
||||
@@ -45,9 +46,6 @@ type Dialog =
|
||||
| { kind: "share"; folder: Folder }
|
||||
| null;
|
||||
|
||||
const isImage = (file: UploadedFile): boolean =>
|
||||
(file.mime_type ?? "").toLowerCase().startsWith("image/");
|
||||
|
||||
export const Browser = () => {
|
||||
const { user, refresh } = useSession();
|
||||
const confirm = useConfirm();
|
||||
@@ -59,6 +57,7 @@ export const Browser = () => {
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const [removing, setRemoving] = useState<string | null>(null);
|
||||
const [dialog, setDialog] = useState<Dialog>(null);
|
||||
const [viewer, setViewer] = useState<number | null>(null);
|
||||
const fileInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
const current = path[path.length - 1] ?? { id: null, name: "Racine" };
|
||||
@@ -165,9 +164,8 @@ export const Browser = () => {
|
||||
<PageHeader
|
||||
title={current.name}
|
||||
description="Vos dossiers et fichiers. Envoyez un fichier ou créez un dossier."
|
||||
/>
|
||||
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
toolbar={
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
{path.length > 1 ? (
|
||||
<button
|
||||
type="button"
|
||||
@@ -205,7 +203,9 @@ export const Browser = () => {
|
||||
))}
|
||||
</ol>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
|
||||
<Card>
|
||||
<div className="flex flex-col gap-3 p-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
@@ -353,20 +353,16 @@ export const Browser = () => {
|
||||
Fichiers
|
||||
</h2>
|
||||
<ul className="flex flex-col divide-y divide-border rounded-lg border border-border bg-surface">
|
||||
{files.map((file) => (
|
||||
{files.map((file, index) => (
|
||||
<li key={file.id} className="flex items-center gap-2 px-3 py-2.5">
|
||||
<span className="flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-sm border border-border bg-surface-muted text-muted-foreground">
|
||||
{isImage(file) ? (
|
||||
<img
|
||||
src={api.thumbnailUrl(file.id)}
|
||||
alt=""
|
||||
loading="lazy"
|
||||
className="h-full w-full object-cover"
|
||||
/>
|
||||
) : (
|
||||
<FileIcon className="h-5 w-5" />
|
||||
)}
|
||||
</span>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setViewer(index)}
|
||||
className="flex h-10 w-10 shrink-0 items-center justify-center overflow-hidden rounded-sm border border-border bg-surface-muted text-muted-foreground transition-colors hover:border-border-strong focus-visible:ring-ring focus-visible:ring-2 focus-visible:outline-none"
|
||||
aria-label={`Aperçu de ${file.name}`}
|
||||
>
|
||||
<MediaThumb id={file.id} mime={file.mime_type} name={file.name} />
|
||||
</button>
|
||||
<span className="min-w-0 flex-1">
|
||||
<span className="block truncate text-sm font-medium text-foreground">
|
||||
{file.name}
|
||||
@@ -471,6 +467,14 @@ export const Browser = () => {
|
||||
{dialog?.kind === "share" ? (
|
||||
<ShareDialog folder={dialog.folder} onClose={() => setDialog(null)} />
|
||||
) : null}
|
||||
|
||||
{viewer !== null ? (
|
||||
<MediaViewer
|
||||
items={files.map((item) => ({ id: item.id, name: item.name, mime_type: item.mime_type }))}
|
||||
startIndex={viewer}
|
||||
onClose={() => setViewer(null)}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,9 @@ import { useCallback, useEffect, useState } from "react";
|
||||
import { Button, Spinner, cn } from "../ui/index.js";
|
||||
import { ApiError, api, formatBytes, type MediaItem } from "../lib/api.js";
|
||||
import { Alert, EmptyState, PageHeader } from "../components/feedback.js";
|
||||
import { FileIcon, ImageIcon } from "../components/icons.js";
|
||||
import { MediaViewer } from "../components/MediaViewer.js";
|
||||
import { MediaThumb } from "../components/MediaThumb.js";
|
||||
import { ImageIcon } from "../components/icons.js";
|
||||
|
||||
const KINDS = [
|
||||
{ value: "", label: "Tout" },
|
||||
@@ -22,6 +24,7 @@ export const Gallery = () => {
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [loadingMore, setLoadingMore] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [viewer, setViewer] = useState<number | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
setLoading(true);
|
||||
@@ -56,31 +59,32 @@ export const Gallery = () => {
|
||||
<PageHeader
|
||||
title="Galerie"
|
||||
description="Parcourez les médias auxquels vous avez accès."
|
||||
toolbar={
|
||||
<div className="flex flex-wrap gap-1.5" role="tablist" aria-label="Filtrer par type">
|
||||
{KINDS.map((option) => (
|
||||
<button
|
||||
key={option.value}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={kind === option.value}
|
||||
onClick={() => {
|
||||
setKind(option.value);
|
||||
setItems([]);
|
||||
}}
|
||||
className={cn(
|
||||
"rounded-sm border px-3 py-1.5 font-display text-[0.6875rem] font-semibold uppercase tracking-label transition-colors",
|
||||
kind === option.value
|
||||
? "border-accent/50 bg-accent/10 text-accent"
|
||||
: "border-border-control text-muted-foreground hover:bg-surface-hover hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
}
|
||||
/>
|
||||
|
||||
<div className="flex flex-wrap gap-1.5" role="tablist" aria-label="Filtrer par type">
|
||||
{KINDS.map((option) => (
|
||||
<button
|
||||
key={option.value}
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={kind === option.value}
|
||||
onClick={() => {
|
||||
setKind(option.value);
|
||||
setItems([]);
|
||||
}}
|
||||
className={cn(
|
||||
"rounded-sm border px-3 py-1.5 font-display text-[0.6875rem] font-semibold uppercase tracking-label transition-colors",
|
||||
kind === option.value
|
||||
? "border-accent/50 bg-accent/10 text-accent"
|
||||
: "border-border-control text-muted-foreground hover:bg-surface-hover hover:text-foreground",
|
||||
)}
|
||||
>
|
||||
{option.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
|
||||
{loading ? (
|
||||
@@ -96,24 +100,13 @@ export const Gallery = () => {
|
||||
) : (
|
||||
<>
|
||||
<ul className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4">
|
||||
{items.map((item) => (
|
||||
<li key={item.id}>
|
||||
<a
|
||||
href={api.downloadUrl(item.id)}
|
||||
download={item.name}
|
||||
className="group flex flex-col overflow-hidden rounded-lg border border-border bg-surface transition-colors hover:border-border-strong"
|
||||
>
|
||||
{items.map((item, index) => {
|
||||
const cardClass =
|
||||
"group flex w-full flex-col overflow-hidden rounded-lg border border-border bg-surface text-left transition-colors hover:border-border-strong";
|
||||
const inner = (
|
||||
<>
|
||||
<span className="flex aspect-square items-center justify-center overflow-hidden bg-surface-muted text-muted-foreground">
|
||||
{item.kind === "image" && item.has_thumbnail ? (
|
||||
<img
|
||||
src={api.thumbnailUrl(item.id)}
|
||||
alt={item.name}
|
||||
loading="lazy"
|
||||
className="h-full w-full object-cover transition-transform duration-fast group-hover:scale-[1.02]"
|
||||
/>
|
||||
) : (
|
||||
<FileIcon className="h-8 w-8" />
|
||||
)}
|
||||
<MediaThumb id={item.id} mime={item.mime_type} name={item.name} size="lg" />
|
||||
</span>
|
||||
<span className="flex flex-col gap-0.5 p-2">
|
||||
<span className="truncate text-xs font-medium text-foreground">
|
||||
@@ -123,9 +116,16 @@ export const Gallery = () => {
|
||||
{formatBytes(item.size_bytes)}
|
||||
</span>
|
||||
</span>
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</>
|
||||
);
|
||||
return (
|
||||
<li key={item.id}>
|
||||
<button type="button" onClick={() => setViewer(index)} className={cardClass}>
|
||||
{inner}
|
||||
</button>
|
||||
</li>
|
||||
);
|
||||
})}
|
||||
</ul>
|
||||
|
||||
{items.length >= PAGE ? (
|
||||
@@ -137,6 +137,18 @@ export const Gallery = () => {
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
|
||||
{viewer !== null ? (
|
||||
<MediaViewer
|
||||
items={items.map((item) => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
mime_type: item.mime_type,
|
||||
}))}
|
||||
startIndex={viewer}
|
||||
onClose={() => setViewer(null)}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -42,29 +42,30 @@ export const Search = () => {
|
||||
<PageHeader
|
||||
title="Recherche"
|
||||
description="Recherchez par nom dans les dossiers et fichiers auxquels vous avez accès."
|
||||
toolbar={
|
||||
<form className="flex items-end gap-2" onSubmit={(event) => void submit(event)}>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
label="Terme recherché"
|
||||
type="search"
|
||||
autoFocus
|
||||
placeholder="facture, rapport…"
|
||||
value={q}
|
||||
onChange={(event) => setQ(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
type="submit"
|
||||
size="md"
|
||||
isLoading={loading}
|
||||
iconLeading={<SearchIcon className="h-3.5 w-3.5" />}
|
||||
>
|
||||
Rechercher
|
||||
</Button>
|
||||
</form>
|
||||
}
|
||||
/>
|
||||
|
||||
<form className="flex items-end gap-2" onSubmit={(event) => void submit(event)}>
|
||||
<div className="flex-1">
|
||||
<Input
|
||||
label="Terme recherché"
|
||||
type="search"
|
||||
autoFocus
|
||||
placeholder="facture, rapport…"
|
||||
value={q}
|
||||
onChange={(event) => setQ(event.target.value)}
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
type="submit"
|
||||
size="md"
|
||||
isLoading={loading}
|
||||
iconLeading={<SearchIcon className="h-3.5 w-3.5" />}
|
||||
>
|
||||
Rechercher
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
{error ? <Alert>{error}</Alert> : null}
|
||||
|
||||
{loading ? (
|
||||
|
||||
Reference in New Issue
Block a user