first commit
This commit is contained in:
commit
367533c02b
171 files changed
+101175
No files matched your search
@@ -0,0 +1,94 @@
|
||||
# dashboard-new-v2
|
||||
|
||||
Poultry dashboard SPA. Looks like the legacy `dashboard/` app and talks to the Django API in `backend/` (`/api/v1/`).
|
||||
|
||||
## Project layout
|
||||
|
||||
```
|
||||
dashboard-new-v2/
|
||||
backend/ ← Django API (manage.py, apps, migrations)
|
||||
components/ ← pages and UI
|
||||
services/ ← API client
|
||||
...
|
||||
```
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- Node 20+
|
||||
- Python 3.11+
|
||||
|
||||
## First-time setup
|
||||
|
||||
**Backend** (terminal 1):
|
||||
|
||||
Install the Python dependencies once — only needed if Django/DRF aren't already
|
||||
in your Python environment (they're listed in `backend/requirements.txt`):
|
||||
|
||||
```bash
|
||||
cd dashboard-new-v2/backend
|
||||
python -m venv .venv
|
||||
# Windows: .venv\Scripts\activate
|
||||
# macOS/Linux: source .venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
Then set up the database and seed data:
|
||||
|
||||
```bash
|
||||
cd dashboard-new-v2/backend
|
||||
python manage.py migrate
|
||||
python manage.py seed_demo
|
||||
# or via the npm wrapper: npm run seed
|
||||
```
|
||||
|
||||
Seed logins:
|
||||
|
||||
- `admin` / `admin123` — superadmin (can create/manage sites and kandang)
|
||||
- `staff` / `staff123` — active staff (owns the seeded site; can read sites/kandang and create cycles, but cannot create/edit/delete sites or kandang)
|
||||
|
||||
`seed_demo` creates both logins plus an API key, then seeds the default Sukawarna demo data: **Kandang 4** (45,000 DOC) and **Kandang 5** (50,000 DOC), both 49-day closed cycles (22 May – 9 Jul 2026) with full daily data (chicken counting, chicken weight, feed sacks, manual input, KPI) and **10-minute IoT panel readings** (144 readings per day per flock). Feed-sack `out` (keluar) data only occurs in the final week of the cycle (~20 sacks total), separate from usage (`feed_use`).
|
||||
|
||||
**Frontend** (terminal 2):
|
||||
|
||||
```bash
|
||||
cd dashboard-new-v2
|
||||
cp .env.example .env
|
||||
npm install
|
||||
```
|
||||
|
||||
## Run (two terminals, like old dashboard)
|
||||
|
||||
**Terminal 1 — API:**
|
||||
|
||||
```bash
|
||||
cd dashboard-new-v2/backend
|
||||
npm run dev
|
||||
# `node dev.mjs` starts Django runserver :8000, preferring the .venv python if
|
||||
# present, otherwise the global python (so no pip install is needed when the
|
||||
# deps are already installed). Or directly: python manage.py runserver 0.0.0.0:8000
|
||||
```
|
||||
|
||||
**Terminal 2 — UI:**
|
||||
|
||||
```bash
|
||||
cd dashboard-new-v2
|
||||
npm run dev
|
||||
```
|
||||
|
||||
Open [http://localhost:3001](http://localhost:3001). Vite proxies `/api` to Django on `:8000`.
|
||||
|
||||
## Screens
|
||||
|
||||
Login, Dashboard (KPI + AI insight + Total Pakan section + in-memory Harian/Akhir Siklus report), Hitung Ayam, Berat Ayam, Standar Ross, Hitung Karung (Sync hari ini + Saldo Awal + daily in/use/out tables), Standar Performa, Panel IoT (per-day 10-minute readings with charts), FCR, EEF, Pengaturan.
|
||||
|
||||
Reports are generated in the browser from live `/api/v1/` data and exportable as **PDF** (multi-page A4, block-aware page breaks, compressed JPEG) and **Excel** (Chicken Counting, Weight, Feed In, Feed Use, Feed Out, FCR, EEF sheets with IoT-vs-manual accuracy). Closing the overlay drops the result; nothing is saved on Django.
|
||||
|
||||
The **Saldo Awal** feature on Hitung Karung posts `feed_initial_balance` to the cycle and compares the manual feed-in against the IoT-detected "in" for that date with an accuracy figure.
|
||||
|
||||
Karung Sync calls karung-web-admin. If that host is down the API often returns 502; stored rows still render.
|
||||
|
||||
## Tests
|
||||
|
||||
```bash
|
||||
npm run test:run
|
||||
```
|
||||
Reference in new issue
Block a user