พอร์ต UI จาก web-at-transit-mock เข้า Next.js + data sync เข้า Postgres/SeaweedFS

- 8 หน้า (home/stops/routes/stop/check/blog/about/credits) แปลง partials → React component ตรง mock
- ตรรกะพอร์ตเป็น src/lib/ui/*.ts (mount()) + runtime/PageRuntime
- CSS: base + pages/*.css import ต่อ route (คงลำดับ cascade ของ mock)
- asset/content: public/{image,resource/data,content,locales,vendor}
- แก้ path รูปไทล์พาร์ทเนอร์ (.image → /image) + fallback absolute
- ลบ UI เดิมที่ไม่ตรง mock (expanded/stops details/old components/globals.css)
- script/sync_data_to_postgres.mjs + sync_images_to_storage.mjs (dry-run/--apply, backup)
- docs/UI-PORT.md + DESIGN.md + README
This commit is contained in:
itmeadmin committed 2026-10-23 15:50:00 +07:00
1 parent 24187fc3b7
commit 138a3d15d8
300 files changed
+20213 -1978

No files matched your search

+36 -10
View File
@@ -148,18 +148,44 @@ curl -X POST http://localhost:8000/api/images \
หรือวางไฟล์ลง `storage/seed-assets/<entity_type>/<entity_id>/...`
แล้ว backend จะ ingest อัตโนมัติเมื่อ images ยังว่าง
## Flow Nodes (อ้างอิงตามจริงในโค้ด)
## UI (frontend) — พอร์ตจาก mock
| โหนด | หน้า | การ action สำคัญ |
|------|------|--------------------|
| **N1** | `/` (Home) | คลิกการ์ดหมวด → `/routes?group=` · คลิกการ์ดจังหวัด → `/routes?province=` |
| **N2** | `/routes` (รายการเส้นทาง) | คลิกการ์ดเส้นทาง → `/routes/[routeId]` |
| **N3** | `/routes/[routeId]` | คลิก "ดูแบบขยาย" → `/routes/[routeId]/expanded` · คลิกชื่อจุดจอด → `/stops/[stopId]` |
| **N3b** | `/routes/[routeId]/expanded` | แกลเลอรีภาพ · เบอร์โทร · เมตาดาตา |
| **N4** | `/stops` (รายการจุดจอด + แผนที่) | popup marker → `/stops/[stopId]` · คลิกการ์ด → `/stops/[stopId]` |
| **N4b** | `/stops/[stopId]` | คลิกเส้นทาง → `/routes/[routeId]` |
หน้าเว็บทั้งหมดพอร์ตมาจาก `D:\Git\workspace\web-at-transit-mock` แบบ 1:1
(มาร์กอัป + CSS + ตรรกะ) แต่เปลี่ยนจาก hash router เป็น route จริงของ Next.js
ทุกหน้ายิง `POST /api/visits` ด้วย `visitor_id` UUID v4 ใน `localStorage`
| Route | หน้า | ไฟล์ |
|------|------|------|
| `/` | หน้าแรก — เลือกจังหวัด → สถานี, การ์ดตามหมวดเส้นทาง | `src/app/page.tsx` |
| `/stops` | ค้นหาป้าย (รหัส 5 หลัก / ชื่อสถานที่) + ป้ายใกล้ฉัน | `src/app/stops/page.tsx` |
| `/stops/[code]` | รายละเอียดป้าย + ตารางเดินรถ + แผนที่ | `src/app/stops/[code]/page.tsx` |
| `/routes`, `/routes/[routeId]` | รายละเอียดสาย + รูปรถ + แผนที่เส้นทาง | `src/app/routes/...` |
| `/check`, `/check/[routeId]` | เช็กเวลาเดินรถทุกจุดจอด | `src/app/check/...` |
| `/blog`, `/blog/[postId]` | บทความ + แผนที่ในบทความ | `src/app/blog/...` |
| `/about`, `/credits` | เกี่ยวกับเรา / เครดิต | `src/app/{about,credits}` |
- มาร์กอัปอยู่ที่ `frontend/src/components/views/*.tsx`
- ตรรกะ (เดิม `ui/*.js`) อยู่ที่ `frontend/src/lib/ui/*.ts` และถูกเรียกผ่าน `PageRuntime`
- CSS: `frontend/src/styles/` (`_shared`, `map`, `shell`, `responsive`) + `styles/pages/*.css`
**ต้อง import CSS ของหน้าใน view ของหน้านั้น** (รายละเอียดใน `docs/UI-PORT.md`)
- ข้อมูล/รูป: `frontend/public/resource/data/`, `frontend/public/image/`,
`frontend/public/content/`, `frontend/public/locales/`
- ดีไซน์: `DESIGN.md` (รัฐธรรมนูญของ UI)
## การเชื่อมกับ core_management
`docker-compose.yml` ใช้ `internal-network` (external) และคุยกับบริการที่รันโดย
`D:\Git\core_management`:
- Postgres: `compose.internal.db.yaml` → ตั้ง `SQL_DB_URL` ใน `.env`
- ไฟล์/รูป: `compose.storage.yaml` → `STORAGE_URL=http://seaweed-filer:8888`
(frontend อ่านผ่าน `/files/...` ที่ proxy ไป backend)
- ไม่มี container ใหม่สำหรับ db/storage ใน repo นี้
อัปโหลดรูปที่มีอยู่เข้า SeaweedFS (ทำครั้งเดียวหลัง backend พร้อม):
```bash
python script/import_assets_to_storage.py --api http://localhost:8080/api --dir frontend/public/image --map script/asset_entity_map.json
```
## Image Flow Overview