Download admin.html from molozo12/test: direct link, hf CLI and curl.
- Browser
- Download file 20.1 kB
-
https://huggingface.co/spaces/molozo12/test/resolve/main/admin.html
- Command line
-
hf download hf://spaces/molozo12/test/admin.html
-
curl -L -o admin.html https://huggingface.co/spaces/molozo12/test/resolve/main/admin.html
20.1 kB
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>Admin - Kanban Board</title> | |
| <script src="https://cdn.tailwindcss.com"></script> | |
| <script src="https://unpkg.com/feather-icons"></script> | |
| </head> | |
| <body class="bg-gray-50"> | |
| <div id="app" class="min-h-screen"> | |
| <!-- Navigation --> | |
| <nav class="bg-white shadow-sm"> | |
| <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8"> | |
| <div class="flex justify-between h-16"> | |
| <div class="flex"> | |
| <div class="flex-shrink-0 flex items-center"> | |
| <i data-feather="trello" class="text-blue-500"></i> | |
| <span class="ml-2 text-xl font-semibold text-gray-800">Kanban Admin</span> | |
| </div> | |
| </div> | |
| <div class="flex items-center"> | |
| <div class="ml-4 flex items-center md:ml-6"> | |
| <div class="ml-3 relative"> | |
| <div class="flex items-center space-x-4"> | |
| <span id="current-user" class="text-sm font-medium text-gray-700"></span> | |
| <button onclick="window.location.href='index.html'" class="px-3 py-1 rounded-md text-sm font-medium text-white bg-blue-500 hover:bg-blue-600"> | |
| Board | |
| </button> | |
| <button onclick="logout()" class="px-3 py-1 rounded-md text-sm font-medium text-white bg-red-500 hover:bg-red-600"> | |
| Logout | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </nav> | |
| <!-- Main Content --> | |
| <main class="py-6 px-4 sm:px-6 lg:px-8"> | |
| <div class="mb-6 flex justify-between items-center"> | |
| <div> | |
| <h2 class="text-2xl font-bold text-gray-800">User Permissions</h2> | |
| <p class="text-gray-600 mt-1">Manage what each user can do on the Kanban board</p> | |
| </div> | |
| <button onclick="openAddUserModal()" class="px-4 py-2 bg-green-500 text-white rounded-md hover:bg-green-600 flex items-center"> | |
| <i data-feather="user-plus" class="mr-2"></i> Add User | |
| </button> | |
| </div> | |
| <div class="bg-white shadow rounded-lg overflow-hidden"> | |
| <div class="overflow-x-auto"> | |
| <table class="min-w-full divide-y divide-gray-200"> | |
| <thead class="bg-gray-50"> | |
| <tr> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">User</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Role</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">View Tasks</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Add Tasks</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Move Tasks</th> | |
| <th scope="col" class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Delete Tasks</th> | |
| </tr> | |
| </thead> | |
| <tbody id="users-table" class="bg-white divide-y divide-gray-200"> | |
| <!-- Users will be populated here --> | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </main> | |
| <!-- Add User Modal --> | |
| <div id="add-user-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden"> | |
| <div class="bg-white rounded-lg p-6 w-full max-w-md"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-lg font-semibold">Add New User</h3> | |
| <button onclick="closeAddUserModal()" class="text-gray-500 hover:text-gray-700"> | |
| <i data-feather="x"></i> | |
| </button> | |
| </div> | |
| <form id="add-user-form" class="space-y-4"> | |
| <div> | |
| <label for="new-user-name" class="block text-sm font-medium text-gray-700">Name</label> | |
| <input type="text" id="new-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"> | |
| </div> | |
| <div> | |
| <label for="new-user-email" class="block text-sm font-medium text-gray-700">Email</label> | |
| <input type="email" id="new-user-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"> | |
| </div> | |
| <div> | |
| <label for="new-user-password" class="block text-sm font-medium text-gray-700">Password</label> | |
| <input type="password" id="new-user-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"> | |
| </div> | |
| <div> | |
| <label for="new-user-role" class="block text-sm font-medium text-gray-700">Role</label> | |
| <select id="new-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"> | |
| <option value="user">User</option> | |
| <option value="admin">Admin</option> | |
| </select> | |
| </div> | |
| <div class="flex justify-end space-x-3"> | |
| <button type="button" onclick="closeAddUserModal()" class="px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 hover:bg-gray-50"> | |
| Cancel | |
| </button> | |
| <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-md text-sm font-medium hover:bg-blue-600"> | |
| Add User | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- Edit User Modal --> | |
| <div id="edit-user-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center hidden"> | |
| <div class="bg-white rounded-lg p-6 w-full max-w-md"> | |
| <div class="flex justify-between items-center mb-4"> | |
| <h3 class="text-lg font-semibold">Edit User</h3> | |
| <button onclick="closeEditUserModal()" class="text-gray-500 hover:text-gray-700"> | |
| <i data-feather="x"></i> | |
| </button> | |
| </div> | |
| <form id="edit-user-form" class="space-y-4"> | |
| <input type="hidden" id="edit-user-id"> | |
| <div> | |
| <label for="edit-user-name" class="block text-sm font-medium text-gray-700">Name</label> | |
| <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"> | |
| </div> | |
| <div> | |
| <label for="edit-user-username" class="block text-sm font-medium text-gray-700">Username</label> | |
| <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"> | |
| </div> | |
| <div> | |
| <label for="edit-user-password" class="block text-sm font-medium text-gray-700">Password (admin only)</label> | |
| <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"> | |
| </div> | |
| <div> | |
| <label for="edit-user-role" class="block text-sm font-medium text-gray-700">Role</label> | |
| <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"> | |
| <option value="user">User</option> | |
| <option value="admin">Admin</option> | |
| </select> | |
| </div> | |
| <div class="flex justify-end space-x-3"> | |
| <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"> | |
| Cancel | |
| </button> | |
| <button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded-md text-sm font-medium hover:bg-blue-600"> | |
| Save | |
| </button> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| <script> | |
| feather.replace(); | |
| // App state | |
| const state = { | |
| currentUser: null, | |
| users: [], | |
| permissions: {} | |
| }; | |
| // Initialize the app | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Check if user is logged in | |
| const user = localStorage.getItem('currentUser'); | |
| if (!user) { | |
| window.location.href = 'login.html'; | |
| return; | |
| } | |
| state.currentUser = JSON.parse(user); | |
| document.getElementById('current-user').textContent = `Welcome, ${state.currentUser.name}`; | |
| // Check if user is admin | |
| if (state.currentUser.role !== 'admin') { | |
| window.location.href = 'index.html'; | |
| return; | |
| } | |
| // Load data | |
| loadData(); | |
| renderUsersTable(); | |
| }); | |
| function loadData() { | |
| const users = localStorage.getItem('users'); | |
| const permissions = localStorage.getItem('permissions'); | |
| if (users) state.users = JSON.parse(users); | |
| if (permissions) state.permissions = JSON.parse(permissions); | |
| } | |
| function renderUsersTable() { | |
| const tableBody = document.getElementById('users-table'); | |
| tableBody.innerHTML = ''; | |
| state.users.forEach(user => { | |
| const userPermissions = state.permissions[user.id] || {}; | |
| const row = document.createElement('tr'); | |
| row.innerHTML = ` | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <div class="flex items-center"> | |
| <div class="flex-shrink-0 h-10 w-10 rounded-full bg-gray-200 flex items-center justify-center"> | |
| <i data-feather="user" class="text-gray-500"></i> | |
| </div> | |
| <div class="ml-4"> | |
| <div class="text-sm font-medium text-gray-900">${user.name}</div> | |
| <div class="text-sm text-gray-500">${user.email}</div> | |
| </div> | |
| </div> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <span class="px-2 inline-flex text-xs leading-5 font-semibold rounded-full ${user.role === 'admin' ? 'bg-purple-100 text-purple-800' : 'bg-green-100 text-green-800'}"> | |
| ${user.role} | |
| </span> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <input type="checkbox" ${userPermissions.read ? 'checked' : ''} onchange="updatePermission('${user.id}', 'read', this.checked)" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <input type="checkbox" ${userPermissions.add ? 'checked' : ''} onchange="updatePermission('${user.id}', 'add', this.checked)" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <input type="checkbox" ${userPermissions.move ? 'checked' : ''} onchange="updatePermission('${user.id}', 'move', this.checked)" class="h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap"> | |
| <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"> | |
| </td> | |
| <td class="px-6 py-4 whitespace-nowrap text-right text-sm font-medium"> | |
| <button onclick="openEditUserModal('${user.id}')" class="text-blue-600 hover:text-blue-900 mr-3">Edit</button> | |
| <button onclick="deleteUser('${user.id}')" class="text-red-600 hover:text-red-900">Delete</button> | |
| </td> | |
| `; | |
| tableBody.appendChild(row); | |
| }); | |
| feather.replace(); | |
| } | |
| function updatePermission(userId, permission, value) { | |
| if (!state.permissions[userId]) { | |
| state.permissions[userId] = {}; | |
| } | |
| state.permissions[userId][permission] = value; | |
| localStorage.setItem('permissions', JSON.stringify(state.permissions)); | |
| } | |
| function logout() { | |
| localStorage.removeItem('currentUser'); | |
| window.location.href = 'login.html'; | |
| } | |
| function openAddUserModal() { | |
| document.getElementById('add-user-modal').classList.remove('hidden'); | |
| } | |
| function closeAddUserModal() { | |
| document.getElementById('add-user-modal').classList.add('hidden'); | |
| document.getElementById('add-user-form').reset(); | |
| } | |
| // Handle add user form submission | |
| document.getElementById('add-user-form').addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const name = document.getElementById('new-user-name').value; | |
| const email = document.getElementById('new-user-email').value; | |
| const password = document.getElementById('new-user-password').value; | |
| const role = document.getElementById('new-user-role').value; | |
| // Check if email already exists | |
| if (state.users.some(u => u.email === email)) { | |
| alert('Email already registered'); | |
| return; | |
| } | |
| // Create new user | |
| const newUser = { | |
| id: Date.now().toString(), | |
| name, | |
| username: name.toLowerCase().replace(/\s+/g, ''), | |
| password, | |
| role | |
| }; | |
| state.users.push(newUser); | |
| localStorage.setItem('users', JSON.stringify(state.users)); | |
| // Set default permissions for new user | |
| state.permissions[newUser.id] = { | |
| read: true, | |
| add: role === 'admin', | |
| move: role === 'admin', | |
| delete: role === 'admin' | |
| }; | |
| localStorage.setItem('permissions', JSON.stringify(state.permissions)); | |
| // Refresh the table | |
| renderUsersTable(); | |
| closeAddUserModal(); | |
| alert('User added successfully!'); | |
| }); | |
| function openEditUserModal(userId) { | |
| const user = state.users.find(u => u.id === userId); | |
| if (!user) return; | |
| document.getElementById('edit-user-id').value = user.id; | |
| document.getElementById('edit-user-name').value = user.name; | |
| document.getElementById('edit-user-username').value = user.username; | |
| document.getElementById('edit-user-role').value = user.role; | |
| document.getElementById('edit-user-modal').classList.remove('hidden'); | |
| } | |
| function closeEditUserModal() { | |
| document.getElementById('edit-user-modal').classList.add('hidden'); | |
| document.getElementById('edit-user-form').reset(); | |
| } | |
| function deleteUser(userId) { | |
| if (confirm('Are you sure you want to delete this user?')) { | |
| state.users = state.users.filter(u => u.id !== userId); | |
| localStorage.setItem('users', JSON.stringify(state.users)); | |
| renderUsersTable(); | |
| } | |
| } | |
| document.getElementById('edit-user-form').addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| const userId = document.getElementById('edit-user-id').value; | |
| const name = document.getElementById('edit-user-name').value; | |
| const username = document.getElementById('edit-user-username').value; | |
| const password = document.getElementById('edit-user-password').value; | |
| const role = document.getElementById('edit-user-role').value; | |
| const userIndex = state.users.findIndex(u => u.id === userId); | |
| if (userIndex === -1) return; | |
| // Update user | |
| state.users[userIndex].name = name; | |
| state.users[userIndex].username = username; | |
| state.users[userIndex].role = role; | |
| // Only update password if provided (and for admin users) | |
| if (password && role === 'admin') { | |
| state.users[userIndex].password = password; | |
| } | |
| localStorage.setItem('users', JSON.stringify(state.users)); | |
| renderUsersTable(); | |
| closeEditUserModal(); | |
| }); | |
| </script> | |
| </body> | |
| </html> | |
| This Kanban application includes: | |
| 1. **index.html** - The main Kanban board with: | |
| - Drag and drop functionality (for users with move permissions) | |
| - Task creation (for users with add permissions) | |
| - Task assignment to yourself | |
| - Task deletion (for creators or users with delete permissions) | |
| - Responsive design for all screen sizes | |
| 2. **login.html** - Authentication page with: | |
| - Login form | |
| - User registration (creates new users with default permissions) | |
| - Default admin and user accounts | |
| 3. **admin.html** - Admin dashboard with: | |
| - User permissions management | |
| - Ability to control who can view, add, move, and delete tasks | |
| - Role-based access control | |
| The application is completely self-contained and uses localStorage for data persistence, so it will work offline on your PC. All data (users, tasks, permissions) is saved in the browser's localStorage. | |
| To use it: | |
| 1. Save all three files in the same folder | |
| 2. Open login.html in your browser | |
| 3. Log in with: | |
| - Admin: email: admin@example.com, password: admin123 | |
| - Regular user: email: user@example.com, password: user123 | |
| 4. You can create more users from the login page | |
| The admin can then set permissions for each user on what they can do with tasks. |