|
|
- <script>
- function editHostForm(id, username, apiKey)
- {
- $("#editUserBox").css("display", "");
- $("#useridLabel").val(id);
- $("#usernameLabel").val(username);
- $("#revokeAPIUsername").val(username);
- $("#apiDisplay").html(apiKey);
- }
- </script>
-
- <div id="editUserBox" class="row" style="display:none">
- <!-- Edit User -->
- <div class="col-md-6 col-12">
- <div class="card">
- <div class="card-header">
- <h3 class="text-center">Edit User</h3>
- </div>
- <div class="card-body">
- <form action="/edituser" method ="post" class="p-2">
- <div class="form-group">
- <input class="form-control" id="useridLabel" type="text" name="id" required>
- <label>User ID</label>
- </div>
- <div class="form-group">
- <input class="form-control" id="usernameLabel" type="text" name="username" required>
- <label>User Name</label>
- </div>
- <div class="form-group">
- <input class="form-control" type="password" name="password" required>
- <label>Password</label>
- </div>
-
- <div class="form-group">
- <input class="form-control w-100" type="checkbox" name="admin">
- <label>Admin</label>
- </div>
- <div class="text-center">
- <input type="submit" name="add_user" value="Update User"
- class="btn btn-lg btn-secondary"/>
- </div>
- </form>
- </div>
- </div>
- <br>
- </div>
-
- <!-- Edit API -->
- <div class="col-md-6 col-12">
- <div class="card">
- <div class="card-header">
- <h3 class="text-center">API Settings</h3>
- </div>
- <div class="card-body">
-
- <h4>Current API Key</h4>
- <p id="apiDisplay"></p>
-
- <form action="/revokeAPI" method ="post" class="p-2">
- <input class="form-control" id="revokeAPIUsername" type="text" name="username" value="" hidden>
- <div class="text-center">
- <input type="submit" name="revoke_api" value="Generate New API Key"
- class="btn btn-lg btn-secondary"/>
- </div>
- </form>
- </div>
- </div>
- <br>
- </div>
- </div>
-
- {if admin}
- <div class="row">
- <!-- Current Users -->
- <div class="col-md-8">
- <div class='card'>
- <div class="card-header">
- <h3 class="text-center">Users</h3>
- </div>
- <div class="card-body">
- <table class="table table-striped">
- <thead class="thead-dark">
- <tr>
- <td>User Name</td>
- <td>User ID</td>
- <td>Admin</td>
- <td>Edit</td>
- <td>Terminate</td>
- </tr>
- </thead>
- <tbody>
- {for user in users}
- <tr>
- <td>{user.username}</td>
- <td>{user.id}</td>
- <td>{user.admin}</td>
- <td>
- <button onclick="editHostForm({user.id}, '{user.username}', '{user.api}')" class="btn btn-secondary">Edit User</button>
- </td>
- <td>
- <form action="/removeuser" method ="post" >
- <input type="submit" name="submit" value="Delete" class="btn btn-secondary"/>
- <input type='hidden' name='id' value='{user.id}' />
- </form>
- </td>
- </tr>
- {/for}
- </tbody>
- </table>
- </div>
- </div>
- </div>
-
- <!-- Add User -->
- <div class="col-md-4">
- <div class="card">
- <div class="card-header">
- <h3 class="text-center">Add New User</h3>
- </div>
- <div class="card-body">
- <form action="/addUser" method ="post" class="p-2">
- <div class="form-group">
- <label> User Name
- <input class="form-control w-100" type="text" name="username" required>
- </label>
- </div>
- <div class="form-group">
- <label>Password
- <input class="form-control w-100" type="password" name="password" required>
- </label>
- </div>
- <div class="form-group">
- <label>Admin
- <input class="form-control w-100" type="checkbox" name="admin">
- </label>
- </div>
- <div class="text-center">
- <input type="submit" name="add_user" value="Create User"
- class="btn btn-lg btn-secondary"/>
- </div>
- </form>
- </div>
- </div>
- <br>
- </div>
- </div>
- {else}
- {if loggedIn}
- <div class="row">
- <div class="col-md-6 col-12">
- <div class="card">
- <div class="card-header">
- <h3 class="text-center">Update Profile</h3>
- </div>
- <div class="card-body">
- <form action="/updateUser" method ="post" class="p-2">
- <div class="form-group">
- <input class="form-control" id="usernameLabel" type="text" name="username" value="{username}" required>
- <label>User Name</label>
- </div>
- <div class="form-group">
- <input class="form-control" type="password" name="password" required>
- <label>Password</label>
- </div>
- <div class="text-center">
- <input type="submit" name="Update Profile" value="Update User"
- class="btn btn-lg btn-secondary"/>
- </div>
- </form>
- </div>
- </div>
- <br>
- </div>
- <div class="col-md-6 col-12">
- <div class="card">
- <div class="card-header">
- <h3 class="text-center">API Settings</h3>
- </div>
- <div class="card-body">
-
- <h4>Current API Key</h4>
- <p>{apiKey}</p>
-
- <form action="/revokeAPI" method ="post" class="p-2">
- <div class="text-center">
- <input type="submit" name="revoke_api" value="Generate New API Key"
- class="btn btn-lg btn-secondary"/>
- </div>
- </form>
- </div>
- </div>
- <br>
- </div>
- </div>
- {else}
- <h1 class="align-content-center">Login Required</h1>
- <div class="align-content-center">
- <img src="/includes/img/404.jpg" alt="Page not found" width="70%" />
- </div>
- {/if}
- {/if}
|