From 41072a2e6de353516ba851913604b3cf55dcae54 Mon Sep 17 00:00:00 2001 From: Hyungi Ahn Date: Fri, 3 Apr 2026 10:37:44 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=88=98=EB=8F=99=20=ED=8E=B8=EC=A7=91?= =?UTF-8?q?=20URL=20=E2=80=94=20=EC=A0=95=EB=B3=B4=20=ED=8C=A8=EB=84=90?= =?UTF-8?q?=EC=97=90=EC=84=9C=20Synology=20Drive=20=EB=A7=81=ED=81=AC=20?= =?UTF-8?q?=EC=9E=85=EB=A0=A5/=EA=B4=80=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - edit_url 컬럼 추가 (migration 006) - PreviewPanel: 편집 링크 입력/수정/표시 UI - DocumentViewer: edit_url 있으면 편집 버튼에서 해당 URL로 새 탭 - API: DocumentResponse/DocumentUpdate에 edit_url 필드 Co-Authored-By: Claude Opus 4.6 (1M context) --- app/api/documents.py | 2 + app/models/document.py | 3 ++ .../src/lib/components/DocumentViewer.svelte | 10 ++-- .../src/lib/components/PreviewPanel.svelte | 48 ++++++++++++++++++- migrations/006_edit_url.sql | 2 + 5 files changed, 58 insertions(+), 7 deletions(-) create mode 100644 migrations/006_edit_url.sql diff --git a/app/api/documents.py b/app/api/documents.py index 31444d7..6a9ac08 100644 --- a/app/api/documents.py +++ b/app/api/documents.py @@ -37,6 +37,7 @@ class DocumentResponse(BaseModel): ai_tags: list | None ai_summary: str | None user_note: str | None + edit_url: str | None preview_status: str | None source_channel: str | None data_origin: str | None @@ -63,6 +64,7 @@ class DocumentUpdate(BaseModel): ai_sub_group: str | None = None ai_tags: list | None = None user_note: str | None = None + edit_url: str | None = None source_channel: str | None = None data_origin: str | None = None diff --git a/app/models/document.py b/app/models/document.py index 99e7499..fa13499 100644 --- a/app/models/document.py +++ b/app/models/document.py @@ -47,6 +47,9 @@ class Document(Base): # 사용자 메모 user_note: Mapped[str | None] = mapped_column(Text) + # 외부 편집 URL + edit_url: Mapped[str | None] = mapped_column(Text) + # 미리보기 preview_status: Mapped[str | None] = mapped_column(String(20), default="none") preview_hash: Mapped[str | None] = mapped_column(String(64)) diff --git a/frontend/src/lib/components/DocumentViewer.svelte b/frontend/src/lib/components/DocumentViewer.svelte index 216d649..8393067 100644 --- a/frontend/src/lib/components/DocumentViewer.svelte +++ b/frontend/src/lib/components/DocumentViewer.svelte @@ -26,12 +26,10 @@ } function getEditUrl(doc) { - if (['odoc', 'osheet', 'docx', 'xlsx', 'pptx', 'odt', 'ods', 'odp'].includes(doc.file_format)) { - return `https://link.hyungi.net`; - } - if (['dwg', 'dxf'].includes(doc.file_format)) { - return 'https://web.autocad.com'; - } + // DB에 저장된 편집 URL 우선 + if (doc.edit_url) return doc.edit_url; + // CAD는 AutoCAD Web + if (['dwg', 'dxf'].includes(doc.file_format)) return 'https://web.autocad.com'; return null; } diff --git a/frontend/src/lib/components/PreviewPanel.svelte b/frontend/src/lib/components/PreviewPanel.svelte index de9459c..6c14633 100644 --- a/frontend/src/lib/components/PreviewPanel.svelte +++ b/frontend/src/lib/components/PreviewPanel.svelte @@ -16,12 +16,18 @@ let newTag = $state(''); let tagEditing = $state(false); - // doc 변경 시 메모 초기화 + // 편집 URL + let editUrlText = $state(''); + let editUrlEditing = $state(false); + + // doc 변경 시 초기화 $effect(() => { if (doc) { noteText = doc.user_note || ''; + editUrlText = doc.edit_url || ''; noteEditing = false; tagEditing = false; + editUrlEditing = false; newTag = ''; } }); @@ -43,6 +49,20 @@ } } + async function saveEditUrl() { + try { + await api(`/documents/${doc.id}`, { + method: 'PATCH', + body: JSON.stringify({ edit_url: editUrlText.trim() || null }), + }); + doc.edit_url = editUrlText.trim() || null; + editUrlEditing = false; + addToast('success', '편집 URL 저장됨'); + } catch (err) { + addToast('error', '편집 URL 저장 실패'); + } + } + async function addTag() { const tag = newTag.trim(); if (!tag) return; @@ -138,6 +158,32 @@ {/if} + +
+

편집 링크

+ {#if editUrlEditing} +
+ + + +
+ {:else if doc.edit_url} +
+ {doc.edit_url} + +
+ {:else} + + {/if} +
+

태그

diff --git a/migrations/006_edit_url.sql b/migrations/006_edit_url.sql new file mode 100644 index 0000000..4189a27 --- /dev/null +++ b/migrations/006_edit_url.sql @@ -0,0 +1,2 @@ +-- 외부 편집 URL (Synology Drive 공유 링크 등) +ALTER TABLE documents ADD COLUMN IF NOT EXISTS edit_url TEXT;