diff --git a/app/api/template/download-docx/route.ts b/app/api/template/download-docx/route.ts index 13f8725..f7e8017 100644 --- a/app/api/template/download-docx/route.ts +++ b/app/api/template/download-docx/route.ts @@ -12,6 +12,7 @@ if (!DOCEDIT_BASE_URL||!EXTERNAL_API_KEY||!TMPL_PATH) { console.error('Missing variable DOCEDIT_BASE_URL, EXTERNAL_API_KEY or TMPL_PATH') } +// console.log("download-docx env",DOCEDIT_BASE_URL,EXTERNAL_API_KEY,TMPL_PATH) async function processRequest(fid: string,tid:string,uid:string,uname:string):Promise> { diff --git a/app/api/template/generate/route.ts b/app/api/template/generate/route.ts index 1a057ee..7b0f506 100644 --- a/app/api/template/generate/route.ts +++ b/app/api/template/generate/route.ts @@ -12,9 +12,12 @@ const PRIVATE_KEY_HEX = process.env.PRIVATE_KEY_HEX ||'' const SECRET = process.env.SECRET || '' const TICKET_SEC = Number(process.env.TICKET_SEC||'300') -if (EXTERNAL_API_KEY || !TMPL_PATH || !PRIVATE_KEY_HEX || !SECRET) +if (!EXTERNAL_API_KEY || !TMPL_PATH || !PRIVATE_KEY_HEX || !SECRET) console.log("api/template/generate: require EXTERNAL_API_KEY, TMPL_PATH and PRIVATE_KEY_HEX") +// console.log("generate env:",EXTERNAL_API_KEY,TMPL_PATH,PRIVATE_KEY_HEX,SECRET) + + export async function POST(request: NextRequest) { // 1. ตรวจสอบ API Key จาก HTTP Header (x-api-key) const apiKey = request.headers.get('x-api-key'); @@ -29,7 +32,7 @@ export async function POST(request: NextRequest) { try { // รับข้อมูล JSON Payload const templateData:DocumentTemplate = (await request.json()); - console.log(templateData) + // console.log(templateData) // ต้องมี templateData.info.ticket_data เป็น json string เสมอ if (!templateData || !templateData.info || !templateData.info.ticket_data || diff --git a/app/tmpl/page.tsx b/app/tmpl/page.tsx index 0eaec44..fa31778 100644 --- a/app/tmpl/page.tsx +++ b/app/tmpl/page.tsx @@ -1,5 +1,6 @@ // app/page.tsx (ระบบ B) 'use client'; +import Link from "next/link"; import type { ChangeEvent } from 'react'; // import { createDownloadFormAction } from './actions'; import DependentDropdown, { DropdownData } from '@/components/utils/DependentDropdown'; @@ -25,10 +26,10 @@ export default function HomePage() {
ตัวอย่าง Frontend ส่งข้อมูลผ่าน <form>(POST) หรือ <a>(GET) เพื่อรองรับ Vanilla JavaScript และ Classic Framework ใช้การเปลี่ยนหน้าเพื่อดาว์นโหลดไฟล์ - ต้องทำให้ ASP.NET มีฟังก์ชั่นเหมือน /docedit/api/template/download-docx + ตัวอย่างหน้าแบบ Plain HTML
-
+

Form POST

@@ -55,23 +56,23 @@ export default function HomePage() {
-

A Link Get

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

A Link Get(new)

+ 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
+ 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 + 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

diff --git a/public/tmpl/dl.html b/public/tmpl/dl.html new file mode 100644 index 0000000..6114ce9 --- /dev/null +++ b/public/tmpl/dl.html @@ -0,0 +1,28 @@ + + + + + + Test Download DOCX a + + +

A a 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 + + + + \ No newline at end of file