Add complete project structure and all files

This commit is contained in:
2025-12-15 13:03:29 +05:00
parent dc4c2521c7
commit f5a3903f5d
139 changed files with 72714 additions and 2 deletions

View File

@@ -0,0 +1,252 @@
<!doctype html>
<html lang="{{ lang }}">
<head>
<meta charset="utf-8">
<title>{{ t('login') }} - {{ t('app_name') }}</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=5, viewport-fit=cover">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="mobile-web-app-capable" content="yes">
<meta name="theme-color" content="#0f172a">
<style>
* {
box-sizing: border-box;
-webkit-tap-highlight-color: transparent;
}
body {
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
margin: 0;
padding: 0;
background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
color: #e5e7eb;
min-height: 100vh;
min-height: -webkit-fill-available;
display: flex;
align-items: center;
justify-content: center;
padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
html {
height: -webkit-fill-available;
}
.login-container {
width: 100%;
max-width: 400px;
padding: 1.5rem;
}
.login-card {
background: #020617;
border-radius: 1rem;
padding: 2rem;
border: 1px solid #1e293b;
}
.login-header {
text-align: center;
margin-bottom: 2rem;
}
.login-header h1 {
margin: 0 0 0.5rem 0;
font-size: 1.75rem;
color: #22c55e;
}
.login-header p {
margin: 0;
color: #9ca3af;
font-size: 0.875rem;
}
.form-group {
margin-bottom: 1.5rem;
}
.form-group label {
display: block;
margin-bottom: 0.5rem;
color: #e5e7eb;
font-weight: 500;
}
.form-group input {
width: 100%;
padding: 0.75rem 1rem;
background: #1e293b;
border: 1px solid #334155;
border-radius: 0.5rem;
color: #e5e7eb;
font-size: 16px; /* Предотвращает зум на iOS */
transition: all 0.2s;
-webkit-appearance: none;
appearance: none;
}
.form-group input:focus {
outline: none;
border-color: #22c55e;
box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.1);
}
.btn {
width: 100%;
padding: 0.875rem 1rem;
background: #22c55e;
color: #020617;
border: none;
border-radius: 0.5rem;
font-size: 1rem;
font-weight: 600;
cursor: pointer;
transition: all 0.2s;
min-height: 48px;
touch-action: manipulation;
}
.btn:hover {
background: #16a34a;
}
.btn:disabled {
opacity: 0.5;
cursor: not-allowed;
}
.error-message {
background: var(--danger-light, #7f1d1d);
border: 1px solid var(--danger, #991b1b);
color: #fca5a5;
padding: 0.75rem 1rem;
border-radius: 0.5rem;
margin-bottom: 1rem;
display: none;
}
.error-message.show {
display: block;
}
.loading {
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid #020617;
border-radius: 50%;
border-top-color: transparent;
animation: spin 0.6s linear infinite;
}
@keyframes spin {
to { transform: rotate(360deg); }
}
.footer {
text-align: center;
margin-top: 2rem;
color: #6b7280;
font-size: 0.875rem;
}
</style>
</head>
<body>
<div class="login-container">
<div class="login-card">
<div class="login-header">
{% if custom_logo_exists %}
<img src="/settings/api/logo.png" alt="{{ panel_name }}" style="height: 128px; width: auto; object-fit: contain; margin-bottom: 0.5rem;">
{% endif %}
<p>{{ t('login_to_continue') }}</p>
</div> <div id="errorMessage" class="error-message"></div>
<form id="loginForm">
<div class="form-group">
<label for="username">{{ t('username') }}</label>
<input
type="text"
id="username"
name="username"
required
autocomplete="username"
placeholder="{{ t('enter_username') }}"
>
</div>
<div class="form-group">
<label for="password">{{ t('password') }}</label>
<input
type="password"
id="password"
name="password"
required
autocomplete="current-password"
placeholder="{{ t('enter_password') }}"
>
</div>
<button type="submit" class="btn" id="loginBtn">
{{ t('login') }}
</button>
</form>
</div>
<div class="footer">
<p>{{ panel_name }} v{{ version }} © 2025</p>
</div>
</div>
<script>
const loginForm = document.getElementById('loginForm');
const loginBtn = document.getElementById('loginBtn');
const errorMessage = document.getElementById('errorMessage');
loginForm.addEventListener('submit', async (e) => {
e.preventDefault();
const username = document.getElementById('username').value;
const password = document.getElementById('password').value;
// Disable button and show loading
loginBtn.disabled = true;
loginBtn.innerHTML = '<span class="loading"></span> ' + '{{ t('logging_in') }}';
errorMessage.classList.remove('show');
try {
const response = await fetch('/api/auth/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ username, password })
});
const data = await response.json();
if (response.ok) {
// Save token to localStorage
localStorage.setItem('access_token', data.access_token);
// Redirect to original page or dashboard
const urlParams = new URLSearchParams(window.location.search);
const returnUrl = urlParams.get('returnUrl') ? decodeURIComponent(urlParams.get('returnUrl')) : '/dashboard';
window.location.href = returnUrl;
} else {
// Show error
errorMessage.textContent = data.detail || '{{ t('login_error_check_credentials') }}';
errorMessage.classList.add('show');
loginBtn.disabled = false;
loginBtn.textContent = '{{ t('login') }}';
}
} catch (error) {
errorMessage.textContent = '{{ t('server_connection_error') }}';
errorMessage.classList.add('show');
loginBtn.disabled = false;
loginBtn.textContent = '{{ t('login') }}';
}
});
// Check if already logged in
const token = localStorage.getItem('access_token');
if (token) {
// Verify token
fetch('/api/auth/me', {
headers: {
'Authorization': `Bearer ${token}`
}
}).then(response => {
if (response.ok) {
const urlParams = new URLSearchParams(window.location.search);
const returnUrl = urlParams.get('returnUrl') ? decodeURIComponent(urlParams.get('returnUrl')) : '/dashboard';
window.location.href = returnUrl;
}
});
}
</script>
</body>
</html>