117 lines
3.2 KiB
Markdown
117 lines
3.2 KiB
Markdown
# Retribusi Frontend
|
|
|
|
Frontend aplikasi Retribusi BAPENDA Kabupaten Garut.
|
|
|
|
## Struktur Project
|
|
|
|
```
|
|
retribusi (frontend)/
|
|
├── public/ # Document root (running directory)
|
|
│ ├── index.php # Login page
|
|
│ ├── dashboard/
|
|
│ │ ├── dashboard.html # Dashboard utama
|
|
│ │ ├── event.html # Halaman event logs
|
|
│ │ ├── settings.html # Halaman pengaturan lokasi & gate
|
|
│ │ ├── css/
|
|
│ │ │ └── app.css # Main stylesheet
|
|
│ │ └── js/
|
|
│ │ ├── config.js # API configuration
|
|
│ │ ├── api.js # API client
|
|
│ │ ├── auth.js # Authentication
|
|
│ │ ├── dashboard.js # Dashboard logic
|
|
│ │ ├── charts.js # Chart.js helpers
|
|
│ │ └── realtime.js # Realtime SSE client
|
|
└── api/ # Legacy API endpoints (deprecated)
|
|
```
|
|
|
|
## Fitur
|
|
|
|
- **Dashboard**: Menampilkan KPI cards, chart harian per jam, dan chart per kategori
|
|
- **Event Logs**: Daftar event dengan filter lokasi, gate, kategori, dan tanggal
|
|
- **Settings**: CRUD untuk lokasi dan gate, termasuk pengaturan URL kamera
|
|
- **Realtime**: Update data real-time menggunakan Server-Sent Events (SSE)
|
|
- **Video Preview**: Preview kamera HLS untuk gate yang memiliki URL kamera
|
|
|
|
## Teknologi
|
|
|
|
- Vanilla JavaScript (ES6 modules)
|
|
- Tailwind CSS
|
|
- Chart.js untuk visualisasi data
|
|
- HLS.js untuk video streaming
|
|
|
|
## Konfigurasi
|
|
|
|
File `public/dashboard/js/config.js` mengatur:
|
|
|
|
- API Base URL (auto-detect local/production)
|
|
- API Key untuk autentikasi
|
|
|
|
## Development
|
|
|
|
1. Pastikan backend API sudah running
|
|
2. Set document root ke folder `public/`
|
|
3. Buka `index.html` untuk login (atau akses root `/`)
|
|
4. Akses dashboard di `dashboard/dashboard.html`
|
|
|
|
## Production
|
|
|
|
Deploy ke web server (Apache/Nginx) dengan konfigurasi:
|
|
|
|
- Base URL: sesuai dengan domain production
|
|
- API Base URL: otomatis terdeteksi dari hostname
|
|
|
|
### URL Rewrite (Opsional)
|
|
|
|
**TIDAK PERLU URL rewrite** untuk aplikasi ini karena:
|
|
|
|
- Semua file HTML bisa diakses langsung (`dashboard.html`, `event.html`, `settings.html`)
|
|
- Tidak ada clean URLs atau SPA routing
|
|
- Struktur file sudah jelas dan mudah diakses
|
|
|
|
**Jika ingin clean URLs** (misalnya `/dashboard` tanpa `.html`), bisa gunakan:
|
|
|
|
- **Apache**: File `.htaccess` sudah disediakan (uncomment bagian clean URLs)
|
|
- **Nginx**: Gunakan `nginx.conf.example` sebagai referensi
|
|
|
|
File konfigurasi:
|
|
|
|
- `.htaccess` - Apache URL rewrite (opsional, sudah include security headers & cache)
|
|
- `nginx.conf.example` - Nginx configuration example
|
|
|
|
### Update di Server Production
|
|
|
|
**Cara 1: Menggunakan Script (Recommended)**
|
|
|
|
```bash
|
|
# Linux/Unix
|
|
cd /path/to/retribusi-frontend
|
|
bash pull.sh
|
|
|
|
# Windows
|
|
cd C:\path\to\retribusi-frontend
|
|
pull.bat
|
|
```
|
|
|
|
**Cara 2: Command Langsung (Sekali Jalan)**
|
|
|
|
```bash
|
|
cd /path/to/retribusi-frontend && git stash && git pull origin main && git stash pop
|
|
```
|
|
|
|
**Cara 3: Manual**
|
|
|
|
```bash
|
|
cd /path/to/retribusi-frontend
|
|
git pull origin main
|
|
```
|
|
|
|
**Fix Dubious Ownership Error (jika muncul)**
|
|
|
|
```bash
|
|
# Tambahkan directory ke safe.directory
|
|
git config --global --add safe.directory /www/wwwroot/retribusi.btekno.cloud/retribusi
|
|
|
|
# Atau gunakan script pull.sh yang sudah auto-fix
|
|
bash pull.sh
|
|
```
|