Initial commit

This commit is contained in:
cw
2026-06-11 12:30:23 +07:00
commit 2676f3a61c
70 changed files with 9867 additions and 0 deletions
+510
View File
@@ -0,0 +1,510 @@
/* ============================================================
SINERGI — Main Stylesheet
Sistem Informasi Geografis Penanganan Kemiskinan
Kota Pontianak
============================================================ */
/* --- CSS Variables --- */
:root {
--clr-primary: #1a3a5c;
--clr-primary-d: #112845;
--clr-primary-l: #2a5c8e;
--clr-accent: #e8a020;
--clr-accent-d: #c87d10;
--clr-success: #16a34a;
--clr-danger: #dc2626;
--clr-warning: #d97706;
--clr-info: #0284c7;
--clr-bg: #f0f4f8;
--clr-surface: #ffffff;
--clr-border: #d1dce8;
--clr-text: #1e2d3d;
--clr-text-muted: #5a6e82;
--clr-sidebar-bg: #112845;
--clr-sidebar-hover: rgba(255,255,255,0.08);
--clr-sidebar-active: rgba(232,160,32,0.18);
--radius-sm: 6px;
--radius-md: 10px;
--radius-lg: 16px;
--shadow-sm: 0 1px 4px rgba(0,0,0,0.08);
--shadow-md: 0 4px 16px rgba(0,0,0,0.10);
--shadow-lg: 0 8px 32px rgba(0,0,0,0.14);
--sidebar-w: 260px;
--topbar-h: 62px;
--font-main: 'Inter', system-ui, -apple-system, sans-serif;
--font-mono: 'JetBrains Mono', 'Fira Code', monospace;
--transition: all 0.2s ease;
}
/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
font-family: var(--font-main);
background: var(--clr-bg);
color: var(--clr-text);
line-height: 1.6;
-webkit-font-smoothing: antialiased;
}
a { color: var(--clr-primary-l); text-decoration: none; }
a:hover { color: var(--clr-accent); }
img { max-width: 100%; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
/* --- Layout: App Shell --- */
.app-shell {
display: grid;
grid-template-columns: var(--sidebar-w) 1fr;
grid-template-rows: var(--topbar-h) 1fr;
min-height: 100vh;
}
/* --- Sidebar --- */
.sidebar {
grid-row: 1 / -1;
background: var(--clr-sidebar-bg);
color: #fff;
display: flex;
flex-direction: column;
overflow-y: auto;
position: sticky;
top: 0;
height: 100vh;
z-index: 100;
transition: var(--transition);
}
.sidebar-brand {
padding: 20px 20px 16px;
border-bottom: 1px solid rgba(255,255,255,0.08);
display: flex;
align-items: center;
gap: 12px;
}
.sidebar-brand-icon {
width: 40px; height: 40px;
background: var(--clr-accent);
border-radius: var(--radius-sm);
display: flex; align-items: center; justify-content: center;
font-size: 20px; flex-shrink: 0;
}
.sidebar-brand-text h1 {
font-size: 1.1rem; font-weight: 700; color: #fff; line-height: 1.2;
}
.sidebar-brand-text p { font-size: 0.68rem; color: rgba(255,255,255,0.5); line-height: 1.3; }
.sidebar-section { padding: 20px 12px 4px; }
.sidebar-section-title {
font-size: 0.65rem; font-weight: 700;
text-transform: uppercase; letter-spacing: 0.1em;
color: rgba(255,255,255,0.35);
padding: 0 8px; margin-bottom: 4px;
}
.sidebar-nav { list-style: none; }
.sidebar-nav li { margin-bottom: 2px; }
.sidebar-nav a {
display: flex; align-items: center; gap: 10px;
padding: 9px 12px; border-radius: var(--radius-sm);
color: rgba(255,255,255,0.78); font-size: 0.875rem; font-weight: 500;
transition: var(--transition); cursor: pointer;
}
.sidebar-nav a:hover { background: var(--clr-sidebar-hover); color: #fff; }
.sidebar-nav a.active {
background: var(--clr-sidebar-active);
color: var(--clr-accent); font-weight: 600;
border-left: 3px solid var(--clr-accent);
}
.sidebar-nav a .nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 1rem; }
.sidebar-nav a .nav-badge {
margin-left: auto; background: var(--clr-danger);
color: #fff; font-size: 0.65rem; font-weight: 700;
padding: 1px 6px; border-radius: 20px; min-width: 18px; text-align: center;
}
.sidebar-footer {
margin-top: auto; padding: 16px 12px;
border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-user {
display: flex; align-items: center; gap: 10px;
padding: 8px 10px; border-radius: var(--radius-sm);
background: rgba(255,255,255,0.06);
}
.sidebar-user-avatar {
width: 34px; height: 34px; border-radius: 50%;
background: var(--clr-primary-l);
display: flex; align-items: center; justify-content: center;
font-weight: 700; font-size: 0.85rem; color: #fff; flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name { font-size: 0.8rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role { font-size: 0.68rem; color: rgba(255,255,255,0.45); }
.sidebar-logout { color: rgba(255,255,255,0.5); font-size: 1rem; cursor: pointer; transition: var(--transition); }
.sidebar-logout:hover { color: var(--clr-danger); }
/* --- Topbar --- */
.topbar {
grid-column: 2;
background: var(--clr-surface);
border-bottom: 1px solid var(--clr-border);
display: flex; align-items: center; gap: 16px;
padding: 0 28px;
box-shadow: var(--shadow-sm);
position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1rem; font-weight: 600; color: var(--clr-text); flex: 1; }
.topbar-breadcrumb { font-size: 0.8rem; color: var(--clr-text-muted); }
.topbar-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.topbar-time { font-size: 0.8rem; color: var(--clr-text-muted); font-family: var(--font-mono); }
/* --- Main Content --- */
.main-content {
grid-column: 2;
padding: 24px 28px;
overflow-x: hidden;
}
/* --- Cards --- */
.card {
background: var(--clr-surface);
border-radius: var(--radius-md);
box-shadow: var(--shadow-sm);
border: 1px solid var(--clr-border);
overflow: hidden;
}
.card-header {
padding: 16px 20px;
border-bottom: 1px solid var(--clr-border);
display: flex; align-items: center; gap: 10px;
}
.card-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--clr-text); }
.card-header .card-icon { font-size: 1.1rem; }
.card-header .card-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 20px; }
.card-body.no-pad { padding: 0; }
/* --- Stat Cards --- */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
gap: 16px;
margin-bottom: 24px;
}
.stat-card {
background: var(--clr-surface);
border-radius: var(--radius-md);
padding: 18px 20px;
border: 1px solid var(--clr-border);
box-shadow: var(--shadow-sm);
display: flex; align-items: flex-start; gap: 14px;
transition: var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.stat-card-icon {
width: 44px; height: 44px; border-radius: var(--radius-sm);
display: flex; align-items: center; justify-content: center;
font-size: 1.3rem; flex-shrink: 0;
}
.stat-card-icon.blue { background: #dbeafe; color: #1d4ed8; }
.stat-card-icon.red { background: #fee2e2; color: #dc2626; }
.stat-card-icon.orange { background: #ffedd5; color: #c2410c; }
.stat-card-icon.yellow { background: #fef9c3; color: #a16207; }
.stat-card-icon.green { background: #dcfce7; color: #15803d; }
.stat-card-icon.purple { background: #f3e8ff; color: #7e22ce; }
.stat-card-icon.teal { background: #ccfbf1; color: #0f766e; }
.stat-card-icon.gray { background: #f1f5f9; color: #475569; }
.stat-card-body { flex: 1; min-width: 0; }
.stat-card-value { font-size: 1.75rem; font-weight: 700; line-height: 1; color: var(--clr-text); }
.stat-card-label { font-size: 0.78rem; color: var(--clr-text-muted); margin-top: 3px; }
.stat-card-sub { font-size: 0.72rem; color: var(--clr-text-muted); margin-top: 6px; }
/* --- Map Container --- */
.map-container {
border-radius: var(--radius-md);
overflow: hidden;
border: 1px solid var(--clr-border);
box-shadow: var(--shadow-sm);
position: relative;
}
.map-container #map, .map-container .map-inner {
width: 100%; border-radius: 0;
}
/* --- Dashboard Grid --- */
.dashboard-grid {
display: grid;
grid-template-columns: 1fr 340px;
gap: 20px;
}
.dashboard-grid.full { grid-template-columns: 1fr; }
@media (max-width: 1100px) {
.dashboard-grid { grid-template-columns: 1fr; }
}
/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
background: #f8fafc; color: var(--clr-text-muted);
font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
letter-spacing: 0.05em; padding: 10px 14px;
border-bottom: 1px solid var(--clr-border); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #f8fafc; }
/* --- Badges --- */
.badge {
display: inline-flex; align-items: center; justify-content: center;
padding: 2px 9px; border-radius: 20px;
font-size: 0.7rem; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap;
}
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-orange { background: #ffedd5; color: #c2410c; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
/* --- Buttons --- */
.btn {
display: inline-flex; align-items: center; gap: 6px;
padding: 8px 16px; border-radius: var(--radius-sm);
font-size: 0.875rem; font-weight: 600; cursor: pointer;
border: none; transition: var(--transition); white-space: nowrap;
}
.btn-primary { background: var(--clr-primary); color: #fff; }
.btn-primary:hover { background: var(--clr-primary-l); }
.btn-accent { background: var(--clr-accent); color: var(--clr-primary-d); }
.btn-accent:hover { background: var(--clr-accent-d); }
.btn-success { background: var(--clr-success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--clr-danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--clr-text-muted); border: 1px solid var(--clr-border); }
.btn-ghost:hover { background: var(--clr-bg); color: var(--clr-text); }
.btn-sm { padding: 5px 11px; font-size: 0.78rem; }
.btn-icon { padding: 7px; }
/* --- Forms --- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--clr-text); margin-bottom: 5px; }
.form-label .required { color: var(--clr-danger); margin-left: 2px; }
.form-control {
width: 100%; padding: 9px 13px;
border: 1px solid var(--clr-border); border-radius: var(--radius-sm);
background: var(--clr-surface); color: var(--clr-text); font-size: 0.875rem;
transition: var(--transition);
}
.form-control:focus { outline: none; border-color: var(--clr-primary-l); box-shadow: 0 0 0 3px rgba(42,92,142,0.12); }
.form-hint { font-size: 0.75rem; color: var(--clr-text-muted); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
/* --- Flash Messages --- */
.flash-message {
display: flex; align-items: flex-start; gap: 10px;
padding: 12px 16px; border-radius: var(--radius-sm);
margin-bottom: 20px; font-size: 0.875rem; font-weight: 500;
}
.flash-success { background: #dcfce7; color: #15803d; border-left: 4px solid #16a34a; }
.flash-error { background: #fee2e2; color: #dc2626; border-left: 4px solid #dc2626; }
.flash-warning { background: #fef9c3; color: #a16207; border-left: 4px solid #d97706; }
.flash-info { background: #dbeafe; color: #1d4ed8; border-left: 4px solid #0284c7; }
/* --- Priority Score Bar --- */
.priority-bar { position: relative; height: 6px; background: #e2e8f0; border-radius: 3px; overflow: hidden; }
.priority-bar-fill { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.priority-bar-fill.high { background: var(--clr-danger); }
.priority-bar-fill.medium { background: var(--clr-warning); }
.priority-bar-fill.low { background: var(--clr-success); }
/* --- Map Legend --- */
.map-legend {
position: absolute; bottom: 28px; left: 12px; z-index: 1000;
background: var(--clr-surface); border-radius: var(--radius-sm);
box-shadow: var(--shadow-md); padding: 12px 14px;
border: 1px solid var(--clr-border); min-width: 160px;
}
.map-legend h4 { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--clr-text-muted); margin-bottom: 8px; }
.map-legend-item { display: flex; align-items: center; gap: 8px; font-size: 0.78rem; margin-bottom: 5px; }
.map-legend-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }
.legend-dot-ekstrem { background: #dc2626; }
.legend-dot-miskin { background: #ea580c; }
.legend-dot-rentan { background: #ca8a04; }
.legend-dot-ri { background: #16a34a; }
.legend-dot-blind { background: #7c3aed; }
.legend-dot-laporan { background: #0284c7; }
/* --- Tabs --- */
.tabs { display: flex; gap: 2px; border-bottom: 2px solid var(--clr-border); margin-bottom: 20px; }
.tab-btn {
padding: 9px 18px; font-size: 0.875rem; font-weight: 600;
color: var(--clr-text-muted); border: none; background: none; cursor: pointer;
border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition);
}
.tab-btn.active { color: var(--clr-primary); border-bottom-color: var(--clr-primary); }
.tab-btn:hover:not(.active) { color: var(--clr-text); }
/* --- Filters --- */
.filters-bar {
display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
margin-bottom: 18px; padding: 14px 16px;
background: var(--clr-surface); border: 1px solid var(--clr-border);
border-radius: var(--radius-sm);
}
.filters-bar select, .filters-bar input {
padding: 7px 11px; border: 1px solid var(--clr-border); border-radius: var(--radius-sm);
background: var(--clr-surface); font-size: 0.85rem; color: var(--clr-text);
}
/* --- Modal --- */
.modal-overlay {
position: fixed; inset: 0; background: rgba(0,0,0,0.48);
z-index: 1000; display: flex; align-items: center; justify-content: center;
padding: 20px; opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.modal-overlay.active { opacity: 1; pointer-events: all; }
.modal {
background: var(--clr-surface); border-radius: var(--radius-lg);
box-shadow: var(--shadow-lg); width: 100%; max-width: 560px;
max-height: 90vh; overflow-y: auto;
transform: translateY(20px); transition: transform 0.2s;
}
.modal-overlay.active .modal { transform: translateY(0); }
.modal-header {
padding: 20px 24px; border-bottom: 1px solid var(--clr-border);
display: flex; align-items: center; justify-content: space-between;
}
.modal-header h3 { font-size: 1rem; font-weight: 700; }
.modal-close { cursor: pointer; color: var(--clr-text-muted); font-size: 1.3rem; border: none; background: none; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--clr-border); display: flex; justify-content: flex-end; gap: 10px; }
/* --- Empty State --- */
.empty-state {
text-align: center; padding: 48px 24px; color: var(--clr-text-muted);
}
.empty-state-icon { font-size: 3rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; }
.empty-state p { font-size: 0.875rem; }
/* --- Pagination --- */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 20px; }
.page-btn {
padding: 6px 11px; border-radius: var(--radius-sm);
font-size: 0.82rem; font-weight: 600; cursor: pointer;
border: 1px solid var(--clr-border); background: var(--clr-surface); color: var(--clr-text-muted);
transition: var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--clr-primary); color: #fff; border-color: var(--clr-primary); }
/* --- Chart Container --- */
.chart-wrap { position: relative; height: 240px; }
/* --- Sidebar list panel --- */
.sidebar-panel {
height: 100%; overflow-y: auto;
border-left: 1px solid var(--clr-border);
background: var(--clr-surface);
}
.sidebar-panel-header {
padding: 16px 20px; border-bottom: 1px solid var(--clr-border);
position: sticky; top: 0; background: var(--clr-surface); z-index: 10;
}
.sidebar-panel-item {
padding: 12px 20px; border-bottom: 1px solid #f1f5f9; cursor: pointer;
transition: var(--transition);
}
.sidebar-panel-item:hover { background: #f8fafc; }
.sidebar-panel-item.active { background: #eff6ff; border-left: 3px solid var(--clr-primary); }
.sidebar-panel-item h4 { font-size: 0.85rem; font-weight: 600; }
.sidebar-panel-item p { font-size: 0.75rem; color: var(--clr-text-muted); margin-top: 2px; }
/* --- Public layout --- */
.public-nav {
position: sticky; top: 0; z-index: 200;
background: var(--clr-primary-d); box-shadow: var(--shadow-md);
padding: 0 32px; height: 64px;
display: flex; align-items: center; gap: 24px;
}
.public-nav-brand {
display: flex; align-items: center; gap: 10px; color: #fff;
font-weight: 800; font-size: 1.15rem; text-decoration: none;
}
.public-nav-brand span { color: var(--clr-accent); }
.public-nav-links { display: flex; gap: 4px; margin-left: auto; }
.public-nav-links a {
color: rgba(255,255,255,0.78); padding: 7px 14px; border-radius: var(--radius-sm);
font-size: 0.875rem; font-weight: 500; transition: var(--transition);
}
.public-nav-links a:hover { background: rgba(255,255,255,0.1); color: #fff; }
.public-nav-links a.btn-login {
background: var(--clr-accent); color: var(--clr-primary-d);
font-weight: 700; padding: 7px 18px;
}
.public-footer {
background: var(--clr-primary-d); color: rgba(255,255,255,0.55);
padding: 32px; text-align: center; font-size: 0.82rem; margin-top: 60px;
}
/* --- Login Page --- */
.login-page {
min-height: 100vh; display: flex;
background: linear-gradient(135deg, var(--clr-primary-d) 0%, var(--clr-primary) 60%, var(--clr-primary-l) 100%);
}
.login-left {
flex: 1; display: flex; flex-direction: column;
align-items: center; justify-content: center; padding: 48px;
color: #fff; display: none;
}
@media (min-width: 900px) { .login-left { display: flex; } }
.login-right {
width: 100%; max-width: 440px; background: #fff;
display: flex; flex-direction: column; justify-content: center;
padding: 48px; box-shadow: var(--shadow-lg);
}
.login-logo { font-size: 3rem; font-weight: 900; letter-spacing: -0.02em; }
.login-logo span { color: var(--clr-accent); }
.login-tagline { font-size: 0.875rem; color: rgba(255,255,255,0.65); margin-top: 8px; max-width: 360px; text-align: center; line-height: 1.5; }
.login-form-title { font-size: 1.5rem; font-weight: 800; color: var(--clr-text); margin-bottom: 6px; }
.login-form-sub { font-size: 0.85rem; color: var(--clr-text-muted); margin-bottom: 28px; }
/* --- Misc --- */
.text-muted { color: var(--clr-text-muted); }
.text-sm { font-size: 0.82rem; }
.text-xs { font-size: 0.72rem; }
.font-bold { font-weight: 700; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-auto { margin-top: auto; }
.w-full { width: 100%; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.section-title { font-size: 1.05rem; font-weight: 700; color: var(--clr-text); margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.divider { border: none; border-top: 1px solid var(--clr-border); margin: 20px 0; }
/* --- Scrollbar --- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
/* --- Responsive --- */
@media (max-width: 900px) {
.app-shell { grid-template-columns: 1fr; }
.sidebar { display: none; }
.topbar, .main-content { grid-column: 1; }
.stats-grid { grid-template-columns: repeat(2, 1fr); }
.form-row.cols-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
.main-content { padding: 16px; }
.topbar { padding: 0 16px; }
.stats-grid { grid-template-columns: 1fr 1fr; }
.form-row.cols-2, .form-row.cols-3 { grid-template-columns: 1fr; }
}
View File
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 714 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 714 KiB

View File
View File
View File
+656
View File
@@ -0,0 +1,656 @@
// public/js/app.js — SINERGI Core JavaScript v1.1
// Fix: Auto-zoom ke Kota Pontianak + auto-fitBounds setelah data dimuat
/* ============================================================
KONSTANTA KOTA PONTIANAK
============================================================ */
const PONTIANAK = {
lat: -0.0263,
lng: 109.3425,
zoom: 13,
// Bounding box seluruh Kota Pontianak (untuk fitBounds fallback)
bounds: [[-0.115, 109.280], [0.055, 109.420]]
};
/* ============================================================
UTILITY FUNCTIONS
============================================================ */
const App = {
url: document.querySelector('meta[name="app-url"]')?.content || '',
formatNumber(n) {
return Number(n || 0).toLocaleString('id-ID');
},
formatRupiah(n) {
return 'Rp ' + Number(n || 0).toLocaleString('id-ID');
},
formatTanggal(str) {
if (!str) return '-';
const bulan = ['','Januari','Februari','Maret','April','Mei','Juni',
'Juli','Agustus','September','Oktober','November','Desember'];
const d = new Date(str);
return `${d.getDate()} ${bulan[d.getMonth() + 1]} ${d.getFullYear()}`;
},
async fetchJSON(url) {
try {
const r = await fetch(url);
return await r.json();
} catch (e) {
console.error('Fetch error:', url, e);
return null;
}
},
showModal(id) {
const el = document.getElementById(id);
if (el) { el.classList.add('active'); document.body.style.overflow = 'hidden'; }
},
hideModal(id) {
const el = document.getElementById(id);
if (el) { el.classList.remove('active'); document.body.style.overflow = ''; }
},
confirmDelete(url, msg = 'Apakah Anda yakin ingin menghapus data ini?') {
if (!confirm(msg)) return false;
const form = document.createElement('form');
form.method = 'POST';
form.action = url;
const csrf = document.querySelector('meta[name="csrf-token"]')?.content || '';
form.innerHTML = `<input type="hidden" name="_token" value="${csrf}">`;
document.body.appendChild(form);
form.submit();
},
startClock() {
const el = document.getElementById('live-clock');
if (!el) return;
const update = () => {
const now = new Date();
el.textContent = now.toLocaleTimeString('id-ID', {
hour: '2-digit', minute: '2-digit', second: '2-digit'
});
};
update();
setInterval(update, 1000);
},
initFlash() {
document.querySelectorAll('.flash-message').forEach(el => {
setTimeout(() => {
el.style.transition = 'opacity 0.5s, max-height 0.5s';
el.style.opacity = '0';
el.style.maxHeight = '0';
el.style.overflow = 'hidden';
setTimeout(() => el.remove(), 500);
}, 4500);
});
},
initTableSearch(inputId, tableId) {
const input = document.getElementById(inputId);
const table = document.getElementById(tableId);
if (!input || !table) return;
input.addEventListener('input', () => {
const q = input.value.toLowerCase();
table.querySelectorAll('tbody tr').forEach(row => {
row.style.display = row.textContent.toLowerCase().includes(q) ? '' : 'none';
});
});
},
init() {
this.startClock();
this.initFlash();
// Close modal on overlay click
document.querySelectorAll('.modal-overlay').forEach(overlay => {
overlay.addEventListener('click', e => {
if (e.target === overlay) overlay.classList.remove('active');
});
});
// Close modal on ESC
document.addEventListener('keydown', e => {
if (e.key === 'Escape') {
document.querySelectorAll('.modal-overlay.active')
.forEach(m => m.classList.remove('active'));
document.body.style.overflow = '';
}
});
// Sidebar active link highlight
const path = window.location.pathname;
document.querySelectorAll('.sidebar-nav a').forEach(a => {
const href = a.getAttribute('href');
if (href && href !== '/' && path.startsWith(href)) {
a.classList.add('active');
}
});
}
};
/* ============================================================
GIS MAP MODULE — dengan auto-zoom ke Pontianak
============================================================ */
const GISMap = {
map: null,
layers: {},
overlayLayers: {},
heatLayer: null,
_allMarkerBounds: [], // Kumpulkan semua koordinat untuk fitBounds akhir
warnaMiskin: {
'Miskin Ekstrem': '#dc2626',
'Miskin': '#ea580c',
'Rentan Miskin': '#ca8a04',
},
createMarker(lat, lng, color, size = 10) {
return L.circleMarker([lat, lng], {
radius: size,
fillColor: color,
color: '#fff',
weight: 2,
opacity: 1,
fillOpacity: 0.88
});
},
createRIMarker(ri) {
const icon = L.divIcon({
className: '',
html: `<div style="
background:#16a34a;color:#fff;width:32px;height:32px;
border-radius:50% 50% 50% 0;transform:rotate(-45deg);
border:2.5px solid #fff;box-shadow:0 2px 8px rgba(0,0,0,0.35);
display:flex;align-items:center;justify-content:center;font-size:14px;
"><span style="transform:rotate(45deg)">⛪</span></div>`,
iconSize: [32, 32],
iconAnchor: [16, 32],
popupAnchor: [0, -34]
});
return L.marker([parseFloat(ri.lat), parseFloat(ri.lng)], { icon });
},
// ─── INISIALISASI PETA ─────────────────────────────────────
// Selalu mulai dari Kota Pontianak, zoom sesuai konteks
init(containerId, lat, lng, zoom) {
// Reset state untuk peta baru
this._allMarkerBounds = [];
// Gunakan koordinat Pontianak sebagai default yang kuat
const centerLat = (lat && !isNaN(lat)) ? lat : PONTIANAK.lat;
const centerLng = (lng && !isNaN(lng)) ? lng : PONTIANAK.lng;
const initZoom = (zoom && !isNaN(zoom)) ? zoom : PONTIANAK.zoom;
this.map = L.map(containerId, {
zoomControl: true,
attributionControl: true,
// Batasi pan agar tidak keluar wilayah Kalimantan Barat
maxBounds: [[-2.0, 107.5], [2.0, 112.0]],
maxBoundsViscosity: 0.8
});
// ── Langsung set view ke Pontianak dulu sebelum tile load ──
this.map.setView([centerLat, centerLng], initZoom);
// Tile layers
const osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a>',
maxZoom: 19,
// Tambahkan subdomains untuk load lebih cepat
subdomains: ['a','b','c']
});
const satellite = L.tileLayer(
'https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: 'Tiles © Esri',
maxZoom: 19
}
);
const topo = L.tileLayer('https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png', {
attribution: '© OpenTopoMap',
maxZoom: 17
});
osm.addTo(this.map);
this.layers = {
'🗺 Peta Jalan': osm,
'🛰 Satelit': satellite,
'🏔 Topografi': topo
};
// Layer control dasar
this._layerControl = L.control.layers(this.layers, {}, {
position: 'topright',
collapsed: true
}).addTo(this.map);
// Tombol reset zoom ke Pontianak
this._addResetButton();
return this.map;
},
// Tombol reset zoom ke seluruh Kota Pontianak
_addResetButton() {
const ResetControl = L.Control.extend({
options: { position: 'topleft' },
onAdd: () => {
const btn = L.DomUtil.create('button', '');
btn.innerHTML = '🏙';
btn.title = 'Kembali ke Kota Pontianak';
btn.style.cssText = `
width:30px;height:30px;border:2px solid rgba(0,0,0,0.2);
border-radius:4px;background:#fff;cursor:pointer;
font-size:14px;display:flex;align-items:center;
justify-content:center;box-shadow:0 1px 5px rgba(0,0,0,0.2);
`;
L.DomEvent.on(btn, 'click', L.DomEvent.stopPropagation)
.on(btn, 'click', L.DomEvent.preventDefault)
.on(btn, 'click', () => {
this.map.flyToBounds(PONTIANAK.bounds, {
duration: 0.8,
padding: [20, 20]
});
});
return btn;
}
});
new ResetControl().addTo(this.map);
},
// ─── LAYER WARGA MISKIN ────────────────────────────────────
addWargaLayer(wargaData, onClickCb) {
const group = L.featureGroup(); // featureGroup mendukung getBounds()
wargaData.forEach(w => {
if (!w.lat || !w.lng) return;
const lat = parseFloat(w.lat);
const lng = parseFloat(w.lng);
if (isNaN(lat) || isNaN(lng)) return;
const color = w.is_blind_spot
? '#7c3aed'
: (this.warnaMiskin[w.status_kemiskinan] || '#6b7280');
const size = w.status_kemiskinan === 'Miskin Ekstrem' ? 11 : 9;
const m = this.createMarker(lat, lng, color, size);
const popup = `
<div style="min-width:200px;font-family:Inter,system-ui,sans-serif">
<strong style="font-size:13px">${w.nama || 'Data laporan'}</strong><br>
<span style="font-size:11px;color:#6b7280">${w.kelurahan || ''}</span><br>
<span style="display:inline-block;margin-top:5px;padding:2px 9px;border-radius:10px;
font-size:11px;font-weight:700;background:${color}22;color:${color}">
${w.status_kemiskinan || ''}
</span>
${w.level_prioritas ? `<br><span style="font-size:11px;margin-top:3px;display:block">
Prioritas: <strong>${w.level_prioritas}</strong>
${w.skor_prioritas ? `(${w.skor_prioritas}/100)` : ''}</span>` : ''}
${w.penghasilan_bulanan !== undefined ? `<span style="font-size:11px;color:#6b7280">
Penghasilan: Rp ${Number(w.penghasilan_bulanan||0).toLocaleString('id-ID')}/bln</span>` : ''}
${w.is_blind_spot ? '<br><span style="color:#7c3aed;font-weight:700;font-size:11px;display:block;margin-top:3px">⚠ Blind Spot — Belum terjangkau RI</span>' : ''}
</div>`;
m.bindPopup(popup, { maxWidth: 240 });
if (onClickCb) m.on('click', () => onClickCb(w));
group.addLayer(m);
this._allMarkerBounds.push([lat, lng]);
});
group.addTo(this.map);
return group;
},
// ─── LAYER RUMAH IBADAH ────────────────────────────────────
addRILayer(riData, onClickCb) {
const group = L.featureGroup();
riData.forEach(ri => {
if (!ri.lat || !ri.lng) return;
const lat = parseFloat(ri.lat);
const lng = parseFloat(ri.lng);
if (isNaN(lat) || isNaN(lng)) return;
const m = this.createRIMarker(ri);
// Radius lingkaran pelayanan
const radius = parseInt(ri.radius_meter) || 500;
const circle = L.circle([lat, lng], {
radius,
fillColor: '#16a34a',
fillOpacity: 0.07,
color: '#16a34a',
weight: 1.5,
dashArray: '6,5',
interactive: false
});
const popup = `
<div style="min-width:200px;font-family:Inter,system-ui,sans-serif">
<strong style="font-size:13px">⛪ ${ri.nama}</strong><br>
<span style="font-size:11px;color:#6b7280">${ri.jenis || ''}${ri.kelurahan || ''}</span>
${ri.alamat ? `<br><span style="font-size:11px;color:#374151">${ri.alamat}</span>` : ''}
<br><span style="font-size:11px;color:#16a34a;font-weight:600;display:block;margin-top:4px">
📏 Radius pelayanan: ${radius.toLocaleString()}m</span>
${ri.nama_ketua ? `<span style="font-size:11px;color:#6b7280">Ketua: ${ri.nama_ketua}</span>` : ''}
</div>`;
m.bindPopup(popup, { maxWidth: 240 });
if (onClickCb) m.on('click', () => onClickCb(ri));
group.addLayer(circle);
group.addLayer(m);
this._allMarkerBounds.push([lat, lng]);
});
group.addTo(this.map);
return group;
},
// ─── LAYER LAPORAN PUBLIK ──────────────────────────────────
addLaporanLayer(laporanData) {
const group = L.featureGroup();
laporanData.forEach(lap => {
if (!lap.lat || !lap.lng) return;
const lat = parseFloat(lap.lat);
const lng = parseFloat(lap.lng);
if (isNaN(lat) || isNaN(lng)) return;
const m = this.createMarker(lat, lng, '#0284c7', 8);
m.bindPopup(`
<div style="min-width:180px;font-family:Inter,system-ui,sans-serif">
<strong style="font-size:13px">📋 Laporan Masuk</strong><br>
<span style="font-size:12px">${lap.nama_warga || ''}</span><br>
<code style="font-size:10px;background:#f1f5f9;padding:1px 5px;border-radius:3px">
${lap.kode_laporan || ''}</code>
</div>`, { maxWidth: 200 });
group.addLayer(m);
this._allMarkerBounds.push([lat, lng]);
});
group.addTo(this.map);
return group;
},
// ─── HEATMAP LAYER ─────────────────────────────────────────
addHeatmap(points) {
if (typeof L.heatLayer === 'undefined') {
console.warn('Leaflet.heat tidak tersedia');
return;
}
const data = points
.map(p => [parseFloat(p.lat), parseFloat(p.lng), parseFloat(p.intensity || 0.5)])
.filter(p => !isNaN(p[0]) && !isNaN(p[1]) && p[0] !== 0);
if (this.heatLayer) this.map.removeLayer(this.heatLayer);
this.heatLayer = L.heatLayer(data, {
radius: 28,
blur: 22,
maxZoom: 16,
max: 1.0,
gradient: {
0.0: 'transparent',
0.3: '#fef9c3',
0.55: '#fb923c',
0.75: '#ef4444',
1.0: '#7f1d1d'
}
}).addTo(this.map);
},
// ─── AUTO FIT BOUNDS ───────────────────────────────────────
// Panggil ini SETELAH semua layer dimuat untuk zoom ke data
autoFitBounds(forceKotaPontianak = false) {
if (forceKotaPontianak || this._allMarkerBounds.length === 0) {
// Tidak ada data → tampilkan seluruh Kota Pontianak
this.map.flyToBounds(PONTIANAK.bounds, {
duration: 0.6,
padding: [20, 20],
maxZoom: 14
});
return;
}
try {
const bounds = L.latLngBounds(this._allMarkerBounds);
if (bounds.isValid()) {
// Jika data sangat menyebar → fit ke batas data
// Jika data sangat mepet (1-2 titik) → zoom level wajar
const boundsSize = bounds.getNorthEast().distanceTo(bounds.getSouthWest());
if (boundsSize < 500) {
// Data terlalu dekat → zoom ke tengah dengan zoom 15
this.map.flyTo(bounds.getCenter(), 15, { duration: 0.6 });
} else {
this.map.flyToBounds(bounds, {
duration: 0.6,
padding: [40, 40],
maxZoom: 15 // Jangan zoom terlalu dekat
});
}
} else {
this.map.flyToBounds(PONTIANAK.bounds, { duration: 0.5 });
}
} catch (e) {
this.map.flyToBounds(PONTIANAK.bounds, { duration: 0.5 });
}
},
// fitBounds dari layerGroup (kompatibel dengan kode lama)
fitBounds(layerGroup) {
try {
const bounds = layerGroup.getBounds();
if (bounds.isValid()) {
this.map.flyToBounds(bounds, { duration: 0.5, padding: [30, 30] });
}
} catch (e) {
this.autoFitBounds(true);
}
}
};
/* ============================================================
CHART MODULE (Chart.js wrapper)
============================================================ */
const Charts = {
defaults: {
fontFamily: "'Inter', system-ui, sans-serif",
colors: ['#1a3a5c', '#e8a020', '#16a34a', '#dc2626', '#0284c7', '#7c3aed', '#ea580c', '#0d9488']
},
bar(canvasId, labels, datasets, opts = {}) {
const ctx = document.getElementById(canvasId);
if (!ctx) return null;
return new Chart(ctx, {
type: 'bar',
data: {
labels,
datasets: datasets.map((d, i) => ({
backgroundColor: this.defaults.colors[i % this.defaults.colors.length] + 'cc',
borderColor: this.defaults.colors[i % this.defaults.colors.length],
borderRadius: 4,
borderWidth: 1,
...d
}))
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: datasets.length > 1 },
tooltip: { callbacks: { label: ctx => ' ' + Number(ctx.raw).toLocaleString('id-ID') } }
},
scales: {
y: { beginAtZero: true, grid: { color: '#f1f5f9' }, ticks: { font: { size: 11 } } },
x: { grid: { display: false }, ticks: { font: { size: 11 } } }
},
...opts
}
});
},
line(canvasId, labels, datasets, opts = {}) {
const ctx = document.getElementById(canvasId);
if (!ctx) return null;
return new Chart(ctx, {
type: 'line',
data: {
labels,
datasets: datasets.map((d, i) => ({
borderColor: this.defaults.colors[i % this.defaults.colors.length],
backgroundColor: this.defaults.colors[i % this.defaults.colors.length] + '18',
tension: 0.4, fill: true, borderWidth: 2.5,
pointRadius: 4, pointHoverRadius: 6,
...d
}))
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: { legend: { display: datasets.length > 1 } },
scales: {
y: { beginAtZero: true, grid: { color: '#f1f5f9' }, ticks: { font: { size: 11 } } },
x: { grid: { display: false }, ticks: { font: { size: 11 } } }
},
...opts
}
});
},
donut(canvasId, labels, data, colors) {
const ctx = document.getElementById(canvasId);
if (!ctx) return null;
return new Chart(ctx, {
type: 'doughnut',
data: {
labels,
datasets: [{
data,
backgroundColor: colors || this.defaults.colors,
borderWidth: 2,
borderColor: '#fff'
}]
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: {
position: 'right',
labels: { font: { size: 11 }, padding: 14, usePointStyle: true }
}
},
cutout: '65%'
}
});
}
};
/* ============================================================
LOCATION PICKER — untuk form laporan & input warga
============================================================ */
const LocationPicker = {
map: null,
marker: null,
init(mapId, latInputId, lngInputId, initLat, initLng) {
// Selalu mulai dari Pontianak
const startLat = (initLat && !isNaN(initLat)) ? initLat : PONTIANAK.lat;
const startLng = (initLng && !isNaN(initLng)) ? initLng : PONTIANAK.lng;
this.map = L.map(mapId, { zoomControl: true }).setView([startLat, startLng], 14);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap',
maxZoom: 19,
subdomains: ['a','b','c']
}).addTo(this.map);
// Jika ada koordinat awal, langsung pasang marker
if (initLat && initLng && !isNaN(initLat)) {
this.placeMarker(initLat, initLng, latInputId, lngInputId);
}
// Klik peta = pasang / pindah marker
this.map.on('click', e => {
this.placeMarker(e.latlng.lat, e.latlng.lng, latInputId, lngInputId);
});
// Kontrol tombol lokasi saya
this._addGeolocateButton(latInputId, lngInputId);
// Instruksi klik
const hint = L.control({ position: 'bottomleft' });
hint.onAdd = () => {
const d = L.DomUtil.create('div');
d.style.cssText = 'background:rgba(255,255,255,0.9);padding:6px 10px;border-radius:6px;font-size:11px;color:#374151;box-shadow:0 1px 4px rgba(0,0,0,0.15)';
d.innerHTML = '📍 Klik peta atau drag marker untuk menentukan lokasi';
return d;
};
hint.addTo(this.map);
},
placeMarker(lat, lng, latInputId, lngInputId) {
if (this.marker) this.map.removeLayer(this.marker);
this.marker = L.marker([lat, lng], {
draggable: true,
autoPan: true
}).addTo(this.map);
this.marker.bindPopup('📍 Lokasi dipilih').openPopup();
document.getElementById(latInputId).value = lat.toFixed(7);
document.getElementById(lngInputId).value = lng.toFixed(7);
this.marker.on('dragend', e => {
const pos = e.target.getLatLng();
document.getElementById(latInputId).value = pos.lat.toFixed(7);
document.getElementById(lngInputId).value = pos.lng.toFixed(7);
});
},
_addGeolocateButton(latInputId, lngInputId) {
const GeoBtn = L.Control.extend({
options: { position: 'topright' },
onAdd: () => {
const btn = L.DomUtil.create('button', '');
btn.innerHTML = '📍 Lokasi Saya';
btn.title = 'Gunakan lokasi GPS saya';
btn.style.cssText = `
padding:6px 10px;border:2px solid rgba(0,0,0,0.2);border-radius:4px;
background:#1a3a5c;color:#fff;cursor:pointer;font-size:11px;font-weight:600;
box-shadow:0 1px 5px rgba(0,0,0,0.2);white-space:nowrap;
`;
L.DomEvent.disableClickPropagation(btn);
btn.onclick = () => {
if (!navigator.geolocation) {
alert('GPS tidak tersedia di browser Anda');
return;
}
btn.innerHTML = '⌛ Mencari...';
btn.disabled = true;
navigator.geolocation.getCurrentPosition(
pos => {
const { latitude, longitude } = pos.coords;
this.placeMarker(latitude, longitude, latInputId, lngInputId);
this.map.flyTo([latitude, longitude], 17, { duration: 0.8 });
btn.innerHTML = '📍 Lokasi Saya';
btn.disabled = false;
},
err => {
alert('Gagal mendapatkan lokasi: ' + err.message);
btn.innerHTML = '📍 Lokasi Saya';
btn.disabled = false;
},
{ enableHighAccuracy: true, timeout: 10000 }
);
};
return btn;
}
});
new GeoBtn().addTo(this.map);
}
};
// ── Bootstrap ──
document.addEventListener('DOMContentLoaded', () => App.init());