Fix Ranking code step1
This commit is contained in:
@ -10,9 +10,40 @@
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.1/css/all.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body class="bg-gray-50">
|
||||
<div class="container mx-auto p-4">
|
||||
<div class="bg-white rounded-lg shadow-lg p-6 mb-6">
|
||||
<!-- ログインフォーム -->
|
||||
<div id="loginForm" class="fixed inset-0 bg-gray-800 bg-opacity-50 flex items-center justify-center">
|
||||
<div class="bg-white p-8 rounded-lg shadow-lg w-96">
|
||||
<h2 class="text-2xl font-bold mb-6 text-center">ログイン</h2>
|
||||
<form onsubmit="return login(event)">
|
||||
<div class="mb-4">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2" for="username">
|
||||
ユーザー名
|
||||
</label>
|
||||
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline"
|
||||
id="username" type="text" placeholder="ユーザー名">
|
||||
</div>
|
||||
<div class="mb-6">
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2" for="password">
|
||||
パスワード
|
||||
</label>
|
||||
<input class="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 mb-3 leading-tight focus:outline-none focus:shadow-outline"
|
||||
id="password" type="password" placeholder="パスワード">
|
||||
</div>
|
||||
<div class="flex items-center justify-center">
|
||||
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded focus:outline-none focus:shadow-outline"
|
||||
type="submit">
|
||||
ログイン
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div id="mainContent" class="container mx-auto p-4">
|
||||
<div class="bg-white rounded-lg shadow-lg p-6 mb-6" style="display: none;">
|
||||
<h1 class="text-2xl font-bold mb-6">通過審査管理画面</h1>
|
||||
<button onclick="logout()" class="px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700">
|
||||
ログアウト
|
||||
</button>
|
||||
|
||||
<!-- 選択フォーム -->
|
||||
<div class="grid grid-cols-1 md:grid-cols-4 gap-4 mb-6">
|
||||
@ -125,8 +156,62 @@
|
||||
let original_goal_time = '';
|
||||
let selected_event_code = '';
|
||||
|
||||
// ユーザー認証用の定数(実際の運用ではサーバーサイドで管理すべき)
|
||||
const VALID_USERNAME = 'admin';
|
||||
const VALID_PASSWORD = 'password123';
|
||||
|
||||
// セッション管理
|
||||
function checkAuth() {
|
||||
const isAuthenticated = sessionStorage.getItem('isAuthenticated');
|
||||
if (isAuthenticated) {
|
||||
document.getElementById('loginForm').style.display = 'none';
|
||||
document.getElementById('mainContent').style.display = 'block';
|
||||
} else {
|
||||
document.getElementById('loginForm').style.display = 'flex';
|
||||
document.getElementById('mainContent').style.display = 'none';
|
||||
}
|
||||
}
|
||||
|
||||
// ログイン処理
|
||||
async function login(event) {
|
||||
event.preventDefault();
|
||||
const username = document.getElementById('username').value;
|
||||
const password = document.getElementById('password').value;
|
||||
|
||||
const response = await fetch('/api/login/', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
identifier: username, // メールアドレス
|
||||
password: password
|
||||
})
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
if (!response.ok) {
|
||||
throw new Error(data.error || 'ログインに失敗しました');
|
||||
}
|
||||
|
||||
// SuperVisor User のみを許可する。
|
||||
console.info('Login successful:', data);
|
||||
sessionStorage.setItem('isAuthenticated', 'true');
|
||||
checkAuth();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// ログアウト処理
|
||||
function logout() {
|
||||
sessionStorage.removeItem('isAuthenticated');
|
||||
checkAuth();
|
||||
}
|
||||
|
||||
// イベントリスナーの設定
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
checkAuth();
|
||||
|
||||
// Sortable初期化これで、通過順序を変更できる
|
||||
const checkinList = document.getElementById('checkinList');
|
||||
new Sortable(checkinList, {
|
||||
|
||||
Reference in New Issue
Block a user