refactor: make poverty map public and remove redundant user authentication requirements

This commit is contained in:
z0rayy
2026-06-10 16:29:04 +07:00
parent bae7c0b294
commit 24e75d6377
6 changed files with 37 additions and 147 deletions
+4 -32
View File
@@ -176,10 +176,7 @@
</head>
<body>
<div id="loader">
<div class="loader-spinner"></div>
<span>Verifikasi Akses...</span>
</div>
<div class="app-wrapper">
<!-- Sidebar -->
@@ -208,14 +205,7 @@
</a>
</div>
</div>
<div class="sidebar-section">
<div class="sidebar-menu">
<div class="sidebar-item" id="logout-btn">
<div class="sidebar-item-icon"></div>
<div class="sidebar-item-text">Logout</div>
</div>
</div>
</div>
</nav>
</aside>
@@ -224,9 +214,8 @@
<header>
<div class="header-title">
<h1>Peta Analisis Kemiskinan</h1>
<div class="header-breadcrumb">Peta terproteksi — Login diperlukan</div>
<div class="header-breadcrumb">Peta interaktif akses publik</div>
</div>
<div class="header-user" id="header-user">Loading...</div>
</header>
<div class="content-area">
<div id="map"></div>
@@ -268,29 +257,12 @@
document.getElementById('sidebar').classList.toggle('collapsed');
});
// Logout
document.getElementById('logout-btn').addEventListener('click', async () => {
await fetch('backend/logout.php');
window.location.href = 'index.html';
});
// Global state
let ibadahData = [], miskinData = [];
let ibadahLayer, miskinLayer, map;
let ibadahRadiuses = {}, ibadahPoints = [];
let ibadahIcon, miskinRedIcon, miskinBlackIcon;
async function checkAuth() {
try {
const res = await fetch('backend/check_auth.php');
if (!res.ok) { window.location.href = 'login.html?redirect=poverty.html'; return; }
const data = await res.json();
document.getElementById('header-user').textContent = '👤 ' + data.username;
document.getElementById('loader').style.display = 'none';
initMap();
} catch (e) { window.location.href = 'login.html?redirect=poverty.html'; }
}
async function initMap() {
map = L.map('map').setView([-0.026, 109.342], 13);
const osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: '© OpenStreetMap', maxZoom: 19 });
@@ -473,7 +445,7 @@
renderMiskin(true);
};
checkAuth();
initMap();
</script>
</body>
</html>