feat(users): implement comprehensive user listing and control
This commit is contained in:
@@ -1560,3 +1560,475 @@ textarea:disabled {
|
||||
bottom: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Users page */
|
||||
.account-error-banner {
|
||||
padding: 8px 10px;
|
||||
color: #000;
|
||||
background: #ffcccc;
|
||||
border: 2px solid #800000;
|
||||
font-weight: bold;
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.account-success-banner {
|
||||
padding: 8px 10px;
|
||||
color: #000;
|
||||
background: #ccffcc;
|
||||
border: 2px solid #008000;
|
||||
font-weight: bold;
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
}
|
||||
|
||||
.users-grid {
|
||||
grid-template-columns: 340px minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.users-form-window .section-body {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.users-table-window {
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.users-table-window .win98-titlebar {
|
||||
flex: 0 0 auto;
|
||||
}
|
||||
|
||||
.users-filters-bar {
|
||||
flex: 0 0 auto;
|
||||
padding: 8px;
|
||||
background: #dfdfdf;
|
||||
border-bottom: 1px solid #808080;
|
||||
}
|
||||
|
||||
.users-filters-form {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(200px, 1fr) 130px 130px 130px 100px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.users-bulk-strip {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
min-height: 38px;
|
||||
padding: 6px 8px;
|
||||
background: #efefef;
|
||||
border-bottom: 1px solid #808080;
|
||||
}
|
||||
|
||||
.table-body-panel {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.table-scroll {
|
||||
height: 400px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.check-cell {
|
||||
width: 28px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.user-cell {
|
||||
min-width: 160px;
|
||||
}
|
||||
|
||||
.email-cell {
|
||||
min-width: 180px;
|
||||
max-width: 260px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.user-main {
|
||||
display: grid;
|
||||
gap: 2px;
|
||||
}
|
||||
|
||||
.username {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.subtle {
|
||||
color: #555;
|
||||
font-size: 11px;
|
||||
line-height: 11px;
|
||||
}
|
||||
|
||||
.actions-cell {
|
||||
white-space: nowrap;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.actions-cell .tiny-button {
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.users-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.users-filters-form {
|
||||
grid-template-columns: 1fr 1fr;
|
||||
}
|
||||
|
||||
.table-scroll {
|
||||
height: 320px;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 620px) {
|
||||
.users-filters-form {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.users-bulk-strip {
|
||||
align-items: stretch;
|
||||
}
|
||||
|
||||
.users-bulk-strip .small-action {
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── Shared form controls ─────────────────────────────────────────── */
|
||||
|
||||
.win98-input,
|
||||
.win98-select {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
height: 26px;
|
||||
padding: 2px 6px;
|
||||
color: #000000;
|
||||
background: #ffffff;
|
||||
border-top: 1px solid #808080;
|
||||
border-left: 1px solid #808080;
|
||||
border-right: 1px solid #ffffff;
|
||||
border-bottom: 1px solid #ffffff;
|
||||
font-family: inherit;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.win98-input:focus,
|
||||
.win98-select:focus {
|
||||
outline: 2px dotted #000078;
|
||||
outline-offset: 1px;
|
||||
}
|
||||
|
||||
.small-action {
|
||||
display: inline-grid;
|
||||
place-items: center;
|
||||
min-width: 72px;
|
||||
height: 24px;
|
||||
padding: 0 8px;
|
||||
color: #000000;
|
||||
background: var(--w98-gray);
|
||||
border-top: 1px solid #ffffff;
|
||||
border-left: 1px solid #ffffff;
|
||||
border-right: 1px solid #808080;
|
||||
border-bottom: 1px solid #808080;
|
||||
box-shadow: inset -1px -1px 0 #a0a0a0, inset 1px 1px 0 #e8e8e8;
|
||||
font-family: inherit;
|
||||
font-size: 12px;
|
||||
line-height: 12px;
|
||||
text-decoration: none;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.small-action:active:not(:disabled) {
|
||||
border-top-color: #808080;
|
||||
border-left-color: #808080;
|
||||
border-right-color: #ffffff;
|
||||
border-bottom-color: #ffffff;
|
||||
box-shadow: inset -1px -1px 0 #e8e8e8, inset 1px 1px 0 #a0a0a0;
|
||||
}
|
||||
|
||||
.small-action.is-primary {
|
||||
background: #000078;
|
||||
color: #ffffff;
|
||||
border-top-color: #4040c0;
|
||||
border-left-color: #4040c0;
|
||||
border-right-color: #000040;
|
||||
border-bottom-color: #000040;
|
||||
}
|
||||
|
||||
.small-action:disabled {
|
||||
color: #808080;
|
||||
text-shadow: 1px 1px 0 #ffffff;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.hero-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.form-grid {
|
||||
display: grid;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.field-row {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
}
|
||||
|
||||
.field-row label {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.field-help {
|
||||
color: #444444;
|
||||
font-size: 11px;
|
||||
line-height: 13px;
|
||||
}
|
||||
|
||||
.button-row {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
gap: 6px;
|
||||
margin-top: 4px;
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
padding: 8px;
|
||||
border-top: 1px solid #c0c0c0;
|
||||
background: #efefef;
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.pagination-info {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.pagination-controls {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
/* ── User edit page ───────────────────────────────────────────────── */
|
||||
|
||||
.ue-content-grid {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1.2fr) minmax(300px, 0.8fr);
|
||||
gap: 10px;
|
||||
align-items: start;
|
||||
}
|
||||
|
||||
.ue-column {
|
||||
display: grid;
|
||||
gap: 10px;
|
||||
align-content: start;
|
||||
}
|
||||
|
||||
.ue-panel-body {
|
||||
padding: 10px;
|
||||
margin: 0 6px 6px;
|
||||
}
|
||||
|
||||
.ue-panel-sub {
|
||||
color: #555555;
|
||||
font-size: 12px;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
.ue-form-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.ue-field {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ue-field label {
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
line-height: 13px;
|
||||
}
|
||||
|
||||
.ue-field-full {
|
||||
grid-column: 1 / -1;
|
||||
}
|
||||
|
||||
.ue-help {
|
||||
color: #444444;
|
||||
font-size: 11px;
|
||||
line-height: 13px;
|
||||
}
|
||||
|
||||
.ue-check-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.ue-check-grid-1col {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.ue-check-card {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: flex-start;
|
||||
padding: 8px;
|
||||
background: #f4f4f4;
|
||||
border-top: 1px solid #ffffff;
|
||||
border-left: 1px solid #ffffff;
|
||||
border-right: 1px solid #c0c0c0;
|
||||
border-bottom: 1px solid #c0c0c0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ue-check-card input[type="checkbox"] {
|
||||
margin-top: 2px;
|
||||
flex: 0 0 auto;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ue-check-copy {
|
||||
display: grid;
|
||||
gap: 3px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.ue-check-copy strong {
|
||||
font-size: 12px;
|
||||
line-height: 13px;
|
||||
}
|
||||
|
||||
.ue-check-copy span {
|
||||
color: #444444;
|
||||
font-size: 11px;
|
||||
line-height: 13px;
|
||||
}
|
||||
|
||||
.ue-info-list {
|
||||
display: grid;
|
||||
gap: 5px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.ue-info-item {
|
||||
display: grid;
|
||||
grid-template-columns: 110px minmax(0, 1fr);
|
||||
gap: 8px;
|
||||
align-items: start;
|
||||
padding: 5px 7px;
|
||||
background: #f5f5f5;
|
||||
border-top: 1px solid #ffffff;
|
||||
border-left: 1px solid #ffffff;
|
||||
border-right: 1px solid #c0c0c0;
|
||||
border-bottom: 1px solid #c0c0c0;
|
||||
font-size: 12px;
|
||||
line-height: 14px;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.ue-info-item strong {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.ue-info-item span {
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.ue-policy-pre {
|
||||
max-height: 260px;
|
||||
margin: 0;
|
||||
padding: 8px;
|
||||
overflow: auto;
|
||||
color: #0a8f2f;
|
||||
background: #050505;
|
||||
border-top: 2px solid #808080;
|
||||
border-left: 2px solid #808080;
|
||||
border-right: 2px solid #ffffff;
|
||||
border-bottom: 2px solid #ffffff;
|
||||
font-family: 'MonoCraft', 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
line-height: 15px;
|
||||
white-space: pre-wrap;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.ue-danger-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.ue-danger-row form {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.ue-danger-btn {
|
||||
border-top-color: #ff8080;
|
||||
border-left-color: #ff8080;
|
||||
border-right-color: #400000;
|
||||
border-bottom-color: #400000;
|
||||
}
|
||||
|
||||
.ue-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
padding: 8px 0 0;
|
||||
}
|
||||
|
||||
.ue-footer-left,
|
||||
.ue-footer-right {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
@media (max-width: 1080px) {
|
||||
.ue-content-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.ue-form-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.ue-check-grid {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.ue-info-item {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
}
|
||||
|
||||
101
static/js/account-user-edit.js
Normal file
101
static/js/account-user-edit.js
Normal file
@@ -0,0 +1,101 @@
|
||||
(function () {
|
||||
const form = document.querySelector('[data-ue-form]');
|
||||
const dirtyIndicator = document.querySelector('[data-ue-dirty]');
|
||||
const menuItems = Array.from(document.querySelectorAll('.menu-item'));
|
||||
const toast = document.getElementById('account-toast');
|
||||
let dirty = false;
|
||||
let toastTimer = null;
|
||||
|
||||
function setDirty(next) {
|
||||
dirty = next;
|
||||
if (dirtyIndicator) {
|
||||
dirtyIndicator.textContent = dirty ? 'Unsaved changes' : 'No unsaved changes';
|
||||
}
|
||||
const chip = document.querySelector('[data-dirty-chip]');
|
||||
if (chip) {
|
||||
chip.textContent = dirty ? '● unsaved' : '';
|
||||
}
|
||||
}
|
||||
|
||||
function showToast(msg, type) {
|
||||
if (!toast) return;
|
||||
toast.textContent = msg;
|
||||
toast.className = 'toast is-visible' + (type ? ' toast-' + type : '');
|
||||
window.clearTimeout(toastTimer);
|
||||
toastTimer = window.setTimeout(function () {
|
||||
toast.classList.remove('is-visible');
|
||||
}, 2400);
|
||||
}
|
||||
|
||||
function closeMenus() {
|
||||
menuItems.forEach(function (item) { item.classList.remove('is-open'); });
|
||||
}
|
||||
|
||||
menuItems.forEach(function (item) {
|
||||
const btn = item.querySelector('.menu-button');
|
||||
if (!btn) return;
|
||||
btn.addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
const open = item.classList.contains('is-open');
|
||||
closeMenus();
|
||||
if (!open) item.classList.add('is-open');
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener('click', closeMenus);
|
||||
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape') {
|
||||
closeMenus();
|
||||
}
|
||||
if ((e.ctrlKey || e.metaKey) && e.key.toLowerCase() === 's') {
|
||||
e.preventDefault();
|
||||
if (form) form.requestSubmit ? form.requestSubmit() : form.submit();
|
||||
}
|
||||
});
|
||||
|
||||
if (form) {
|
||||
form.addEventListener('change', function () { setDirty(true); });
|
||||
form.addEventListener('input', function () { setDirty(true); });
|
||||
form.addEventListener('submit', function () { setDirty(false); });
|
||||
}
|
||||
|
||||
document.querySelectorAll('[data-ue-command]').forEach(function (el) {
|
||||
el.addEventListener('click', function () {
|
||||
closeMenus();
|
||||
const cmd = el.getAttribute('data-ue-command');
|
||||
switch (cmd) {
|
||||
case 'save':
|
||||
if (form) { form.requestSubmit ? form.requestSubmit() : form.submit(); }
|
||||
break;
|
||||
case 'discard':
|
||||
if (dirty && form) {
|
||||
if (window.confirm('Discard unsaved changes?')) {
|
||||
setDirty(false);
|
||||
form.reset();
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'reset-password': {
|
||||
const resetForm = document.querySelector('form[action*="/password/reset"]');
|
||||
if (resetForm && window.confirm('Reset this user\'s password? A temporary password will be generated and shown.')) {
|
||||
resetForm.submit();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
showToast('Action: ' + cmd);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// sticky scroll shadow on taskbar
|
||||
const header = document.querySelector('.top-taskbar');
|
||||
if (header) {
|
||||
function updateScroll() {
|
||||
header.classList.toggle('is-scrolled', window.scrollY > 4);
|
||||
}
|
||||
updateScroll();
|
||||
window.addEventListener('scroll', updateScroll, { passive: true });
|
||||
}
|
||||
}());
|
||||
67
static/js/account-users.js
Normal file
67
static/js/account-users.js
Normal file
@@ -0,0 +1,67 @@
|
||||
(function () {
|
||||
const masterCheck = document.getElementById('master-check');
|
||||
const rowChecks = document.querySelectorAll('.row-check');
|
||||
const bulkForm = document.getElementById('users-bulk-form');
|
||||
const selectedIdsInput = document.getElementById('bulk-selected-ids');
|
||||
const selectedCount = document.getElementById('selected-count');
|
||||
const focusCreateBtn = document.querySelector('[data-users-action="focus-create"]');
|
||||
const selectVisibleBtns = document.querySelectorAll('[data-users-action="select-visible"]');
|
||||
|
||||
function updateSelected() {
|
||||
const checked = document.querySelectorAll('.row-check:checked');
|
||||
const ids = Array.from(checked).map(cb => cb.value);
|
||||
selectedIdsInput.value = ids.join(',');
|
||||
if (selectedCount) {
|
||||
selectedCount.textContent = ids.length + ' selected';
|
||||
}
|
||||
if (masterCheck) {
|
||||
const allRowChecks = document.querySelectorAll('.row-check');
|
||||
masterCheck.checked = allRowChecks.length > 0 && checked.length === allRowChecks.length;
|
||||
masterCheck.indeterminate = checked.length > 0 && checked.length < allRowChecks.length;
|
||||
}
|
||||
}
|
||||
|
||||
if (masterCheck) {
|
||||
masterCheck.addEventListener('change', function () {
|
||||
document.querySelectorAll('.row-check').forEach(function (cb) {
|
||||
cb.checked = masterCheck.checked;
|
||||
});
|
||||
updateSelected();
|
||||
});
|
||||
}
|
||||
|
||||
document.addEventListener('change', function (event) {
|
||||
if (event.target.classList.contains('row-check')) {
|
||||
updateSelected();
|
||||
}
|
||||
});
|
||||
|
||||
selectVisibleBtns.forEach(function (btn) {
|
||||
btn.addEventListener('click', function () {
|
||||
document.querySelectorAll('.row-check').forEach(function (cb) {
|
||||
cb.checked = true;
|
||||
});
|
||||
updateSelected();
|
||||
});
|
||||
});
|
||||
|
||||
if (focusCreateBtn) {
|
||||
focusCreateBtn.addEventListener('click', function () {
|
||||
var usernameInput = document.getElementById('users-username');
|
||||
if (usernameInput) {
|
||||
usernameInput.scrollIntoView({ behavior: 'smooth' });
|
||||
setTimeout(function () { usernameInput.focus(); }, 150);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
updateSelected();
|
||||
})();
|
||||
|
||||
function setBulkAction(actionUrl) {
|
||||
var form = document.getElementById('users-bulk-form');
|
||||
if (form) {
|
||||
form.action = actionUrl;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user