Role management, login logic, and debug improvements. MariaDB login now uses correct syntax.
This commit is contained in:
@@ -25,6 +25,22 @@
|
||||
<a href="{{ url_for('warehouse.import_locations_csv') }}" class="btn" style="padding: 4px 12px; font-size: 0.95em;">Go to Import Page</a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Delete Location Area -->
|
||||
{% if session['role'] in ['administrator', 'management'] %}
|
||||
<div style="margin-top: 32px; padding: 12px; border-top: 1px solid #eee;">
|
||||
<label style="font-weight:bold;">Delete location from table</label>
|
||||
<div style="font-size:0.95em; margin-bottom:8px;">To delete a location, enter the ID of the location and press delete.<br>To delete 2 or multiple locations, enter the IDs separated by "," and then press delete.</div>
|
||||
<form method="POST" style="display:flex; gap:8px; align-items:center;" onsubmit="return confirmDeleteLocations();">
|
||||
<input type="text" name="delete_ids" placeholder="e.g. 5,7,12" style="width:160px;">
|
||||
<button type="submit" name="delete_locations" value="1" class="btn" style="padding:4px 16px;">Delete Locations</button>
|
||||
</form>
|
||||
<script>
|
||||
function confirmDeleteLocations() {
|
||||
return confirm('Do you really want to delete the selected locations?');
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
<!-- Locations Table Card -->
|
||||
<div class="card scan-table-card">
|
||||
|
||||
43
py_app/app/templates/edit_access_roles.html
Normal file
43
py_app/app/templates/edit_access_roles.html
Normal file
@@ -0,0 +1,43 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}Edit Access Roles{% endblock %}
|
||||
{% block content %}
|
||||
<div class="card" style="max-width: 700px; margin: 32px auto;">
|
||||
<h3>Role Access Management</h3>
|
||||
<p>Configure which roles can view or execute functions on each app page and feature.</p>
|
||||
<table class="scan-table" style="width:100%;">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Role</th>
|
||||
<th>Access Level</th>
|
||||
<th>Editable</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>superadmin</td>
|
||||
<td>Full access to all pages and functions</td>
|
||||
<td><span style="color:#888;">Not editable</span></td>
|
||||
</tr>
|
||||
{% for role in roles %}
|
||||
{% if role != 'superadmin' %}
|
||||
<tr>
|
||||
<td>{{ role }}</td>
|
||||
<td>
|
||||
<form method="POST" action="{{ url_for('main.update_role_access', role=role) }}">
|
||||
<select name="access_level">
|
||||
<option value="view">View Only</option>
|
||||
<option value="execute">View & Execute</option>
|
||||
<option value="none">No Access</option>
|
||||
</select>
|
||||
<button type="submit" class="btn">Save</button>
|
||||
</form>
|
||||
</td>
|
||||
<td>Editable</td>
|
||||
</tr>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<p style="margin-top:16px; color:#888;">Only superadmin users can view and manage role access.</p>
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -37,9 +37,9 @@
|
||||
</div>
|
||||
</form>
|
||||
<!-- Popup Modal -->
|
||||
<div id="popup-modal" style="display:none; position:fixed; top:0; left:0; width:100vw; height:100vh; background:rgba(0,0,0,0.3); z-index:9999; align-items:center; justify-content:center;">
|
||||
<div style="background:#fff; padding:32px; border-radius:8px; box-shadow:0 2px 8px #333; text-align:center;">
|
||||
<h3>Performing the creation of the warehouse locations</h3>
|
||||
<div id="popup-modal" class="popup" style="display:none; position:fixed; top:0; left:0; width:100vw; height:100vh; background:var(--app-overlay-bg, rgba(30,41,59,0.85)); z-index:9999; align-items:center; justify-content:center;">
|
||||
<div class="popup-content" style="margin:auto; padding:32px; border-radius:8px; box-shadow:0 2px 8px #333; min-width:320px; max-width:400px; text-align:center;">
|
||||
<h3 style="color:var(--app-label-text);">Performing the creation of the warehouse locations</h3>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
|
||||
@@ -8,10 +8,10 @@
|
||||
<h3>Manage Users</h3>
|
||||
<ul class="user-list">
|
||||
{% for user in users %}
|
||||
<li data-user-id="{{ user.id }}">
|
||||
<li data-user-id="{{ user.id }}" data-username="{{ user.username }}" data-email="{{ user.email if user.email else '' }}" data-role="{{ user.role }}">
|
||||
<span class="user-name">{{ user.username }}</span>
|
||||
<span class="user-role">Role: {{ user.role }}</span>
|
||||
<button class="btn edit-btn">Edit Rights</button>
|
||||
<button class="btn edit-user-btn" data-user-id="{{ user.id }}" data-username="{{ user.username }}" data-email="{{ user.email if user.email else '' }}" data-role="{{ user.role }}">Edit User</button>
|
||||
<button class="btn delete-btn">Delete User</button>
|
||||
</li>
|
||||
{% endfor %}
|
||||
@@ -35,51 +35,37 @@
|
||||
<button type="submit" class="btn">Save/Update External Database Info Settings</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-top: 32px;">
|
||||
<h3>Edit Access Roles</h3>
|
||||
<p>Manage which roles can view or execute functions on each app page and feature.</p>
|
||||
<a href="{{ url_for('main.edit_access_roles') }}" class="btn">Edit Access Roles</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Popup for creating a new user -->
|
||||
<div id="create-user-popup" class="popup">
|
||||
<div class="popup-content">
|
||||
<h3>Create User</h3>
|
||||
<form id="create-user-form" method="POST" action="{{ url_for('main.create_user') }}">
|
||||
<!-- Popup for creating/editing a user -->
|
||||
<div id="user-popup" class="popup" style="display:none; position:fixed; top:0; left:0; width:100vw; height:100vh; background:var(--app-overlay-bg, rgba(30,41,59,0.85)); z-index:9999; align-items:center; justify-content:center;">
|
||||
<div class="popup-content" style="margin:auto; padding:32px; border-radius:8px; box-shadow:0 2px 8px #333; min-width:320px; max-width:400px; text-align:center;">
|
||||
<h3 id="user-popup-title">Create/Edit User</h3>
|
||||
<form id="user-form" method="POST" action="{{ url_for('main.create_user') }}">
|
||||
<label for="username">Username:</label>
|
||||
<input type="text" id="username" name="username" required>
|
||||
<label for="email">Email Address:</label>
|
||||
<input type="email" id="email" name="email" required>
|
||||
<label for="password">Password:</label>
|
||||
<input type="password" id="password" name="password" required>
|
||||
<label for="role">Role:</label>
|
||||
<select id="role" name="role" required>
|
||||
<option value="superadmin">Superadmin</option>
|
||||
<option value="administrator">Administrator</option>
|
||||
<option value="quality">Quality</option>
|
||||
<option value="warehouse">Warehouse</option>
|
||||
<option value="scan">Scan</option>
|
||||
<option value="admin">Admin</option>
|
||||
<option value="manager">Manager</option>
|
||||
<option value="warehouse_manager">Warehouse Manager</option>
|
||||
<option value="warehouse_worker">Warehouse Worker</option>
|
||||
<option value="quality_manager">Quality Manager</option>
|
||||
<option value="quality_worker">Quality Worker</option>
|
||||
</select>
|
||||
<button type="submit" class="btn">Create</button>
|
||||
<button type="button" id="close-popup-btn" class="btn cancel-btn">Cancel</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Popup for editing a user -->
|
||||
<div id="edit-user-popup" class="popup">
|
||||
<div class="popup-content">
|
||||
<h3>Edit User</h3>
|
||||
<form id="edit-user-form" method="POST" action="{{ url_for('main.edit_user') }}">
|
||||
<input type="hidden" id="edit-user-id" name="user_id">
|
||||
<label for="edit-username">Username:</label>
|
||||
<input type="text" id="edit-username" name="username" readonly>
|
||||
<label for="edit-password">New Password:</label>
|
||||
<input type="password" id="edit-password" name="password">
|
||||
<label for="edit-role">Role:</label>
|
||||
<select id="edit-role" name="role" required>
|
||||
<option value="superadmin">Superadmin</option>
|
||||
<option value="administrator">Administrator</option>
|
||||
<option value="quality">Quality</option>
|
||||
<option value="warehouse">Warehouse</option>
|
||||
<option value="scan">Scan</option>
|
||||
</select>
|
||||
<button type="submit" class="btn">Update</button>
|
||||
<button type="button" id="close-edit-popup-btn" class="btn cancel-btn">Cancel</button>
|
||||
<button type="submit" class="btn">Save</button>
|
||||
<button type="button" id="close-user-popup-btn" class="btn cancel-btn">Cancel</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -95,4 +81,27 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
document.getElementById('create-user-btn').onclick = function() {
|
||||
document.getElementById('user-popup').style.display = 'flex';
|
||||
document.getElementById('user-popup-title').innerText = 'Create User';
|
||||
document.getElementById('user-form').reset();
|
||||
document.getElementById('user-form').setAttribute('action', '{{ url_for("main.create_user") }}');
|
||||
};
|
||||
document.getElementById('close-user-popup-btn').onclick = function() {
|
||||
document.getElementById('user-popup').style.display = 'none';
|
||||
};
|
||||
// Edit User button logic
|
||||
Array.from(document.getElementsByClassName('edit-user-btn')).forEach(function(btn) {
|
||||
btn.onclick = function() {
|
||||
document.getElementById('user-popup').style.display = 'flex';
|
||||
document.getElementById('user-popup-title').innerText = 'Edit User';
|
||||
document.getElementById('username').value = btn.getAttribute('data-username');
|
||||
document.getElementById('email').value = btn.getAttribute('data-email');
|
||||
document.getElementById('role').value = btn.getAttribute('data-role');
|
||||
document.getElementById('password').value = '';
|
||||
document.getElementById('user-form').setAttribute('action', '/edit_user/' + btn.getAttribute('data-user-id'));
|
||||
};
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user