diff --git a/.env.example b/.env.example index 7ee4d24..d8250bd 100644 --- a/.env.example +++ b/.env.example @@ -23,7 +23,7 @@ DOCVER_API_KEY= DOCVER_TOKEN_SECRET= # ใช้ตอน migrate และ การใช้งาน DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:54322/ecourt-note -### สำหรับโค้ดตัวอย่างระบบนอกเรียกเข้ามาไม่ได้ใช้ในระบบนี้ +### สำหรับโค้ดตัวอย่างระบบนอกเรียกเข้ามาไม่ได้ใช้ในระบบนี้ ห้ามเอาไช้ DOCEDIT_BASE_URL=http://127.0.0.1:3000/docedit # Optional เวลาหมดอายุที่ฝังไว้ในข้อมูล (ticket_data), worker ควรเท่ากับจำนวน CPU core -1 TMPL_PATH='./public/tmpl' diff --git a/app/api/template/download-docx/route.ts b/app/api/template/download-docx/route.ts index d13ae96..d4dbc82 100644 --- a/app/api/template/download-docx/route.ts +++ b/app/api/template/download-docx/route.ts @@ -34,8 +34,7 @@ async function processRequest(fid: string, tid: string, uid: string, uname: stri try { //ตรวจสอบ docx เวอร์ชั่นล่าสุดก่อนถ้าไม่พบค่อยเอาจากฐานข้อมูลมาสร้าง raw Json const params = new URLSearchParams({ type: 'docx', ticket_data }); - console.log(`search ${DOCEDIT_BASE_URL}/api/document/latest?${params.toString()}`); - const lastestDocxResponse = await fetch(`${DOCEDIT_BASE_URL}/api/document/latest?${params.toString()}`, { + const lastestDocxResponse = await fetch(`${DOCEDIT_BASE_URL}/api/documents/latest?${params.toString()}`, { method: 'GET', headers: { 'Content-Type': 'application/json', @@ -44,7 +43,7 @@ async function processRequest(fid: string, tid: string, uid: string, uname: stri }); // เช็ค Content-Type และ Status ก่อน const contentType = lastestDocxResponse.headers.get('content-type') || ''; - if (lastestDocxResponse.ok && !!contentType.includes('text/html')) { + if (lastestDocxResponse.ok && !contentType.includes('text/html')) { console.log('Fund latest docx from docedit, returning stream to browser'); const stream = lastestDocxResponse.body; //ส่ง Binary Stream กลับไปยัง Browser พร้อม Header กำหนดประเภทไฟล์ diff --git a/app/tmpl/page.tsx b/app/tmpl/page.tsx index c394d9f..64b7b60 100644 --- a/app/tmpl/page.tsx +++ b/app/tmpl/page.tsx @@ -2,8 +2,15 @@ 'use client'; import Link from "next/link"; import type { ChangeEvent } from 'react'; -// import { createDownloadFormAction } from './actions'; import DependentDropdown, { DropdownData } from '@/components/utils/DependentDropdown'; +import { + Bookmark,ToyBrick,FilePenLine,BicepsFlexed,Rocket,Workflow, Files,Blocks,FileQuestionMark, + ExternalLink, + FileText, + Highlighter, + MessagesSquare, +} from "lucide-react"; + @@ -21,92 +28,242 @@ export default function HomePage() { } return (
-
-

ตัวอย่างการใช้ สร้างเอกสารจาก Template

-
- ตัวอย่าง Frontend ส่งข้อมูลผ่าน <form>(POST) หรือ <a>(GET) - เพื่อรองรับ Vanilla JavaScript และ Classic Framework ใช้การเปลี่ยนหน้าเพื่อดาว์นโหลดไฟล์ - ตัวอย่างหน้าแบบ Plain HTML -
-
-
-

Form POST

- -
-
- uid: -
-
- uname: -
- - -
-
-

A Link Get(new)

- T_no_warning_john_xxx.docx
- TF_no_warning_P2_john_xxx.docx
- TS_P2_IN_john_xxx.docx
+
+

+ eCourt Template +

+

+ ระบบสร้างเทมเพลตเอกสารแบบใหม่ MS Word จากไฟล์ JSON และ Template docx +

- T12_b2_IN_john_xxx.docx
- T12_FD155_3s-long_john_xxx.docx
-
-
-

Template & Data

- Template: T_X.docx,   - T12_X.docx
- Data: TF_no_warning_P2.json,   - T_no_warning.json,   - TS_P2_IN.json
- T12_b2_IN.json,   - T12_FD155_3s-long.json -
-
-

Flow

-
- หน้านี้(เลือกไฟล์)
- ↓
- download-docx(ตรวจสิทธิ์,ส่งเทมเพลต ID,ส่งข้อมูล)
- ↓
- generate(เปิดเทมเพลต,สร้าง docx)
- ↓
- ดาว์นโหลด docx เปิด MS Word อัตโนมัติ
- ↓
- Add-ins ตรวจสอบไฟล์, ผู้ใช้แก้ไข docx
- ↓
- Versioning(คุมเวอร์ชั่น)
- ↓
- ecourt(อัปเดตฐานข้อมูลและไฟล์)
+
+
+

+ ระบบนี้ทำอะไรได้ +

-
-
-
-
-

Addin

- ติดตั้ง Word Add-ins ด้วยสคริปต์นี้
- install-word-addins.ps1 -
- ติดติดปัญหาบน Power Shell ให้เรียกสองบรรทัดล่างก่อน
-

Unblock-File .\install-word-addins.ps1

-

Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned -Force

-

.\install-word-addins.ps1 -Install

-
+
+ {[ + { + icon: FileText, + title: "DOCX Template", + detail: + "ออกแบบหน้าของเอกสารจาก Microsoft Word โดยไม่ต้องใช้เครื่องมือพิเศษ " + + "สามารถนำเอกสารตัวเดิมมาใช้ออกแบบได้เลย " + + "ไม่จำเป็นต้องมีความรู้ด้านการเขียนโปรแกรมหรือ XML ก็สามารถสร้างเทมเพลตได้", + }, + { + icon: FilePenLine, + title: "Fill Form", + detail: + "รอรับ Rich และ Plain Text Content Control " + + "สามารถสร้างฟอร์มสำหรับกรอกข้อมูลพร้อมข้อมูลตั้งต้น " + + "ผู้ใช้สามารถนำไปกรอกข้อมูลใน Word ได้เลย และสามารถเใช้โปรแกรมดึงข้อมูลกับมาเก็บในฐานข้อมูลได้", + }, + { + icon: ToyBrick, + title: "Integrate with Other System", + detail: + "มี Web API สำหรับสร้างเอกสารจากเทมเพลต(DOCX) กับข้อมูล(JSON) " + + "มี API Key เพื่อจำกัดการใช้งาน สามารถออกบัตรผ่านที่ลงลายเซ็นต์ด้วย HmacSha256" + + "เพื่อให้ผสานกับระบบงานอื่นๆ ได้อย่างปลอดภัย", + }, + { + icon: FileText, + title: "Dynamic Document", + detail: + "รองรับเทมเพลตที่ซับซ้อน ข้อมูลที่มีไม่แน่นอนอย่างอาเรย์ การแสดงผลตามเงื่อนไขแบบต่างๆ " + + "สามารถเขียนโปรแกรมเพิ่มลงในเทมเพลตได้ รองรับ FOR , IF แทรกโค้ด " + + "ฟังก์ชั่นในตัวเพื่อรองรับการสร้าง Content Control Bookmark ฯลฯ", + }, + { + icon: Rocket, + title: " High Performance", + detail: + "containerization ขยายระบบได้ง่าย, ระบบเทมเพลตใช้การ XML โดยตรง " + + "การสร้าง template เป็นแบบ Multi-Thread รองรับ CPU หลายแกน " + + "", + }, + ].map(({ icon: Icon, title, detail }) => ( +
+ + + +
+

{title}

+

+ {detail} +

+
+
+ ))} +
+ + +
+
+

+ ตัวอย่างการใช้งาน +

+
+
+ +
+ + + +
+

Link (GET)

+

+ T_no_warning_john_xxx.docx
+ TF_no_warning_P2_john_xxx.docx
+ TS_P2_IN_john_xxx.docx
+ + T12_b2_IN_john_xxx.docx
+ T12_FD155_3s-long_john_xxx.docx
+ +

+
+
+ +
+ + + +
+

Template & Data

+

+

+ Template: T_X.docx,   + T12_X.docx
+ Data: TF_no_warning_P2.json,   + T_no_warning.json,   + TS_P2_IN.json
+ T12_b2_IN.json,   + T12_FD155_3s-long.json + +

+
+
+ +
+ + + +
+

Form (POST)

+

+ +

+ +
+
+ +
+
+ +
+ + + +

+
+
+ +
+ + + +
+

Flow

+

+

+ ลิงค์เลือกไฟล์
+ ↓
+ ตรวจสิทธิ์ สร้าง docx
+ ↓
+ ดาว์นโหลด เปิด Word
+ ↓
+ Add-ins ตรวจสอบไฟล์
+ ↓
+ Versioning
+ ↓
+ อัปเดตฐานข้อมูลและไฟล์
+
+

+
+
+ +
+ + + +
+

วิธีการใช้งาน

+

+ + แนะนำเทมเพลตของ Docedit เบื้องต้น
+ + Sideload Office add-ins +

+
+
+ +
+
+
+
+

+ Add-ins +

+
+
+ + + +
+

+ Word Add-ins
+

+

+ ดาวน์โหลด  + + manifest.xml   + ไว้ที่ SharePoint แชร์เน็ตเวิร์ก หรือดาวน์โหลดสคริปต์ PowerShell(Dev Install)   + + install-word-addins.ps1   + แล้วใช้คำสั่ง PowerShell ด้านล่างเพื่อติดตั้ง Add-ins ใน Word
+
+

Unblock-File .\install-word-addins.ps1

+

Set-ExecutionPolicy -Scope Process -ExecutionPolicy RemoteSigned -Force

+

.\install-word-addins.ps1 -Install

+ +

+
+
+
-
); } \ No newline at end of file