molozo12 commited on
Commit
a777593
·
verified ·
1 Parent(s): 8995ca3

also admin should be able to edit the users. I would like that for login, the users to not need a password, just a username and only admin to ask for a password if that username is added. the login should be user based not email based - Follow Up Deployment

Browse files
Files changed (3) hide show
  1. admin.html +98 -0
  2. login.html +13 -12
  3. prompts.txt +3 -1
admin.html CHANGED
@@ -112,6 +112,48 @@
112
  </div>
113
  </div>
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  <script>
116
  feather.replace();
117
 
@@ -190,6 +232,10 @@
190
  <td class="px-6 py-4 whitespace-nowrap">
191
  <input type="checkbox" ${userPermissions.delete ? 'checked' : ''} onchange="updatePermission('${user.id}', 'delete', this.checked)" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
192
  </td>
 
 
 
 
193
  `;
194
  tableBody.appendChild(row);
195
  });
@@ -260,6 +306,58 @@
260
  closeAddUserModal();
261
  alert('User added successfully!');
262
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
263
  </script>
264
  </body>
265
  </html>
 
112
  </div>
113
  </div>
114
 
115
+ <!-- Edit User Modal -->
116
+ <div id="edit-user-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden">
117
+ <div class="bg-white rounded-lg p-6 w-full max-w-md">
118
+ <div class="flex justify-between items-center mb-4">
119
+ <h3 class="text-lg font-semibold">Edit User</h3>
120
+ <button onclick="closeEditUserModal()" class="text-gray-500 hover:text-gray-700">
121
+ <i data-feather="x"></i>
122
+ </button>
123
+ </div>
124
+ <form id="edit-user-form" class="space-y-4">
125
+ <input type="hidden" id="edit-user-id">
126
+ <div>
127
+ <label for="edit-user-name" class="block text-sm font-medium text-gray-700">Name</label>
128
+ <input type="text" id="edit-user-name" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
129
+ </div>
130
+ <div>
131
+ <label for="edit-user-username" class="block text-sm font-medium text-gray-700">Username</label>
132
+ <input type="text" id="edit-user-username" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
133
+ </div>
134
+ <div>
135
+ <label for="edit-user-password" class="block text-sm font-medium text-gray-700">Password (admin only)</label>
136
+ <input type="password" id="edit-user-password" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
137
+ </div>
138
+ <div>
139
+ <label for="edit-user-role" class="block text-sm font-medium text-gray-700">Role</label>
140
+ <select id="edit-user-role" class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
141
+ <option value="user">User</option>
142
+ <option value="admin">Admin</option>
143
+ </select>
144
+ </div>
145
+ <div class="flex justify-end space-x-3">
146
+ <button type="button" onclick="closeEditUserModal()" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50">
147
+ Cancel
148
+ </button>
149
+ <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-md text-sm font-medium hover:bg-blue-600">
150
+ Save
151
+ </button>
152
+ </div>
153
+ </form>
154
+ </div>
155
+ </div>
156
+
157
  <script>
158
  feather.replace();
159
 
 
232
  <td class="px-6 py-4 whitespace-nowrap">
233
  <input type="checkbox" ${userPermissions.delete ? 'checked' : ''} onchange="updatePermission('${user.id}', 'delete', this.checked)" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded">
234
  </td>
235
+ <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium">
236
+ <button onclick="openEditUserModal('${user.id}')" class="text-blue-600 hover:text-blue-900 mr-3">Edit</button>
237
+ <button onclick="deleteUser('${user.id}')" class="text-red-600 hover:text-red-900">Delete</button>
238
+ </td>
239
  `;
240
  tableBody.appendChild(row);
241
  });
 
306
  closeAddUserModal();
307
  alert('User added successfully!');
308
  });
309
+
310
+ function openEditUserModal(userId) {
311
+ const user = state.users.find(u => u.id === userId);
312
+ if (!user) return;
313
+
314
+ document.getElementById('edit-user-id').value = user.id;
315
+ document.getElementById('edit-user-name').value = user.name;
316
+ document.getElementById('edit-user-username').value = user.username;
317
+ document.getElementById('edit-user-role').value = user.role;
318
+
319
+ document.getElementById('edit-user-modal').classList.remove('hidden');
320
+ }
321
+
322
+ function closeEditUserModal() {
323
+ document.getElementById('edit-user-modal').classList.add('hidden');
324
+ document.getElementById('edit-user-form').reset();
325
+ }
326
+
327
+ function deleteUser(userId) {
328
+ if (confirm('Are you sure you want to delete this user?')) {
329
+ state.users = state.users.filter(u => u.id !== userId);
330
+ localStorage.setItem('users', JSON.stringify(state.users));
331
+ renderUsersTable();
332
+ }
333
+ }
334
+
335
+ document.getElementById('edit-user-form').addEventListener('submit', function(e) {
336
+ e.preventDefault();
337
+
338
+ const userId = document.getElementById('edit-user-id').value;
339
+ const name = document.getElementById('edit-user-name').value;
340
+ const username = document.getElementById('edit-user-username').value;
341
+ const password = document.getElementById('edit-user-password').value;
342
+ const role = document.getElementById('edit-user-role').value;
343
+
344
+ const userIndex = state.users.findIndex(u => u.id === userId);
345
+ if (userIndex === -1) return;
346
+
347
+ // Update user
348
+ state.users[userIndex].name = name;
349
+ state.users[userIndex].username = username;
350
+ state.users[userIndex].role = role;
351
+
352
+ // Only update password if provided (and for admin users)
353
+ if (password && role === 'admin') {
354
+ state.users[userIndex].password = password;
355
+ }
356
+
357
+ localStorage.setItem('users', JSON.stringify(state.users));
358
+ renderUsersTable();
359
+ closeEditUserModal();
360
+ });
361
  </script>
362
  </body>
363
  </html>
login.html CHANGED
@@ -17,13 +17,8 @@
17
 
18
  <form id="login-form" class="space-y-6">
19
  <div>
20
- <label for="email" class="block text-sm font-medium text-gray-700">Email</label>
21
- <input type="email" id="email" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
22
- </div>
23
-
24
- <div>
25
- <label for="password" class="block text-sm font-medium text-gray-700">Password</label>
26
- <input type="password" id="password" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
27
  </div>
28
 
29
  <div>
@@ -119,17 +114,23 @@
119
  function handleLogin(e) {
120
  e.preventDefault();
121
 
122
- const email = document.getElementById('email').value;
123
- const password = document.getElementById('password').value;
124
-
125
  const users = JSON.parse(localStorage.getItem('users') || '[]');
126
- const user = users.find(u => u.email === email && u.password === password);
127
 
128
  if (user) {
 
 
 
 
 
 
 
 
129
  localStorage.setItem('currentUser', JSON.stringify(user));
130
  window.location.href = 'index.html';
131
  } else {
132
- alert('Invalid email or password');
133
  }
134
  }
135
 
 
17
 
18
  <form id="login-form" class="space-y-6">
19
  <div>
20
+ <label for="username" class="block text-sm font-medium text-gray-700">Username</label>
21
+ <input type="text" id="username" required class="mt-1 block w-full border border-gray-300 rounded-md shadow-sm py-2 px-3 focus:outline-none focus:ring-blue-500 focus:border-blue-500">
 
 
 
 
 
22
  </div>
23
 
24
  <div>
 
114
  function handleLogin(e) {
115
  e.preventDefault();
116
 
117
+ const username = document.getElementById('username').value;
 
 
118
  const users = JSON.parse(localStorage.getItem('users') || '[]');
119
+ const user = users.find(u => u.username === username);
120
 
121
  if (user) {
122
+ // Only require password for admin users
123
+ if (user.role === 'admin') {
124
+ const password = prompt("Please enter admin password:");
125
+ if (password !== user.password) {
126
+ alert('Invalid password');
127
+ return;
128
+ }
129
+ }
130
  localStorage.setItem('currentUser', JSON.stringify(user));
131
  window.location.href = 'index.html';
132
  } else {
133
+ alert('User not found');
134
  }
135
  }
136
 
prompts.txt CHANGED
@@ -1,3 +1,5 @@
1
  can you create a kanban page that is self contained (so i can run it on my pc). I would like to have also an admin page, to set who can add tasks, who can move them, who can read them based on the user login. All users should be able to see the groups tasks and can select tasks they will work on
2
  can you also add an export to excel future and also export to pdf (make it nice) , so that people can save their work?
3
- admin should be able to add more users also directly
 
 
 
1
  can you create a kanban page that is self contained (so i can run it on my pc). I would like to have also an admin page, to set who can add tasks, who can move them, who can read them based on the user login. All users should be able to see the groups tasks and can select tasks they will work on
2
  can you also add an export to excel future and also export to pdf (make it nice) , so that people can save their work?
3
+ admin should be able to add more users also directly
4
+ also admin should be able to edit the users. I would like that for login, the users to not need a password, just a username and only admin to ask for a password if that username is added. the login should be user based not email based
5
+ also admin should be able to edit the users. I would like that for login, the users to not need a password, just a username and only admin to ask for a password if that username is added. the login should be user based not email based