geethareddy commited on
Commit
23dde53
·
verified ·
1 Parent(s): cb49ced

Create login.html

Browse files
Files changed (1) hide show
  1. templates/login.html +197 -0
templates/login.html ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Login - AI Coach</title>
7
+ <style>
8
+ body {
9
+ font-family: 'Roboto', Arial, sans-serif;
10
+ background: linear-gradient(135deg, #f0f2f5 0%, #e9ecef 100%);
11
+ display: flex;
12
+ justify-content: center;
13
+ align-items: center;
14
+ height: 100vh;
15
+ margin: 0;
16
+ color: #2d3748;
17
+ }
18
+ .login-container {
19
+ background-color: #fff;
20
+ padding: 40px;
21
+ border-radius: 12px;
22
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
23
+ width: 100%;
24
+ max-width: 400px;
25
+ text-align: center;
26
+ }
27
+ h2 {
28
+ margin-bottom: 30px;
29
+ color: #1a3c7a;
30
+ font-size: 24px;
31
+ font-weight: 700;
32
+ }
33
+ .form-group {
34
+ margin-bottom: 20px;
35
+ text-align: left;
36
+ }
37
+ label {
38
+ display: block;
39
+ margin-bottom: 8px;
40
+ font-size: 14px;
41
+ font-weight: 500;
42
+ color: #4a5568;
43
+ }
44
+ input {
45
+ width: 100%;
46
+ padding: 12px;
47
+ border: 2px solid #e2e8f0;
48
+ border-radius: 8px;
49
+ font-size: 16px;
50
+ box-sizing: border-box;
51
+ transition: border-color 0.3s ease, box-shadow 0.3s ease;
52
+ }
53
+ input:focus {
54
+ border-color: #ed8936;
55
+ outline: none;
56
+ box-shadow: 0 0 8px rgba(237, 137, 54, 0.3);
57
+ }
58
+ button {
59
+ width: 100%;
60
+ padding: 12px;
61
+ background: linear-gradient(to right, #f6ad55, #ed8936);
62
+ color: #fff;
63
+ border: none;
64
+ border-radius: 8px;
65
+ font-size: 16px;
66
+ font-weight: 600;
67
+ cursor: pointer;
68
+ transition: background 0.3s ease, transform 0.1s ease;
69
+ }
70
+ button:hover {
71
+ background: linear-gradient(to right, #ed8936, #dd6b20);
72
+ transform: scale(1.02);
73
+ }
74
+ .error, .success {
75
+ margin-bottom: 20px;
76
+ padding: 10px;
77
+ border-radius: 8px;
78
+ font-size: 14px;
79
+ }
80
+ .error {
81
+ background-color: #f56565;
82
+ color: #fff;
83
+ }
84
+ .success {
85
+ background-color: #48bb78;
86
+ color: #fff;
87
+ }
88
+ .link {
89
+ margin-top: 20px;
90
+ font-size: 14px;
91
+ color: #4a5568;
92
+ }
93
+ .link a {
94
+ color: #ed8936;
95
+ text-decoration: none;
96
+ font-weight: 500;
97
+ }
98
+ .link a:hover {
99
+ text-decoration: underline;
100
+ }
101
+ @media (max-width: 500px) {
102
+ .login-container {
103
+ padding: 20px;
104
+ margin: 20px;
105
+ }
106
+ h2 {
107
+ font-size: 20px;
108
+ }
109
+ input, button {
110
+ font-size: 14px;
111
+ }
112
+ }
113
+ </style>
114
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
115
+ </head>
116
+ <body>
117
+ <div class="login-container">
118
+ <h2>Login to AI Coach</h2>
119
+ <div id="error" class="error" style="display: none;"></div>
120
+ <div id="success" class="success" style="display: none;"></div>
121
+ <form id="login-form">
122
+ <div class="form-group">
123
+ <label for="supervisor_id">Supervisor ID</label>
124
+ <input type="text" id="supervisor_id" name="supervisor_id" placeholder="Enter Supervisor ID" required>
125
+ </div>
126
+ <div class="form-group">
127
+ <label for="password">Password</label>
128
+ <input type="password" id="password" name="password" placeholder="Enter password" required>
129
+ </div>
130
+ <button type="submit">Login</button>
131
+ </form>
132
+ <div class="link">
133
+ Don't have an account? <a href="/signup">Sign up</a>
134
+ </div>
135
+ <div class="link">
136
+ Login as <a href="#" onclick="guestLogin()">Guest</a>
137
+ </div>
138
+ </div>
139
+
140
+ <script>
141
+ function showMessage(type, message) {
142
+ const element = document.getElementById(type);
143
+ element.textContent = message;
144
+ element.style.display = 'block';
145
+ setTimeout(() => {
146
+ element.style.display = 'none';
147
+ }, 5000);
148
+ }
149
+
150
+ async function guestLogin() {
151
+ try {
152
+ const response = await fetch('/login', {
153
+ method: 'POST',
154
+ headers: { 'Content-Type': 'application/json' },
155
+ body: JSON.stringify({ supervisor_id: 'GUEST', password: '' })
156
+ });
157
+ const result = await response.json();
158
+ if (result.status === 'success') {
159
+ showMessage('success', result.message);
160
+ setTimeout(() => {
161
+ window.location.href = result.redirect; // Redirect to the URL returned in the response
162
+ }, 1000);
163
+ } else {
164
+ showMessage('error', result.message);
165
+ }
166
+ } catch (error) {
167
+ showMessage('error', 'Error during guest login: ' + error.message);
168
+ }
169
+ }
170
+
171
+ document.getElementById('login-form').addEventListener('submit', async (e) => {
172
+ e.preventDefault();
173
+ const supervisor_id = document.getElementById('supervisor_id').value.trim();
174
+ const password = document.getElementById('password').value;
175
+ try {
176
+ const response = await fetch('/login', {
177
+ method: 'POST',
178
+ headers: { 'Content-Type': 'application/json' },
179
+ body: JSON.stringify({ supervisor_id, password })
180
+ });
181
+ const result = await response.json();
182
+ if (result.status === 'success') {
183
+ showMessage('success', result.message);
184
+ setTimeout(() => {
185
+ window.location.href = result.redirect; // Redirect to the URL returned in the response
186
+ }, 1000);
187
+ } else {
188
+ showMessage('error', result.message);
189
+ }
190
+ } catch (error) {
191
+ showMessage('error', 'Error during login: ' + error.message);
192
+ }
193
+ });
194
+
195
+ </script>
196
+ </body>
197
+ </html>