updated the manage player pages

This commit is contained in:
Ske087
2025-01-24 21:18:47 +02:00
parent 9e7bccaae1
commit df0f11eabd
10 changed files with 213 additions and 82 deletions

View File

@@ -15,6 +15,10 @@
.dark-mode label, .dark-mode th, .dark-mode td {
color: #ffffff;
}
.img-preview {
max-width: 100px;
max-height: 100px;
}
</style>
</head>
<body class="{{ 'dark-mode' if theme == 'dark' else '' }}">
@@ -25,57 +29,98 @@
<h2>Manage Users</h2>
</div>
<div class="card-body">
<!-- Manage User Roles Section -->
<h3>Manage User Roles</h3>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.username }}</td>
<td>{{ user.role }}</td>
<td>
<form action="{{ url_for('change_role', user_id=user.id) }}" method="post" class="d-inline">
<select name="role" class="form-select d-inline-block" style="width: auto;">
<option value="user" {% if user.role == 'user' %}selected{% endif %}>User</option>
<option value="admin" {% if user.role == 'admin' %}selected{% endif %}>Admin</option>
</select>
<button type="submit" class="btn btn-sm btn-primary">Change Role</button>
</form>
<form action="{{ url_for('delete_user', user_id=user.id) }}" method="post" class="d-inline">
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this user?');">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
<div class="row">
<div class="col-md-5">
<h3>Manage User Roles</h3>
<table class="table">
<thead>
<tr>
<th>Username</th>
<th>Role</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.username }}</td>
<td>{{ user.role }}</td>
<td>
<form action="{{ url_for('change_role', user_id=user.id) }}" method="post" class="d-inline">
<select name="role" class="form-select d-inline-block" style="width: auto;">
<option value="user" {% if user.role == 'user' %}selected{% endif %}>User</option>
<option value="admin" {% if user.role == 'admin' %}selected{% endif %}>Admin</option>
</select>
<button type="submit" class="btn btn-sm btn-primary">Change Role</button>
</form>
<form action="{{ url_for('delete_user', user_id=user.id) }}" method="post" class="d-inline">
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('Are you sure you want to delete this user?');">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<div class="col-md-1 d-flex justify-content-center">
<div class="vr"></div>
</div>
<div class="col-md-6">
<h3>Add User</h3>
<form action="{{ url_for('create_user') }}" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="password" name="password" required>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select {{ 'dark-mode' if theme == 'dark' else '' }}" id="role" name="role" required>
<option value="admin">Admin</option>
<option value="user">User</option>
</select>
</div>
<button type="submit" class="btn btn-primary">Add User</button>
</form>
</div>
</div>
</div>
</div>
<!-- Add New User Section -->
<h3 class="mt-4">Add New User</h3>
<form action="{{ url_for('create_user') }}" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
<div class="card mb-4 {{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="card-header">
<h2>Upload Personalization Photos for the App</h2>
</div>
<div class="card-body">
<form action="{{ url_for('upload_personalization_pictures') }}" method="post" enctype="multipart/form-data">
<div class="row mb-3">
<div class="col-md-4">
<label for="logo" class="form-label">Current Logo</label>
{% if logo_exists %}
<img src="{{ url_for('static', filename='uploads/logo.png') }}" alt="Current Logo" class="img-thumbnail img-preview mb-3">
{% endif %}
</div>
<div class="col-md-8">
<label for="logo" class="form-label">Select New Logo</label>
<input type="file" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="logo" name="logo">
</div>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
<div class="row mb-3">
<div class="col-md-4">
<label for="login_picture" class="form-label">Current Login Page Picture</label>
{% if login_picture_exists %}
<img src="{{ url_for('static', filename='uploads/login_picture.png') }}" alt="Current Login Picture" class="img-thumbnail img-preview mb-3">
{% endif %}
</div>
<div class="col-md-8">
<label for="login_picture" class="form-label">Select New Login Page Picture</label>
<input type="file" class="form-control {{ 'dark-mode' if theme == 'dark' else '' }}" id="login_picture" name="login_picture">
</div>
</div>
<div class="mb-3">
<label for="role" class="form-label">Role</label>
<select class="form-select" id="role" name="role" required>
<option value="user">User</option>
<option value="admin">Admin</option>
</select>
</div>
<button type="submit" class="btn btn-success">Create User</button>
<button type="submit" class="btn btn-primary">Upload Pictures</button>
</form>
</div>
</div>

View File

@@ -14,11 +14,20 @@
background-color: #1e1e1e;
color: #ffffff;
}
.logo {
max-height: 100px;
margin-right: 20px;
}
</style>
</head>
<body class="{{ 'dark-mode' if theme == 'dark' else '' }}">
<div class="container py-5">
<h1 class="text-center mb-4">Dashboard</h1>
<div class="d-flex justify-content-start align-items-center mb-4">
{% if logo_exists %}
<img src="{{ url_for('static', filename='uploads/logo.png') }}" alt="Logo" class="logo">
{% endif %}
<h1 class="mb-0">Dashboard</h1>
</div>
<!-- Sign Out Button -->
<div class="text-end mb-4">

View File

@@ -3,30 +3,40 @@
<head>
<title>Edit Player</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
body.dark-mode {
background-color: #121212;
color: #ffffff;
}
.card.dark-mode {
background-color: #1e1e1e;
color: #ffffff;
}
.dark-mode label, .dark-mode th, .dark-mode td {
color: #ffffff;
}
</style>
</head>
<body>
<body class="{% if theme == 'dark' %}dark-mode{% endif %}">
<div class="container py-5">
<h1 class="text-center mb-4">Edit Player</h1>
<form action="{{ url_for('edit_player', player_id=player.id) }}" method="post">
<div class="mb-3">
<label for="username" class="form-label">Player Name</label>
<input type="text" class="form-control" id="username" name="username" value="{{ player.username }}" required>
<input type="text" class="form-control {% if theme == 'dark' %}dark-mode{% endif %}" id="username" name="username" value="{{ player.username }}" required>
</div>
<div class="mb-3">
<label for="hostname" class="form-label">Hostname</label>
<input type="text" class="form-control" id="hostname" name="hostname" value="{{ player.hostname }}" required>
</div>
<div class="mb-3">
<label for="ip" class="form-label">IP Address</label>
<input type="text" class="form-control" id="ip" name="ip" value="{{ player.ip }}" required>
<input type="text" class="form-control {% if theme == 'dark' %}dark-mode{% endif %}" id="hostname" name="hostname" value="{{ player.hostname }}" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password (leave blank to keep current password)</label>
<input type="password" class="form-control" id="password" name="password">
<input type="password" class="form-control {% if theme == 'dark' %}dark-mode{% endif %}" id="password" name="password">
</div>
<button type="submit" class="btn btn-primary">Update Player</button>
</form>
<a href="{{ url_for('player_page', player_id=player.id) }}" class="btn btn-secondary mt-3">Back to Player Page</a>
<a href="{{ return_url }}" class="btn btn-secondary mt-3">Back to Player Page</a>
<a href="{{ url_for('dashboard') }}" class="btn btn-secondary mt-3">Back to Dashboard</a>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
</body>

View File

@@ -3,21 +3,37 @@
<head>
<title>Login</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css" rel="stylesheet">
<style>
.login-picture {
max-width: 100%;
height: auto;
margin-bottom: 20px;
}
</style>
</head>
<body>
<div class="container py-5">
<h1 class="text-center mb-4">Login</h1>
<form action="{{ url_for('login') }}" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
<div class="row">
<div class="col-md-6 text-center">
{% if login_picture_exists %}
<img src="{{ url_for('static', filename='uploads/login_picture.png') }}" alt="Login Picture" class="login-picture">
{% endif %}
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
<div class="col-md-6">
<h1 class="text-center mb-4">Login</h1>
<form action="{{ url_for('login') }}" method="post">
<div class="mb-3">
<label for="username" class="form-label">Username</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Password</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary w-100">Login</button>
</form>
</div>
<button type="submit" class="btn btn-primary">Login</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"></script>
</body>

View File

@@ -29,9 +29,8 @@
<div class="card-body">
<p><strong>Player Name:</strong> {{ player.username }}</p>
<p><strong>Hostname:</strong> {{ player.hostname }}</p>
<p><strong>IP Address:</strong> {{ player.ip }}</p>
{% if current_user.role == 'admin' %}
<a href="{{ url_for('edit_player', player_id=player.id) }}" class="btn btn-warning">Update</a>
<a href="{{ url_for('edit_player', player_id=player.id, return_url=url_for('player_page', player_id=player.id)) }}" class="btn btn-warning">Update</a>
<form action="{{ url_for('delete_player', player_id=player.id) }}" method="post" style="display:inline;">
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this player?');">Delete</button>
</form>
@@ -63,14 +62,16 @@
{% if content %}
<ul class="list-group">
{% for media in content %}
<li class="list-group-item {% if theme == 'dark' %}dark-mode{% endif %}">
<p><strong>Media Name:</strong> {{ media.file_name }}</p>
<p><strong>Duration:</strong> {{ media.duration }} minutes</p>
<form action="{{ url_for('edit_content', content_id=media.id) }}" method="post" style="display:inline;">
<div class="input-group mb-3">
<input type="number" class="form-control" name="duration" value="{{ media.duration }}" required>
<button type="submit" class="btn btn-warning">Edit</button>
<li class="list-group-item d-flex align-items-center {% if theme == 'dark' %}dark-mode{% endif %}">
<div class="flex-grow-1">
<p class="mb-0"><strong>Media Name:</strong> {{ media.file_name }}</p>
</div>
<form action="{{ url_for('edit_content', content_id=media.id) }}" method="post" class="d-flex align-items-center">
<div class="input-group me-2">
<span class="input-group-text">seconds</span>
<input type="number" class="form-control {% if theme == 'dark' %}dark-mode{% endif %}" name="duration" value="{{ media.duration }}" required>
</div>
<button type="submit" class="btn btn-warning me-2">Edit</button>
</form>
<form action="{{ url_for('delete_content', content_id=media.id) }}" method="post" style="display:inline;">
<button type="submit" class="btn btn-danger" onclick="return confirm('Are you sure you want to delete this media?');">Delete</button>