Merge pull request #161 from R0m1k3/claude/notes-api-with-tasks-qAROu

feat: highlight notes created via API with red background
This commit is contained in:
LogiFlow authored and GitHub committed 2025-12-21 17:57:40 +01:00
commit c09ec545c2
4 files changed
+24 -5

No files matched your search

+11
View File
@@ -123,11 +123,22 @@ async function initDatabase() {
archived BOOLEAN DEFAULT FALSE,
archived_at TIMESTAMP,
priority INTEGER DEFAULT 0,
created_via VARCHAR(20) DEFAULT 'web',
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)
`);
// Migration: ajouter la colonne created_via si elle n'existe pas
await client.query(`
DO $$
BEGIN
IF NOT EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'notes' AND column_name = 'created_via') THEN
ALTER TABLE notes ADD COLUMN created_via VARCHAR(20) DEFAULT 'web';
END IF;
END $$;
`);
// Table note_todos
await client.query(`
CREATE TABLE IF NOT EXISTS note_todos (
+5 -4
View File
@@ -74,7 +74,7 @@ router.get('/', async (req, res) => {
const notes = await getAll(`
SELECT
n.id, n.title, n.content, n.image_filename, n.archived, n.priority,
n.created_at, n.updated_at,
n.created_via, n.created_at, n.updated_at,
(SELECT COUNT(*) FROM note_todos WHERE note_id = n.id) as todos_count,
(SELECT COUNT(*) FROM note_todos WHERE note_id = n.id AND completed = TRUE) as todos_completed
FROM notes n
@@ -242,10 +242,10 @@ router.post('/full',
logger.info(`[CREATE NOTE FULL] Début création - user_id: ${req.user.id}, title: "${title}", todos: ${todos.length}, tags: ${tags.length}`);
// 1. Créer la note
// 1. Créer la note (marquée comme créée via API)
const noteResult = await runQuery(`
INSERT INTO notes (user_id, title, content)
VALUES ($1, $2, $3)
INSERT INTO notes (user_id, title, content, created_via)
VALUES ($1, $2, $3, 'api')
RETURNING *
`, [req.user.id, title, content || '']);
@@ -325,6 +325,7 @@ router.post('/full',
image_filename: null,
archived: false,
priority: 0,
created_via: 'api',
todos: createdTodos,
tags: createdTags,
images: [],
+7 -1
View File
@@ -1397,7 +1397,7 @@ const Index = () => {
paginatedNotes.map(note => (
<Card
key={note.id}
className="cursor-pointer hover:shadow-md transition-all group relative"
className={`cursor-pointer hover:shadow-md transition-all group relative ${note.created_via === 'api' ? 'bg-red-50 dark:bg-red-950/30 border-red-200 dark:border-red-900' : ''}`}
onClick={() => handleOpenNote(note)}
>
<CardContent className="p-4">
@@ -1451,6 +1451,12 @@ const Index = () => {
{note.content ? cleanHtmlContent(note.content) : "Note vide"}
</p>
<div className="flex gap-2 flex-wrap mb-2">
{note.created_via === 'api' && (
<Badge className="bg-red-100 text-red-700 dark:bg-red-900/50 dark:text-red-300 text-xs">
<Zap className="h-3 w-3 mr-1" />
API
</Badge>
)}
{note.todos && note.todos.length > 0 && (
<Badge variant="secondary">
<CheckSquare className="h-3 w-3 mr-1" />
+1
View File
@@ -29,6 +29,7 @@ export interface Note {
title: string;
content: string;
archived?: boolean;
created_via?: 'web' | 'api';
created_at?: string;
updated_at?: string;
todos: Todo[];