- Fix deteksi transisi bulan untuk semua bulan (tidak hanya 1 Januari) - Perbaikan validasi data dengan threshold 20% untuk transisi bulan/tahun - Auto-reset chart jika data hourly tidak valid - Setup force local mode untuk testing API lokal - Perbaikan normalisasi dan validasi tanggal - Enhanced logging untuk debugging transisi
133 lines
5.9 KiB
HTML
133 lines
5.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="id">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Login - Sistem Monitoring Retribusi</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap" rel="stylesheet">
|
|
<script>
|
|
tailwind.config = {
|
|
theme: {
|
|
extend: {
|
|
fontFamily: {
|
|
outfit: ['Outfit', 'sans-serif'],
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
</head>
|
|
|
|
<body class="font-outfit bg-gray-50 min-h-screen flex items-center justify-center p-4">
|
|
<div class="w-full max-w-md">
|
|
<div class="bg-white rounded-lg shadow-lg p-8 md:p-10 border border-gray-200">
|
|
<div class="text-center mb-8">
|
|
<h1 class="text-2xl font-bold text-gray-900 mb-2">Sistem Monitoring Retribusi</h1>
|
|
<p class="text-gray-600 text-sm">Silakan login untuk melanjutkan</p>
|
|
</div>
|
|
<form id="loginForm" class="space-y-5">
|
|
<div>
|
|
<label for="username" class="block text-sm font-medium text-gray-700 mb-2">Username</label>
|
|
<input
|
|
type="text"
|
|
id="username"
|
|
name="username"
|
|
required
|
|
autocomplete="username"
|
|
class="w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-900 focus:border-transparent transition-all text-gray-900 placeholder-gray-400"
|
|
placeholder="Masukkan username">
|
|
</div>
|
|
<div>
|
|
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">Password</label>
|
|
<input
|
|
type="password"
|
|
id="password"
|
|
name="password"
|
|
required
|
|
autocomplete="current-password"
|
|
class="w-full px-4 py-2.5 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-gray-900 focus:border-transparent transition-all text-gray-900 placeholder-gray-400"
|
|
placeholder="Masukkan password">
|
|
</div>
|
|
<div id="errorMessage" class="hidden bg-red-50 border border-red-200 text-red-700 p-3 rounded-lg text-sm"></div>
|
|
<button
|
|
type="submit"
|
|
class="w-full bg-gray-900 text-white font-medium py-2.5 px-6 rounded-lg hover:bg-gray-800 focus:outline-none focus:ring-2 focus:ring-gray-900 focus:ring-offset-2 transition-all duration-200">
|
|
Login
|
|
</button>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Pakai API & Auth dari dashboard/js -->
|
|
<script type="module">
|
|
import {
|
|
Auth
|
|
} from './dashboard/js/auth.js';
|
|
window.Auth = Auth;
|
|
|
|
// Hapus auto-redirect untuk mencegah redirect loop
|
|
// Biarkan user login dulu, redirect hanya setelah login berhasil
|
|
|
|
document.getElementById('loginForm').addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
const errorDiv = document.getElementById('errorMessage');
|
|
errorDiv.classList.add('hidden');
|
|
|
|
const username = document.getElementById('username').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
|
|
const submitBtn = e.target.querySelector('button[type="submit"]');
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = 'Memproses...';
|
|
|
|
try {
|
|
// Import config untuk cek API Base URL
|
|
const { API_CONFIG } = await import('./dashboard/js/config.js');
|
|
console.log('[Login] API Base URL:', API_CONFIG.BASE_URL);
|
|
|
|
const {
|
|
apiLogin
|
|
} = await import('./dashboard/js/api.js');
|
|
|
|
console.log('[Login] Attempting login for:', username);
|
|
const response = await apiLogin(username, password);
|
|
console.log('[Login] Response:', response);
|
|
|
|
if (response.token) {
|
|
Auth.saveToken(response.token);
|
|
Auth.saveUser(response.user);
|
|
// Arahkan ke dashboard
|
|
window.location.href = 'dashboard/dashboard.html';
|
|
} else {
|
|
throw new Error('Response tidak berisi token.');
|
|
}
|
|
} catch (error) {
|
|
console.error('[Login] Error:', error);
|
|
let errorMessage = error.message || 'Login gagal. Silakan coba lagi.';
|
|
|
|
// Tambahkan info lebih detail untuk debugging
|
|
if (error.message === 'Failed to fetch' || error.message.includes('fetch')) {
|
|
try {
|
|
const { API_CONFIG } = await import('./dashboard/js/config.js');
|
|
errorMessage = 'Gagal terhubung ke server API. Pastikan backend API sudah running di ' + API_CONFIG.BASE_URL;
|
|
} catch (e) {
|
|
errorMessage = 'Gagal terhubung ke server API. Pastikan backend API sudah running di https://api.btekno.cloud';
|
|
}
|
|
}
|
|
|
|
errorDiv.textContent = errorMessage;
|
|
errorDiv.classList.remove('hidden');
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Login';
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|
|
|