Move index.php dari root ke public/ - running directory sekarang di public
This commit is contained in:
10
README.md
10
README.md
@@ -6,8 +6,8 @@ Frontend aplikasi Retribusi BAPENDA Kabupaten Garut.
|
||||
|
||||
```
|
||||
retribusi (frontend)/
|
||||
├── index.php # Login page
|
||||
├── public/
|
||||
├── public/ # Document root (running directory)
|
||||
│ ├── index.php # Login page
|
||||
│ ├── dashboard/
|
||||
│ │ ├── dashboard.html # Dashboard utama
|
||||
│ │ ├── event.html # Halaman event logs
|
||||
@@ -21,7 +21,6 @@ retribusi (frontend)/
|
||||
│ │ ├── dashboard.js # Dashboard logic
|
||||
│ │ ├── charts.js # Chart.js helpers
|
||||
│ │ └── realtime.js # Realtime SSE client
|
||||
│ └── index.php
|
||||
└── api/ # Legacy API endpoints (deprecated)
|
||||
```
|
||||
|
||||
@@ -50,8 +49,9 @@ File `public/dashboard/js/config.js` mengatur:
|
||||
## Development
|
||||
|
||||
1. Pastikan backend API sudah running
|
||||
2. Buka `index.php` untuk login
|
||||
3. Akses dashboard di `public/dashboard/dashboard.html`
|
||||
2. Set document root ke folder `public/`
|
||||
3. Buka `index.php` untuk login (atau akses root `/`)
|
||||
4. Akses dashboard di `dashboard/dashboard.html`
|
||||
|
||||
## Production
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="id">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
@@ -20,6 +21,7 @@
|
||||
}
|
||||
</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">
|
||||
@@ -30,53 +32,51 @@
|
||||
<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
|
||||
<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"
|
||||
>
|
||||
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
|
||||
<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"
|
||||
>
|
||||
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"
|
||||
>
|
||||
<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 public/dashboard/js -->
|
||||
<!-- Pakai API & Auth dari dashboard/js -->
|
||||
<script type="module">
|
||||
import { Auth } from './public/dashboard/js/auth.js';
|
||||
import {
|
||||
Auth
|
||||
} from './dashboard/js/auth.js';
|
||||
window.Auth = Auth;
|
||||
|
||||
// Jika sudah login, langsung arahkan ke dashboard utama (public/dashboard)
|
||||
|
||||
// Jika sudah login, langsung arahkan ke dashboard
|
||||
// Cek dulu apakah kita sudah di dashboard untuk menghindari redirect loop
|
||||
// Gunakan check yang lebih spesifik untuk mencegah loop
|
||||
(function() {
|
||||
// Cek apakah ini benar-benar halaman index.php (bukan dashboard)
|
||||
const currentPath = window.location.pathname;
|
||||
const isIndexPage = currentPath.endsWith('index.php') || currentPath.endsWith('/') || currentPath === '/';
|
||||
const isDashboardPage = currentPath.includes('dashboard.html') || currentPath.includes('event.html') || currentPath.includes('settings.html');
|
||||
|
||||
|
||||
// Hanya redirect jika:
|
||||
// 1. User sudah authenticated
|
||||
// 2. Kita di index page (bukan dashboard)
|
||||
@@ -85,7 +85,7 @@
|
||||
const redirectKey = 'auth_redirect_done';
|
||||
if (!sessionStorage.getItem(redirectKey)) {
|
||||
sessionStorage.setItem(redirectKey, '1');
|
||||
window.location.href = 'public/dashboard/dashboard.html';
|
||||
window.location.href = 'dashboard/dashboard.html';
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -95,22 +95,24 @@
|
||||
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 {
|
||||
const { apiLogin } = await import('./public/dashboard/js/api.js');
|
||||
const {
|
||||
apiLogin
|
||||
} = await import('./dashboard/js/api.js');
|
||||
const response = await apiLogin(username, password);
|
||||
if (response.token) {
|
||||
Auth.saveToken(response.token);
|
||||
Auth.saveUser(response.user);
|
||||
// Arahkan ke dashboard utama (public/dashboard)
|
||||
window.location.href = 'public/dashboard/dashboard.html';
|
||||
// Arahkan ke dashboard
|
||||
window.location.href = 'dashboard/dashboard.html';
|
||||
} else {
|
||||
throw new Error('Response tidak berisi token.');
|
||||
}
|
||||
@@ -123,6 +125,6 @@
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user