215 lines
6.1 KiB
HTML
215 lines
6.1 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<title>Login - War Dashboard</title>
|
|
<link rel="stylesheet" href="/static/styles.css" />
|
|
<style>
|
|
.login-container {
|
|
display: flex;
|
|
justify-content: center;
|
|
align-items: center;
|
|
min-height: 100vh;
|
|
padding: 2rem;
|
|
}
|
|
|
|
.login-card {
|
|
background: linear-gradient(135deg, #1a1a26 0%, #2d2d44 100%);
|
|
border: 1px solid rgba(102, 204, 255, 0.2);
|
|
border-radius: 12px;
|
|
padding: 3rem;
|
|
max-width: 450px;
|
|
width: 100%;
|
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
|
|
}
|
|
|
|
.login-card h1 {
|
|
text-align: center;
|
|
color: #66ccff;
|
|
margin-bottom: 0.5rem;
|
|
font-size: 2rem;
|
|
}
|
|
|
|
.login-subtitle {
|
|
text-align: center;
|
|
color: #99a7bf;
|
|
margin-bottom: 2rem;
|
|
font-size: 0.95rem;
|
|
}
|
|
|
|
.login-form {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 1.5rem;
|
|
}
|
|
|
|
.form-group {
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 0.5rem;
|
|
}
|
|
|
|
.form-group label {
|
|
color: #66ccff;
|
|
font-weight: bold;
|
|
font-size: 1rem;
|
|
}
|
|
|
|
.form-group input {
|
|
padding: 0.8rem;
|
|
border-radius: 6px;
|
|
border: 1px solid rgba(255, 255, 255, 0.1);
|
|
background-color: #1a1a26;
|
|
color: #f0f0f0;
|
|
font-size: 1rem;
|
|
transition: border-color 0.3s;
|
|
}
|
|
|
|
.form-group input:focus {
|
|
outline: none;
|
|
border-color: #66ccff;
|
|
}
|
|
|
|
.login-btn {
|
|
padding: 1rem;
|
|
background-color: #4CAF50;
|
|
color: white;
|
|
border: none;
|
|
border-radius: 6px;
|
|
font-size: 1.1rem;
|
|
font-weight: bold;
|
|
cursor: pointer;
|
|
transition: background-color 0.3s;
|
|
margin-top: 0.5rem;
|
|
}
|
|
|
|
.login-btn:hover {
|
|
background-color: #45a049;
|
|
}
|
|
|
|
.login-btn:disabled {
|
|
background-color: #666;
|
|
cursor: not-allowed;
|
|
}
|
|
|
|
.error-message {
|
|
background-color: rgba(244, 67, 54, 0.1);
|
|
border: 1px solid rgba(244, 67, 54, 0.5);
|
|
border-radius: 6px;
|
|
padding: 1rem;
|
|
color: #f44336;
|
|
text-align: center;
|
|
display: none;
|
|
}
|
|
|
|
.error-message.show {
|
|
display: block;
|
|
}
|
|
|
|
.info-text {
|
|
text-align: center;
|
|
color: #99a7bf;
|
|
font-size: 0.85rem;
|
|
margin-top: 1rem;
|
|
line-height: 1.5;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="login-container">
|
|
<div class="login-card">
|
|
<h1>War Dashboard</h1>
|
|
<p class="login-subtitle">Please log in to continue</p>
|
|
|
|
<div id="error-msg" class="error-message"></div>
|
|
|
|
<form class="login-form" id="login-form">
|
|
<div class="form-group">
|
|
<label for="name">Name</label>
|
|
<input
|
|
type="text"
|
|
id="name"
|
|
name="name"
|
|
placeholder="Enter your name"
|
|
required
|
|
autocomplete="username"
|
|
/>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="password">Password</label>
|
|
<input
|
|
type="password"
|
|
id="password"
|
|
name="password"
|
|
placeholder="Enter password"
|
|
required
|
|
autocomplete="current-password"
|
|
/>
|
|
</div>
|
|
|
|
<button type="submit" class="login-btn" id="submit-btn">Log In</button>
|
|
</form>
|
|
|
|
<p class="info-text">
|
|
Contact Faction Management if you need the shared password.
|
|
</p>
|
|
</div>
|
|
</div>
|
|
|
|
<script>
|
|
const form = document.getElementById('login-form');
|
|
const errorMsg = document.getElementById('error-msg');
|
|
const submitBtn = document.getElementById('submit-btn');
|
|
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
|
|
const name = document.getElementById('name').value.trim();
|
|
const password = document.getElementById('password').value;
|
|
|
|
if (!name || !password) {
|
|
showError('Please enter both name and password');
|
|
return;
|
|
}
|
|
|
|
// Disable submit button
|
|
submitBtn.disabled = true;
|
|
submitBtn.textContent = 'Logging in...';
|
|
errorMsg.classList.remove('show');
|
|
|
|
try {
|
|
const response = await fetch('/auth/login', {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json'
|
|
},
|
|
body: JSON.stringify({ name, password })
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
if (response.ok) {
|
|
// Successful login - redirect to dashboard
|
|
window.location.href = '/';
|
|
} else {
|
|
// Show error message
|
|
showError(data.detail || 'Login failed');
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Log In';
|
|
}
|
|
} catch (error) {
|
|
showError('An error occurred. Please try again.');
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = 'Log In';
|
|
}
|
|
});
|
|
|
|
function showError(message) {
|
|
errorMsg.textContent = message;
|
|
errorMsg.classList.add('show');
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|