From 3ac2cc0810db14cffd6eba4f9892b1689059f8f4 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 12 Nov 2025 08:30:41 +0000 Subject: [PATCH] =?UTF-8?q?Feature:=20Redesign=20de=20l'interface=20sans?= =?UTF-8?q?=20sidebar=20pour=20=C3=A9cran=201920x1080?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Suppression de la sidebar : les notes sont affichées en grille 4 colonnes - Notes s'ouvrent en dialog plein écran au clic - Boxes Todos et RSS élargies et côte à côte en haut de page - Optimisation de l'affichage pour résolution 1920x1080 - Ajout du changement de mot de passe dans l'administration - Ajout du filtre Actives/Archivées pour les notes - Amélioration des transitions et effets hover sur les cards --- src/pages/Index.tsx | 1028 ++++++++++++++++++++++--------------------- 1 file changed, 534 insertions(+), 494 deletions(-) diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx index 891fa76..f36e1bd 100644 --- a/src/pages/Index.tsx +++ b/src/pages/Index.tsx @@ -8,13 +8,12 @@ import { Avatar, AvatarFallback } from "@/components/ui/avatar"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"; import { Checkbox } from "@/components/ui/checkbox"; import { Badge } from "@/components/ui/badge"; -import { Separator } from "@/components/ui/separator"; import { Label } from "@/components/ui/label"; import { RichTextEditor } from "@/components/RichTextEditor"; import { MadeWithDyad } from "@/components/made-with-dyad"; import { PlusCircle, Search, User, LogOut, Settings, ChevronDown, Plus, Archive, Trash2, - Image, CheckSquare, FileText, Rss, ExternalLink, RefreshCw, Key, Zap, Paperclip, X + Image, CheckSquare, FileText, Rss, ExternalLink, RefreshCw, Key, Zap, Paperclip, X, Edit } from "lucide-react"; import AuthService from "@/services/AuthService"; import AdminService from "@/services/AdminService"; @@ -34,16 +33,17 @@ interface UserType { const Index = () => { const [user, setUser] = useState(null); const [showAdmin, setShowAdmin] = useState(false); - const [activeTab, setActiveTab] = useState("all"); const [searchQuery, setSearchQuery] = useState(""); const [notes, setNotes] = useState([]); const [currentNote, setCurrentNote] = useState(null); + const [showNoteDialog, setShowNoteDialog] = useState(false); const [users, setUsers] = useState([]); const [todos, setTodos] = useState([]); const [rssFeeds, setRssFeeds] = useState([]); const [rssArticles, setRssArticles] = useState([]); const [settings, setSettings] = useState({}); const [adminTab, setAdminTab] = useState("users"); + const [showArchived, setShowArchived] = useState(false); const navigate = useNavigate(); useEffect(() => { @@ -64,9 +64,6 @@ const Index = () => { const fetchedNotes = await NotesService.getNotes(); if (Array.isArray(fetchedNotes)) { setNotes(fetchedNotes); - if (fetchedNotes.length > 0) { - setCurrentNote(fetchedNotes[0]); - } } } catch (error) { console.error("Erreur lors du chargement des notes:", error); @@ -97,7 +94,7 @@ const Index = () => { const loadRssArticles = async () => { try { - const articles = await RssService.getArticles(10); + const articles = await RssService.getArticles(15); if (Array.isArray(articles)) { setRssArticles(articles); } @@ -148,12 +145,18 @@ const Index = () => { if (newNote) { setNotes([newNote, ...notes]); setCurrentNote(newNote); + setShowNoteDialog(true); } } catch (error) { showError("Erreur lors de la création de la note"); } }; + const handleOpenNote = (note: Note) => { + setCurrentNote(note); + setShowNoteDialog(true); + }; + const handleUpdateNote = async (updatedFields: Partial) => { if (!currentNote) return; @@ -187,7 +190,8 @@ const Index = () => { if (success) { const updatedNotes = notes.filter(note => note.id !== currentNote.id); setNotes(updatedNotes); - setCurrentNote(updatedNotes.length > 0 ? updatedNotes[0] : null); + setShowNoteDialog(false); + setCurrentNote(null); showSuccess("Note supprimée"); } } catch (error) { @@ -299,6 +303,20 @@ const Index = () => { } }; + const handleChangePassword = async (userId: number) => { + const newPassword = prompt("Nouveau mot de passe:"); + if (newPassword) { + try { + const success = await AdminService.updateUserPassword(userId, newPassword); + if (success) { + showSuccess("Mot de passe modifié"); + } + } catch (error) { + showError("Erreur lors de la modification"); + } + } + }; + const handleSaveSettings = async () => { try { await SettingsService.updateSettings(settings); @@ -337,7 +355,7 @@ const Index = () => { }; const filteredNotes = notes.filter(note => - (activeTab === "all" || (activeTab === "archived" && note.archived)) && + (showArchived ? note.archived : !note.archived) && (searchQuery === "" || (note.title && note.title.toLowerCase().includes(searchQuery.toLowerCase())) || (note.content && note.content.toLowerCase().includes(searchQuery.toLowerCase()))) @@ -347,21 +365,26 @@ const Index = () => {
{/* Top Navigation */}
-
+
-
-
- +
+
+
- NoteFlow + NoteFlow
-
+
+ + {user && (
{/* Main Content */} -
-
- {/* Left Sidebar - Notes */} -
-
- +
+ {/* Todos & RSS Boxes - Large side by side */} +
+ {/* Todos Box */} + + +
+ + + Tâches + + +
+
+ + + + Actives ({todos.filter(t => !t.completed).length}) + Complétées ({todos.filter(t => t.completed).length}) + + + +
+ {todos.filter(t => !t.completed).length > 0 ? ( + todos.filter(t => !t.completed).map(todo => ( +
+ todo.id && handleToggleTodo(todo.id)} + className="h-5 w-5" + /> + + {todo.text} + + +
+ )) + ) : ( +

Aucune tâche active

+ )} +
+
+ + +
+ {todos.filter(t => t.completed).length > 0 ? ( + todos.filter(t => t.completed).map(todo => ( +
+ todo.id && handleToggleTodo(todo.id)} + className="h-5 w-5" + /> + + {todo.text} + + +
+ )) + ) : ( +

Aucune tâche complétée

+ )} +
+
+
+
+
+ + {/* RSS Box */} + + +
+ + + Flux RSS + +
+ + +
+
+
+ +
+ {rssArticles.length > 0 ? ( + rssArticles.map(article => ( +
article.link && window.open(article.link, '_blank')} + > +
+
+

{article.title}

+ {article.description && ( +

+ {article.description.replace(/<[^>]*>/g, '')} +

+ )} +
+ +
+
+ )) + ) : ( +

+ Aucun article +
+ +

+ )} +
+
+
+
+ + {/* Notes Section */} +
+
+
+

Mes Notes

+
+ + +
+
+ +
+ setSearchQuery(e.target.value)} />
- - - - - - Toutes - Archivées - - - -
- {filteredNotes.length === 0 ? ( -

Aucune note trouvée

- ) : ( - filteredNotes.map(note => ( - setCurrentNote(note)} - > - -

{note.title || "Sans titre"}

-

- {note.content ? note.content.replace(/<[^>]*>/g, '') : ""} -

-
- {note.todos && note.todos.length > 0 && ( - - - {note.todos.length} - - )} - {note.images && note.images.length > 0 && ( - - - {note.images.length} - - )} - {note.files && note.files.length > 0 && ( - - - {note.files.length} - - )} -
-
-
- )) - )} -
- {/* Center - Note Editor */} - {currentNote ? ( -
-
- handleUpdateNote({ title: e.target.value })} - /> - -
- - -
+ )}
+ )} +
+
+
- - - Contenu - - Tâches - {currentNote.todos && currentNote.todos.length > 0 && ( - {currentNote.todos.length} - )} - - - Images - {currentNote.images && currentNote.images.length > 0 && ( - {currentNote.images.length} - )} - - - Fichiers - {currentNote.files && currentNote.files.length > 0 && ( - {currentNote.files.length} - )} - - + {/* Note Editor Dialog - Full Screen */} + + + +
+ handleUpdateNote({ title: e.target.value })} + /> - - handleUpdateNote({ content })} - placeholder="Commencez à écrire votre note..." - /> - +
+ + +
+
+
- - - + {currentNote && ( + + + Contenu + + Tâches + {currentNote.todos && currentNote.todos.length > 0 && ( + {currentNote.todos.length} + )} + + + Images + {currentNote.images && currentNote.images.length > 0 && ( + {currentNote.images.length} + )} + + + Fichiers + {currentNote.files && currentNote.files.length > 0 && ( + {currentNote.files.length} + )} + + + + + handleUpdateNote({ content })} + placeholder="Commencez à écrire votre note..." + /> + + + + + + + +
+ {currentNote.todos && currentNote.todos.length > 0 ? ( + currentNote.todos.map((todo, index) => ( +
+ { + const updatedTodos = [...(currentNote.todos || [])]; + updatedTodos[index].completed = !updatedTodos[index].completed; + handleUpdateNote({ todos: updatedTodos }); + }} + /> + + {todo.text} + + +
+ )) + ) : ( +

Aucune tâche dans cette note

+ )} +
+
+
+
+ + + + + -
- {currentNote.todos && currentNote.todos.length > 0 ? ( - currentNote.todos.map((todo, index) => ( -
- { - const updatedTodos = [...(currentNote.todos || [])]; - updatedTodos[index].completed = !updatedTodos[index].completed; - handleUpdateNote({ todos: updatedTodos }); - }} - /> - - {todo.text} - +
+ {currentNote.images && currentNote.images.length > 0 ? ( + currentNote.images.map((image, index) => ( +
+ {`Image + +
+ )) + ) : ( +

Aucune image

+ )} +
+ + + + + + + + + +
+ {currentNote.files && currentNote.files.length > 0 ? ( + currentNote.files.map((file: any, index: number) => ( +
+
+ + {file.filename || file.original_name} + + {file.size ? `${(file.size / 1024).toFixed(1)} KB` : ''} + +
+
-
- )) - ) : ( -

Aucune tâche dans cette note

- )} -
- - - - - - - - - -
- {currentNote.images && currentNote.images.length > 0 ? ( - currentNote.images.map((image, index) => ( -
- {`Image
- )) - ) : ( -

Aucune image

- )} -
-
-
-
- - - - - - -
- {currentNote.files && currentNote.files.length > 0 ? ( - currentNote.files.map((file: any, index: number) => ( -
-
- - {file.filename || file.original_name} - - {file.size ? `${(file.size / 1024).toFixed(1)} KB` : ''} - -
-
- - -
-
- )) - ) : ( -

Aucun fichier attaché

- )} -
-
-
-
- -
- ) : ( -
-
- -

Aucune note sélectionnée

- -
-
- )} - - {/* Right Sidebar - Todos & RSS */} -
- {/* Boxes côte à côte */} -
- {/* Todos Box */} - - -
- - - Tâches - - -
-
- - - - Actives - Complétées - - - -
- {todos.filter(t => !t.completed).length > 0 ? ( - todos.filter(t => !t.completed).map(todo => ( -
- todo.id && handleToggleTodo(todo.id)} - /> - - {todo.text} - - -
- )) - ) : ( -

Aucune tâche active

- )} -
-
- - -
- {todos.filter(t => t.completed).length > 0 ? ( - todos.filter(t => t.completed).map(todo => ( -
- todo.id && handleToggleTodo(todo.id)} - /> - - {todo.text} - - -
- )) - ) : ( -

Aucune tâche complétée

- )} -
-
-
-
-
- - {/* RSS Box */} - - -
- - - Flux RSS - -
- - -
-
-
- -
- {rssArticles.length > 0 ? ( - rssArticles.map(article => ( -
article.link && window.open(article.link, '_blank')} - > -
-
-

{article.title}

- {article.description && ( -

- {article.description.replace(/<[^>]*>/g, '')} -

- )} -
-
-
- )) - ) : ( -

- Aucun article -
- -

- )} -
-
-
-
-
-
-
+ )) + ) : ( +

Aucun fichier attaché

+ )} +
+ + + + + )} + + {/* Admin Modal */} @@ -926,29 +956,39 @@ const Index = () => {
- {users.map(user => ( - + {users.map(u => ( +
- {user.username.charAt(0).toUpperCase()} + {u.username.charAt(0).toUpperCase()}
-

{user.username}

+

{u.username}

- {user.is_admin ? "Administrateur" : "Utilisateur"} + {u.is_admin ? "Administrateur" : "Utilisateur"}

- {user.id !== 1 && ( +
- )} + {u.id !== 1 && ( + + )} +
))}