Remove Admin Mode UI floating panel and improve API error handling
This commit is contained in:
@@ -158,3 +158,8 @@ CREATE TABLE `tanah` (
|
||||
`geom` text,
|
||||
PRIMARY KEY (`id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=24 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
||||
|
||||
-- Grant privileges on both databases to webgis_user
|
||||
GRANT ALL PRIVILEGES ON poverty_db.* TO 'webgis_user'@'%';
|
||||
GRANT ALL PRIVILEGES ON spbu_db.* TO 'webgis_user'@'%';
|
||||
FLUSH PRIVILEGES;
|
||||
|
||||
+4
-13
@@ -48,11 +48,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="auth-controls" style="position: absolute; top: 10px; right: 10px; z-index: 1000; background: white; padding: 10px; border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: flex; gap: 8px; align-items: center; font-family: sans-serif;">
|
||||
<span id="api-key-status" style="font-size: 13px; font-weight: bold; color: #666;">Guest Mode</span>
|
||||
<button id="btn-api-key" onclick="promptApiKey()" style="padding: 6px 12px; border-radius: 4px; border: none; background: #1976d2; color: white; cursor: pointer; font-weight: bold; font-size: 12px; transition: all 0.2s;">🔑 Set API Key</button>
|
||||
</div>
|
||||
|
||||
<div id="map" style="height:100vh;"></div>
|
||||
|
||||
<script>
|
||||
@@ -97,8 +92,7 @@ function promptApiKey() {
|
||||
|
||||
function handleApiResponse(res, callback) {
|
||||
if (res.status === 401) {
|
||||
alert('Akses Ditolak: API Key tidak valid atau kosong. Silakan atur API Key terlebih dahulu.');
|
||||
promptApiKey();
|
||||
alert('Akses Ditolak: API Key tidak valid atau kosong.');
|
||||
} else {
|
||||
res.json().then(data => {
|
||||
if (data && data.success === false) {
|
||||
@@ -106,12 +100,9 @@ function handleApiResponse(res, callback) {
|
||||
} else if (callback) {
|
||||
callback(data);
|
||||
}
|
||||
}).catch(() => {
|
||||
if (res.ok && callback) {
|
||||
callback();
|
||||
} else {
|
||||
alert('Terjadi kesalahan koneksi server');
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error('Failed to parse API JSON response', err);
|
||||
alert('Gagal memproses data: Response server tidak valid (Kemungkinan masalah koneksi database).');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user