first init
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
# Dependensi (dipasang ulang dengan `npm install`)
|
||||
node_modules/
|
||||
|
||||
# Data aplikasi: database, kunci sesi, dan gambar unggahan pengguna
|
||||
data/
|
||||
uploads/
|
||||
*.db
|
||||
*.db-wal
|
||||
*.db-shm
|
||||
|
||||
# Konfigurasi rahasia
|
||||
.env
|
||||
.env.*
|
||||
|
||||
# Log dan file sistem
|
||||
*.log
|
||||
npm-debug.log*
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
desktop.ini
|
||||
@@ -0,0 +1,76 @@
|
||||
# Logharian
|
||||
|
||||
Website pelaporan log harian kegiatan mahasiswa. Ketua tim menulis log (deskripsi, boleh dengan gambar), dosen memantau dan memberi komentar, operator mengelola semuanya.
|
||||
|
||||
Dokumentasi lengkap (fitur, hak akses, database, daftar URL, hosting): lihat **[DOKUMENTASI.md](DOKUMENTASI.md)**.
|
||||
|
||||
## Menjalankan
|
||||
|
||||
Butuh **Node.js 22.13+** (memakai SQLite bawaan Node, jadi tidak perlu install database).
|
||||
|
||||
```bash
|
||||
npm install
|
||||
npm start # http://localhost:3000
|
||||
npm run dev # mode pengembangan, restart otomatis saat file berubah
|
||||
npm run seed:demo # opsional: isi akun & kegiatan contoh
|
||||
```
|
||||
|
||||
Saat pertama dijalankan, akun operator dibuat otomatis: **admin / admin123** — segera ganti lewat menu **Akun**.
|
||||
Akun demo (setelah `seed:demo`): `dosen1`, `dosen2`, `ketua1`, `ketua2`, semua berpassword `password123`.
|
||||
|
||||
## Level akun
|
||||
|
||||
| Level | Hak akses |
|
||||
|---|---|
|
||||
| **Operator** (admin) | Akses penuh: kelola pengguna & kegiatan, lihat semua log, ubah/hapus log, hapus komentar. |
|
||||
| **Dosen** | Melihat log pada kegiatan yang ditugaskan kepadanya, dan berkomentar. |
|
||||
| **Ketua Tim** | Menulis, mengubah, dan menghapus log untuk kegiatan yang ia pimpin; membaca dan membalas komentar. |
|
||||
|
||||
Hanya ketua tim yang **sudah ditambahkan operator** sebagai ketua sebuah kegiatan yang bisa menulis log untuk kegiatan itu.
|
||||
|
||||
## Alur penggunaan
|
||||
|
||||
1. Operator membuat akun **Dosen** dan **Ketua Tim** (menu *Pengguna*).
|
||||
2. Operator membuat **Kegiatan**, memilih ketua timnya, dan mencentang dosen pemantau.
|
||||
3. Ketua tim login → buka kalender kegiatan → klik tanggal → *Tulis laporan* → isi deskripsi (wajib), judul & gambar (opsional, maks. 5 gambar @ 3 MB, atau link Google Drive).
|
||||
4. Dosen login → buka kegiatan → baca log → tulis komentar. Ketua tim bisa membalas.
|
||||
|
||||
## Konfigurasi (variabel lingkungan, opsional)
|
||||
|
||||
| Variabel | Default | Keterangan |
|
||||
|---|---|---|
|
||||
| `PORT` | `3000` | Port server |
|
||||
| `ADMIN_PASSWORD` | `admin123` | Password akun operator awal (hanya dipakai saat dibuat pertama kali) |
|
||||
| `SESSION_SECRET` | dibuat otomatis di `data/` | Kunci sesi |
|
||||
| `DB_PATH` | `data/logharian.db` | Lokasi database SQLite |
|
||||
| `UPLOAD_DIR` | `uploads/` | Lokasi file gambar |
|
||||
| `COOKIE_SECURE` | – | Isi `1` bila situs dijalankan lewat HTTPS |
|
||||
| `TRUST_PROXY` | – | Isi `1` bila di belakang reverse proxy (Nginx, dll.) |
|
||||
|
||||
## Struktur
|
||||
|
||||
```
|
||||
src/
|
||||
server.js konfigurasi Express, sesi, middleware
|
||||
db.js skema database & akun operator awal
|
||||
access.js aturan hak akses & query bersama
|
||||
middleware.js login, level akun, CSRF, format tanggal
|
||||
upload.js unggah gambar (multer)
|
||||
routes/auth.js login, logout, ganti password
|
||||
routes/admin.js kelola pengguna & kegiatan (operator)
|
||||
routes/logs.js dashboard, log harian, komentar, gambar
|
||||
views/ template EJS
|
||||
public/css/ gaya tampilan
|
||||
data/ database (dibuat otomatis, jangan di-commit)
|
||||
uploads/ gambar unggahan (dibuat otomatis, jangan di-commit)
|
||||
```
|
||||
|
||||
## Keamanan yang sudah diterapkan
|
||||
|
||||
- Password di-hash dengan bcrypt; pembatasan percobaan login.
|
||||
- Token CSRF di semua form; cookie sesi `httpOnly` + `SameSite=Lax`.
|
||||
- Gambar tidak bisa diakses publik — dilayani lewat `/gambar/:id` dengan pengecekan hak akses.
|
||||
- Hanya file JPG/PNG/WEBP/GIF yang diterima; nama file diacak.
|
||||
- Akun yang dinonaktifkan langsung keluar dari sesi.
|
||||
|
||||
**Backup**: cukup salin folder `data/` dan `uploads/`.
|
||||
Generated
+962
@@ -0,0 +1,962 @@
|
||||
{
|
||||
"name": "logharian",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "logharian",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"bcryptjs": "^3.0.3",
|
||||
"ejs": "^7.0.2",
|
||||
"express": "^4.22.3",
|
||||
"express-session": "^1.19.0",
|
||||
"multer": "^2.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/accepts": {
|
||||
"version": "1.3.8",
|
||||
"resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz",
|
||||
"integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-types": "~2.1.34",
|
||||
"negotiator": "0.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/append-field": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/append-field/-/append-field-1.0.0.tgz",
|
||||
"integrity": "sha512-klpgFSWLW1ZEs8svjfb7g4qWY0YS5imI82dTg+QahUvJ8YqAY0P10Uk8tTyh9ZGuYEZEMaeJYCF5BFuX552hsw==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/array-flatten": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz",
|
||||
"integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/bcryptjs": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/bcryptjs/-/bcryptjs-3.0.3.tgz",
|
||||
"integrity": "sha512-GlF5wPWnSa/X5LKM1o0wz0suXIINz1iHRLvTS+sLyi7XPbe5ycmYI3DlZqVGZZtDgl4DmasFg7gOB3JYbphV5g==",
|
||||
"license": "BSD-3-Clause",
|
||||
"bin": {
|
||||
"bcrypt": "bin/bcrypt"
|
||||
}
|
||||
},
|
||||
"node_modules/body-parser": {
|
||||
"version": "1.20.9",
|
||||
"resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.9.tgz",
|
||||
"integrity": "sha512-FISIQxV5u91Y9gvuFq3q/tA/qTqLJn3AhRcEvyozyhJTh5OBFFtv827AdHU7Rbyct4r+Ba1/99oFa1Y3yuFsdw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
"content-type": "~1.0.5",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "~1.2.0",
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"on-finished": "~2.4.1",
|
||||
"qs": "~6.16.0",
|
||||
"raw-body": "~2.5.3",
|
||||
"type-is": "~1.6.18",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/busboy": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz",
|
||||
"integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==",
|
||||
"dependencies": {
|
||||
"streamsearch": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10.16.0"
|
||||
}
|
||||
},
|
||||
"node_modules/bytes": {
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz",
|
||||
"integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bind-apply-helpers": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
|
||||
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/call-bound": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
|
||||
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"get-intrinsic": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/content-disposition": {
|
||||
"version": "0.5.4",
|
||||
"resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz",
|
||||
"integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safe-buffer": "5.2.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/content-type": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
|
||||
"integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie": {
|
||||
"version": "0.7.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.2.tgz",
|
||||
"integrity": "sha512-yki5XnKuf750l50uGTllt6kKILY4nQ1eNIQatoXEByZ5dWgnKqbnqmTrBE5B4N7lrMJKQ2ytWMiTO2o0v6Ew/w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/cookie-signature": {
|
||||
"version": "1.0.7",
|
||||
"resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.7.tgz",
|
||||
"integrity": "sha512-NXdYc3dLr47pBkpUCHtKSwIOQXLVn8dZEuywboCOJY/osA0wFSLlSawr3KN8qXJEyX66FcONTH8EIlVuK0yyFA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "2.6.9",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
|
||||
"integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "2.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/depd": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
|
||||
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/destroy": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz",
|
||||
"integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8",
|
||||
"npm": "1.2.8000 || >= 1.4.16"
|
||||
}
|
||||
},
|
||||
"node_modules/dunder-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"gopd": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/ee-first": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz",
|
||||
"integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/ejs": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/ejs/-/ejs-7.0.2.tgz",
|
||||
"integrity": "sha512-LcDSEP6Oclb9sTiSyG0MpG0RuKvLDRxCOOt+2sIk+kdk1rMkFU8SRnT0qaNt5zvU0LOV1YXXOvIoZL/sKwabvw==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"ejs": "bin/cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.12.18"
|
||||
}
|
||||
},
|
||||
"node_modules/encodeurl": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.3.tgz",
|
||||
"integrity": "sha512-mIteYONiEfc4xWf2F1WXovh1c8npzS00vNeiUPdwFF+QlVJni+gNvpQltLMQhob8rew/bWWc/bGTuUr0EUGt0w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/es-define-property": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
|
||||
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-errors": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
|
||||
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/es-object-atoms": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.2.tgz",
|
||||
"integrity": "sha512-HWcBoN6NileqtSydK2FqHbS/LoDd2pqrnQHLyJzBj4kOp/ky2MWMN694xOfkK8/SnUsW2DH7EfyVlydKCsm1Zw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/escape-html": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
|
||||
"integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/etag": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/express": {
|
||||
"version": "4.22.3",
|
||||
"resolved": "https://registry.npmjs.org/express/-/express-4.22.3.tgz",
|
||||
"integrity": "sha512-Bdcs4+3qlpVlx2NRn6fgX2Ue2/gGRaPeawebgclM0ERSCqDpA+owF1fdPwjJUTAJWMTuAaxjDf+hzb0/4eKvvw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"accepts": "~1.3.8",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "~1.20.5",
|
||||
"content-disposition": "~0.5.4",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "~0.7.1",
|
||||
"cookie-signature": "~1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "~1.3.1",
|
||||
"fresh": "~0.5.2",
|
||||
"http-errors": "~2.0.0",
|
||||
"merge-descriptors": "1.0.3",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "~0.1.13",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "~6.16.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.2.1",
|
||||
"send": "~0.19.0",
|
||||
"serve-static": "~1.16.2",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "~2.0.1",
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/express-session": {
|
||||
"version": "1.19.0",
|
||||
"resolved": "https://registry.npmjs.org/express-session/-/express-session-1.19.0.tgz",
|
||||
"integrity": "sha512-0csaMkGq+vaiZTmSMMGkfdCOabYv192VbytFypcvI0MANrp+4i/7yEkJ0sbAEhycQjntaKGzYfjfXQyVb7BHMA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"cookie": "~0.7.2",
|
||||
"cookie-signature": "~1.0.7",
|
||||
"debug": "~2.6.9",
|
||||
"depd": "~2.0.0",
|
||||
"on-headers": "~1.1.0",
|
||||
"parseurl": "~1.3.3",
|
||||
"safe-buffer": "~5.2.1",
|
||||
"uid-safe": "~2.1.5"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/finalhandler": {
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.2.tgz",
|
||||
"integrity": "sha512-aA4RyPcd3badbdABGDuTXCMTtOneUCAYH/gxoYRTZlIJdF0YPWuGqiAsIrhNnnqdXGswYk6dGujem4w80UJFhg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"on-finished": "~2.4.1",
|
||||
"parseurl": "~1.3.3",
|
||||
"statuses": "~2.0.2",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/forwarded": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
|
||||
"integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/fresh": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
|
||||
"integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/function-bind": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
|
||||
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-intrinsic": {
|
||||
"version": "1.3.0",
|
||||
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
|
||||
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bind-apply-helpers": "^1.0.2",
|
||||
"es-define-property": "^1.0.1",
|
||||
"es-errors": "^1.3.0",
|
||||
"es-object-atoms": "^1.1.1",
|
||||
"function-bind": "^1.1.2",
|
||||
"get-proto": "^1.0.1",
|
||||
"gopd": "^1.2.0",
|
||||
"has-symbols": "^1.1.0",
|
||||
"hasown": "^2.0.2",
|
||||
"math-intrinsics": "^1.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/get-proto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
|
||||
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"dunder-proto": "^1.0.1",
|
||||
"es-object-atoms": "^1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/gopd": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
|
||||
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/has-symbols": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
|
||||
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/hasown": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz",
|
||||
"integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"function-bind": "^1.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/http-errors": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.1.tgz",
|
||||
"integrity": "sha512-4FbRdAX+bSdmo4AUFuS0WNiPz8NgFt+r8ThgNWmlrjQjt1Q7ZR9+zTlce2859x4KSXrwIsaeTqDoKQmtP8pLmQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"depd": "~2.0.0",
|
||||
"inherits": "~2.0.4",
|
||||
"setprototypeof": "~1.2.0",
|
||||
"statuses": "~2.0.2",
|
||||
"toidentifier": "~1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/iconv-lite": {
|
||||
"version": "0.4.24",
|
||||
"resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz",
|
||||
"integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"safer-buffer": ">= 2.1.2 < 3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/inherits": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
|
||||
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/ipaddr.js": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz",
|
||||
"integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
}
|
||||
},
|
||||
"node_modules/math-intrinsics": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
|
||||
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/media-typer": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/merge-descriptors": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz",
|
||||
"integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==",
|
||||
"license": "MIT",
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/methods": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
|
||||
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
|
||||
"integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==",
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"mime": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-db": {
|
||||
"version": "1.52.0",
|
||||
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
|
||||
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/mime-types": {
|
||||
"version": "2.1.35",
|
||||
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
|
||||
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"mime-db": "1.52.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
"integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/multer": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/multer/-/multer-2.5.0.tgz",
|
||||
"integrity": "sha512-BsqOzYGVq49JcW2IzoSAxeKYRevb+dGGPPWleOR8Lrlk4igwxu1/9pwSXlByhCb7MVZDrNJFC0IBP5/O5nLYRw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"append-field": "^1.0.0",
|
||||
"busboy": "^1.6.0",
|
||||
"type-is": "^1.6.18"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 10.16.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/negotiator": {
|
||||
"version": "0.6.3",
|
||||
"resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz",
|
||||
"integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/object-inspect": {
|
||||
"version": "1.13.4",
|
||||
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
|
||||
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/on-finished": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.2.tgz",
|
||||
"integrity": "sha512-ATWUv387i+nLD49EiDoOft5scf32Vsdz3ktrQJG9bi7jRFmaXTssvyvj1EmeKVVgvesbqUtvQQvaS2TpTukAZQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ee-first": "1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/on-headers": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.1.0.tgz",
|
||||
"integrity": "sha512-737ZY3yNnXy37FHkQxPzt4UZ2UWPWiCZWLvFZ4fu5cueciegX0zGPnrlY6bwRg4FdQOe9YU8MkmJwGhoMybl8A==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/parseurl": {
|
||||
"version": "1.3.3",
|
||||
"resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz",
|
||||
"integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/path-to-regexp": {
|
||||
"version": "0.1.13",
|
||||
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.13.tgz",
|
||||
"integrity": "sha512-A/AGNMFN3c8bOlvV9RreMdrv7jsmF9XIfDeCd87+I8RNg6s78BhJxMu69NEMHBSJFxKidViTEdruRwEk/WIKqA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/proxy-addr": {
|
||||
"version": "2.0.8",
|
||||
"resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.8.tgz",
|
||||
"integrity": "sha512-5nnx0yGyVUcY6t9RnWcARWtwT9F1D8O9rt08htPvnd49W1IgZtmLkhu9WfMzQj1cFxjHIO6connUNVW5k7AVyQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"forwarded": "0.2.0",
|
||||
"ipaddr.js": "1.9.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.10"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
}
|
||||
},
|
||||
"node_modules/qs": {
|
||||
"version": "6.16.2",
|
||||
"resolved": "https://registry.npmjs.org/qs/-/qs-6.16.2.tgz",
|
||||
"integrity": "sha512-VYdnB5S7/0IeXzBacUtwNAaM6d7Y/PgYnNC7bJCI6meqA/OgnsQbZMtVW8Dt2D1PHgbHGtYmhSoEIgvt7xZ2ZA==",
|
||||
"license": "BSD-3-Clause",
|
||||
"dependencies": {
|
||||
"es-define-property": "^1.0.1",
|
||||
"side-channel": "^1.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/random-bytes": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/random-bytes/-/random-bytes-1.0.0.tgz",
|
||||
"integrity": "sha512-iv7LhNVO047HzYR3InF6pUcUsPQiHTM1Qal51DcGSuZFBil1aBBWG5eHPNek7bvILMaYJ/8RU1e8w1AMdHmLQQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/range-parser": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz",
|
||||
"integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/raw-body": {
|
||||
"version": "2.5.3",
|
||||
"resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.3.tgz",
|
||||
"integrity": "sha512-s4VSOf6yN0rvbRZGxs8Om5CWj6seneMwK3oDb4lWDH0UPhWcxwOWw5+qk24bxq87szX1ydrwylIOp2uG1ojUpA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bytes": "~3.1.2",
|
||||
"http-errors": "~2.0.1",
|
||||
"iconv-lite": "~0.4.24",
|
||||
"unpipe": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
|
||||
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/feross"
|
||||
},
|
||||
{
|
||||
"type": "patreon",
|
||||
"url": "https://www.patreon.com/feross"
|
||||
},
|
||||
{
|
||||
"type": "consulting",
|
||||
"url": "https://feross.org/support"
|
||||
}
|
||||
],
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/safer-buffer": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz",
|
||||
"integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/send": {
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/send/-/send-0.19.2.tgz",
|
||||
"integrity": "sha512-VMbMxbDeehAxpOtWJXlcUS5E8iXh6QmN+BkRX1GARS3wRaXEEgzCcB10gTQazO42tpNIya8xIyNx8fll1OFPrg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"debug": "2.6.9",
|
||||
"depd": "2.0.0",
|
||||
"destroy": "1.2.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"fresh": "~0.5.2",
|
||||
"http-errors": "~2.0.1",
|
||||
"mime": "1.6.0",
|
||||
"ms": "2.1.3",
|
||||
"on-finished": "~2.4.1",
|
||||
"range-parser": "~1.2.1",
|
||||
"statuses": "~2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/send/node_modules/ms": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/serve-static": {
|
||||
"version": "1.16.3",
|
||||
"resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.3.tgz",
|
||||
"integrity": "sha512-x0RTqQel6g5SY7Lg6ZreMmsOzncHFU7nhnRWkKgWuMTu5NN0DR5oruckMqRvacAN9d5w6ARnRBXl9xhDCgfMeA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"parseurl": "~1.3.3",
|
||||
"send": "~0.19.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
}
|
||||
},
|
||||
"node_modules/setprototypeof": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
|
||||
"integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/side-channel": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz",
|
||||
"integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.4",
|
||||
"side-channel-list": "^1.0.1",
|
||||
"side-channel-map": "^1.0.1",
|
||||
"side-channel-weakmap": "^1.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-list": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.1.tgz",
|
||||
"integrity": "sha512-mjn/0bi/oUURjc5Xl7IaWi/OJJJumuoJFQJfDDyO46+hBWsfaVM65TBHq2eoZBhzl9EchxOijpkbRC8SVBQU0w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"es-errors": "^1.3.0",
|
||||
"object-inspect": "^1.13.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-map": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
|
||||
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/side-channel-weakmap": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
|
||||
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"call-bound": "^1.0.2",
|
||||
"es-errors": "^1.3.0",
|
||||
"get-intrinsic": "^1.2.5",
|
||||
"object-inspect": "^1.13.3",
|
||||
"side-channel-map": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/ljharb"
|
||||
}
|
||||
},
|
||||
"node_modules/statuses": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.2.tgz",
|
||||
"integrity": "sha512-DvEy55V3DB7uknRo+4iOGT5fP1slR8wQohVdknigZPMpMstaKJQWhwiYBACJE3Ul2pTnATihhBYnRhZQHGBiRw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/streamsearch": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz",
|
||||
"integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/toidentifier": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
|
||||
"integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/type-is": {
|
||||
"version": "1.6.18",
|
||||
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz",
|
||||
"integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"media-typer": "0.3.0",
|
||||
"mime-types": "~2.1.24"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/uid-safe": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/uid-safe/-/uid-safe-2.1.5.tgz",
|
||||
"integrity": "sha512-KPHm4VL5dDXKz01UuEd88Df+KzynaohSL9fBh096KWAxSKZQDI2uBrVqtvRM4rwrIrRRKsdLNML/lnaaVSRioA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"random-bytes": "~1.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/unpipe": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
|
||||
"integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/utils-merge": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz",
|
||||
"integrity": "sha512-pMZTvIkT1d+TFGvDOqodOclx0QWkkgi6Tdoa8gC8ffGAAqz9pzPTZWAybbsHHoED/ztMtkv/VoYTYyShUn81hA==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/vary": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
|
||||
"integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "logharian",
|
||||
"version": "1.0.0",
|
||||
"main": "src/server.js",
|
||||
"scripts": {
|
||||
"start": "node --disable-warning=ExperimentalWarning src/server.js",
|
||||
"dev": "node --disable-warning=ExperimentalWarning --watch src/server.js",
|
||||
"seed:demo": "node --disable-warning=ExperimentalWarning scripts/seed-demo.js"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"type": "commonjs",
|
||||
"description": "Pelaporan log harian kegiatan mahasiswa",
|
||||
"dependencies": {
|
||||
"bcryptjs": "^3.0.3",
|
||||
"ejs": "^7.0.2",
|
||||
"express": "^4.22.3",
|
||||
"express-session": "^1.19.0",
|
||||
"multer": "^2.5.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=22.13"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,664 @@
|
||||
/* =========================================================
|
||||
Logharian — Palet: abu-abu cerah + biru dongker
|
||||
(mengikuti MonitoringMahasiswa/Contohwarna.css)
|
||||
========================================================= */
|
||||
:root {
|
||||
--navy-950: #07132a;
|
||||
--navy-900: #0b1d3a;
|
||||
--navy-800: #11284f;
|
||||
--navy-700: #1a3766;
|
||||
--navy-600: #244a85;
|
||||
--navy-500: #3a63a8;
|
||||
--navy-200: #b9c8e2;
|
||||
--navy-100: #dde5f2;
|
||||
--navy-50: #eef2f9;
|
||||
|
||||
--white: #ffffff;
|
||||
--gray-25: #f9fafb;
|
||||
--gray-50: #f3f5f8;
|
||||
--gray-100: #eceff4;
|
||||
--gray-200: #dfe4eb;
|
||||
--gray-300: #c8d0db;
|
||||
--gray-400: #9aa5b5;
|
||||
--gray-500: #6e7a8d;
|
||||
--gray-600: #505b6d;
|
||||
--gray-700: #353f50;
|
||||
--ink: #0e1a2e;
|
||||
|
||||
--ok: #15805a;
|
||||
--ok-bg: #e3f3eb;
|
||||
--warn: #a96400;
|
||||
--warn-bg: #fff1d9;
|
||||
--danger: #bf3328;
|
||||
--danger-bg: #fce8e6;
|
||||
--info: #2d5da8;
|
||||
--info-bg: #e6edf8;
|
||||
|
||||
--radius: 16px;
|
||||
--radius-sm: 10px;
|
||||
--shadow-sm: 0 1px 2px rgba(11, 29, 58, .05), 0 1px 3px rgba(11, 29, 58, .07);
|
||||
--shadow: 0 6px 20px rgba(11, 29, 58, .07), 0 1px 3px rgba(11, 29, 58, .06);
|
||||
--shadow-lg: 0 24px 60px rgba(7, 19, 42, .22);
|
||||
--focus: 0 0 0 4px rgba(58, 99, 168, .15);
|
||||
|
||||
--font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
|
||||
color-scheme: light;
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; }
|
||||
html { -webkit-text-size-adjust: 100%; }
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: var(--font);
|
||||
font-size: 15px;
|
||||
line-height: 1.55;
|
||||
color: var(--ink);
|
||||
background: var(--gray-50);
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
a { color: var(--navy-600); text-decoration: none; }
|
||||
a:hover { text-decoration: underline; }
|
||||
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.015em; }
|
||||
h1 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
|
||||
h2 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
|
||||
p { margin: 0 0 6px; }
|
||||
.muted { color: var(--gray-500); }
|
||||
.small { font-size: 13px; }
|
||||
img { max-width: 100%; }
|
||||
:focus-visible { outline: 2px solid var(--navy-500); outline-offset: 2px; }
|
||||
|
||||
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
|
||||
.main { padding-top: 32px; padding-bottom: 64px; }
|
||||
@media (max-width: 720px) { .wrap { padding: 0 16px; } .main { padding-top: 20px; } }
|
||||
|
||||
/* ---------- Top bar (gelap) ---------- */
|
||||
html, body { overflow-x: clip; }
|
||||
.topbar {
|
||||
position: sticky; top: 0; z-index: 40;
|
||||
background: var(--navy-950);
|
||||
border-bottom: 1px solid rgba(255, 255, 255, .08);
|
||||
box-shadow: 0 1px 0 rgba(7, 19, 42, .4);
|
||||
}
|
||||
.topbar-inner { display: flex; align-items: center; gap: 28px; min-height: 66px; flex-wrap: wrap; }
|
||||
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-weight: 800; font-size: 17px; letter-spacing: -.02em; }
|
||||
.brand:hover { text-decoration: none; color: #fff; }
|
||||
.brand-logo {
|
||||
width: 38px; height: 38px; border-radius: 10px; flex: none; object-fit: contain;
|
||||
background: #fff; padding: 2px; box-shadow: 0 0 0 1px rgba(255, 255, 255, .15);
|
||||
}
|
||||
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
|
||||
.nav a {
|
||||
position: relative; font-size: 14px; font-weight: 600; color: var(--navy-200);
|
||||
padding: 8px 14px; border-radius: 10px; white-space: nowrap; transition: background .15s, color .15s;
|
||||
}
|
||||
.nav a:hover { color: #fff; background: rgba(255, 255, 255, .07); text-decoration: none; }
|
||||
.nav a.active { color: #fff; background: rgba(255, 255, 255, .12); }
|
||||
.nav a.active::after {
|
||||
content: ''; position: absolute; left: 14px; right: 14px; bottom: 3px; height: 2px;
|
||||
border-radius: 2px; background: #ffb547;
|
||||
}
|
||||
.who { display: flex; align-items: center; gap: 10px; }
|
||||
.who form { margin: 0; }
|
||||
.who-name { font-size: 14px; font-weight: 600; color: #fff; }
|
||||
.who .btn-ghost { --fg: var(--navy-200); }
|
||||
.who .btn-ghost:hover { --bg: rgba(255, 255, 255, .08); --fg: #fff; }
|
||||
.avatar {
|
||||
width: 34px; height: 34px; border-radius: 10px; flex: none;
|
||||
display: grid; place-items: center; font-weight: 800; font-size: 12.5px;
|
||||
background: linear-gradient(145deg, var(--navy-500), var(--navy-700)); color: #fff;
|
||||
box-shadow: 0 0 0 1px rgba(255, 255, 255, .15);
|
||||
}
|
||||
@media (max-width: 720px) {
|
||||
.topbar-inner { gap: 8px; padding-top: 10px; padding-bottom: 8px; }
|
||||
.nav { order: 3; flex-basis: 100%; }
|
||||
.who { margin-left: auto; }
|
||||
.who-name { display: none; }
|
||||
}
|
||||
|
||||
/* ---------- Pita judul halaman ---------- */
|
||||
.page-hero {
|
||||
position: relative; isolation: isolate; color: #fff;
|
||||
margin: -32px 0 24px; padding: 28px 0 30px;
|
||||
}
|
||||
.page-hero::before {
|
||||
content: ''; position: absolute; z-index: -2; top: 0; bottom: 0; left: calc(50% - 50vw); right: calc(50% - 50vw);
|
||||
background:
|
||||
radial-gradient(700px 300px at 85% 0%, rgba(58, 99, 168, .35), transparent 70%),
|
||||
linear-gradient(180deg, var(--navy-900), var(--navy-800));
|
||||
}
|
||||
.page-hero::after {
|
||||
content: ''; position: absolute; z-index: -1; top: 0; bottom: 0; left: calc(50% - 50vw); right: calc(50% - 50vw);
|
||||
background-image: radial-gradient(rgba(255, 255, 255, .09) 1px, transparent 1px);
|
||||
background-size: 22px 22px;
|
||||
mask-image: linear-gradient(90deg, transparent 35%, #000 85%);
|
||||
-webkit-mask-image: linear-gradient(90deg, transparent 35%, #000 85%);
|
||||
}
|
||||
.page-hero .page-head { margin-bottom: 0; align-items: flex-end; }
|
||||
.page-hero h1 { color: #fff; font-size: 28px; margin: 4px 0 6px; }
|
||||
.page-hero .eyebrow { color: #ffb547; margin: 0; }
|
||||
.page-hero .sub { color: #c7d3e8; margin: 0; }
|
||||
.page-hero .muted { color: #c7d3e8; }
|
||||
.page-hero strong { color: #fff; }
|
||||
.page-hero .crumbs { color: var(--navy-200); margin-bottom: 14px; }
|
||||
.page-hero .crumbs a { color: var(--navy-200); }
|
||||
.page-hero .crumbs a:hover { color: #fff; }
|
||||
.page-hero .crumbs span { color: #fff; }
|
||||
.page-hero .btn { --bg: rgba(255, 255, 255, .06); --fg: #fff; --bd: rgba(255, 255, 255, .28); }
|
||||
.page-hero .btn:hover { --bg: rgba(255, 255, 255, .12); border-color: #fff; }
|
||||
.page-hero .btn-primary { --bg: #fff; --fg: var(--navy-900); --bd: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, .2); }
|
||||
.page-hero .btn-primary:hover { --bg: var(--navy-50); border-color: var(--navy-50); }
|
||||
.hero-facts { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
|
||||
.hero-facts > span {
|
||||
display: flex; flex-direction: column; padding: 8px 14px; border-radius: 12px;
|
||||
background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .12); min-width: 0;
|
||||
}
|
||||
.hero-facts small { font-size: 11.5px; font-weight: 600; color: var(--navy-200); }
|
||||
.hero-facts strong { font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }
|
||||
@media (max-width: 720px) {
|
||||
.page-hero { margin-top: -20px; padding: 22px 0 24px; }
|
||||
.page-hero h1 { font-size: 23px; }
|
||||
}
|
||||
|
||||
/* ---------- Cards & layout ---------- */
|
||||
.card {
|
||||
background: var(--white);
|
||||
border: 1px solid var(--gray-200);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow-sm);
|
||||
padding: 24px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
@media (max-width: 720px) { .card { padding: 18px; } }
|
||||
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
|
||||
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
|
||||
.eyebrow { display: inline-block; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--navy-600); margin-bottom: 6px; }
|
||||
.crumbs { font-size: 13px; color: var(--gray-500); margin-bottom: 10px; font-weight: 600; }
|
||||
.crumbs a { color: var(--gray-500); }
|
||||
.crumbs a:hover { color: var(--navy-700); }
|
||||
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
|
||||
.grid-2.tight { gap: 14px; }
|
||||
.grid-dash { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 20px; align-items: start; }
|
||||
@media (max-width: 860px) { .grid-dash, .grid-2 { grid-template-columns: 1fr; } }
|
||||
.stack { display: flex; flex-direction: column; gap: 18px; }
|
||||
.form-narrow { max-width: 700px; }
|
||||
/* Halaman form diletakkan di tengah */
|
||||
.form-page { max-width: 700px; margin: 0 auto; }
|
||||
.form-page .form-narrow { margin-left: auto; margin-right: auto; }
|
||||
|
||||
/* ---------- Tiles (statistik) ---------- */
|
||||
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
|
||||
.stat { display: flex; flex-direction: column; padding: 18px 20px; margin: 0; }
|
||||
.stat-num { font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
|
||||
.stat-label { font-size: 12.5px; color: var(--gray-500); font-weight: 600; margin-top: 6px; }
|
||||
.stat.dark { background: var(--navy-800); border-color: var(--navy-800); color: #fff; }
|
||||
.stat.dark .stat-label { color: var(--navy-200); }
|
||||
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
|
||||
|
||||
/* ---------- Buttons ---------- */
|
||||
.btn {
|
||||
--bg: var(--white); --fg: var(--navy-900); --bd: var(--gray-300);
|
||||
display: inline-flex; align-items: center; justify-content: center; gap: 8px;
|
||||
font: inherit; font-weight: 700; font-size: 14px;
|
||||
padding: 10px 18px; border-radius: 12px; cursor: pointer;
|
||||
background: var(--bg); color: var(--fg); border: 1px solid var(--bd);
|
||||
transition: transform .08s, background .15s, box-shadow .15s, border-color .15s;
|
||||
white-space: nowrap; text-decoration: none !important;
|
||||
}
|
||||
.btn:hover { border-color: var(--navy-500); color: var(--fg); }
|
||||
.btn:active { transform: translateY(1px); }
|
||||
.btn-primary { --bg: var(--navy-800); --fg: #fff; --bd: var(--navy-800); box-shadow: 0 6px 16px rgba(17, 40, 79, .22); }
|
||||
.btn-primary:hover { --bg: var(--navy-700); border-color: var(--navy-700); }
|
||||
.btn-ghost { --bg: transparent; --bd: transparent; --fg: var(--navy-700); }
|
||||
.btn-ghost:hover { --bg: var(--navy-50); border-color: transparent; }
|
||||
.btn-danger { --bg: var(--danger); --fg: #fff; --bd: var(--danger); }
|
||||
.btn-danger:hover { --bg: #a52a20; border-color: #a52a20; }
|
||||
.btn-danger-ghost { --bg: var(--white); --fg: var(--danger); --bd: #efc1bc; }
|
||||
.btn-danger-ghost:hover { --bg: var(--danger-bg); border-color: var(--danger); }
|
||||
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
|
||||
.btn-block { width: 100%; }
|
||||
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--navy-600); font-weight: 700; cursor: pointer; }
|
||||
.btn-link:hover { text-decoration: underline; }
|
||||
@media (max-width: 720px) { .btn { min-height: 44px; } .btn-sm { min-height: 36px; } }
|
||||
|
||||
/* ---------- Forms ---------- */
|
||||
.field { display: flex; flex-direction: column; gap: 6px; border: 0; padding: 0; margin: 0; min-width: 0; }
|
||||
label, legend { font-size: 13px; font-weight: 700; color: var(--gray-700); padding: 0; }
|
||||
.opt { font-weight: 500; color: var(--gray-500); }
|
||||
input[type=text], input:not([type]), input[type=password], input[type=date], input[type=search], input[type=file],
|
||||
select, textarea {
|
||||
font: inherit; color: var(--ink); width: 100%;
|
||||
padding: 11px 14px; border-radius: 12px;
|
||||
border: 1px solid var(--gray-300); background: var(--white);
|
||||
transition: border-color .15s, box-shadow .15s;
|
||||
}
|
||||
input[type=file] { padding: 9px 12px; background: var(--gray-25); }
|
||||
textarea { resize: vertical; min-height: 84px; }
|
||||
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--navy-500); box-shadow: var(--focus); }
|
||||
[aria-invalid=true] { border-color: var(--danger); }
|
||||
.hint { font-size: 12px; color: var(--gray-500); }
|
||||
.err { font-size: 13px; font-weight: 600; color: var(--danger); }
|
||||
.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; font-weight: 500; color: var(--ink); cursor: pointer; }
|
||||
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--navy-700); flex: none; }
|
||||
.check-list { display: grid; gap: 10px; max-height: 260px; overflow-y: auto; padding: 12px 14px; border: 1px solid var(--gray-200); border-radius: 12px; background: var(--gray-25); }
|
||||
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }
|
||||
.radio-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
|
||||
@media (max-width: 600px) { .radio-cards { grid-template-columns: 1fr; } }
|
||||
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 14px; border: 2px solid var(--gray-200); border-radius: 14px; cursor: pointer; font-weight: 500; background: #fff; transition: .12s; }
|
||||
.radio-card:hover { border-color: var(--navy-500); background: var(--navy-50); }
|
||||
.radio-card span { display: flex; flex-direction: column; color: var(--ink); }
|
||||
.radio-card:has(input:checked) { border-color: var(--navy-800); background: var(--navy-50); }
|
||||
.radio-card input { margin-top: 3px; accent-color: var(--navy-800); }
|
||||
|
||||
.filters { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; padding: 18px 20px; }
|
||||
.filters .field { min-width: 160px; }
|
||||
.filters .grow { flex: 1; min-width: 200px; }
|
||||
.filter-actions { display: flex; gap: 8px; }
|
||||
|
||||
/* ---------- Notice & chip ---------- */
|
||||
.alert {
|
||||
padding: 14px 16px; border-radius: 12px; font-size: 14px; margin-bottom: 18px;
|
||||
background: var(--gray-50); border: 1px solid var(--gray-200); color: var(--gray-700);
|
||||
}
|
||||
.alert-success { background: var(--ok-bg); border-color: #bfe3d0; color: #0f5d41; }
|
||||
.alert-error { background: var(--danger-bg); border-color: #f2c3be; color: #8d2219; }
|
||||
.alert-info { background: var(--info-bg); border-color: #c9d7ee; color: var(--navy-800); }
|
||||
|
||||
.badge {
|
||||
display: inline-flex; align-items: center; gap: 6px;
|
||||
font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
|
||||
background: var(--gray-100); color: var(--gray-600); white-space: nowrap;
|
||||
}
|
||||
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
|
||||
.role-admin { background: var(--navy-800); color: #fff; }
|
||||
.role-dosen { background: var(--info-bg); color: var(--info); }
|
||||
.role-ketua { background: var(--warn-bg); color: var(--warn); }
|
||||
.badge-ok { background: var(--ok-bg); color: var(--ok); }
|
||||
.badge-off { background: var(--gray-100); color: var(--gray-500); }
|
||||
|
||||
/* ---------- Daftar kegiatan ---------- */
|
||||
.keg-list, .log-list, .comments { list-style: none; margin: 0; padding: 0; }
|
||||
.keg-list { display: grid; gap: 10px; }
|
||||
.keg-item {
|
||||
display: flex; align-items: center; justify-content: space-between; gap: 12px;
|
||||
padding: 14px 16px; border-radius: 12px; background: var(--gray-25); border: 1px solid var(--gray-100);
|
||||
}
|
||||
.keg-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
|
||||
.keg-name { font-weight: 700; color: var(--ink); }
|
||||
.keg-name:hover { color: var(--navy-600); }
|
||||
|
||||
/* ---------- Daftar log ---------- */
|
||||
.log-list li + li { border-top: 1px solid var(--gray-100); }
|
||||
.log-item { display: flex; gap: 14px; padding: 14px 0; color: inherit; align-items: center; }
|
||||
.log-item:hover { text-decoration: none; }
|
||||
.log-list li:first-child .log-item { padding-top: 0; }
|
||||
.log-list li:last-child .log-item { padding-bottom: 0; }
|
||||
.log-item:hover .log-title { color: var(--navy-600); }
|
||||
.log-thumb { width: 64px; height: 64px; flex: none; border-radius: 12px; object-fit: cover; border: 1px solid var(--gray-200); }
|
||||
.log-thumb-empty { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--navy-700); background: var(--navy-50); border-color: var(--navy-100); }
|
||||
.log-body { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
|
||||
.log-meta { font-size: 12.5px; color: var(--gray-500); font-weight: 600; display: flex; gap: 4px; flex-wrap: wrap; }
|
||||
.log-title { font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
|
||||
.log-stats { font-size: 12.5px; color: var(--gray-500); display: flex; gap: 12px; font-weight: 600; }
|
||||
.has-comments { color: var(--info); }
|
||||
|
||||
/* ---------- Detail log ---------- */
|
||||
.prose { white-space: pre-wrap; overflow-wrap: anywhere; max-width: 72ch; color: var(--gray-700); }
|
||||
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-top: 22px; }
|
||||
.gallery a { display: block; border-radius: 12px; overflow: hidden; border: 1px solid var(--gray-200); transition: box-shadow .15s, border-color .15s; }
|
||||
.gallery a:hover { border-color: var(--navy-500); box-shadow: var(--shadow); }
|
||||
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
|
||||
.img-preview, .img-edit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
|
||||
.img-preview img, .img-edit img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; border: 1px solid var(--gray-200); display: block; }
|
||||
.img-edit { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 13px; }
|
||||
.img-edit span { display: flex; align-items: center; gap: 6px; }
|
||||
.img-edit input { accent-color: var(--danger); }
|
||||
.img-edit:has(input:checked) img { opacity: .35; border-color: var(--danger); }
|
||||
|
||||
.comments { display: grid; gap: 12px; margin-bottom: 20px; }
|
||||
.comment { padding: 14px 16px; border-radius: 12px; background: var(--gray-25); border: 1px solid var(--gray-100); }
|
||||
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
|
||||
.comment-del { margin: 0 0 0 auto; }
|
||||
.comment-del .btn-link { color: var(--gray-500); font-weight: 600; }
|
||||
.comment-del .btn-link:hover { color: var(--danger); }
|
||||
|
||||
/* ---------- Konfirmasi hapus ---------- */
|
||||
.danger-zone { position: relative; }
|
||||
.danger-zone summary { list-style: none; }
|
||||
.danger-zone summary::-webkit-details-marker { display: none; }
|
||||
.danger-pop { margin-top: 8px; padding: 14px 16px; border: 1px solid #f2c3be; border-radius: 12px; background: var(--danger-bg); color: #8d2219; max-width: 360px; font-size: 14px; }
|
||||
.danger-pop p { margin-bottom: 10px; }
|
||||
.danger-card { border-color: #f2c3be; }
|
||||
.danger-card h2 { color: var(--danger); }
|
||||
|
||||
/* ---------- Tabel ---------- */
|
||||
.table-wrap { overflow-x: auto; padding: 0; }
|
||||
.table-wrap > p, .table-wrap > .empty-inline { padding: 24px; }
|
||||
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
||||
.table th {
|
||||
text-align: left; font-size: 12px; font-weight: 700; color: var(--gray-500);
|
||||
text-transform: uppercase; letter-spacing: .06em; padding: 12px 16px;
|
||||
background: var(--gray-25); border-bottom: 1px solid var(--gray-200); white-space: nowrap;
|
||||
}
|
||||
.table td { padding: 14px 16px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
|
||||
.table td a { color: var(--ink); }
|
||||
.table td a:hover { color: var(--navy-600); }
|
||||
.table tr:last-child td { border-bottom: 0; }
|
||||
.row-actions { text-align: right; white-space: nowrap; }
|
||||
.row-off td { color: var(--gray-400); }
|
||||
@media (max-width: 720px) {
|
||||
.table thead { display: none; }
|
||||
.table, .table tbody, .table tr, .table td { display: block; width: 100%; }
|
||||
.table tr { padding: 14px 16px; border-bottom: 1px solid var(--gray-100); }
|
||||
.table tr:last-child { border-bottom: 0; }
|
||||
.table td { border: 0; padding: 2px 0; }
|
||||
.table td[data-label]::before { content: attr(data-label) ": "; color: var(--gray-500); font-size: 12px; font-weight: 600; }
|
||||
.row-actions { text-align: left; padding-top: 10px !important; }
|
||||
}
|
||||
|
||||
/* ---------- Lain-lain ---------- */
|
||||
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 10px 16px; margin: 0 0 14px; font-size: 14px; }
|
||||
.dl dt { color: var(--gray-500); }
|
||||
.dl dd { margin: 0; font-weight: 600; }
|
||||
.empty { text-align: center; padding: 56px 24px; }
|
||||
.empty p { color: var(--gray-500); margin-bottom: 18px; }
|
||||
.empty-inline { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; color: var(--gray-500); font-size: 14px; }
|
||||
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--gray-100); }
|
||||
|
||||
/* ---------- Login ---------- */
|
||||
.login { min-height: calc(100vh - 96px); display: grid; place-items: center; }
|
||||
.auth { display: grid; grid-template-columns: 1fr 1fr; overflow: hidden; padding: 0; width: 100%; max-width: 900px; margin: 0; }
|
||||
.auth-side {
|
||||
background: linear-gradient(165deg, var(--navy-800), var(--navy-950)); color: #fff;
|
||||
padding: 40px; display: flex; flex-direction: column;
|
||||
}
|
||||
.auth-side .eyebrow { color: var(--navy-200); margin: 0; }
|
||||
.auth-brand { display: flex; align-items: center; gap: 12px; }
|
||||
.auth-brand img { width: 48px; height: 48px; border-radius: 12px; background: #fff; padding: 3px; object-fit: contain; }
|
||||
.auth-side h1 { font-size: 30px; font-weight: 800; margin: 8px 0 12px; }
|
||||
.auth-side p { color: #c7d3e8; }
|
||||
.auth-list { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
|
||||
.auth-list li { display: flex; gap: 12px; align-items: flex-start; font-size: 14px; color: #dbe4f3; }
|
||||
.auth-list li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #ffb547; margin-top: 7px; flex: none; }
|
||||
.auth-form { padding: 40px; }
|
||||
.auth-form h2 { font-size: 22px; font-weight: 800; margin-bottom: 4px; }
|
||||
@media (max-width: 760px) {
|
||||
.auth { grid-template-columns: 1fr; }
|
||||
.auth-side, .auth-form { padding: 28px 22px; }
|
||||
.auth-list { display: none; }
|
||||
}
|
||||
|
||||
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
|
||||
svg.ic { width: 13px; height: 13px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
|
||||
.badge-danger { background: var(--danger-bg); color: var(--danger); }
|
||||
.badge-warn { background: var(--warn-bg); color: var(--warn); }
|
||||
.badge-info { background: var(--info-bg); color: var(--info); }
|
||||
|
||||
/* =========================================================
|
||||
DASBOR OPERATOR
|
||||
========================================================= */
|
||||
.admin-dash { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
|
||||
@media (max-width: 960px) { .admin-dash { grid-template-columns: 1fr; } }
|
||||
.panel-main { padding: 24px; min-height: 420px; }
|
||||
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
|
||||
.panel-head h2 { margin: 0; font-size: 18px; font-weight: 800; }
|
||||
|
||||
.keg-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
|
||||
.keg-card {
|
||||
display: flex; flex-direction: column; gap: 12px; color: var(--ink);
|
||||
background: #fff; border: 1px solid var(--gray-200); border-radius: 16px; padding: 20px;
|
||||
box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s;
|
||||
}
|
||||
.keg-card:hover { text-decoration: none; border-color: var(--navy-500); box-shadow: var(--shadow); transform: translateY(-1px); }
|
||||
.keg-card-top { display: flex; gap: 6px; flex-wrap: wrap; }
|
||||
.keg-card-title { font-size: 17px; font-weight: 800; letter-spacing: -.015em; }
|
||||
.keg-card:hover .keg-card-title { color: var(--navy-600); }
|
||||
.keg-card-dl { display: grid; grid-template-columns: 64px 1fr; gap: 4px 10px; margin: 0; font-size: 13px; }
|
||||
.keg-card-dl dt { color: var(--gray-500); font-weight: 600; }
|
||||
.keg-card-dl dd { margin: 0; color: var(--gray-700); overflow-wrap: anywhere; }
|
||||
.keg-progress-label { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--gray-600); font-weight: 600; }
|
||||
.progress { height: 6px; border-radius: 99px; background: var(--gray-100); overflow: hidden; margin-top: 6px; }
|
||||
.progress i { display: block; height: 100%; background: var(--navy-700); border-radius: 99px; }
|
||||
.keg-card-foot { margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--gray-200); display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
.keg-card-cta { font-size: 13px; font-weight: 700; color: var(--navy-700); transition: transform .15s; }
|
||||
.keg-card:hover .keg-card-cta { color: var(--navy-600); transform: translateX(2px); }
|
||||
|
||||
.panel-side { padding: 18px; position: sticky; top: 86px; }
|
||||
.panel-side h2 { font-size: 14px; margin-bottom: 10px; }
|
||||
.mini-logs { list-style: none; margin: 0; padding: 0; max-height: 70vh; overflow-y: auto; }
|
||||
.mini-logs li + li { border-top: 1px solid var(--gray-100); }
|
||||
.mini-logs a { display: flex; flex-direction: column; gap: 1px; padding: 9px 4px; border-radius: 8px; color: var(--ink); }
|
||||
.mini-logs a:hover { text-decoration: none; background: var(--gray-25); }
|
||||
.mini-meta { font-size: 11.5px; color: var(--gray-500); font-weight: 600; }
|
||||
.mini-title { font-size: 13px; font-weight: 700; line-height: 1.35; overflow-wrap: anywhere; }
|
||||
.mini-keg { font-size: 12px; color: var(--navy-600); font-weight: 600; }
|
||||
@media (max-width: 960px) { .panel-side { position: static; } }
|
||||
|
||||
/* =========================================================
|
||||
KALENDER KEGIATAN
|
||||
========================================================= */
|
||||
.cal-card { padding: 20px; }
|
||||
.cal-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
|
||||
.cal-nav { display: flex; align-items: center; gap: 8px; }
|
||||
.cal-nav .btn-sm { min-width: 36px; font-size: 16px; }
|
||||
.cal-title { margin: 0 6px; font-size: 20px; font-weight: 800; min-width: 160px; text-align: center; }
|
||||
.cal-summary { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
|
||||
|
||||
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
|
||||
.cal-dow { font-size: 12px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .06em; text-align: center; padding: 4px 0; }
|
||||
.cal-day {
|
||||
position: relative; display: flex; flex-direction: column; gap: 4px;
|
||||
min-height: 96px; padding: 10px; border-radius: 12px; border: 1px solid var(--gray-200);
|
||||
background: #fff; color: var(--ink); font-size: 12px;
|
||||
}
|
||||
a.cal-day { cursor: pointer; transition: transform .1s, box-shadow .15s, border-color .15s; }
|
||||
a.cal-day:hover { text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--navy-500); }
|
||||
.cal-num { font-size: 15px; font-weight: 800; line-height: 1; }
|
||||
.cal-info { font-weight: 700; }
|
||||
.cal-meta { display: flex; gap: 8px; margin-top: auto; color: inherit; opacity: .85; font-weight: 600; }
|
||||
.cal-meta span { display: inline-flex; align-items: center; gap: 3px; }
|
||||
|
||||
.st-filled { background: var(--ok-bg); border-color: #bfe3d0; color: #0f5d41; }
|
||||
.st-missing { background: var(--danger-bg); border-color: #f2c3be; color: #8d2219; }
|
||||
.st-today { background: var(--warn-bg); border-color: #f2d7a6; color: #7a4a00; }
|
||||
.st-future { background: #fff; color: var(--gray-400); }
|
||||
.st-outside { background: var(--gray-50); border-style: dashed; color: var(--gray-400); }
|
||||
.cal-day.other { opacity: .45; }
|
||||
.cal-day.is-today { box-shadow: 0 0 0 2px var(--navy-800); }
|
||||
.cal-day.is-today .cal-num::after { content: 'Hari ini'; margin-left: 6px; font-size: 10.5px; font-weight: 700; color: var(--navy-800); letter-spacing: .02em; }
|
||||
.cal-day.is-today.st-today .cal-info { display: none; }
|
||||
|
||||
.cal-legend { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 16px; font-size: 12.5px; color: var(--gray-600); font-weight: 600; }
|
||||
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
|
||||
.lg { display: inline-block; width: 14px; height: 14px; border-radius: 4px; border: 1px solid var(--gray-300); }
|
||||
.lg-filled { background: var(--ok-bg); border-color: #8fcfae; }
|
||||
.lg-missing { background: var(--danger-bg); border-color: #eaa9a2; }
|
||||
.lg-today { background: var(--warn-bg); border-color: #f0c98a; }
|
||||
.lg-future { background: #fff; }
|
||||
|
||||
@media (max-width: 720px) {
|
||||
.cal { gap: 4px; }
|
||||
.cal-day { min-height: 54px; padding: 6px; border-radius: 8px; align-items: center; }
|
||||
.cal-info, .cal-meta, .cal-day.is-today .cal-num::after { display: none; }
|
||||
.cal-num { font-size: 14px; }
|
||||
.cal-title { font-size: 17px; min-width: 0; }
|
||||
}
|
||||
|
||||
/* ---------- Popup laporan harian ---------- */
|
||||
.day-dialog {
|
||||
width: min(720px, calc(100vw - 32px)); max-height: 90vh; padding: 0;
|
||||
border: 0; border-radius: 20px; background: var(--gray-50); color: var(--ink);
|
||||
box-shadow: var(--shadow-lg); overflow: hidden;
|
||||
}
|
||||
.day-dialog[open] { display: flex; flex-direction: column; animation: rise .18s ease-out; }
|
||||
.day-dialog::backdrop { background: rgba(7, 19, 42, .6); backdrop-filter: blur(3px); }
|
||||
@keyframes rise { from { transform: translateY(10px); opacity: 0; } }
|
||||
.dlg-close {
|
||||
position: absolute; top: 18px; right: 18px; z-index: 2;
|
||||
width: 36px; height: 36px; border-radius: 10px; cursor: pointer;
|
||||
background: #fff; color: var(--navy-800); border: 1px solid var(--gray-200);
|
||||
box-shadow: 0 4px 12px rgba(7, 19, 42, .25);
|
||||
font-size: 14px; font-weight: 700; display: grid; place-items: center;
|
||||
}
|
||||
.dlg-close:hover { background: var(--navy-50); border-color: var(--navy-500); }
|
||||
.dlg-body { overflow-y: auto; min-height: 160px; }
|
||||
.dlg-loading { padding: 64px 24px; text-align: center; }
|
||||
|
||||
/* Kepala popup: pita biru dongker */
|
||||
.day-head {
|
||||
position: relative; overflow: hidden;
|
||||
background: linear-gradient(160deg, var(--navy-800), var(--navy-950)); color: #fff;
|
||||
padding: 24px 72px 22px 24px;
|
||||
}
|
||||
.day-head::after {
|
||||
content: ''; position: absolute; right: -50px; top: -60px; width: 200px; height: 200px;
|
||||
border-radius: 50%; border: 30px solid rgba(255, 255, 255, .05); pointer-events: none;
|
||||
}
|
||||
.day-head-keg { display: block; font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--navy-200); }
|
||||
.day-head h2 { font-size: 22px; font-weight: 800; margin: 6px 0 12px; color: #fff; }
|
||||
.day-head-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: #c7d3e8; }
|
||||
.day-body { padding: 20px 24px 24px; }
|
||||
.day-empty { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 20px; border-radius: 14px; background: #fff; border: 1px dashed var(--gray-300); color: var(--gray-600); }
|
||||
|
||||
/* Nomor laporan */
|
||||
.day-num {
|
||||
width: 28px; height: 28px; border-radius: 9px; flex: none;
|
||||
display: grid; place-items: center; font-size: 13px; font-weight: 800;
|
||||
background: var(--navy-800); color: #fff;
|
||||
}
|
||||
|
||||
/* Daftar lompat */
|
||||
.day-index { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 18px; }
|
||||
.day-index a {
|
||||
display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 12px;
|
||||
background: #fff; border: 1px solid var(--gray-200); color: var(--ink);
|
||||
transition: border-color .15s;
|
||||
}
|
||||
.day-index a:hover { text-decoration: none; border-color: var(--navy-500); }
|
||||
.day-index-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
|
||||
.day-index-time { font-size: 11.5px; font-weight: 600; color: var(--gray-500); font-variant-numeric: tabular-nums; }
|
||||
.day-index-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
|
||||
|
||||
/* Kartu laporan */
|
||||
.day-log {
|
||||
scroll-margin-top: 16px; background: #fff; border: 1px solid var(--gray-200);
|
||||
border-radius: 14px; overflow: hidden;
|
||||
}
|
||||
.day-log + .day-log { margin-top: 16px; }
|
||||
.day-log:target { box-shadow: 0 0 0 3px rgba(58, 99, 168, .35); }
|
||||
.day-log-head {
|
||||
display: flex; align-items: center; gap: 12px; padding: 14px 16px;
|
||||
background: var(--navy-50); border-bottom: 1px solid var(--navy-100); color: var(--ink);
|
||||
transition: background .15s;
|
||||
}
|
||||
.day-log-head:hover { text-decoration: none; background: var(--navy-100); }
|
||||
.day-log-titles { display: flex; flex-direction: column; min-width: 0; flex: 1; }
|
||||
.day-log-time { font-size: 12px; font-weight: 600; color: var(--navy-600); }
|
||||
.day-log-title { font-size: 16px; font-weight: 800; letter-spacing: -.01em; overflow-wrap: anywhere; }
|
||||
.day-log-head:hover .day-log-title { text-decoration: underline; text-decoration-color: var(--navy-200); text-underline-offset: 3px; }
|
||||
.day-log-open { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 700; color: var(--navy-700); white-space: nowrap; }
|
||||
.day-log-open .ic { width: 15px; height: 15px; transition: transform .15s; }
|
||||
.day-log-head:hover .day-log-open .ic { transform: translateX(3px); }
|
||||
|
||||
.day-log-body { padding: 16px; }
|
||||
.day-desc { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--gray-700); }
|
||||
.day-desc.clamp {
|
||||
display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
|
||||
}
|
||||
.day-more { display: inline-block; margin-top: 6px; font-size: 13px; font-weight: 700; }
|
||||
|
||||
.day-gallery { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-top: 14px; }
|
||||
.day-gallery a { position: relative; display: block; border-radius: 10px; overflow: hidden; border: 1px solid var(--gray-200); }
|
||||
.day-gallery a:hover { border-color: var(--navy-500); }
|
||||
.day-gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
|
||||
.more-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(7, 19, 42, .6); color: #fff; font-size: 18px; font-weight: 800; }
|
||||
|
||||
.day-stats { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 12.5px; font-weight: 600; color: var(--gray-500); }
|
||||
.day-stats span { display: inline-flex; align-items: center; gap: 5px; }
|
||||
|
||||
.day-comments { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--gray-200); }
|
||||
.day-comments summary { cursor: pointer; font-size: 13px; font-weight: 700; color: var(--navy-700); list-style: none; display: inline-flex; align-items: center; gap: 6px; }
|
||||
.day-comments summary::-webkit-details-marker { display: none; }
|
||||
.day-comments summary::before { content: '▸'; font-size: 11px; transition: transform .15s; }
|
||||
.day-comments[open] summary::before { transform: rotate(90deg); }
|
||||
.day-comments[open] summary { margin-bottom: 10px; }
|
||||
.day-comments .comments { margin: 0 0 12px; gap: 8px; }
|
||||
.day-comments .day-more { margin: 0 0 10px; }
|
||||
.comment-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
|
||||
.comment-form textarea { min-height: 60px; }
|
||||
|
||||
.day-edit { margin-left: auto; font-weight: 700; }
|
||||
|
||||
/* Versi halaman penuh (tanpa JavaScript) */
|
||||
.day-page { padding: 0; overflow: hidden; background: var(--gray-50); }
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.day-dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 20px 20px 0 0; }
|
||||
.day-head { padding: 20px 60px 18px 16px; }
|
||||
.day-head h2 { font-size: 19px; }
|
||||
.day-body { padding: 16px; }
|
||||
.day-log-open { font-size: 0; gap: 0; }
|
||||
.day-log-open .ic { width: 18px; height: 18px; }
|
||||
.day-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
||||
}
|
||||
|
||||
/* =========================================================
|
||||
KOMPONEN TAMBAHAN
|
||||
========================================================= */
|
||||
.mt { margin-top: 24px; }
|
||||
.field-label { font-size: 13px; font-weight: 700; color: var(--gray-700); }
|
||||
.cal-hint { margin-top: -4px; }
|
||||
|
||||
/* Tanggal terpilih di form laporan */
|
||||
.date-chip {
|
||||
display: flex; align-items: center; gap: 14px; padding: 14px 16px;
|
||||
border-radius: 14px; background: var(--navy-50); border: 1px solid var(--navy-100);
|
||||
}
|
||||
.date-chip-icon {
|
||||
width: 48px; height: 52px; border-radius: 12px; flex: none; overflow: hidden;
|
||||
display: flex; flex-direction: column; background: #fff; border: 1px solid var(--navy-100);
|
||||
box-shadow: var(--shadow-sm);
|
||||
}
|
||||
.date-chip-icon::before { content: ''; height: 12px; background: var(--navy-800); flex: none; }
|
||||
.date-chip-icon span { flex: 1; display: grid; place-items: center; font-size: 19px; font-weight: 800; color: var(--navy-900); }
|
||||
.date-chip-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
|
||||
.date-chip-text small { font-size: 12px; font-weight: 600; color: var(--navy-600); }
|
||||
.date-chip-text strong { font-size: 16px; font-weight: 800; }
|
||||
|
||||
/* Kotak dokumentasi (gambar + link Drive) */
|
||||
.doc-box { border: 1px solid var(--gray-200); border-radius: 14px; padding: 16px 18px 18px; margin: 0; background: var(--gray-25); min-width: 0; }
|
||||
.doc-box legend { padding: 0 6px; font-size: 14px; font-weight: 800; color: var(--ink); }
|
||||
.doc-box > .field + .field, .doc-box > .field + .doc-or, .doc-box > .doc-or + .field { margin-top: 14px; }
|
||||
.doc-or { display: flex; align-items: center; gap: 12px; font-size: 12px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .08em; }
|
||||
.doc-or::before, .doc-or::after { content: ''; flex: 1; height: 1px; background: var(--gray-200); }
|
||||
input[type=url] {
|
||||
font: inherit; color: var(--ink); width: 100%; padding: 11px 14px; border-radius: 12px;
|
||||
border: 1px solid var(--gray-300); background: var(--white); transition: border-color .15s, box-shadow .15s;
|
||||
}
|
||||
.size-warn { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); border: 1px solid #f2d7a6; color: #7a4a00; font-size: 13px; font-weight: 600; }
|
||||
.pulse-field { border-color: var(--warn) !important; box-shadow: 0 0 0 4px rgba(169, 100, 0, .15) !important; }
|
||||
|
||||
/* Link Google Drive */
|
||||
.drive-link {
|
||||
display: inline-flex; align-items: center; gap: 8px; margin-top: 14px;
|
||||
padding: 9px 14px; border-radius: 12px; font-size: 13.5px; font-weight: 700;
|
||||
background: var(--info-bg); color: var(--navy-800); border: 1px solid #c9d7ee;
|
||||
}
|
||||
.drive-link .ic { width: 16px; height: 16px; }
|
||||
.drive-link:hover { text-decoration: none; border-color: var(--navy-500); }
|
||||
|
||||
/* Tambah laporan dari popup */
|
||||
.day-add {
|
||||
display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap;
|
||||
padding: 12px 14px; margin-bottom: 16px; border-radius: 12px;
|
||||
background: #fff; border: 1px dashed var(--navy-200); font-size: 13.5px; font-weight: 600; color: var(--gray-600);
|
||||
}
|
||||
|
||||
/* Halaman detail laporan */
|
||||
.log-layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; align-items: start; }
|
||||
@media (max-width: 960px) { .log-layout { grid-template-columns: 1fr; } }
|
||||
.log-delete { margin-top: 24px; padding-top: 16px; border-top: 1px dashed var(--gray-200); }
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
* { transition: none !important; }
|
||||
.day-dialog[open] { animation: none; }
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 36 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
@@ -0,0 +1,37 @@
|
||||
// Mengisi data contoh untuk mencoba aplikasi. Jalankan: npm run seed:demo
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { db, tx, ensureAdmin } = require('../src/db');
|
||||
|
||||
ensureAdmin();
|
||||
|
||||
const hash = bcrypt.hashSync('password123', 10);
|
||||
const addUser = db.prepare(`INSERT OR IGNORE INTO users (username, password_hash, nama, role, nomor_induk) VALUES (?, ?, ?, ?, ?)`);
|
||||
const idOf = (u) => db.prepare('SELECT id FROM users WHERE username = ?').get(u).id;
|
||||
|
||||
tx(() => {
|
||||
addUser.run('dosen1', hash, 'Dr. Rina Pratiwi', 'dosen', '198001012005012001');
|
||||
addUser.run('dosen2', hash, 'Budi Santoso, M.Kom', 'dosen', '198505052010121002');
|
||||
addUser.run('ketua1', hash, 'Andi Saputra', 'ketua', 'D1041201001');
|
||||
addUser.run('ketua2', hash, 'Sari Wulandari', 'ketua', 'D1041201002');
|
||||
|
||||
if (!db.prepare('SELECT 1 FROM kegiatan').get()) {
|
||||
const k1 = Number(db.prepare(`INSERT INTO kegiatan (nama, deskripsi, ketua_id, tanggal_mulai, tanggal_selesai)
|
||||
VALUES (?, ?, ?, ?, ?)`).run('KKN Desa Sungai Ambawang', 'Program digitalisasi data desa.', idOf('ketua1'), '2026-11-01', '2026-12-15').lastInsertRowid);
|
||||
const k2 = Number(db.prepare(`INSERT INTO kegiatan (nama, deskripsi, ketua_id, tanggal_mulai, tanggal_selesai)
|
||||
VALUES (?, ?, ?, ?, ?)`).run('Magang Tim Web Fakultas', null, idOf('ketua2'), '2026-10-15', '2027-01-15').lastInsertRowid);
|
||||
const kd = db.prepare('INSERT INTO kegiatan_dosen (kegiatan_id, dosen_id) VALUES (?, ?)');
|
||||
kd.run(k1, idOf('dosen1'));
|
||||
kd.run(k2, idOf('dosen1'));
|
||||
kd.run(k2, idOf('dosen2'));
|
||||
|
||||
const log = db.prepare('INSERT INTO logs (kegiatan_id, author_id, tanggal, judul, deskripsi) VALUES (?, ?, ?, ?, ?)');
|
||||
const l1 = Number(log.run(k1, idOf('ketua1'), '2026-11-14', 'Survei kantor desa',
|
||||
'Tim bertemu kepala desa dan perangkat desa.\nMendata kebutuhan sistem administrasi kependudukan.').lastInsertRowid);
|
||||
log.run(k1, idOf('ketua1'), '2026-11-15', null, 'Menyusun daftar kebutuhan dan rancangan basis data awal.');
|
||||
db.prepare('INSERT INTO comments (log_id, user_id, isi) VALUES (?, ?, ?)')
|
||||
.run(l1, idOf('dosen1'), 'Bagus. Tolong lampirkan foto dokumentasi rapat pada log berikutnya.');
|
||||
}
|
||||
});
|
||||
|
||||
console.log('Data demo siap. Password semua akun demo: password123');
|
||||
console.log(' dosen1, dosen2 (Dosen) · ketua1, ketua2 (Ketua Tim) · admin (Operator)');
|
||||
@@ -0,0 +1,80 @@
|
||||
const { db } = require('./db');
|
||||
|
||||
function getKegiatan(id) {
|
||||
return db.prepare(`
|
||||
SELECT k.*, u.nama AS ketua_nama, u.nomor_induk AS ketua_nim
|
||||
FROM kegiatan k JOIN users u ON u.id = k.ketua_id
|
||||
WHERE k.id = ?`).get(Number(id));
|
||||
}
|
||||
|
||||
function getDosenKegiatan(kegiatanId) {
|
||||
return db.prepare(`
|
||||
SELECT u.id, u.nama, u.nomor_induk FROM kegiatan_dosen kd
|
||||
JOIN users u ON u.id = kd.dosen_id
|
||||
WHERE kd.kegiatan_id = ? ORDER BY u.nama`).all(kegiatanId);
|
||||
}
|
||||
|
||||
// Operator: semua. Ketua: kegiatan yang dipimpin. Dosen: kegiatan yang ditugaskan.
|
||||
function canView(user, k) {
|
||||
if (!user || !k) return false;
|
||||
if (user.role === 'admin') return true;
|
||||
if (user.role === 'ketua') return k.ketua_id === user.id;
|
||||
if (user.role === 'dosen') {
|
||||
return !!db.prepare('SELECT 1 FROM kegiatan_dosen WHERE kegiatan_id = ? AND dosen_id = ?').get(k.id, user.id);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Hanya ketua tim dari kegiatan tersebut yang boleh menulis laporan.
|
||||
function canReport(user, k) {
|
||||
return !!user && !!k && user.role === 'ketua' && k.ketua_id === user.id;
|
||||
}
|
||||
|
||||
function canEditLog(user, k) {
|
||||
return !!user && (user.role === 'admin' || canReport(user, k));
|
||||
}
|
||||
|
||||
const LOG_SELECT = `
|
||||
SELECT l.*, k.nama AS kegiatan_nama, u.nama AS author_nama,
|
||||
(SELECT COUNT(*) FROM comments c WHERE c.log_id = l.id) AS jml_komentar,
|
||||
(SELECT COUNT(*) FROM log_images i WHERE i.log_id = l.id) AS jml_gambar,
|
||||
(SELECT i.id FROM log_images i WHERE i.log_id = l.id ORDER BY i.id LIMIT 1) AS thumb_id
|
||||
FROM logs l
|
||||
JOIN kegiatan k ON k.id = l.kegiatan_id
|
||||
JOIN users u ON u.id = l.author_id`;
|
||||
|
||||
// Log yang boleh dilihat user (untuk dashboard).
|
||||
function recentLogsFor(user, limit = 10) {
|
||||
if (user.role === 'admin') {
|
||||
return db.prepare(`${LOG_SELECT} ORDER BY l.tanggal DESC, l.id DESC LIMIT ?`).all(limit);
|
||||
}
|
||||
if (user.role === 'ketua') {
|
||||
return db.prepare(`${LOG_SELECT} WHERE k.ketua_id = ? ORDER BY l.tanggal DESC, l.id DESC LIMIT ?`).all(user.id, limit);
|
||||
}
|
||||
return db.prepare(`${LOG_SELECT}
|
||||
WHERE l.kegiatan_id IN (SELECT kegiatan_id FROM kegiatan_dosen WHERE dosen_id = ?)
|
||||
ORDER BY l.tanggal DESC, l.id DESC LIMIT ?`).all(user.id, limit);
|
||||
}
|
||||
|
||||
const KEGIATAN_SELECT = `
|
||||
SELECT k.*, u.nama AS ketua_nama,
|
||||
(SELECT COUNT(*) FROM logs l WHERE l.kegiatan_id = k.id) AS jml_log,
|
||||
(SELECT MAX(l.tanggal) FROM logs l WHERE l.kegiatan_id = k.id) AS log_terakhir,
|
||||
(SELECT COUNT(DISTINCT l.tanggal) FROM logs l WHERE l.kegiatan_id = k.id
|
||||
AND l.tanggal >= COALESCE(k.tanggal_mulai, substr(k.created_at, 1, 10))
|
||||
AND (k.tanggal_selesai IS NULL OR l.tanggal <= k.tanggal_selesai)) AS hari_terisi,
|
||||
(SELECT GROUP_CONCAT(d.nama, ', ') FROM kegiatan_dosen kd JOIN users d ON d.id = kd.dosen_id
|
||||
WHERE kd.kegiatan_id = k.id) AS dosen_nama
|
||||
FROM kegiatan k JOIN users u ON u.id = k.ketua_id`;
|
||||
|
||||
function kegiatanFor(user) {
|
||||
if (user.role === 'admin') return db.prepare(`${KEGIATAN_SELECT} ORDER BY k.id DESC`).all();
|
||||
if (user.role === 'ketua') return db.prepare(`${KEGIATAN_SELECT} WHERE k.ketua_id = ? ORDER BY k.id DESC`).all(user.id);
|
||||
return db.prepare(`${KEGIATAN_SELECT}
|
||||
WHERE k.id IN (SELECT kegiatan_id FROM kegiatan_dosen WHERE dosen_id = ?) ORDER BY k.id DESC`).all(user.id);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getKegiatan, getDosenKegiatan, canView, canReport, canEditLog,
|
||||
LOG_SELECT, recentLogsFor, kegiatanFor,
|
||||
};
|
||||
@@ -0,0 +1,74 @@
|
||||
// Utilitas kalender bulanan untuk halaman kegiatan.
|
||||
const BULAN = ['Januari', 'Februari', 'Maret', 'April', 'Mei', 'Juni', 'Juli', 'Agustus', 'September', 'Oktober', 'November', 'Desember'];
|
||||
|
||||
function ymd(d) {
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||
}
|
||||
function parse(s) {
|
||||
const [y, m, d] = s.split('-').map(Number);
|
||||
return new Date(y, m - 1, d);
|
||||
}
|
||||
function monthKey(s) { return s.slice(0, 7); }
|
||||
function shiftMonth(key, delta) {
|
||||
const [y, m] = key.split('-').map(Number);
|
||||
const d = new Date(y, m - 1 + delta, 1);
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}`;
|
||||
}
|
||||
function monthLabel(key) {
|
||||
const [y, m] = key.split('-').map(Number);
|
||||
return `${BULAN[m - 1]} ${y}`;
|
||||
}
|
||||
|
||||
// Periode wajib lapor: tanggal mulai (atau tanggal dibuat) s.d. tanggal selesai (bila ada).
|
||||
function period(k) {
|
||||
return { start: k.tanggal_mulai || String(k.created_at).slice(0, 10), end: k.tanggal_selesai || null };
|
||||
}
|
||||
|
||||
function dayStatus(date, hasLog, p, today) {
|
||||
if (hasLog) return 'filled';
|
||||
if (date > today) return 'future';
|
||||
if (date < p.start || (p.end && date > p.end)) return 'outside';
|
||||
return date === today ? 'today' : 'missing';
|
||||
}
|
||||
|
||||
// Bulan yang ditampilkan pertama: bulan ini bila masih dalam periode, selain itu bulan terdekat dari periode.
|
||||
function defaultMonth(k, today) {
|
||||
const p = period(k);
|
||||
if (p.end && today > p.end) return monthKey(p.end);
|
||||
if (today < p.start) return monthKey(p.start);
|
||||
return monthKey(today);
|
||||
}
|
||||
|
||||
// Grid Senin–Minggu untuk satu bulan.
|
||||
function monthGrid(key) {
|
||||
const [y, m] = key.split('-').map(Number);
|
||||
const first = new Date(y, m - 1, 1);
|
||||
const offset = (first.getDay() + 6) % 7; // Senin = 0
|
||||
const start = new Date(y, m - 1, 1 - offset);
|
||||
const last = new Date(y, m, 0);
|
||||
const totalDays = offset + last.getDate();
|
||||
const cells = Math.ceil(totalDays / 7) * 7;
|
||||
const days = [];
|
||||
for (let i = 0; i < cells; i++) {
|
||||
const d = new Date(start.getFullYear(), start.getMonth(), start.getDate() + i);
|
||||
days.push({ date: ymd(d), day: d.getDate(), inMonth: d.getMonth() === m - 1 });
|
||||
}
|
||||
return { days, from: days[0].date, to: days[days.length - 1].date };
|
||||
}
|
||||
|
||||
// Jumlah hari dalam periode yang sudah lewat (termasuk hari ini).
|
||||
function elapsedDays(k, today) {
|
||||
const p = period(k);
|
||||
const end = p.end && p.end < today ? p.end : today;
|
||||
if (end < p.start) return 0;
|
||||
return Math.round((parse(end) - parse(p.start)) / 86400000) + 1;
|
||||
}
|
||||
|
||||
function phase(k, today) {
|
||||
const p = period(k);
|
||||
if (today < p.start) return 'belum';
|
||||
if (p.end && today > p.end) return 'selesai';
|
||||
return 'berjalan';
|
||||
}
|
||||
|
||||
module.exports = { ymd, monthKey, shiftMonth, monthLabel, period, dayStatus, defaultMonth, monthGrid, elapsedDays, phase };
|
||||
@@ -0,0 +1,98 @@
|
||||
const { DatabaseSync } = require('node:sqlite');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
const DATA_DIR = path.join(__dirname, '..', 'data');
|
||||
fs.mkdirSync(DATA_DIR, { recursive: true });
|
||||
|
||||
const db = new DatabaseSync(process.env.DB_PATH || path.join(DATA_DIR, 'logharian.db'));
|
||||
db.exec('PRAGMA foreign_keys = ON; PRAGMA journal_mode = WAL;');
|
||||
|
||||
db.exec(`
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
username TEXT NOT NULL UNIQUE COLLATE NOCASE,
|
||||
password_hash TEXT NOT NULL,
|
||||
nama TEXT NOT NULL,
|
||||
role TEXT NOT NULL CHECK (role IN ('admin','dosen','ketua')),
|
||||
nomor_induk TEXT,
|
||||
aktif INTEGER NOT NULL DEFAULT 1,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS kegiatan (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
nama TEXT NOT NULL,
|
||||
deskripsi TEXT,
|
||||
ketua_id INTEGER NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
|
||||
tanggal_mulai TEXT,
|
||||
tanggal_selesai TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS kegiatan_dosen (
|
||||
kegiatan_id INTEGER NOT NULL REFERENCES kegiatan(id) ON DELETE CASCADE,
|
||||
dosen_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
PRIMARY KEY (kegiatan_id, dosen_id)
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS logs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
kegiatan_id INTEGER NOT NULL REFERENCES kegiatan(id) ON DELETE CASCADE,
|
||||
author_id INTEGER NOT NULL REFERENCES users(id) ON DELETE RESTRICT,
|
||||
tanggal TEXT NOT NULL,
|
||||
judul TEXT,
|
||||
deskripsi TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime')),
|
||||
updated_at TEXT
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_logs_kegiatan ON logs (kegiatan_id, tanggal DESC);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS log_images (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
log_id INTEGER NOT NULL REFERENCES logs(id) ON DELETE CASCADE,
|
||||
filename TEXT NOT NULL,
|
||||
original_name TEXT,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime'))
|
||||
);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS comments (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
log_id INTEGER NOT NULL REFERENCES logs(id) ON DELETE CASCADE,
|
||||
user_id INTEGER NOT NULL REFERENCES users(id) ON DELETE CASCADE,
|
||||
isi TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now','localtime'))
|
||||
);
|
||||
CREATE INDEX IF NOT EXISTS idx_comments_log ON comments (log_id);
|
||||
`);
|
||||
|
||||
// Migrasi kecil: kolom link dokumentasi (Google Drive) pada log.
|
||||
if (!db.prepare('PRAGMA table_info(logs)').all().some((c) => c.name === 'link_dokumentasi')) {
|
||||
db.exec('ALTER TABLE logs ADD COLUMN link_dokumentasi TEXT');
|
||||
}
|
||||
|
||||
function tx(fn) {
|
||||
db.exec('BEGIN');
|
||||
try {
|
||||
const result = fn();
|
||||
db.exec('COMMIT');
|
||||
return result;
|
||||
} catch (err) {
|
||||
db.exec('ROLLBACK');
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
// Akun operator awal bila belum ada satu pun admin.
|
||||
function ensureAdmin() {
|
||||
const exists = db.prepare("SELECT 1 FROM users WHERE role = 'admin' LIMIT 1").get();
|
||||
if (exists) return;
|
||||
const password = process.env.ADMIN_PASSWORD || 'admin123';
|
||||
db.prepare('INSERT INTO users (username, password_hash, nama, role) VALUES (?, ?, ?, ?)')
|
||||
.run('admin', bcrypt.hashSync(password, 10), 'Operator', 'admin');
|
||||
console.log('[logharian] Akun operator dibuat -> username: admin, password: ' + password);
|
||||
console.log('[logharian] Segera ganti password lewat menu Akun.');
|
||||
}
|
||||
|
||||
module.exports = { db, tx, ensureAdmin, DATA_DIR };
|
||||
@@ -0,0 +1,140 @@
|
||||
const crypto = require('crypto');
|
||||
const { db } = require('./db');
|
||||
const { removeFiles } = require('./upload');
|
||||
|
||||
const ROLE_LABEL = { admin: 'Operator', dosen: 'Dosen', ketua: 'Ketua Tim' };
|
||||
|
||||
// Versi aset = waktu ubah terakhir style.css, agar browser memuat CSS baru setiap kali file berubah.
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const CSS_FILE = path.join(__dirname, '..', 'public', 'css', 'style.css');
|
||||
function assetVersion() {
|
||||
try { return Math.floor(fs.statSync(CSS_FILE).mtimeMs).toString(36); } catch { return '1'; }
|
||||
}
|
||||
|
||||
function flash(req, res, next) {
|
||||
req.flash = (type, msg) => {
|
||||
req.session.flash = req.session.flash || [];
|
||||
req.session.flash.push({ type, msg });
|
||||
};
|
||||
res.locals.flashes = (req.session && req.session.flash) || [];
|
||||
if (req.session) delete req.session.flash;
|
||||
next();
|
||||
}
|
||||
|
||||
// Memuat ulang data user di setiap request agar penonaktifan akun langsung berlaku.
|
||||
function loadUser(req, res, next) {
|
||||
res.locals.currentUser = null;
|
||||
if (req.session.userId) {
|
||||
const user = db.prepare('SELECT id, username, nama, role, nomor_induk, aktif FROM users WHERE id = ?')
|
||||
.get(req.session.userId);
|
||||
if (user && user.aktif) {
|
||||
req.user = user;
|
||||
res.locals.currentUser = user;
|
||||
} else {
|
||||
delete req.session.userId;
|
||||
}
|
||||
}
|
||||
next();
|
||||
}
|
||||
|
||||
function locals(req, res, next) {
|
||||
res.locals.path = req.path;
|
||||
res.locals.assetVersion = assetVersion();
|
||||
res.locals.roleLabel = (r) => ROLE_LABEL[r] || r;
|
||||
res.locals.fmtDate = fmtDate;
|
||||
res.locals.fmtDateShort = fmtDateShort;
|
||||
res.locals.fmtDateTime = fmtDateTime;
|
||||
res.locals.today = today();
|
||||
next();
|
||||
}
|
||||
|
||||
function requireLogin(req, res, next) {
|
||||
if (!req.user) return res.redirect('/login');
|
||||
next();
|
||||
}
|
||||
|
||||
function requireRole(...roles) {
|
||||
return (req, res, next) => {
|
||||
if (!req.user) return res.redirect('/login');
|
||||
if (!roles.includes(req.user.role)) return forbidden(res);
|
||||
next();
|
||||
};
|
||||
}
|
||||
|
||||
function forbidden(res) {
|
||||
return res.status(403).render('error', { title: 'Akses ditolak', message: 'Anda tidak memiliki akses ke halaman ini.' });
|
||||
}
|
||||
|
||||
function notFound(res) {
|
||||
return res.status(404).render('error', { title: 'Tidak ditemukan', message: 'Halaman atau data yang Anda cari tidak ada.' });
|
||||
}
|
||||
|
||||
// ---- CSRF ----
|
||||
function csrfSetup(req, res, next) {
|
||||
if (!req.session.csrf) req.session.csrf = crypto.randomBytes(24).toString('hex');
|
||||
res.locals.csrfToken = req.session.csrf;
|
||||
next();
|
||||
}
|
||||
|
||||
function tokenValid(req) {
|
||||
const sent = (req.body && req.body._csrf) || '';
|
||||
const expected = req.session.csrf || '';
|
||||
return sent.length === expected.length && sent.length > 0 &&
|
||||
crypto.timingSafeEqual(Buffer.from(sent), Buffer.from(expected));
|
||||
}
|
||||
|
||||
function csrfReject(req, res) {
|
||||
removeFiles(req.files);
|
||||
return res.status(403).render('error', { title: 'Sesi kedaluwarsa', message: 'Formulir sudah kedaluwarsa. Muat ulang halaman lalu coba lagi.' });
|
||||
}
|
||||
|
||||
// Dipakai global untuk form biasa; form multipart diverifikasi setelah multer (csrfVerify).
|
||||
function csrfVerifyNonMultipart(req, res, next) {
|
||||
if (req.method !== 'POST' || req.is('multipart/form-data')) return next();
|
||||
if (!tokenValid(req)) return csrfReject(req, res);
|
||||
next();
|
||||
}
|
||||
|
||||
function csrfVerify(req, res, next) {
|
||||
if (!tokenValid(req)) return csrfReject(req, res);
|
||||
next();
|
||||
}
|
||||
|
||||
// ---- Tanggal ----
|
||||
function today() {
|
||||
const d = new Date();
|
||||
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function parseYmd(s) {
|
||||
const [y, m, d] = String(s).split('-').map(Number);
|
||||
return new Date(y, m - 1, d);
|
||||
}
|
||||
|
||||
function fmtDate(s) {
|
||||
if (!s) return '-';
|
||||
return parseYmd(s).toLocaleDateString('id-ID', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
|
||||
}
|
||||
|
||||
function fmtDateShort(s) {
|
||||
if (!s) return '-';
|
||||
return parseYmd(s).toLocaleDateString('id-ID', { day: 'numeric', month: 'short', year: 'numeric' });
|
||||
}
|
||||
|
||||
function fmtDateTime(s) {
|
||||
if (!s) return '-';
|
||||
const d = new Date(String(s).replace(' ', 'T'));
|
||||
return d.toLocaleString('id-ID', { day: 'numeric', month: 'short', year: 'numeric', hour: '2-digit', minute: '2-digit' });
|
||||
}
|
||||
|
||||
function isValidDate(s) {
|
||||
if (!/^\d{4}-\d{2}-\d{2}$/.test(s || '')) return false;
|
||||
const d = parseYmd(s);
|
||||
return !isNaN(d) && d.getFullYear() === Number(s.slice(0, 4));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
flash, loadUser, locals, requireLogin, requireRole, forbidden, notFound,
|
||||
csrfSetup, csrfVerify, csrfVerifyNonMultipart, today, isValidDate, ROLE_LABEL,
|
||||
};
|
||||
@@ -0,0 +1,231 @@
|
||||
const router = require('express').Router();
|
||||
const bcrypt = require('bcryptjs');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { db, tx } = require('../db');
|
||||
const { requireRole, notFound, isValidDate, ROLE_LABEL } = require('../middleware');
|
||||
const { getDosenKegiatan, kegiatanFor } = require('../access');
|
||||
const { UPLOAD_DIR } = require('../upload');
|
||||
|
||||
router.use(requireRole('admin'));
|
||||
|
||||
/* ================= PENGGUNA ================= */
|
||||
|
||||
router.get('/users', (req, res) => {
|
||||
const role = ROLE_LABEL[req.query.role] ? req.query.role : '';
|
||||
const q = String(req.query.q || '').trim();
|
||||
const where = [];
|
||||
const params = [];
|
||||
if (role) { where.push('role = ?'); params.push(role); }
|
||||
if (q) { where.push('(nama LIKE ? OR username LIKE ? OR nomor_induk LIKE ?)'); params.push(`%${q}%`, `%${q}%`, `%${q}%`); }
|
||||
const users = db.prepare(`
|
||||
SELECT u.*,
|
||||
(SELECT COUNT(*) FROM kegiatan k WHERE k.ketua_id = u.id) AS jml_kegiatan_ketua,
|
||||
(SELECT COUNT(*) FROM kegiatan_dosen kd WHERE kd.dosen_id = u.id) AS jml_kegiatan_dosen
|
||||
FROM users u ${where.length ? 'WHERE ' + where.join(' AND ') : ''}
|
||||
ORDER BY CASE role WHEN 'admin' THEN 0 WHEN 'dosen' THEN 1 ELSE 2 END, nama`).all(...params);
|
||||
res.render('admin/users', { title: 'Pengguna', users, role, q });
|
||||
});
|
||||
|
||||
const emptyUser = { id: null, nama: '', username: '', role: 'ketua', nomor_induk: '', aktif: 1 };
|
||||
|
||||
router.get('/users/baru', (req, res) => {
|
||||
const role = ROLE_LABEL[req.query.role] ? req.query.role : 'ketua';
|
||||
res.render('admin/user-form', { title: 'Tambah pengguna', u: { ...emptyUser, role }, errors: {} });
|
||||
});
|
||||
|
||||
function readUserForm(body, isNew) {
|
||||
const u = {
|
||||
nama: String(body.nama || '').trim(),
|
||||
username: String(body.username || '').trim(),
|
||||
role: String(body.role || ''),
|
||||
nomor_induk: String(body.nomor_induk || '').trim(),
|
||||
aktif: body.aktif ? 1 : 0,
|
||||
password: String(body.password || ''),
|
||||
};
|
||||
const errors = {};
|
||||
if (!u.nama) errors.nama = 'Nama wajib diisi.';
|
||||
if (!/^[a-zA-Z0-9._-]{3,40}$/.test(u.username)) errors.username = 'Username 3–40 karakter: huruf, angka, titik, minus, atau garis bawah.';
|
||||
if (!ROLE_LABEL[u.role]) errors.role = 'Pilih level akun.';
|
||||
if (isNew && u.password.length < 8) errors.password = 'Password minimal 8 karakter.';
|
||||
if (!isNew && u.password && u.password.length < 8) errors.password = 'Password minimal 8 karakter, atau kosongkan bila tidak diganti.';
|
||||
return { u, errors };
|
||||
}
|
||||
|
||||
router.post('/users', (req, res) => {
|
||||
const { u, errors } = readUserForm(req.body, true);
|
||||
if (!errors.username && db.prepare('SELECT 1 FROM users WHERE username = ?').get(u.username)) {
|
||||
errors.username = 'Username sudah dipakai.';
|
||||
}
|
||||
if (Object.keys(errors).length) {
|
||||
return res.status(400).render('admin/user-form', { title: 'Tambah pengguna', u: { ...u, id: null }, errors });
|
||||
}
|
||||
db.prepare('INSERT INTO users (username, password_hash, nama, role, nomor_induk, aktif) VALUES (?, ?, ?, ?, ?, ?)')
|
||||
.run(u.username, bcrypt.hashSync(u.password, 10), u.nama, u.role, u.nomor_induk || null, u.aktif);
|
||||
req.flash('success', `Akun ${u.nama} (${ROLE_LABEL[u.role]}) berhasil ditambahkan.`);
|
||||
res.redirect('/admin/users');
|
||||
});
|
||||
|
||||
router.get('/users/:id/edit', (req, res) => {
|
||||
const u = db.prepare('SELECT * FROM users WHERE id = ?').get(Number(req.params.id));
|
||||
if (!u) return notFound(res);
|
||||
res.render('admin/user-form', { title: 'Ubah pengguna', u, errors: {} });
|
||||
});
|
||||
|
||||
router.post('/users/:id', (req, res) => {
|
||||
const id = Number(req.params.id);
|
||||
const existing = db.prepare('SELECT * FROM users WHERE id = ?').get(id);
|
||||
if (!existing) return notFound(res);
|
||||
|
||||
const { u, errors } = readUserForm(req.body, false);
|
||||
if (!errors.username && db.prepare('SELECT 1 FROM users WHERE username = ? AND id <> ?').get(u.username, id)) {
|
||||
errors.username = 'Username sudah dipakai.';
|
||||
}
|
||||
if (id === req.user.id && (u.role !== 'admin' || !u.aktif)) {
|
||||
errors.role = 'Anda tidak bisa menurunkan level atau menonaktifkan akun Anda sendiri.';
|
||||
}
|
||||
if (existing.role === 'ketua' && u.role !== 'ketua' &&
|
||||
db.prepare('SELECT 1 FROM kegiatan WHERE ketua_id = ?').get(id)) {
|
||||
errors.role = 'Akun ini masih menjadi ketua sebuah kegiatan. Ganti ketua kegiatan tersebut dulu.';
|
||||
}
|
||||
if (Object.keys(errors).length) {
|
||||
return res.status(400).render('admin/user-form', { title: 'Ubah pengguna', u: { ...u, id }, errors });
|
||||
}
|
||||
|
||||
tx(() => {
|
||||
db.prepare('UPDATE users SET username = ?, nama = ?, role = ?, nomor_induk = ?, aktif = ? WHERE id = ?')
|
||||
.run(u.username, u.nama, u.role, u.nomor_induk || null, u.aktif, id);
|
||||
if (u.password) {
|
||||
db.prepare('UPDATE users SET password_hash = ? WHERE id = ?').run(bcrypt.hashSync(u.password, 10), id);
|
||||
}
|
||||
if (existing.role === 'dosen' && u.role !== 'dosen') {
|
||||
db.prepare('DELETE FROM kegiatan_dosen WHERE dosen_id = ?').run(id);
|
||||
}
|
||||
});
|
||||
req.flash('success', `Akun ${u.nama} berhasil diperbarui.`);
|
||||
res.redirect('/admin/users');
|
||||
});
|
||||
|
||||
router.post('/users/:id/hapus', (req, res) => {
|
||||
const id = Number(req.params.id);
|
||||
const u = db.prepare('SELECT * FROM users WHERE id = ?').get(id);
|
||||
if (!u) return notFound(res);
|
||||
if (id === req.user.id) {
|
||||
req.flash('error', 'Anda tidak bisa menghapus akun Anda sendiri.');
|
||||
return res.redirect('/admin/users');
|
||||
}
|
||||
const ketuaOf = db.prepare('SELECT COUNT(*) AS n FROM kegiatan WHERE ketua_id = ?').get(id).n;
|
||||
const logs = db.prepare('SELECT COUNT(*) AS n FROM logs WHERE author_id = ?').get(id).n;
|
||||
if (ketuaOf || logs) {
|
||||
req.flash('error', `${u.nama} masih terkait dengan ${ketuaOf} kegiatan dan ${logs} log. Nonaktifkan akunnya saja agar riwayat laporan tetap utuh.`);
|
||||
return res.redirect('/admin/users');
|
||||
}
|
||||
db.prepare('DELETE FROM users WHERE id = ?').run(id);
|
||||
req.flash('success', `Akun ${u.nama} telah dihapus.`);
|
||||
res.redirect('/admin/users');
|
||||
});
|
||||
|
||||
/* ================= KEGIATAN ================= */
|
||||
|
||||
function formOptions() {
|
||||
return {
|
||||
ketuaList: db.prepare("SELECT id, nama, nomor_induk, aktif FROM users WHERE role = 'ketua' ORDER BY nama").all(),
|
||||
dosenList: db.prepare("SELECT id, nama, nomor_induk, aktif FROM users WHERE role = 'dosen' ORDER BY nama").all(),
|
||||
};
|
||||
}
|
||||
|
||||
router.get('/kegiatan', (req, res) => {
|
||||
res.render('admin/kegiatan', { title: 'Kegiatan', kegiatan: kegiatanFor(req.user) });
|
||||
});
|
||||
|
||||
router.get('/kegiatan/baru', (req, res) => {
|
||||
res.render('admin/kegiatan-form', {
|
||||
title: 'Tambah kegiatan',
|
||||
k: { id: null, nama: '', deskripsi: '', ketua_id: null, tanggal_mulai: '', tanggal_selesai: '' },
|
||||
dosenIds: [], errors: {}, ...formOptions(),
|
||||
});
|
||||
});
|
||||
|
||||
function readKegiatanForm(body) {
|
||||
const k = {
|
||||
nama: String(body.nama || '').trim(),
|
||||
deskripsi: String(body.deskripsi || '').trim(),
|
||||
ketua_id: Number(body.ketua_id) || null,
|
||||
tanggal_mulai: String(body.tanggal_mulai || ''),
|
||||
tanggal_selesai: String(body.tanggal_selesai || ''),
|
||||
};
|
||||
const dosenIds = [].concat(body.dosen_ids || []).map(Number).filter(Boolean);
|
||||
const errors = {};
|
||||
if (!k.nama) errors.nama = 'Nama kegiatan wajib diisi.';
|
||||
if (!k.ketua_id || !db.prepare("SELECT 1 FROM users WHERE id = ? AND role = 'ketua'").get(k.ketua_id)) {
|
||||
errors.ketua_id = 'Pilih ketua tim dari akun berlevel Ketua Tim.';
|
||||
}
|
||||
if (k.tanggal_mulai && !isValidDate(k.tanggal_mulai)) errors.tanggal_mulai = 'Tanggal tidak valid.';
|
||||
if (k.tanggal_selesai && !isValidDate(k.tanggal_selesai)) errors.tanggal_selesai = 'Tanggal tidak valid.';
|
||||
if (k.tanggal_mulai && k.tanggal_selesai && k.tanggal_selesai < k.tanggal_mulai) {
|
||||
errors.tanggal_selesai = 'Tanggal selesai tidak boleh sebelum tanggal mulai.';
|
||||
}
|
||||
return { k, dosenIds, errors };
|
||||
}
|
||||
|
||||
function saveDosen(kegiatanId, dosenIds) {
|
||||
db.prepare('DELETE FROM kegiatan_dosen WHERE kegiatan_id = ?').run(kegiatanId);
|
||||
const ins = db.prepare(`INSERT OR IGNORE INTO kegiatan_dosen (kegiatan_id, dosen_id)
|
||||
SELECT ?, id FROM users WHERE id = ? AND role = 'dosen'`);
|
||||
for (const d of dosenIds) ins.run(kegiatanId, d);
|
||||
}
|
||||
|
||||
router.post('/kegiatan', (req, res) => {
|
||||
const { k, dosenIds, errors } = readKegiatanForm(req.body);
|
||||
if (Object.keys(errors).length) {
|
||||
return res.status(400).render('admin/kegiatan-form', { title: 'Tambah kegiatan', k: { ...k, id: null }, dosenIds, errors, ...formOptions() });
|
||||
}
|
||||
const id = tx(() => {
|
||||
const r = db.prepare('INSERT INTO kegiatan (nama, deskripsi, ketua_id, tanggal_mulai, tanggal_selesai) VALUES (?, ?, ?, ?, ?)')
|
||||
.run(k.nama, k.deskripsi || null, k.ketua_id, k.tanggal_mulai || null, k.tanggal_selesai || null);
|
||||
saveDosen(Number(r.lastInsertRowid), dosenIds);
|
||||
return Number(r.lastInsertRowid);
|
||||
});
|
||||
req.flash('success', `Kegiatan "${k.nama}" berhasil ditambahkan.`);
|
||||
res.redirect('/kegiatan/' + id);
|
||||
});
|
||||
|
||||
router.get('/kegiatan/:id/edit', (req, res) => {
|
||||
const k = db.prepare('SELECT * FROM kegiatan WHERE id = ?').get(Number(req.params.id));
|
||||
if (!k) return notFound(res);
|
||||
const dosenIds = getDosenKegiatan(k.id).map((d) => d.id);
|
||||
res.render('admin/kegiatan-form', { title: 'Ubah kegiatan', k, dosenIds, errors: {}, ...formOptions() });
|
||||
});
|
||||
|
||||
router.post('/kegiatan/:id', (req, res) => {
|
||||
const id = Number(req.params.id);
|
||||
if (!db.prepare('SELECT 1 FROM kegiatan WHERE id = ?').get(id)) return notFound(res);
|
||||
const { k, dosenIds, errors } = readKegiatanForm(req.body);
|
||||
if (Object.keys(errors).length) {
|
||||
return res.status(400).render('admin/kegiatan-form', { title: 'Ubah kegiatan', k: { ...k, id }, dosenIds, errors, ...formOptions() });
|
||||
}
|
||||
tx(() => {
|
||||
db.prepare('UPDATE kegiatan SET nama = ?, deskripsi = ?, ketua_id = ?, tanggal_mulai = ?, tanggal_selesai = ? WHERE id = ?')
|
||||
.run(k.nama, k.deskripsi || null, k.ketua_id, k.tanggal_mulai || null, k.tanggal_selesai || null, id);
|
||||
saveDosen(id, dosenIds);
|
||||
});
|
||||
req.flash('success', `Kegiatan "${k.nama}" berhasil diperbarui.`);
|
||||
res.redirect('/kegiatan/' + id);
|
||||
});
|
||||
|
||||
router.post('/kegiatan/:id/hapus', (req, res) => {
|
||||
const id = Number(req.params.id);
|
||||
const k = db.prepare('SELECT * FROM kegiatan WHERE id = ?').get(id);
|
||||
if (!k) return notFound(res);
|
||||
if (String(req.body.konfirmasi || '').trim() !== k.nama) {
|
||||
req.flash('error', 'Nama kegiatan yang diketik tidak cocok. Kegiatan tidak dihapus.');
|
||||
return res.redirect('/admin/kegiatan/' + id + '/edit');
|
||||
}
|
||||
const files = db.prepare(`SELECT i.filename FROM log_images i JOIN logs l ON l.id = i.log_id WHERE l.kegiatan_id = ?`).all(id);
|
||||
db.prepare('DELETE FROM kegiatan WHERE id = ?').run(id);
|
||||
for (const f of files) fs.unlink(path.join(UPLOAD_DIR, f.filename), () => {});
|
||||
req.flash('success', `Kegiatan "${k.nama}" beserta seluruh lognya telah dihapus.`);
|
||||
res.redirect('/admin/kegiatan');
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,79 @@
|
||||
const router = require('express').Router();
|
||||
const bcrypt = require('bcryptjs');
|
||||
const { db } = require('../db');
|
||||
const { requireLogin } = require('../middleware');
|
||||
|
||||
// Pembatasan percobaan login sederhana per IP+username.
|
||||
const attempts = new Map();
|
||||
const WINDOW = 15 * 60 * 1000;
|
||||
const MAX_ATTEMPTS = 8;
|
||||
|
||||
function tooMany(key) {
|
||||
const a = attempts.get(key);
|
||||
if (!a || Date.now() - a.first > WINDOW) return false;
|
||||
return a.count >= MAX_ATTEMPTS;
|
||||
}
|
||||
function recordFail(key) {
|
||||
const a = attempts.get(key);
|
||||
if (!a || Date.now() - a.first > WINDOW) attempts.set(key, { first: Date.now(), count: 1 });
|
||||
else a.count++;
|
||||
}
|
||||
|
||||
router.get('/login', (req, res) => {
|
||||
if (req.user) return res.redirect('/');
|
||||
res.render('login', { title: 'Masuk', username: '', error: null });
|
||||
});
|
||||
|
||||
router.post('/login', (req, res, next) => {
|
||||
const username = String(req.body.username || '').trim();
|
||||
const password = String(req.body.password || '');
|
||||
const key = req.ip + '|' + username.toLowerCase();
|
||||
|
||||
if (tooMany(key)) {
|
||||
return res.status(429).render('login', { title: 'Masuk', username, error: 'Terlalu banyak percobaan. Coba lagi dalam 15 menit.' });
|
||||
}
|
||||
|
||||
const user = db.prepare('SELECT * FROM users WHERE username = ?').get(username);
|
||||
if (!user || !bcrypt.compareSync(password, user.password_hash)) {
|
||||
recordFail(key);
|
||||
return res.status(401).render('login', { title: 'Masuk', username, error: 'Username atau password tidak cocok.' });
|
||||
}
|
||||
if (!user.aktif) {
|
||||
return res.status(403).render('login', { title: 'Masuk', username, error: 'Akun ini sedang dinonaktifkan. Hubungi operator.' });
|
||||
}
|
||||
|
||||
attempts.delete(key);
|
||||
req.session.regenerate((err) => {
|
||||
if (err) return next(err);
|
||||
req.session.userId = user.id;
|
||||
res.redirect('/');
|
||||
});
|
||||
});
|
||||
|
||||
router.post('/logout', (req, res) => {
|
||||
req.session.destroy(() => {
|
||||
res.clearCookie('logharian.sid');
|
||||
res.redirect('/login');
|
||||
});
|
||||
});
|
||||
|
||||
router.get('/akun', requireLogin, (req, res) => {
|
||||
res.render('akun', { title: 'Akun saya', error: null });
|
||||
});
|
||||
|
||||
router.post('/akun/password', requireLogin, (req, res) => {
|
||||
const { lama = '', baru = '', konfirmasi = '' } = req.body;
|
||||
const row = db.prepare('SELECT password_hash FROM users WHERE id = ?').get(req.user.id);
|
||||
let error = null;
|
||||
if (!bcrypt.compareSync(lama, row.password_hash)) error = 'Password lama tidak cocok.';
|
||||
else if (baru.length < 8) error = 'Password baru minimal 8 karakter.';
|
||||
else if (baru !== konfirmasi) error = 'Konfirmasi password baru tidak sama.';
|
||||
|
||||
if (error) return res.status(400).render('akun', { title: 'Akun saya', error });
|
||||
|
||||
db.prepare('UPDATE users SET password_hash = ? WHERE id = ?').run(bcrypt.hashSync(baru, 10), req.user.id);
|
||||
req.flash('success', 'Password berhasil diganti.');
|
||||
res.redirect('/akun');
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,295 @@
|
||||
const router = require('express').Router();
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const { db, tx } = require('../db');
|
||||
const { requireLogin, forbidden, notFound, csrfVerify, isValidDate, today } = require('../middleware');
|
||||
const {
|
||||
getKegiatan, getDosenKegiatan, canView, canReport, canEditLog,
|
||||
LOG_SELECT, recentLogsFor, kegiatanFor,
|
||||
} = require('../access');
|
||||
const { handleUpload, removeFiles, UPLOAD_DIR, MAX_FILES, MAX_SIZE_MB } = require('../upload');
|
||||
const cal = require('../calendar');
|
||||
|
||||
const MAX_DESC = 5000;
|
||||
|
||||
router.use(requireLogin);
|
||||
|
||||
/* ---------- Dashboard ---------- */
|
||||
router.get('/', (req, res) => {
|
||||
const u = req.user;
|
||||
const data = { title: 'Dashboard', kegiatan: kegiatanFor(u), logs: recentLogsFor(u, 12) };
|
||||
{
|
||||
// Panel kartu kegiatan (sama untuk semua level akun).
|
||||
const t = today();
|
||||
const filledToday = new Set(db.prepare('SELECT DISTINCT kegiatan_id FROM logs WHERE tanggal = ?').all(t).map((r) => r.kegiatan_id));
|
||||
data.kegiatan.forEach((k) => {
|
||||
k.fase = cal.phase(k, t);
|
||||
k.hari_berjalan = cal.elapsedDays(k, t);
|
||||
k.persen = k.hari_berjalan ? Math.min(100, Math.round((k.hari_terisi / k.hari_berjalan) * 100)) : 0;
|
||||
k.sudah_hari_ini = filledToday.has(k.id);
|
||||
});
|
||||
}
|
||||
if (u.role === 'admin') {
|
||||
data.stats = db.prepare(`SELECT
|
||||
(SELECT COUNT(*) FROM users WHERE role = 'dosen') AS dosen,
|
||||
(SELECT COUNT(*) FROM users WHERE role = 'ketua') AS ketua,
|
||||
(SELECT COUNT(*) FROM kegiatan) AS kegiatan,
|
||||
(SELECT COUNT(*) FROM logs WHERE tanggal = ?) AS log_hari_ini`).get(today());
|
||||
}
|
||||
if (u.role !== 'admin') {
|
||||
const aktif = data.kegiatan.filter((k) => k.fase === 'berjalan');
|
||||
data.roleStats = {
|
||||
kegiatan: data.kegiatan.length,
|
||||
berjalan: aktif.length,
|
||||
terisi: aktif.filter((k) => k.sudah_hari_ini).length,
|
||||
belum: aktif.filter((k) => !k.sudah_hari_ini).length,
|
||||
};
|
||||
}
|
||||
res.render('dashboard', data);
|
||||
});
|
||||
|
||||
/* ---------- Middleware pemuat ---------- */
|
||||
function loadKegiatan(req, res, next) {
|
||||
const k = getKegiatan(req.params.id);
|
||||
if (!k) return notFound(res);
|
||||
if (!canView(req.user, k)) return forbidden(res);
|
||||
req.kegiatan = k;
|
||||
next();
|
||||
}
|
||||
|
||||
function loadLog(req, res, next) {
|
||||
const log = db.prepare(`${LOG_SELECT} WHERE l.id = ?`).get(Number(req.params.id));
|
||||
if (!log) return notFound(res);
|
||||
const k = getKegiatan(log.kegiatan_id);
|
||||
if (!canView(req.user, k)) return forbidden(res);
|
||||
req.log = log;
|
||||
req.kegiatan = k;
|
||||
next();
|
||||
}
|
||||
|
||||
/* ---------- Halaman kegiatan (kalender bulanan) ---------- */
|
||||
router.get('/kegiatan/:id', loadKegiatan, (req, res) => {
|
||||
const k = req.kegiatan;
|
||||
const t = today();
|
||||
const bulan = /^\d{4}-(0[1-9]|1[0-2])$/.test(req.query.bulan || '') ? req.query.bulan : cal.defaultMonth(k, t);
|
||||
const grid = cal.monthGrid(bulan);
|
||||
const p = cal.period(k);
|
||||
|
||||
const rows = db.prepare(`
|
||||
SELECT l.tanggal, COUNT(*) AS n,
|
||||
SUM((SELECT COUNT(*) FROM comments c WHERE c.log_id = l.id)) AS kom,
|
||||
SUM((SELECT COUNT(*) FROM log_images i WHERE i.log_id = l.id)) AS img
|
||||
FROM logs l WHERE l.kegiatan_id = ? AND l.tanggal BETWEEN ? AND ?
|
||||
GROUP BY l.tanggal`).all(k.id, grid.from, grid.to);
|
||||
const byDate = Object.fromEntries(rows.map((r) => [r.tanggal, r]));
|
||||
|
||||
const reporter = canReport(req.user, k);
|
||||
const summary = { filled: 0, missing: 0 };
|
||||
const days = grid.days.map((d) => {
|
||||
const info = byDate[d.date];
|
||||
const status = cal.dayStatus(d.date, !!info, p, t);
|
||||
if (d.inMonth && status === 'filled') summary.filled++;
|
||||
if (d.inMonth && (status === 'missing' || status === 'today')) summary.missing++;
|
||||
// Hari yang bisa diklik: ada log, atau hari wajib lapor yang sudah lewat/hari ini.
|
||||
const clickable = status === 'filled' || status === 'missing' || status === 'today';
|
||||
return { ...d, status, isToday: d.date === t, n: info ? info.n : 0, kom: info ? info.kom : 0, img: info ? info.img : 0, clickable };
|
||||
});
|
||||
|
||||
const openDay = isValidDate(req.query.hari) ? req.query.hari : '';
|
||||
|
||||
res.render('kegiatan', {
|
||||
title: k.nama, k, dosen: getDosenKegiatan(k.id), canReport: reporter,
|
||||
bulan, bulanLabel: cal.monthLabel(bulan), prev: cal.shiftMonth(bulan, -1), next: cal.shiftMonth(bulan, 1),
|
||||
thisMonth: cal.monthKey(t), days, summary, period: p, openDay,
|
||||
totalLog: db.prepare('SELECT COUNT(*) AS n FROM logs WHERE kegiatan_id = ?').get(k.id).n,
|
||||
});
|
||||
});
|
||||
|
||||
/* ---------- Laporan satu hari (isi popup kalender) ---------- */
|
||||
router.get('/kegiatan/:id/hari/:tanggal', loadKegiatan, (req, res) => {
|
||||
const k = req.kegiatan;
|
||||
const tanggal = req.params.tanggal;
|
||||
if (!isValidDate(tanggal)) return notFound(res);
|
||||
const t = today();
|
||||
|
||||
const logs = db.prepare(`${LOG_SELECT} WHERE l.kegiatan_id = ? AND l.tanggal = ? ORDER BY l.id`).all(k.id, tanggal);
|
||||
const imgStmt = db.prepare('SELECT id, original_name FROM log_images WHERE log_id = ? ORDER BY id');
|
||||
const comStmt = db.prepare(`SELECT c.*, u.nama, u.role FROM comments c JOIN users u ON u.id = c.user_id
|
||||
WHERE c.log_id = ? ORDER BY c.id`);
|
||||
logs.forEach((l) => { l.images = imgStmt.all(l.id); l.comments = comStmt.all(l.id); });
|
||||
|
||||
const status = cal.dayStatus(tanggal, logs.length > 0, cal.period(k), t);
|
||||
const data = {
|
||||
k, tanggal, logs, status,
|
||||
canReport: canReport(req.user, k) && tanggal <= t,
|
||||
canEdit: canEditLog(req.user, k),
|
||||
kembali: `/kegiatan/${k.id}?bulan=${tanggal.slice(0, 7)}&hari=${tanggal}`,
|
||||
};
|
||||
res.set('Vary', 'X-Requested-With');
|
||||
if (req.get('X-Requested-With') === 'fetch') return res.render('partials/hari-panel', data);
|
||||
res.render('hari', { title: 'Laporan ' + tanggal, ...data });
|
||||
});
|
||||
|
||||
/* ---------- Tulis log baru (khusus ketua tim) ---------- */
|
||||
function requireReporter(req, res, next) {
|
||||
if (!canReport(req.user, req.kegiatan)) return forbidden(res);
|
||||
next();
|
||||
}
|
||||
|
||||
function readLogForm(req) {
|
||||
const v = {
|
||||
tanggal: String(req.body.tanggal || ''),
|
||||
judul: String(req.body.judul || '').trim(),
|
||||
deskripsi: String(req.body.deskripsi || '').trim(),
|
||||
link_dokumentasi: String(req.body.link_dokumentasi || '').trim(),
|
||||
};
|
||||
const errors = {};
|
||||
if (v.link_dokumentasi) {
|
||||
let ok = false;
|
||||
try {
|
||||
const url = new URL(v.link_dokumentasi);
|
||||
ok = url.protocol === 'https:' && ['drive.google.com', 'docs.google.com'].includes(url.hostname);
|
||||
} catch { ok = false; }
|
||||
if (!ok || v.link_dokumentasi.length > 500) {
|
||||
errors.link_dokumentasi = 'Gunakan link Google Drive yang diawali https://drive.google.com/ atau https://docs.google.com/.';
|
||||
}
|
||||
}
|
||||
if (!isValidDate(v.tanggal)) errors.tanggal = 'Pilih tanggal kegiatan.';
|
||||
else if (v.tanggal > today()) errors.tanggal = 'Tanggal log tidak boleh melewati hari ini.';
|
||||
if (!v.deskripsi) errors.deskripsi = 'Deskripsi kegiatan wajib diisi.';
|
||||
else if (v.deskripsi.length > MAX_DESC) errors.deskripsi = `Deskripsi maksimal ${MAX_DESC} karakter.`;
|
||||
if (v.judul.length > 150) errors.judul = 'Judul maksimal 150 karakter.';
|
||||
if (req.uploadError) errors.gambar = req.uploadError;
|
||||
return { v, errors };
|
||||
}
|
||||
|
||||
function formView(req, extra) {
|
||||
return { k: req.kegiatan, MAX_FILES, MAX_SIZE_MB, MAX_DESC, images: [], ...extra };
|
||||
}
|
||||
|
||||
// Tanggal laporan dipilih dari kalender; tanpa tanggal yang sah, ketua diarahkan ke kalender.
|
||||
router.get('/kegiatan/:id/log/baru', loadKegiatan, requireReporter, (req, res) => {
|
||||
const tanggal = req.query.tanggal;
|
||||
if (!isValidDate(tanggal) || tanggal > today()) {
|
||||
req.flash('info', 'Pilih tanggal laporan pada kalender terlebih dahulu.');
|
||||
return res.redirect('/kegiatan/' + req.kegiatan.id);
|
||||
}
|
||||
res.render('log-form', formView(req, {
|
||||
title: 'Tulis log harian', log: null, errors: {},
|
||||
v: { tanggal, judul: '', deskripsi: '', link_dokumentasi: '' },
|
||||
}));
|
||||
});
|
||||
|
||||
router.post('/kegiatan/:id/log', loadKegiatan, requireReporter, handleUpload('gambar'), csrfVerify, (req, res) => {
|
||||
const { v, errors } = readLogForm(req);
|
||||
if (Object.keys(errors).length) {
|
||||
removeFiles(req.files);
|
||||
if (req.files && req.files.length && !errors.gambar) errors.gambar = 'Gambar perlu dipilih ulang.';
|
||||
return res.status(400).render('log-form', formView(req, { title: 'Tulis log harian', log: null, v, errors }));
|
||||
}
|
||||
const id = tx(() => {
|
||||
const r = db.prepare('INSERT INTO logs (kegiatan_id, author_id, tanggal, judul, deskripsi, link_dokumentasi) VALUES (?, ?, ?, ?, ?, ?)')
|
||||
.run(req.kegiatan.id, req.user.id, v.tanggal, v.judul || null, v.deskripsi, v.link_dokumentasi || null);
|
||||
const logId = Number(r.lastInsertRowid);
|
||||
const ins = db.prepare('INSERT INTO log_images (log_id, filename, original_name) VALUES (?, ?, ?)');
|
||||
for (const f of req.files || []) ins.run(logId, f.filename, f.originalname.slice(0, 200));
|
||||
return logId;
|
||||
});
|
||||
req.flash('success', 'Log harian berhasil disimpan.');
|
||||
// Kembali ke kalender dengan popup tanggal tersebut terbuka.
|
||||
res.redirect(`/kegiatan/${req.kegiatan.id}?bulan=${v.tanggal.slice(0, 7)}&hari=${v.tanggal}#lap-${id}`);
|
||||
});
|
||||
|
||||
/* ---------- Detail log + komentar ---------- */
|
||||
router.get('/log/:id', loadLog, (req, res) => {
|
||||
const images = db.prepare('SELECT * FROM log_images WHERE log_id = ? ORDER BY id').all(req.log.id);
|
||||
const comments = db.prepare(`SELECT c.*, u.nama, u.role FROM comments c JOIN users u ON u.id = c.user_id
|
||||
WHERE c.log_id = ? ORDER BY c.id`).all(req.log.id);
|
||||
res.render('log', {
|
||||
title: req.log.judul || 'Log ' + req.log.tanggal,
|
||||
log: req.log, k: req.kegiatan, images, comments,
|
||||
canEdit: canEditLog(req.user, req.kegiatan),
|
||||
});
|
||||
});
|
||||
|
||||
/* ---------- Ubah / hapus log ---------- */
|
||||
function requireEditor(req, res, next) {
|
||||
if (!canEditLog(req.user, req.kegiatan)) return forbidden(res);
|
||||
next();
|
||||
}
|
||||
|
||||
router.get('/log/:id/edit', loadLog, requireEditor, (req, res) => {
|
||||
const images = db.prepare('SELECT * FROM log_images WHERE log_id = ? ORDER BY id').all(req.log.id);
|
||||
res.render('log-form', formView(req, { title: 'Ubah log', log: req.log, v: req.log, errors: {}, images }));
|
||||
});
|
||||
|
||||
router.post('/log/:id', loadLog, requireEditor, handleUpload('gambar'), csrfVerify, (req, res) => {
|
||||
const images = db.prepare('SELECT * FROM log_images WHERE log_id = ? ORDER BY id').all(req.log.id);
|
||||
const removeIds = new Set([].concat(req.body.hapus_gambar || []).map(Number));
|
||||
const toRemove = images.filter((i) => removeIds.has(i.id));
|
||||
const { v, errors } = readLogForm(req);
|
||||
if (images.length - toRemove.length + (req.files || []).length > MAX_FILES) {
|
||||
errors.gambar = `Total gambar maksimal ${MAX_FILES}. Hapus sebagian gambar lama atau kurangi unggahan.`;
|
||||
}
|
||||
if (Object.keys(errors).length) {
|
||||
removeFiles(req.files);
|
||||
return res.status(400).render('log-form', formView(req, { title: 'Ubah log', log: req.log, v, errors, images }));
|
||||
}
|
||||
tx(() => {
|
||||
db.prepare("UPDATE logs SET tanggal = ?, judul = ?, deskripsi = ?, link_dokumentasi = ?, updated_at = datetime('now','localtime') WHERE id = ?")
|
||||
.run(v.tanggal, v.judul || null, v.deskripsi, v.link_dokumentasi || null, req.log.id);
|
||||
const del = db.prepare('DELETE FROM log_images WHERE id = ? AND log_id = ?');
|
||||
for (const i of toRemove) del.run(i.id, req.log.id);
|
||||
const ins = db.prepare('INSERT INTO log_images (log_id, filename, original_name) VALUES (?, ?, ?)');
|
||||
for (const f of req.files || []) ins.run(req.log.id, f.filename, f.originalname.slice(0, 200));
|
||||
});
|
||||
removeFiles(toRemove);
|
||||
req.flash('success', 'Log berhasil diperbarui.');
|
||||
res.redirect('/log/' + req.log.id);
|
||||
});
|
||||
|
||||
router.post('/log/:id/hapus', loadLog, requireEditor, (req, res) => {
|
||||
const images = db.prepare('SELECT filename FROM log_images WHERE log_id = ?').all(req.log.id);
|
||||
db.prepare('DELETE FROM logs WHERE id = ?').run(req.log.id);
|
||||
removeFiles(images);
|
||||
req.flash('success', 'Log telah dihapus.');
|
||||
res.redirect('/kegiatan/' + req.kegiatan.id);
|
||||
});
|
||||
|
||||
/* ---------- Komentar ---------- */
|
||||
router.post('/log/:id/komentar', loadLog, (req, res) => {
|
||||
const isi = String(req.body.isi || '').trim();
|
||||
// Kembali ke kalender bila komentar dikirim dari popup (hanya path internal yang diizinkan).
|
||||
const kembali = /^\/kegiatan\/\d+\?bulan=\d{4}-\d{2}&hari=\d{4}-\d{2}-\d{2}$/.test(req.body.kembali || '') ? req.body.kembali : null;
|
||||
if (!isi || isi.length > 2000) {
|
||||
req.flash('error', isi ? 'Komentar maksimal 2000 karakter.' : 'Komentar tidak boleh kosong.');
|
||||
return res.redirect(kembali || '/log/' + req.log.id + '#komentar');
|
||||
}
|
||||
const r = db.prepare('INSERT INTO comments (log_id, user_id, isi) VALUES (?, ?, ?)').run(req.log.id, req.user.id, isi);
|
||||
if (kembali) req.flash('success', 'Komentar terkirim.');
|
||||
res.redirect(kembali || '/log/' + req.log.id + '#c' + r.lastInsertRowid);
|
||||
});
|
||||
|
||||
router.post('/komentar/:id/hapus', (req, res) => {
|
||||
const c = db.prepare('SELECT * FROM comments WHERE id = ?').get(Number(req.params.id));
|
||||
if (!c) return notFound(res);
|
||||
if (c.user_id !== req.user.id && req.user.role !== 'admin') return forbidden(res);
|
||||
db.prepare('DELETE FROM comments WHERE id = ?').run(c.id);
|
||||
req.flash('success', 'Komentar dihapus.');
|
||||
res.redirect('/log/' + c.log_id + '#komentar');
|
||||
});
|
||||
|
||||
/* ---------- Gambar (dengan pengecekan akses) ---------- */
|
||||
router.get('/gambar/:id', (req, res) => {
|
||||
const img = db.prepare(`SELECT i.*, l.kegiatan_id FROM log_images i JOIN logs l ON l.id = i.log_id WHERE i.id = ?`)
|
||||
.get(Number(req.params.id));
|
||||
if (!img) return res.sendStatus(404);
|
||||
if (!canView(req.user, getKegiatan(img.kegiatan_id))) return res.sendStatus(403);
|
||||
const file = path.join(UPLOAD_DIR, path.basename(img.filename));
|
||||
if (!fs.existsSync(file)) return res.sendStatus(404);
|
||||
res.set('Cache-Control', 'private, max-age=86400');
|
||||
res.set('X-Content-Type-Options', 'nosniff');
|
||||
res.sendFile(file);
|
||||
});
|
||||
|
||||
module.exports = router;
|
||||
@@ -0,0 +1,62 @@
|
||||
const express = require('express');
|
||||
const session = require('express-session');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
const { db, ensureAdmin, DATA_DIR } = require('./db');
|
||||
const SqliteStore = require('./session-store');
|
||||
const mw = require('./middleware');
|
||||
|
||||
function sessionSecret() {
|
||||
if (process.env.SESSION_SECRET) return process.env.SESSION_SECRET;
|
||||
const file = path.join(DATA_DIR, 'session-secret.txt');
|
||||
if (!fs.existsSync(file)) fs.writeFileSync(file, crypto.randomBytes(32).toString('hex'));
|
||||
return fs.readFileSync(file, 'utf8').trim();
|
||||
}
|
||||
|
||||
ensureAdmin();
|
||||
|
||||
const app = express();
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', path.join(__dirname, '..', 'views'));
|
||||
app.disable('x-powered-by');
|
||||
if (process.env.TRUST_PROXY) app.set('trust proxy', 1);
|
||||
|
||||
app.use((req, res, next) => {
|
||||
res.set('X-Frame-Options', 'DENY');
|
||||
res.set('Referrer-Policy', 'same-origin');
|
||||
next();
|
||||
});
|
||||
app.use(express.static(path.join(__dirname, '..', 'public'), { maxAge: '1h' }));
|
||||
app.use(express.urlencoded({ extended: false, limit: '100kb' }));
|
||||
app.use(session({
|
||||
store: new SqliteStore(db),
|
||||
secret: sessionSecret(),
|
||||
name: 'logharian.sid',
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
cookie: {
|
||||
httpOnly: true,
|
||||
sameSite: 'lax',
|
||||
secure: process.env.COOKIE_SECURE === '1',
|
||||
maxAge: 8 * 60 * 60 * 1000,
|
||||
},
|
||||
}));
|
||||
app.use(mw.flash);
|
||||
app.use(mw.loadUser);
|
||||
app.use(mw.locals);
|
||||
app.use(mw.csrfSetup);
|
||||
app.use(mw.csrfVerifyNonMultipart);
|
||||
|
||||
app.use(require('./routes/auth'));
|
||||
app.use('/admin', require('./routes/admin'));
|
||||
app.use(require('./routes/logs'));
|
||||
|
||||
app.use((req, res) => mw.notFound(res));
|
||||
app.use((err, req, res, next) => {
|
||||
console.error(err);
|
||||
res.status(500).render('error', { title: 'Terjadi kesalahan', message: 'Server mengalami kendala. Coba lagi beberapa saat lagi.' });
|
||||
});
|
||||
|
||||
const PORT = Number(process.env.PORT) || 3000;
|
||||
app.listen(PORT, () => console.log(`[logharian] Berjalan di http://localhost:${PORT}`));
|
||||
@@ -0,0 +1,51 @@
|
||||
const session = require('express-session');
|
||||
|
||||
const DAY = 24 * 60 * 60 * 1000;
|
||||
|
||||
// Penyimpanan sesi di SQLite agar login tidak hilang saat server restart.
|
||||
class SqliteStore extends session.Store {
|
||||
constructor(db) {
|
||||
super();
|
||||
this.db = db;
|
||||
db.exec('CREATE TABLE IF NOT EXISTS sessions (sid TEXT PRIMARY KEY, sess TEXT NOT NULL, expires INTEGER NOT NULL)');
|
||||
this.db.prepare('DELETE FROM sessions WHERE expires < ?').run(Date.now());
|
||||
}
|
||||
|
||||
expiry(sess) {
|
||||
return sess && sess.cookie && sess.cookie.expires
|
||||
? new Date(sess.cookie.expires).getTime()
|
||||
: Date.now() + DAY;
|
||||
}
|
||||
|
||||
get(sid, cb) {
|
||||
try {
|
||||
const row = this.db.prepare('SELECT sess, expires FROM sessions WHERE sid = ?').get(sid);
|
||||
if (!row || row.expires < Date.now()) return cb(null, null);
|
||||
cb(null, JSON.parse(row.sess));
|
||||
} catch (err) { cb(err); }
|
||||
}
|
||||
|
||||
set(sid, sess, cb) {
|
||||
try {
|
||||
this.db.prepare('INSERT OR REPLACE INTO sessions (sid, sess, expires) VALUES (?, ?, ?)')
|
||||
.run(sid, JSON.stringify(sess), this.expiry(sess));
|
||||
cb && cb(null);
|
||||
} catch (err) { cb && cb(err); }
|
||||
}
|
||||
|
||||
touch(sid, sess, cb) {
|
||||
try {
|
||||
this.db.prepare('UPDATE sessions SET expires = ? WHERE sid = ?').run(this.expiry(sess), sid);
|
||||
cb && cb(null);
|
||||
} catch (err) { cb && cb(err); }
|
||||
}
|
||||
|
||||
destroy(sid, cb) {
|
||||
try {
|
||||
this.db.prepare('DELETE FROM sessions WHERE sid = ?').run(sid);
|
||||
cb && cb(null);
|
||||
} catch (err) { cb && cb(err); }
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SqliteStore;
|
||||
@@ -0,0 +1,50 @@
|
||||
const multer = require('multer');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const crypto = require('crypto');
|
||||
|
||||
const UPLOAD_DIR = process.env.UPLOAD_DIR || path.join(__dirname, '..', 'uploads');
|
||||
fs.mkdirSync(UPLOAD_DIR, { recursive: true });
|
||||
|
||||
const MAX_FILES = 5;
|
||||
const MAX_SIZE_MB = 3;
|
||||
const EXT = { 'image/jpeg': '.jpg', 'image/png': '.png', 'image/webp': '.webp', 'image/gif': '.gif' };
|
||||
|
||||
const upload = multer({
|
||||
storage: multer.diskStorage({
|
||||
destination: UPLOAD_DIR,
|
||||
filename: (req, file, cb) => cb(null, crypto.randomBytes(16).toString('hex') + EXT[file.mimetype]),
|
||||
}),
|
||||
limits: { fileSize: MAX_SIZE_MB * 1024 * 1024, files: MAX_FILES },
|
||||
fileFilter: (req, file, cb) => {
|
||||
if (EXT[file.mimetype]) return cb(null, true);
|
||||
const err = new Error('Format gambar harus JPG, PNG, WEBP, atau GIF.');
|
||||
err.code = 'BAD_TYPE';
|
||||
cb(err);
|
||||
},
|
||||
});
|
||||
|
||||
// Menangkap error multer agar bisa ditampilkan sebagai pesan di form, bukan halaman error.
|
||||
function handleUpload(field) {
|
||||
const mw = upload.array(field, MAX_FILES);
|
||||
return (req, res, next) => mw(req, res, (err) => {
|
||||
if (err) {
|
||||
req.uploadError =
|
||||
err.code === 'LIMIT_FILE_SIZE' ? `Ada gambar yang lebih dari ${MAX_SIZE_MB} MB. Kecilkan ukurannya, atau unggah ke Google Drive lalu tempel link-nya di kolom link dokumentasi.` :
|
||||
err.code === 'LIMIT_FILE_COUNT' || err.code === 'LIMIT_UNEXPECTED_FILE' ? `Maksimal ${MAX_FILES} gambar per log.` :
|
||||
err.message || 'Gambar gagal diunggah.';
|
||||
removeFiles(req.files);
|
||||
req.files = [];
|
||||
}
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
function removeFiles(files) {
|
||||
for (const f of files || []) {
|
||||
const p = f.path || path.join(UPLOAD_DIR, f.filename);
|
||||
fs.unlink(p, () => {});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { handleUpload, removeFiles, UPLOAD_DIR, MAX_FILES, MAX_SIZE_MB };
|
||||
@@ -0,0 +1,95 @@
|
||||
<%- include('../partials/head') %>
|
||||
<div class="form-page">
|
||||
<section class="page-hero">
|
||||
<nav class="crumbs"><a href="/admin/kegiatan">Kegiatan</a> / <span><%= k.id ? k.nama : 'Baru' %></span></nav>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow">Operator · Kegiatan</span>
|
||||
<h1><%= title %></h1>
|
||||
<p class="sub">Tentukan ketua tim yang melapor dan dosen yang memantau.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<form class="card stack form-narrow" method="post" action="<%= k.id ? '/admin/kegiatan/' + k.id : '/admin/kegiatan' %>">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
|
||||
<div class="field">
|
||||
<label for="nama">Nama kegiatan</label>
|
||||
<input id="nama" name="nama" value="<%= k.nama %>" required placeholder="mis. KKN Desa Sungai Ambawang">
|
||||
<% if (errors.nama) { %><span class="err"><%= errors.nama %></span><% } %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="deskripsi">Deskripsi <span class="opt">(opsional)</span></label>
|
||||
<textarea id="deskripsi" name="deskripsi" rows="3"><%= k.deskripsi || '' %></textarea>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="ketua_id">Ketua tim</label>
|
||||
<% if (!ketuaList.length) { %>
|
||||
<p class="muted">Belum ada akun Ketua Tim. <a href="/admin/users/baru?role=ketua">Tambah ketua tim dulu</a>.</p>
|
||||
<% } else { %>
|
||||
<select id="ketua_id" name="ketua_id" required>
|
||||
<option value="">Pilih ketua tim</option>
|
||||
<% ketuaList.forEach(function (u) { %>
|
||||
<option value="<%= u.id %>" <%= k.ketua_id === u.id ? 'selected' : '' %>><%= u.nama %><%= u.nomor_induk ? ' — ' + u.nomor_induk : '' %><%= u.aktif ? '' : ' (nonaktif)' %></option>
|
||||
<% }) %>
|
||||
</select>
|
||||
<span class="hint">Hanya ketua tim ini yang dapat menulis log untuk kegiatan.</span>
|
||||
<% } %>
|
||||
<% if (errors.ketua_id) { %><span class="err"><%= errors.ketua_id %></span><% } %>
|
||||
</div>
|
||||
|
||||
<fieldset class="field">
|
||||
<legend>Dosen pemantau</legend>
|
||||
<% if (!dosenList.length) { %>
|
||||
<p class="muted">Belum ada akun Dosen. <a href="/admin/users/baru?role=dosen">Tambah dosen</a>.</p>
|
||||
<% } else { %>
|
||||
<div class="check-list">
|
||||
<% dosenList.forEach(function (d) { %>
|
||||
<label class="check">
|
||||
<input type="checkbox" name="dosen_ids" value="<%= d.id %>" <%= dosenIds.includes(d.id) ? 'checked' : '' %>>
|
||||
<%= d.nama %><%= d.nomor_induk ? ' — ' + d.nomor_induk : '' %><%= d.aktif ? '' : ' (nonaktif)' %>
|
||||
</label>
|
||||
<% }) %>
|
||||
</div>
|
||||
<span class="hint">Dosen yang dipilih bisa melihat dan mengomentari log kegiatan ini.</span>
|
||||
<% } %>
|
||||
</fieldset>
|
||||
|
||||
<div class="grid-2 tight">
|
||||
<div class="field">
|
||||
<label for="tanggal_mulai">Tanggal mulai <span class="opt">(opsional)</span></label>
|
||||
<input type="date" id="tanggal_mulai" name="tanggal_mulai" value="<%= k.tanggal_mulai || '' %>">
|
||||
<% if (errors.tanggal_mulai) { %><span class="err"><%= errors.tanggal_mulai %></span><% } %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="tanggal_selesai">Tanggal selesai <span class="opt">(opsional)</span></label>
|
||||
<input type="date" id="tanggal_selesai" name="tanggal_selesai" value="<%= k.tanggal_selesai || '' %>">
|
||||
<% if (errors.tanggal_selesai) { %><span class="err"><%= errors.tanggal_selesai %></span><% } %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary"><%= k.id ? 'Simpan perubahan' : 'Tambah kegiatan' %></button>
|
||||
<a class="btn btn-ghost" href="<%= k.id ? '/kegiatan/' + k.id : '/admin/kegiatan' %>">Batal</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<% if (k.id) { %>
|
||||
<section class="card form-narrow danger-card">
|
||||
<h2>Hapus kegiatan</h2>
|
||||
<p class="muted">Seluruh log, gambar, dan komentar pada kegiatan ini ikut terhapus permanen.</p>
|
||||
<form method="post" action="/admin/kegiatan/<%= k.id %>/hapus" class="stack">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<div class="field">
|
||||
<label for="konfirmasi">Ketik nama kegiatan untuk konfirmasi</label>
|
||||
<input id="konfirmasi" name="konfirmasi" autocomplete="off" placeholder="<%= k.nama %>" required>
|
||||
</div>
|
||||
<div><button type="submit" class="btn btn-danger">Hapus kegiatan ini</button></div>
|
||||
</form>
|
||||
</section>
|
||||
<% } %>
|
||||
</div>
|
||||
<%- include('../partials/foot') %>
|
||||
@@ -0,0 +1,37 @@
|
||||
<%- include('../partials/head') %>
|
||||
<section class="page-hero">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow">Operator</span>
|
||||
<h1>Kegiatan</h1>
|
||||
<p class="sub">Atur kegiatan, ketua tim, dan dosen pemantaunya.</p>
|
||||
</div>
|
||||
<div class="actions"><a class="btn btn-primary" href="/admin/kegiatan/baru">Tambah kegiatan</a></div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="card table-wrap">
|
||||
<% if (!kegiatan.length) { %>
|
||||
<div class="empty-inline">
|
||||
<p>Belum ada kegiatan. Pastikan akun ketua tim sudah dibuat, lalu tambahkan kegiatan.</p>
|
||||
<a class="btn btn-primary btn-sm" href="/admin/kegiatan/baru">Tambah kegiatan</a>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<table class="table">
|
||||
<thead><tr><th>Kegiatan</th><th>Ketua tim</th><th>Dosen pemantau</th><th>Periode</th><th>Log</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<% kegiatan.forEach(function (k) { %>
|
||||
<tr>
|
||||
<td data-label="Kegiatan"><a href="/kegiatan/<%= k.id %>"><strong><%= k.nama %></strong></a></td>
|
||||
<td data-label="Ketua tim"><%= k.ketua_nama %></td>
|
||||
<td data-label="Dosen"><%= k.dosen_nama || '-' %></td>
|
||||
<td data-label="Periode"><%= k.tanggal_mulai ? fmtDateShort(k.tanggal_mulai) + ' – ' + fmtDateShort(k.tanggal_selesai) : '-' %></td>
|
||||
<td data-label="Log"><%= k.jml_log %><% if (k.log_terakhir) { %> <span class="muted small">(terakhir <%= fmtDateShort(k.log_terakhir) %>)</span><% } %></td>
|
||||
<td class="row-actions"><a class="btn btn-sm" href="/admin/kegiatan/<%= k.id %>/edit">Ubah</a></td>
|
||||
</tr>
|
||||
<% }) %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% } %>
|
||||
</div>
|
||||
<%- include('../partials/foot') %>
|
||||
@@ -0,0 +1,82 @@
|
||||
<%- include('../partials/head') %>
|
||||
<div class="form-page">
|
||||
<section class="page-hero">
|
||||
<nav class="crumbs"><a href="/admin/users">Pengguna</a> / <span><%= u.id ? u.nama : 'Baru' %></span></nav>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow">Operator · Pengguna</span>
|
||||
<h1><%= title %></h1>
|
||||
<p class="sub"><%= u.id ? 'Perbarui data akun ' + u.nama + '.' : 'Buat akun baru untuk dosen, ketua tim, atau operator.' %></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<form class="card stack form-narrow" method="post" action="<%= u.id ? '/admin/users/' + u.id : '/admin/users' %>">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
|
||||
<fieldset class="field">
|
||||
<legend>Level akun</legend>
|
||||
<div class="radio-cards">
|
||||
<label class="radio-card">
|
||||
<input type="radio" name="role" value="ketua" <%= u.role === 'ketua' ? 'checked' : '' %>>
|
||||
<span><strong>Ketua Tim</strong><span class="muted small">Menulis log harian kegiatannya</span></span>
|
||||
</label>
|
||||
<label class="radio-card">
|
||||
<input type="radio" name="role" value="dosen" <%= u.role === 'dosen' ? 'checked' : '' %>>
|
||||
<span><strong>Dosen</strong><span class="muted small">Melihat dan mengomentari log</span></span>
|
||||
</label>
|
||||
<label class="radio-card">
|
||||
<input type="radio" name="role" value="admin" <%= u.role === 'admin' ? 'checked' : '' %>>
|
||||
<span><strong>Operator</strong><span class="muted small">Akses penuh ke seluruh data</span></span>
|
||||
</label>
|
||||
</div>
|
||||
<% if (errors.role) { %><span class="err"><%= errors.role %></span><% } %>
|
||||
</fieldset>
|
||||
|
||||
<div class="field">
|
||||
<label for="nama">Nama lengkap</label>
|
||||
<input id="nama" name="nama" value="<%= u.nama %>" required>
|
||||
<% if (errors.nama) { %><span class="err"><%= errors.nama %></span><% } %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="nomor_induk">NIM / NIP <span class="opt">(opsional)</span></label>
|
||||
<input id="nomor_induk" name="nomor_induk" value="<%= u.nomor_induk || '' %>">
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="username">Username</label>
|
||||
<input id="username" name="username" value="<%= u.username %>" autocomplete="off" required>
|
||||
<span class="hint">Dipakai untuk login. Contoh: NIM mahasiswa atau NIP dosen.</span>
|
||||
<% if (errors.username) { %><span class="err"><%= errors.username %></span><% } %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="password"><%= u.id ? 'Password baru' : 'Password' %><% if (u.id) { %> <span class="opt">(kosongkan bila tidak diganti)</span><% } %></label>
|
||||
<input id="password" name="password" type="password" autocomplete="new-password" <%= u.id ? '' : 'required' %> minlength="8">
|
||||
<span class="hint">Minimal 8 karakter. Sampaikan ke pemilik akun agar segera diganti.</span>
|
||||
<% if (errors.password) { %><span class="err"><%= errors.password %></span><% } %>
|
||||
</div>
|
||||
<label class="check">
|
||||
<input type="checkbox" name="aktif" value="1" <%= u.aktif ? 'checked' : '' %>> Akun aktif (bisa login)
|
||||
</label>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary"><%= u.id ? 'Simpan perubahan' : 'Tambah pengguna' %></button>
|
||||
<a class="btn btn-ghost" href="/admin/users">Batal</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<% if (u.id && u.id !== currentUser.id) { %>
|
||||
<section class="card form-narrow danger-card">
|
||||
<h2>Hapus akun</h2>
|
||||
<p class="muted">Akun yang masih menjadi ketua kegiatan atau sudah menulis log tidak bisa dihapus — nonaktifkan saja agar riwayat tetap tersimpan.</p>
|
||||
<details class="danger-zone">
|
||||
<summary class="btn btn-danger-ghost">Hapus akun <%= u.nama %>…</summary>
|
||||
<form method="post" action="/admin/users/<%= u.id %>/hapus" class="danger-pop">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<p>Akun <strong><%= u.nama %></strong> dan komentarnya akan dihapus permanen.</p>
|
||||
<button type="submit" class="btn btn-danger btn-sm">Hapus akun <%= u.username %></button>
|
||||
</form>
|
||||
</details>
|
||||
</section>
|
||||
<% } %>
|
||||
</div>
|
||||
<%- include('../partials/foot') %>
|
||||
@@ -0,0 +1,57 @@
|
||||
<%- include('../partials/head') %>
|
||||
<section class="page-hero">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow">Operator</span>
|
||||
<h1>Pengguna</h1>
|
||||
<p class="sub">Kelola akun operator, dosen, dan ketua tim.</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<a class="btn" href="/admin/users/baru?role=dosen">Tambah dosen</a>
|
||||
<a class="btn btn-primary" href="/admin/users/baru?role=ketua">Tambah ketua tim</a>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<form class="filters card" method="get">
|
||||
<div class="field">
|
||||
<label for="role">Level</label>
|
||||
<select id="role" name="role">
|
||||
<option value="">Semua level</option>
|
||||
<% ['admin', 'dosen', 'ketua'].forEach(function (r) { %>
|
||||
<option value="<%= r %>" <%= role === r ? 'selected' : '' %>><%= roleLabel(r) %></option>
|
||||
<% }) %>
|
||||
</select>
|
||||
</div>
|
||||
<div class="field grow">
|
||||
<label for="q">Cari</label>
|
||||
<input type="search" id="q" name="q" value="<%= q %>" placeholder="Nama, username, atau NIM/NIP">
|
||||
</div>
|
||||
<div class="filter-actions"><button class="btn" type="submit">Terapkan filter</button></div>
|
||||
</form>
|
||||
|
||||
<div class="card table-wrap">
|
||||
<% if (!users.length) { %>
|
||||
<p class="muted">Tidak ada pengguna yang cocok. <a href="/admin/users">Tampilkan semua</a></p>
|
||||
<% } else { %>
|
||||
<table class="table">
|
||||
<thead><tr><th>Nama</th><th>Username</th><th>NIM / NIP</th><th>Level</th><th>Kegiatan</th><th>Status</th><th></th></tr></thead>
|
||||
<tbody>
|
||||
<% users.forEach(function (u) { %>
|
||||
<tr class="<%= u.aktif ? '' : 'row-off' %>">
|
||||
<td data-label="Nama"><strong><%= u.nama %></strong></td>
|
||||
<td data-label="Username"><%= u.username %></td>
|
||||
<td data-label="NIM / NIP"><%= u.nomor_induk || '-' %></td>
|
||||
<td data-label="Level"><span class="badge role-<%= u.role %>"><%= roleLabel(u.role) %></span></td>
|
||||
<td data-label="Kegiatan"><%= u.role === 'ketua' ? u.jml_kegiatan_ketua : u.role === 'dosen' ? u.jml_kegiatan_dosen : '-' %></td>
|
||||
<td data-label="Status"><span class="badge <%= u.aktif ? 'badge-ok' : 'badge-off' %>"><%= u.aktif ? 'Aktif' : 'Nonaktif' %></span></td>
|
||||
<td class="row-actions">
|
||||
<a class="btn btn-sm" href="/admin/users/<%= u.id %>/edit">Ubah</a>
|
||||
</td>
|
||||
</tr>
|
||||
<% }) %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% } %>
|
||||
</div>
|
||||
<%- include('../partials/foot') %>
|
||||
@@ -0,0 +1,44 @@
|
||||
<%- include('partials/head') %>
|
||||
<section class="page-hero">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow"><%= roleLabel(currentUser.role) %></span>
|
||||
<h1>Akun saya</h1>
|
||||
<p class="sub">Lihat profil dan ganti password Anda.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<div class="grid-2">
|
||||
<section class="card">
|
||||
<h2>Profil</h2>
|
||||
<dl class="dl">
|
||||
<dt>Nama</dt><dd><%= currentUser.nama %></dd>
|
||||
<dt>Username</dt><dd><%= currentUser.username %></dd>
|
||||
<dt>Level</dt><dd><%= roleLabel(currentUser.role) %></dd>
|
||||
<dt>NIM / NIP</dt><dd><%= currentUser.nomor_induk || '-' %></dd>
|
||||
</dl>
|
||||
<p class="muted small">Perubahan data profil dilakukan oleh operator.</p>
|
||||
</section>
|
||||
<section class="card">
|
||||
<h2>Ganti password</h2>
|
||||
<% if (error) { %><div class="alert alert-error" role="alert"><%= error %></div><% } %>
|
||||
<form method="post" action="/akun/password" class="stack">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<div class="field">
|
||||
<label for="lama">Password lama</label>
|
||||
<input id="lama" name="lama" type="password" autocomplete="current-password" required>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="baru">Password baru</label>
|
||||
<input id="baru" name="baru" type="password" autocomplete="new-password" minlength="8" required>
|
||||
<span class="hint">Minimal 8 karakter.</span>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="konfirmasi">Ulangi password baru</label>
|
||||
<input id="konfirmasi" name="konfirmasi" type="password" autocomplete="new-password" required>
|
||||
</div>
|
||||
<div><button type="submit" class="btn btn-primary">Simpan password</button></div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<%- include('partials/foot') %>
|
||||
@@ -0,0 +1,104 @@
|
||||
<%- include('partials/head') %>
|
||||
<%
|
||||
var role = currentUser.role;
|
||||
var isAdmin = role === 'admin';
|
||||
var FASE = { berjalan: ['badge-info', 'Berjalan'], belum: ['badge-off', 'Belum mulai'], selesai: ['badge-off', 'Selesai'] };
|
||||
var PANEL = { admin: 'Rangkaian kegiatan', dosen: 'Kegiatan yang Anda pantau', ketua: 'Kegiatan yang Anda pimpin' };
|
||||
var HINT = { admin: 'Pilih kegiatan untuk melihat kalender laporan', dosen: 'Pilih kegiatan untuk melihat kalender laporan', ketua: 'Pilih kegiatan, lalu klik tanggal di kalender untuk menulis laporan' };
|
||||
%>
|
||||
<section class="page-hero">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow"><%= fmtDate(today) %></span>
|
||||
<h1>Halo, <%= currentUser.nama %></h1>
|
||||
<% if (isAdmin) { %>
|
||||
<p class="sub"><%= stats.kegiatan %> kegiatan · <%= stats.ketua %> ketua tim · <%= stats.dosen %> dosen · <%= stats.log_hari_ini %> log masuk hari ini</p>
|
||||
<% } else if (role === 'dosen') { %>
|
||||
<p class="sub">Memantau <%= roleStats.kegiatan %> kegiatan<% if (roleStats.berjalan) { %> · hari ini <%= roleStats.terisi %> sudah lapor, <%= roleStats.belum %> belum<% } %></p>
|
||||
<% } else { %>
|
||||
<p class="sub">
|
||||
<% if (!roleStats.berjalan) { %>Tidak ada kegiatan yang sedang berjalan.
|
||||
<% } else if (roleStats.belum) { %><%= roleStats.belum %> kegiatan belum dilaporkan hari ini.
|
||||
<% } else { %>Semua kegiatan sudah dilaporkan hari ini. Terima kasih!<% } %>
|
||||
</p>
|
||||
<% } %>
|
||||
</div>
|
||||
<% if (isAdmin) { %>
|
||||
<div class="actions">
|
||||
<a class="btn" href="/admin/users/baru">Tambah pengguna</a>
|
||||
<a class="btn btn-primary" href="/admin/kegiatan/baru">Tambah kegiatan</a>
|
||||
</div>
|
||||
<% } %>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="admin-dash">
|
||||
<section class="card panel-main">
|
||||
<div class="panel-head">
|
||||
<h2><%= PANEL[role] %></h2>
|
||||
<span class="muted small"><%= HINT[role] %></span>
|
||||
</div>
|
||||
<% if (!kegiatan.length) { %>
|
||||
<div class="empty-inline">
|
||||
<% if (isAdmin) { %>
|
||||
<p>Belum ada kegiatan. Tambahkan akun ketua tim dulu, lalu buat kegiatan.</p>
|
||||
<a class="btn btn-primary btn-sm" href="/admin/kegiatan/baru">Tambah kegiatan</a>
|
||||
<% } else if (role === 'dosen') { %>
|
||||
<p>Anda belum ditugaskan sebagai dosen pemantau di kegiatan mana pun. Hubungi operator untuk ditambahkan.</p>
|
||||
<% } else { %>
|
||||
<p>Anda belum ditetapkan sebagai ketua tim di kegiatan mana pun. Hubungi operator untuk ditambahkan.</p>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<div class="keg-grid">
|
||||
<% kegiatan.forEach(function (k) { var f = FASE[k.fase]; %>
|
||||
<a class="keg-card" href="/kegiatan/<%= k.id %>">
|
||||
<div class="keg-card-top">
|
||||
<span class="badge <%= f[0] %>"><%= f[1] %></span>
|
||||
<% if (k.fase === 'berjalan') { %>
|
||||
<span class="badge <%= k.sudah_hari_ini ? 'badge-ok' : 'badge-warn' %>"><%= k.sudah_hari_ini ? 'Hari ini terisi' : 'Hari ini belum' %></span>
|
||||
<% } %>
|
||||
</div>
|
||||
<h3 class="keg-card-title"><%= k.nama %></h3>
|
||||
<dl class="keg-card-dl">
|
||||
<% if (role !== 'ketua') { %><dt>Ketua</dt><dd><%= k.ketua_nama %></dd><% } %>
|
||||
<dt>Dosen</dt><dd><%= k.dosen_nama || 'Belum ada' %></dd>
|
||||
<dt>Periode</dt><dd><%= k.tanggal_mulai ? fmtDateShort(k.tanggal_mulai) : fmtDateShort(String(k.created_at).slice(0, 10)) %> – <%= k.tanggal_selesai ? fmtDateShort(k.tanggal_selesai) : 'tanpa batas' %></dd>
|
||||
</dl>
|
||||
<div class="keg-progress">
|
||||
<div class="keg-progress-label">
|
||||
<span><strong><%= k.hari_terisi %></strong> dari <%= k.hari_berjalan %> hari terisi</span>
|
||||
<span><%= k.persen %>%</span>
|
||||
</div>
|
||||
<div class="progress" role="progressbar" aria-valuenow="<%= k.persen %>" aria-valuemin="0" aria-valuemax="100" aria-label="Kelengkapan laporan"><i style="width: <%= k.persen %>%"></i></div>
|
||||
</div>
|
||||
<span class="keg-card-foot">
|
||||
<span class="muted small"><%= k.log_terakhir ? 'Log terakhir ' + fmtDateShort(k.log_terakhir) : 'Belum ada log' %></span>
|
||||
<span class="keg-card-cta"><%= role === 'ketua' ? 'Buka kalender & lapor' : 'Buka kalender' %> →</span>
|
||||
</span>
|
||||
</a>
|
||||
<% }) %>
|
||||
</div>
|
||||
<% } %>
|
||||
</section>
|
||||
|
||||
<aside class="card panel-side">
|
||||
<h2><%= role === 'ketua' ? 'Laporan terakhir Anda' : 'Log terbaru' %></h2>
|
||||
<% if (!logs.length) { %>
|
||||
<p class="muted small">Belum ada log yang masuk.</p>
|
||||
<% } else { %>
|
||||
<ul class="mini-logs">
|
||||
<% logs.forEach(function (l) { %>
|
||||
<li>
|
||||
<a href="/kegiatan/<%= l.kegiatan_id %>?bulan=<%= l.tanggal.slice(0, 7) %>&hari=<%= l.tanggal %>">
|
||||
<span class="mini-meta"><%= fmtDateShort(l.tanggal) %><% if (l.jml_komentar) { %> · <%= l.jml_komentar %> komentar<% } %></span>
|
||||
<span class="mini-title"><%= l.judul || l.deskripsi.slice(0, 60) + (l.deskripsi.length > 60 ? '…' : '') %></span>
|
||||
<span class="mini-keg"><%= l.kegiatan_nama %></span>
|
||||
</a>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
<% } %>
|
||||
</aside>
|
||||
</div>
|
||||
<%- include('partials/foot') %>
|
||||
@@ -0,0 +1,7 @@
|
||||
<%- include('partials/head') %>
|
||||
<div class="card empty">
|
||||
<h1><%= title %></h1>
|
||||
<p class="muted"><%= message %></p>
|
||||
<a class="btn btn-primary" href="/">Kembali ke dashboard</a>
|
||||
</div>
|
||||
<%- include('partials/foot') %>
|
||||
@@ -0,0 +1,4 @@
|
||||
<%- include('partials/head') %>
|
||||
<nav class="crumbs"><a href="/kegiatan/<%= k.id %>?bulan=<%= tanggal.slice(0, 7) %>"><%= k.nama %></a> / <span><%= fmtDateShort(tanggal) %></span></nav>
|
||||
<section class="card day-page"><%- include("partials/hari-panel") %></section>
|
||||
<%- include('partials/foot') %>
|
||||
@@ -0,0 +1,142 @@
|
||||
<%- include('partials/head') %>
|
||||
<section class="page-hero">
|
||||
<nav class="crumbs"><a href="/">Dashboard</a> / <span><%= k.nama %></span></nav>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow">Kalender laporan kegiatan</span>
|
||||
<h1><%= k.nama %></h1>
|
||||
<div class="hero-facts">
|
||||
<span><small>Ketua tim</small><strong><%= k.ketua_nama %></strong></span>
|
||||
<span><small>Periode</small><strong><%= fmtDateShort(period.start) %> – <%= period.end ? fmtDateShort(period.end) : 'tanpa batas' %></strong></span>
|
||||
<span><small>Dosen pemantau</small><strong><%= dosen.length ? dosen.map(function (d) { return d.nama; }).join(', ') : 'Belum ada' %></strong></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<% if (currentUser.role === 'admin') { %><a class="btn" href="/admin/kegiatan/<%= k.id %>/edit">Ubah kegiatan</a><% } %>
|
||||
<% if (canReport && thisMonth === bulan && days.some(function (d) { return d.isToday && d.clickable; })) { %>
|
||||
<a class="btn btn-primary" href="/kegiatan/<%= k.id %>/log/baru?tanggal=<%= today %>">Tulis log hari ini</a>
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<% if (canReport) { %>
|
||||
<div class="alert alert-info cal-hint">
|
||||
<strong>Cara melapor:</strong> klik tanggal pada kalender, lalu pilih <em>Tulis laporan</em>. Tanggal merah berarti belum dilaporkan. Satu tanggal boleh berisi lebih dari satu laporan.
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<section class="card cal-card">
|
||||
<div class="cal-toolbar">
|
||||
<div class="cal-nav">
|
||||
<a class="btn btn-sm" href="?bulan=<%= prev %>" aria-label="Bulan sebelumnya">‹</a>
|
||||
<h2 class="cal-title"><%= bulanLabel %></h2>
|
||||
<a class="btn btn-sm" href="?bulan=<%= next %>" aria-label="Bulan berikutnya">›</a>
|
||||
<% if (bulan !== thisMonth) { %><a class="btn btn-sm btn-ghost" href="?bulan=<%= thisMonth %>">Bulan ini</a><% } %>
|
||||
</div>
|
||||
<div class="cal-summary">
|
||||
<span class="badge badge-ok"><%= summary.filled %> hari terisi</span>
|
||||
<span class="badge badge-danger"><%= summary.missing %> hari belum diisi</span>
|
||||
<span class="muted small"><%= totalLog %> log total</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="cal" role="grid" aria-label="Kalender laporan <%= bulanLabel %>">
|
||||
<% ['Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab', 'Min'].forEach(function (h) { %>
|
||||
<div class="cal-dow" role="columnheader"><%= h %></div>
|
||||
<% }) %>
|
||||
<% days.forEach(function (d) {
|
||||
var cls = 'cal-day st-' + d.status + (d.inMonth ? '' : ' other') + (d.isToday ? ' is-today' : '');
|
||||
var label = fmtDate(d.date) + ': ' + ({ filled: d.n + ' laporan', missing: 'belum diisi', today: 'hari ini, belum diisi', future: 'belum tiba', outside: 'di luar periode' })[d.status];
|
||||
%>
|
||||
<% if (d.clickable) { %>
|
||||
<a class="<%= cls %>" role="gridcell" href="/kegiatan/<%= k.id %>/hari/<%= d.date %>" data-day="<%= d.date %>" aria-label="<%= label %>">
|
||||
<% } else { %>
|
||||
<div class="<%= cls %>" role="gridcell" aria-label="<%= label %>">
|
||||
<% } %>
|
||||
<span class="cal-num"><%= d.day %></span>
|
||||
<% if (d.status === 'filled') { %>
|
||||
<span class="cal-info"><%= d.n > 1 ? d.n + ' laporan' : 'Terisi' %></span>
|
||||
<span class="cal-meta">
|
||||
<% if (d.img) { %><span title="<%= d.img %> gambar"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="2"/><path d="m21 17-5-5-9 8"/></svg><%= d.img %></span><% } %>
|
||||
<% if (d.kom) { %><span title="<%= d.kom %> komentar"><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/></svg><%= d.kom %></span><% } %>
|
||||
</span>
|
||||
<% } else if (d.status === 'missing') { %>
|
||||
<span class="cal-info">Belum diisi</span>
|
||||
<% } else if (d.status === 'today') { %>
|
||||
<span class="cal-info">Hari ini</span>
|
||||
<% } %>
|
||||
<% if (d.clickable) { %></a><% } else { %></div><% } %>
|
||||
<% }) %>
|
||||
</div>
|
||||
|
||||
<div class="cal-legend">
|
||||
<span><i class="lg lg-filled"></i>Sudah diisi</span>
|
||||
<span><i class="lg lg-missing"></i>Belum diisi</span>
|
||||
<span><i class="lg lg-today"></i>Hari ini</span>
|
||||
<span><i class="lg lg-future"></i>Belum tiba / di luar periode</span>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<dialog class="day-dialog" id="day-dialog" aria-labelledby="day-title">
|
||||
<button type="button" class="dlg-close" aria-label="Tutup" data-close>✕</button>
|
||||
<div class="dlg-body"></div>
|
||||
</dialog>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var dlg = document.getElementById('day-dialog');
|
||||
var body = dlg.querySelector('.dlg-body');
|
||||
var lastTrigger = null;
|
||||
|
||||
function setParam(day) {
|
||||
var u = new URL(location.href);
|
||||
if (day) { u.searchParams.set('hari', day); u.searchParams.set('bulan', day.slice(0, 7)); }
|
||||
else { u.searchParams.delete('hari'); u.hash = ''; }
|
||||
history.replaceState(null, '', u);
|
||||
}
|
||||
|
||||
function open(url, day) {
|
||||
var slow = setTimeout(function () { body.innerHTML = '<p class="muted dlg-loading">Memuat laporan…</p>'; }, 120);
|
||||
body.innerHTML = '';
|
||||
if (!dlg.open) dlg.showModal();
|
||||
fetch(url, { headers: { 'X-Requested-With': 'fetch' }, credentials: 'same-origin' })
|
||||
.then(function (r) { if (!r.ok) throw new Error(r.status); return r.text(); })
|
||||
.then(function (html) {
|
||||
clearTimeout(slow); body.innerHTML = html; setParam(day);
|
||||
// Lompat ke laporan tertentu bila URL membawa #lap-ID (mis. setelah menyimpan log).
|
||||
var target = location.hash && body.querySelector(location.hash.replace(/[^#\w-]/g, ''));
|
||||
if (target) target.scrollIntoView({ block: 'start' });
|
||||
})
|
||||
.catch(function () {
|
||||
clearTimeout(slow);
|
||||
body.innerHTML = '<p>Laporan belum bisa dimuat. <a href="' + url + '">Buka di halaman terpisah</a>.</p>';
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll('[data-day]').forEach(function (a) {
|
||||
a.addEventListener('click', function (e) {
|
||||
if (e.ctrlKey || e.metaKey || e.shiftKey) return;
|
||||
e.preventDefault();
|
||||
lastTrigger = a;
|
||||
open(a.href, a.dataset.day);
|
||||
});
|
||||
});
|
||||
|
||||
dlg.addEventListener('click', function (e) {
|
||||
if (e.target === dlg || e.target.hasAttribute('data-close')) dlg.close();
|
||||
});
|
||||
dlg.addEventListener('close', function () {
|
||||
setParam(null);
|
||||
if (lastTrigger) lastTrigger.focus();
|
||||
});
|
||||
|
||||
var initial = <%- JSON.stringify(openDay) %>;
|
||||
if (initial) {
|
||||
var cell = document.querySelector('[data-day="' + initial + '"]');
|
||||
lastTrigger = cell;
|
||||
open('/kegiatan/<%= k.id %>/hari/' + initial, initial);
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
<%- include('partials/foot') %>
|
||||
@@ -0,0 +1,144 @@
|
||||
<%- include('partials/head') %>
|
||||
<%
|
||||
var kalender = '/kegiatan/' + k.id + '?bulan=' + String(v.tanggal).slice(0, 7) + '&hari=' + v.tanggal;
|
||||
%>
|
||||
<div class="form-page">
|
||||
<section class="page-hero">
|
||||
<nav class="crumbs">
|
||||
<a href="/kegiatan/<%= k.id %>"><%= k.nama %></a> /
|
||||
<% if (log) { %><a href="/log/<%= log.id %>">Laporan</a> / <span>Ubah</span><% } else { %><span>Laporan baru</span><% } %>
|
||||
</nav>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow"><%= log ? 'Ubah laporan harian' : 'Laporan harian baru' %></span>
|
||||
<h1><%= log ? (log.judul || 'Laporan tanpa judul') : fmtDate(v.tanggal) %></h1>
|
||||
<p class="sub"><%= k.nama %></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<form class="card stack form-narrow" method="post" enctype="multipart/form-data"
|
||||
action="<%= log ? '/log/' + log.id : '/kegiatan/' + k.id + '/log' %>">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
|
||||
<% if (log) { %>
|
||||
<div class="field">
|
||||
<label for="tanggal">Tanggal kegiatan</label>
|
||||
<input type="date" id="tanggal" name="tanggal" value="<%= v.tanggal %>" max="<%= today %>" required
|
||||
aria-invalid="<%= errors.tanggal ? 'true' : 'false' %>">
|
||||
<% if (errors.tanggal) { %><span class="err"><%= errors.tanggal %></span><% } %>
|
||||
</div>
|
||||
<% } else { %>
|
||||
<input type="hidden" name="tanggal" value="<%= v.tanggal %>">
|
||||
<div class="date-chip">
|
||||
<span class="date-chip-icon" aria-hidden="true">
|
||||
<span><%= Number(String(v.tanggal).slice(8, 10)) %></span>
|
||||
</span>
|
||||
<span class="date-chip-text">
|
||||
<small>Tanggal laporan (dipilih dari kalender)</small>
|
||||
<strong><%= fmtDate(v.tanggal) %></strong>
|
||||
</span>
|
||||
<a class="btn btn-sm" href="/kegiatan/<%= k.id %>?bulan=<%= String(v.tanggal).slice(0, 7) %>">Ganti tanggal</a>
|
||||
</div>
|
||||
<% if (errors.tanggal) { %><span class="err"><%= errors.tanggal %></span><% } %>
|
||||
<% } %>
|
||||
|
||||
<div class="field">
|
||||
<label for="judul">Judul <span class="opt">(opsional)</span></label>
|
||||
<input id="judul" name="judul" value="<%= v.judul || '' %>" maxlength="150" placeholder="mis. Survei lokasi hari ke-3">
|
||||
<% if (errors.judul) { %><span class="err"><%= errors.judul %></span><% } %>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label for="deskripsi">Deskripsi kegiatan</label>
|
||||
<textarea id="deskripsi" name="deskripsi" rows="8" maxlength="<%= MAX_DESC %>" required
|
||||
aria-invalid="<%= errors.deskripsi ? 'true' : 'false' %>"><%= v.deskripsi %></textarea>
|
||||
<span class="hint">Ceritakan apa yang dikerjakan tim, hasil, dan kendala hari itu.</span>
|
||||
<% if (errors.deskripsi) { %><span class="err"><%= errors.deskripsi %></span><% } %>
|
||||
</div>
|
||||
|
||||
<fieldset class="doc-box">
|
||||
<legend>Dokumentasi <span class="opt">(opsional)</span></legend>
|
||||
|
||||
<% if (images.length) { %>
|
||||
<div class="field">
|
||||
<span class="field-label">Gambar saat ini</span>
|
||||
<div class="img-edit-grid">
|
||||
<% images.forEach(function (img) { %>
|
||||
<label class="img-edit">
|
||||
<img src="/gambar/<%= img.id %>" alt="<%= img.original_name || '' %>">
|
||||
<span><input type="checkbox" name="hapus_gambar" value="<%= img.id %>"> Hapus</span>
|
||||
</label>
|
||||
<% }) %>
|
||||
</div>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div class="field">
|
||||
<label for="gambar">Unggah gambar</label>
|
||||
<input type="file" id="gambar" name="gambar" accept="image/jpeg,image/png,image/webp,image/gif" multiple
|
||||
aria-describedby="gambar-hint">
|
||||
<span class="hint" id="gambar-hint">Maksimal <%= MAX_FILES %> gambar, masing-masing <strong>≤ <%= MAX_SIZE_MB %> MB</strong> (JPG, PNG, WEBP, GIF).</span>
|
||||
<div id="size-warn" class="size-warn" role="alert" hidden></div>
|
||||
<% if (errors.gambar) { %><span class="err"><%= errors.gambar %></span><% } %>
|
||||
<div id="preview" class="img-preview"></div>
|
||||
</div>
|
||||
|
||||
<div class="doc-or"><span>atau / dan</span></div>
|
||||
|
||||
<div class="field">
|
||||
<label for="link_dokumentasi">Link Google Drive</label>
|
||||
<input type="url" id="link_dokumentasi" name="link_dokumentasi" value="<%= v.link_dokumentasi || '' %>" maxlength="500"
|
||||
placeholder="https://drive.google.com/…" aria-invalid="<%= errors.link_dokumentasi ? 'true' : 'false' %>">
|
||||
<span class="hint">Untuk foto/video berukuran besar. Pastikan akses folder diatur ke <em>"Siapa saja yang memiliki link"</em> agar dosen bisa membukanya.</span>
|
||||
<% if (errors.link_dokumentasi) { %><span class="err"><%= errors.link_dokumentasi %></span><% } %>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="form-actions">
|
||||
<button type="submit" class="btn btn-primary"><%= log ? 'Simpan perubahan' : 'Kirim laporan' %></button>
|
||||
<a class="btn btn-ghost" href="<%= log ? '/log/' + log.id : kalender %>">Batal</a>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var MAX = <%= MAX_SIZE_MB %> * 1024 * 1024;
|
||||
var MAX_FILES = <%= MAX_FILES %>;
|
||||
var input = document.getElementById('gambar');
|
||||
var box = document.getElementById('preview');
|
||||
var warn = document.getElementById('size-warn');
|
||||
var link = document.getElementById('link_dokumentasi');
|
||||
|
||||
input.addEventListener('change', function () {
|
||||
var keep = new DataTransfer();
|
||||
var tooBig = [];
|
||||
Array.prototype.forEach.call(input.files, function (f) {
|
||||
if (f.size > MAX) tooBig.push(f.name + ' (' + (f.size / 1048576).toFixed(1) + ' MB)');
|
||||
else if (keep.items.length < MAX_FILES) keep.items.add(f);
|
||||
});
|
||||
var dropped = input.files.length - keep.items.length - tooBig.length;
|
||||
input.files = keep.files;
|
||||
|
||||
var msgs = [];
|
||||
if (tooBig.length) {
|
||||
msgs.push('Tidak diunggah karena lebih dari <%= MAX_SIZE_MB %> MB: ' + tooBig.join(', ') +
|
||||
'. Unggah file tersebut ke Google Drive lalu tempel link-nya di bawah.');
|
||||
}
|
||||
if (dropped > 0) msgs.push('Hanya ' + MAX_FILES + ' gambar pertama yang dipakai.');
|
||||
warn.textContent = msgs.join(' ');
|
||||
warn.hidden = !msgs.length;
|
||||
if (tooBig.length) link.classList.add('pulse-field');
|
||||
|
||||
box.innerHTML = '';
|
||||
Array.prototype.forEach.call(input.files, function (f) {
|
||||
var img = document.createElement('img');
|
||||
img.src = URL.createObjectURL(f);
|
||||
img.alt = f.name;
|
||||
box.appendChild(img);
|
||||
});
|
||||
});
|
||||
})();
|
||||
</script>
|
||||
</div>
|
||||
<%- include('partials/foot') %>
|
||||
@@ -0,0 +1,93 @@
|
||||
<%- include('partials/head') %>
|
||||
<section class="page-hero">
|
||||
<nav class="crumbs">
|
||||
<a href="/kegiatan/<%= k.id %>?bulan=<%= log.tanggal.slice(0, 7) %>&hari=<%= log.tanggal %>"><%= k.nama %></a> /
|
||||
<span>Laporan <%= fmtDateShort(log.tanggal) %></span>
|
||||
</nav>
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow"><%= fmtDate(log.tanggal) %></span>
|
||||
<h1><%= log.judul || 'Laporan harian' %></h1>
|
||||
<p class="sub">
|
||||
Dilaporkan oleh <%= log.author_nama %> · <%= fmtDateTime(log.created_at) %>
|
||||
<% if (log.updated_at) { %> · diubah <%= fmtDateTime(log.updated_at) %><% } %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<a class="btn" href="/kegiatan/<%= k.id %>?bulan=<%= log.tanggal.slice(0, 7) %>&hari=<%= log.tanggal %>">Kembali ke kalender</a>
|
||||
<% if (canEdit) { %><a class="btn btn-primary" href="/log/<%= log.id %>/edit">Ubah laporan</a><% } %>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="log-layout">
|
||||
<article class="card log-detail">
|
||||
<h2>Deskripsi kegiatan</h2>
|
||||
<div class="prose"><%= log.deskripsi %></div>
|
||||
|
||||
<% if (images.length || log.link_dokumentasi) { %>
|
||||
<h2 class="mt">Dokumentasi</h2>
|
||||
<% } %>
|
||||
<% if (images.length) { %>
|
||||
<div class="gallery">
|
||||
<% images.forEach(function (img) { %>
|
||||
<a href="/gambar/<%= img.id %>" target="_blank" rel="noopener">
|
||||
<img src="/gambar/<%= img.id %>" alt="<%= img.original_name || 'Lampiran log' %>" loading="lazy">
|
||||
</a>
|
||||
<% }) %>
|
||||
</div>
|
||||
<% } %>
|
||||
<% if (log.link_dokumentasi) { %>
|
||||
<a class="drive-link" href="<%= log.link_dokumentasi %>" target="_blank" rel="noopener noreferrer">
|
||||
<svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>
|
||||
Buka dokumentasi di Google Drive <span aria-hidden="true">↗</span>
|
||||
</a>
|
||||
<% } %>
|
||||
|
||||
<% if (canEdit) { %>
|
||||
<details class="danger-zone log-delete">
|
||||
<summary class="btn btn-sm btn-danger-ghost">Hapus laporan…</summary>
|
||||
<form method="post" action="/log/<%= log.id %>/hapus" class="danger-pop">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<p>Laporan tanggal <strong><%= fmtDateShort(log.tanggal) %></strong> beserta gambar dan komentarnya akan dihapus permanen.</p>
|
||||
<button type="submit" class="btn btn-danger btn-sm">Hapus laporan ini</button>
|
||||
</form>
|
||||
</details>
|
||||
<% } %>
|
||||
</article>
|
||||
|
||||
<section class="card" id="komentar">
|
||||
<h2>Komentar (<%= comments.length %>)</h2>
|
||||
<% if (!comments.length) { %>
|
||||
<p class="muted small"><%= currentUser.role === 'dosen' ? 'Belum ada komentar. Berikan masukan untuk tim di bawah.' : 'Belum ada komentar dari dosen.' %></p>
|
||||
<% } %>
|
||||
<ul class="comments">
|
||||
<% comments.forEach(function (c) { %>
|
||||
<li class="comment" id="c<%= c.id %>">
|
||||
<div class="comment-head">
|
||||
<strong><%= c.nama %></strong>
|
||||
<span class="badge role-<%= c.role %>"><%= roleLabel(c.role) %></span>
|
||||
<span class="muted small"><%= fmtDateTime(c.created_at) %></span>
|
||||
<% if (c.user_id === currentUser.id || currentUser.role === 'admin') { %>
|
||||
<form method="post" action="/komentar/<%= c.id %>/hapus" class="comment-del">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<button type="submit" class="btn-link small" aria-label="Hapus komentar dari <%= c.nama %>">Hapus</button>
|
||||
</form>
|
||||
<% } %>
|
||||
</div>
|
||||
<div class="prose"><%= c.isi %></div>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
|
||||
<form method="post" action="/log/<%= log.id %>/komentar" class="stack">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<div class="field">
|
||||
<label for="isi"><%= currentUser.role === 'ketua' ? 'Balas komentar' : 'Tulis komentar' %></label>
|
||||
<textarea id="isi" name="isi" rows="3" maxlength="2000" required></textarea>
|
||||
</div>
|
||||
<div><button type="submit" class="btn btn-primary">Kirim komentar</button></div>
|
||||
</form>
|
||||
</section>
|
||||
</div>
|
||||
<%- include('partials/foot') %>
|
||||
@@ -0,0 +1,34 @@
|
||||
<%- include('partials/head') %>
|
||||
<div class="login">
|
||||
<div class="card auth">
|
||||
<div class="auth-side">
|
||||
<div class="auth-brand"><img src="/img/logo.png" alt="" width="48" height="48"><span class="eyebrow">Logharian</span></div>
|
||||
<h1>Log harian kegiatan mahasiswa</h1>
|
||||
<p>Catat progres tim setiap hari, dipantau langsung oleh dosen pembimbing.</p>
|
||||
<ul class="auth-list">
|
||||
<li>Ketua tim melaporkan kegiatan dengan deskripsi dan foto dokumentasi.</li>
|
||||
<li>Dosen membaca laporan dan memberi komentar.</li>
|
||||
<li>Operator mengelola akun dan kegiatan.</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="auth-form">
|
||||
<h2>Masuk</h2>
|
||||
<p class="muted small" style="margin-bottom:20px">Gunakan akun yang diberikan operator.</p>
|
||||
<% if (error) { %><div class="alert alert-error" role="alert"><%= error %></div><% } %>
|
||||
<form method="post" action="/login" class="stack">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<div class="field">
|
||||
<label for="username">Username</label>
|
||||
<input id="username" name="username" value="<%= username %>" autocomplete="username" required autofocus>
|
||||
</div>
|
||||
<div class="field">
|
||||
<label for="password">Password</label>
|
||||
<input id="password" name="password" type="password" autocomplete="current-password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary btn-block">Masuk</button>
|
||||
</form>
|
||||
<p class="muted small" style="margin-top:18px">Belum punya akun atau lupa password? Hubungi operator.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%- include('partials/foot') %>
|
||||
@@ -0,0 +1,3 @@
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,137 @@
|
||||
<%
|
||||
var STATUS = {
|
||||
filled: ['badge-ok', 'Sudah diisi'],
|
||||
missing: ['badge-danger', 'Belum diisi'],
|
||||
today: ['badge-warn', 'Hari ini belum diisi'],
|
||||
future: ['badge-off', 'Belum tiba'],
|
||||
outside: ['badge-off', 'Di luar periode kegiatan']
|
||||
};
|
||||
var st = STATUS[status];
|
||||
var jam = function (s) { return String(s).slice(11, 16); };
|
||||
var MAX_IMG = 4;
|
||||
var MAX_KOM = 2;
|
||||
%>
|
||||
<div class="day-panel">
|
||||
<header class="day-head">
|
||||
<span class="day-head-keg"><%= k.nama %></span>
|
||||
<h2 id="day-title"><%= fmtDate(tanggal) %></h2>
|
||||
<div class="day-head-meta">
|
||||
<span class="badge <%= st[0] %>"><%= st[1] %></span>
|
||||
<% if (logs.length) { %><span><%= logs.length %> laporan dari <%= k.ketua_nama %></span><% } %>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div class="day-body">
|
||||
<% if (!logs.length) { %>
|
||||
<div class="day-empty">
|
||||
<% if (status === 'missing' || status === 'today') { %>
|
||||
<p><strong><%= k.ketua_nama %></strong> belum mengirim laporan untuk tanggal ini.</p>
|
||||
<% } else { %>
|
||||
<p>Tidak ada laporan pada tanggal ini.</p>
|
||||
<% } %>
|
||||
<% if (canReport) { %>
|
||||
<a class="btn btn-primary" href="/kegiatan/<%= k.id %>/log/baru?tanggal=<%= tanggal %>">Tulis laporan untuk tanggal ini</a>
|
||||
<% } %>
|
||||
</div>
|
||||
<% } else if (canReport) { %>
|
||||
<div class="day-add">
|
||||
<span>Ada kegiatan lain di tanggal ini?</span>
|
||||
<a class="btn btn-sm btn-primary" href="/kegiatan/<%= k.id %>/log/baru?tanggal=<%= tanggal %>">+ Tulis laporan tambahan</a>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<% if (logs.length > 1) { %>
|
||||
<nav class="day-index" aria-label="Lompat ke laporan">
|
||||
<% logs.forEach(function (l, i) { %>
|
||||
<a href="#lap-<%= l.id %>">
|
||||
<span class="day-num"><%= i + 1 %></span>
|
||||
<span class="day-index-text">
|
||||
<span class="day-index-time">Pukul <%= jam(l.created_at) %></span>
|
||||
<span class="day-index-title"><%= l.judul || 'Laporan tanpa judul' %></span>
|
||||
</span>
|
||||
</a>
|
||||
<% }) %>
|
||||
</nav>
|
||||
<% } %>
|
||||
|
||||
<% logs.forEach(function (l, i) {
|
||||
var long = l.deskripsi.length > 260 || l.deskripsi.split('\n').length > 4;
|
||||
var shownImg = l.images.slice(0, MAX_IMG);
|
||||
var moreImg = l.images.length - shownImg.length;
|
||||
var shownKom = l.comments.slice(-MAX_KOM);
|
||||
%>
|
||||
<article class="day-log" id="lap-<%= l.id %>">
|
||||
<a class="day-log-head" href="/log/<%= l.id %>">
|
||||
<span class="day-num"><%= i + 1 %></span>
|
||||
<span class="day-log-titles">
|
||||
<span class="day-log-time">
|
||||
<%= logs.length > 1 ? 'Laporan ' + (i + 1) + ' dari ' + logs.length + ' · ' : '' %>Pukul <%= jam(l.created_at) %><% if (l.updated_at) { %> · diubah<% } %>
|
||||
</span>
|
||||
<span class="day-log-title"><%= l.judul || 'Laporan tanpa judul' %></span>
|
||||
</span>
|
||||
<span class="day-log-open">Buka laporan
|
||||
<svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M5 12h14M13 6l6 6-6 6"/></svg>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
<div class="day-log-body">
|
||||
<div class="day-desc<%= long ? ' clamp' : '' %>"><%= l.deskripsi %></div>
|
||||
<% if (l.link_dokumentasi) { %>
|
||||
<a class="drive-link" href="<%= l.link_dokumentasi %>" target="_blank" rel="noopener noreferrer">
|
||||
<svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"/></svg>
|
||||
Dokumentasi di Google Drive <span aria-hidden="true">↗</span>
|
||||
</a>
|
||||
<% } %>
|
||||
|
||||
<% if (l.images.length) { %>
|
||||
<div class="day-gallery">
|
||||
<% shownImg.forEach(function (img, j) { %>
|
||||
<a href="<%= (moreImg > 0 && j === shownImg.length - 1) ? '/log/' + l.id : '/gambar/' + img.id %>"
|
||||
<%- (moreImg > 0 && j === shownImg.length - 1) ? '' : 'target="_blank" rel="noopener"' %>
|
||||
class="<%= (moreImg > 0 && j === shownImg.length - 1) ? 'has-more' : '' %>">
|
||||
<img src="/gambar/<%= img.id %>" alt="<%= img.original_name || 'Lampiran log' %>" loading="lazy">
|
||||
<% if (moreImg > 0 && j === shownImg.length - 1) { %><span class="more-overlay">+<%= moreImg %></span><% } %>
|
||||
</a>
|
||||
<% }) %>
|
||||
</div>
|
||||
<% } %>
|
||||
|
||||
<div class="day-stats">
|
||||
<span><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="9" cy="10" r="2"/><path d="m21 17-5-5-9 8"/></svg><%= l.images.length ? l.images.length + ' gambar' : 'Tanpa gambar' %></span>
|
||||
<span><svg class="ic" viewBox="0 0 24 24" aria-hidden="true"><path d="M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z"/></svg><%= l.comments.length %> komentar</span>
|
||||
<% if (canEdit) { %><a class="day-edit" href="/log/<%= l.id %>/edit">Ubah laporan</a><% } %>
|
||||
</div>
|
||||
|
||||
<details class="day-comments"<%= l.comments.length ? ' open' : '' %>>
|
||||
<summary><%= l.comments.length ? 'Komentar' : 'Beri komentar' %></summary>
|
||||
<% if (l.comments.length > MAX_KOM) { %>
|
||||
<a class="day-more" href="/log/<%= l.id %>#komentar">Lihat semua <%= l.comments.length %> komentar →</a>
|
||||
<% } %>
|
||||
<% if (shownKom.length) { %>
|
||||
<ul class="comments">
|
||||
<% shownKom.forEach(function (c) { %>
|
||||
<li class="comment">
|
||||
<div class="comment-head">
|
||||
<strong><%= c.nama %></strong>
|
||||
<span class="badge role-<%= c.role %>"><%= roleLabel(c.role) %></span>
|
||||
<span class="muted small"><%= fmtDateTime(c.created_at) %></span>
|
||||
</div>
|
||||
<div class="prose"><%= c.isi %></div>
|
||||
</li>
|
||||
<% }) %>
|
||||
</ul>
|
||||
<% } %>
|
||||
<form method="post" action="/log/<%= l.id %>/komentar" class="comment-form">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<input type="hidden" name="kembali" value="<%= kembali %>">
|
||||
<label for="isi-<%= l.id %>" class="sr-only">Komentar untuk laporan <%= i + 1 %></label>
|
||||
<textarea id="isi-<%= l.id %>" name="isi" rows="2" maxlength="2000" required
|
||||
placeholder="<%= currentUser.role === 'ketua' ? 'Balas komentar dosen…' : 'Tulis masukan untuk tim…' %>"></textarea>
|
||||
<button type="submit" class="btn btn-sm">Kirim komentar</button>
|
||||
</form>
|
||||
</details>
|
||||
</div>
|
||||
</article>
|
||||
<% }) %>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,43 @@
|
||||
<!doctype html>
|
||||
<html lang="id">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title><%= typeof title !== 'undefined' ? title + ' · ' : '' %>Logharian</title>
|
||||
<link rel="icon" href="/favicon.ico" sizes="any">
|
||||
<link rel="icon" href="/favicon.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="/img/apple-touch-icon.png">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap">
|
||||
<link rel="stylesheet" href="/css/style.css?v=<%= assetVersion %>">
|
||||
</head>
|
||||
<body>
|
||||
<% if (currentUser) { %>
|
||||
<header class="topbar">
|
||||
<div class="wrap topbar-inner">
|
||||
<a class="brand" href="/"><img class="brand-logo" src="/img/logo.png" alt="" width="38" height="38">Logharian</a>
|
||||
<nav class="nav" aria-label="Menu utama">
|
||||
<a href="/" class="<%= path === '/' ? 'active' : '' %>">Dashboard</a>
|
||||
<% if (currentUser.role === 'admin') { %>
|
||||
<a href="/admin/kegiatan" class="<%= path.startsWith('/admin/kegiatan') || path.startsWith('/kegiatan') ? 'active' : '' %>">Kegiatan</a>
|
||||
<a href="/admin/users" class="<%= path.startsWith('/admin/users') ? 'active' : '' %>">Pengguna</a>
|
||||
<% } %>
|
||||
<a href="/akun" class="<%= path === '/akun' ? 'active' : '' %>">Akun</a>
|
||||
</nav>
|
||||
<div class="who">
|
||||
<span class="avatar" aria-hidden="true"><%= currentUser.nama.split(/\s+/).filter(function (w) { return /^[A-Za-z]/.test(w); }).slice(0, 2).map(function (w) { return w[0]; }).join('').toUpperCase() %></span>
|
||||
<span class="who-name"><%= currentUser.nama %></span>
|
||||
<span class="badge role-<%= currentUser.role %>"><%= roleLabel(currentUser.role) %></span>
|
||||
<form method="post" action="/logout">
|
||||
<input type="hidden" name="_csrf" value="<%= csrfToken %>">
|
||||
<button type="submit" class="btn btn-ghost btn-sm">Keluar</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<% } %>
|
||||
<main class="wrap main">
|
||||
<% flashes.forEach(function (f) { %>
|
||||
<div class="alert alert-<%= f.type %>" role="status"><%= f.msg %></div>
|
||||
<% }) %>
|
||||
Reference in New Issue
Block a user