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)/
|
retribusi (frontend)/
|
||||||
├── index.php # Login page
|
├── public/ # Document root (running directory)
|
||||||
├── public/
|
│ ├── index.php # Login page
|
||||||
│ ├── dashboard/
|
│ ├── dashboard/
|
||||||
│ │ ├── dashboard.html # Dashboard utama
|
│ │ ├── dashboard.html # Dashboard utama
|
||||||
│ │ ├── event.html # Halaman event logs
|
│ │ ├── event.html # Halaman event logs
|
||||||
@@ -21,7 +21,6 @@ retribusi (frontend)/
|
|||||||
│ │ ├── dashboard.js # Dashboard logic
|
│ │ ├── dashboard.js # Dashboard logic
|
||||||
│ │ ├── charts.js # Chart.js helpers
|
│ │ ├── charts.js # Chart.js helpers
|
||||||
│ │ └── realtime.js # Realtime SSE client
|
│ │ └── realtime.js # Realtime SSE client
|
||||||
│ └── index.php
|
|
||||||
└── api/ # Legacy API endpoints (deprecated)
|
└── api/ # Legacy API endpoints (deprecated)
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -50,8 +49,9 @@ File `public/dashboard/js/config.js` mengatur:
|
|||||||
## Development
|
## Development
|
||||||
|
|
||||||
1. Pastikan backend API sudah running
|
1. Pastikan backend API sudah running
|
||||||
2. Buka `index.php` untuk login
|
2. Set document root ke folder `public/`
|
||||||
3. Akses dashboard di `public/dashboard/dashboard.html`
|
3. Buka `index.php` untuk login (atau akses root `/`)
|
||||||
|
4. Akses dashboard di `dashboard/dashboard.html`
|
||||||
|
|
||||||
## Production
|
## Production
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="id">
|
<html lang="id">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
@@ -20,6 +21,7 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body class="font-outfit bg-gray-50 min-h-screen flex items-center justify-center p-4">
|
<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="w-full max-w-md">
|
||||||
<div class="bg-white rounded-lg shadow-lg p-8 md:p-10 border border-gray-200">
|
<div class="bg-white rounded-lg shadow-lg p-8 md:p-10 border border-gray-200">
|
||||||
@@ -37,8 +39,7 @@
|
|||||||
required
|
required
|
||||||
autocomplete="username"
|
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"
|
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>
|
||||||
<div>
|
<div>
|
||||||
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">Password</label>
|
<label for="password" class="block text-sm font-medium text-gray-700 mb-2">Password</label>
|
||||||
@@ -49,28 +50,27 @@
|
|||||||
required
|
required
|
||||||
autocomplete="current-password"
|
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"
|
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>
|
||||||
<div id="errorMessage" class="hidden bg-red-50 border border-red-200 text-red-700 p-3 rounded-lg text-sm"></div>
|
<div id="errorMessage" class="hidden bg-red-50 border border-red-200 text-red-700 p-3 rounded-lg text-sm"></div>
|
||||||
<button
|
<button
|
||||||
type="submit"
|
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"
|
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
|
Login
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Pakai API & Auth dari public/dashboard/js -->
|
<!-- Pakai API & Auth dari dashboard/js -->
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import { Auth } from './public/dashboard/js/auth.js';
|
import {
|
||||||
|
Auth
|
||||||
|
} from './dashboard/js/auth.js';
|
||||||
window.Auth = Auth;
|
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
|
// Cek dulu apakah kita sudah di dashboard untuk menghindari redirect loop
|
||||||
// Gunakan check yang lebih spesifik untuk mencegah loop
|
|
||||||
(function() {
|
(function() {
|
||||||
// Cek apakah ini benar-benar halaman index.php (bukan dashboard)
|
// Cek apakah ini benar-benar halaman index.php (bukan dashboard)
|
||||||
const currentPath = window.location.pathname;
|
const currentPath = window.location.pathname;
|
||||||
@@ -85,7 +85,7 @@
|
|||||||
const redirectKey = 'auth_redirect_done';
|
const redirectKey = 'auth_redirect_done';
|
||||||
if (!sessionStorage.getItem(redirectKey)) {
|
if (!sessionStorage.getItem(redirectKey)) {
|
||||||
sessionStorage.setItem(redirectKey, '1');
|
sessionStorage.setItem(redirectKey, '1');
|
||||||
window.location.href = 'public/dashboard/dashboard.html';
|
window.location.href = 'dashboard/dashboard.html';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,13 +104,15 @@
|
|||||||
submitBtn.textContent = 'Memproses...';
|
submitBtn.textContent = 'Memproses...';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { apiLogin } = await import('./public/dashboard/js/api.js');
|
const {
|
||||||
|
apiLogin
|
||||||
|
} = await import('./dashboard/js/api.js');
|
||||||
const response = await apiLogin(username, password);
|
const response = await apiLogin(username, password);
|
||||||
if (response.token) {
|
if (response.token) {
|
||||||
Auth.saveToken(response.token);
|
Auth.saveToken(response.token);
|
||||||
Auth.saveUser(response.user);
|
Auth.saveUser(response.user);
|
||||||
// Arahkan ke dashboard utama (public/dashboard)
|
// Arahkan ke dashboard
|
||||||
window.location.href = 'public/dashboard/dashboard.html';
|
window.location.href = 'dashboard/dashboard.html';
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Response tidak berisi token.');
|
throw new Error('Response tidak berisi token.');
|
||||||
}
|
}
|
||||||
@@ -123,6 +125,6 @@
|
|||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user