mirror of
https://github.com/hyzendust/hyzendust.github.io.git
synced 2026-06-30 23:12:16 +02:00
Remove: admin row from table
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1401,10 +1401,6 @@
|
|||||||
background: #d4edda;
|
background: #d4edda;
|
||||||
color: #155724;
|
color: #155724;
|
||||||
}
|
}
|
||||||
.admin-badge--admin {
|
|
||||||
background: #dbeafe;
|
|
||||||
color: #1e3a8a;
|
|
||||||
}
|
|
||||||
.admin-badge--blocked {
|
.admin-badge--blocked {
|
||||||
background: #f8d7da;
|
background: #f8d7da;
|
||||||
color: #721c24;
|
color: #721c24;
|
||||||
|
|||||||
@@ -57,47 +57,31 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var adminIndex = users.findIndex(function (u) {
|
|
||||||
return u.username === username;
|
|
||||||
});
|
|
||||||
var adminUser = adminIndex === -1 ? null : users[adminIndex];
|
|
||||||
var otherUsers = users.filter(function (u) {
|
|
||||||
return u.username !== username;
|
|
||||||
});
|
|
||||||
var html =
|
var html =
|
||||||
'<table class="admin-table">' +
|
'<table class="admin-table">' +
|
||||||
'<tbody><tr class="admin-table__header">' +
|
'<tbody><tr class="admin-table__header">' +
|
||||||
'<th>#</th><th>Username</th><th>Email</th><th>Joined</th><th>Status</th>' +
|
'<th>#</th><th>Username</th><th>Email</th><th>Joined</th><th>Status</th><th>Actions</th>' +
|
||||||
(adminUser ? '<th rowspan="2">Actions</th>' : '<th>Actions</th>') +
|
|
||||||
'</tr>';
|
'</tr>';
|
||||||
|
|
||||||
function userRow(u, isCurrentUser) {
|
function userRow(u) {
|
||||||
var joined = new Date(u.created_at).toLocaleDateString();
|
var joined = new Date(u.created_at).toLocaleDateString();
|
||||||
var blocked = u.blocked === true || u.blocked === 't' || u.blocked === '1';
|
var blocked = u.blocked === true || u.blocked === 't' || u.blocked === '1';
|
||||||
var status = isCurrentUser
|
var status = blocked
|
||||||
? '<span class="admin-badge admin-badge--admin">Admin</span>'
|
? '<span class="admin-badge admin-badge--blocked">Blocked</span>'
|
||||||
: blocked
|
: '<span class="admin-badge admin-badge--active">Active</span>';
|
||||||
? '<span class="admin-badge admin-badge--blocked">Blocked</span>'
|
var blockBtn = blocked
|
||||||
: '<span class="admin-badge admin-badge--active">Active</span>';
|
? '<button class="admin-btn admin-btn--unblock" data-id="' +
|
||||||
var blockBtn = '';
|
u.id +
|
||||||
var deleteBtn = '';
|
'" data-action="unblock_user">Unblock</button>'
|
||||||
|
: '<button class="admin-btn admin-btn--block" data-id="' +
|
||||||
if (!isCurrentUser) {
|
u.id +
|
||||||
blockBtn = blocked
|
'" data-action="block_user">Block</button>';
|
||||||
? '<button class="admin-btn admin-btn--unblock" data-id="' +
|
var deleteBtn =
|
||||||
u.id +
|
'<button class="admin-btn admin-btn--delete" data-id="' +
|
||||||
'" data-action="unblock_user">Unblock</button>'
|
|
||||||
: '<button class="admin-btn admin-btn--block" data-id="' +
|
|
||||||
u.id +
|
|
||||||
'" data-action="block_user">Block</button>';
|
|
||||||
|
|
||||||
deleteBtn =
|
|
||||||
'<button class="admin-btn admin-btn--delete" data-id="' +
|
|
||||||
u.id +
|
u.id +
|
||||||
'" data-username="' +
|
'" data-username="' +
|
||||||
escHtml(u.username) +
|
escHtml(u.username) +
|
||||||
'" data-action="delete_user">Delete Records</button>';
|
'" data-action="delete_user">Delete Records</button>';
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
'<tr id="user-row-' +
|
'<tr id="user-row-' +
|
||||||
@@ -118,18 +102,17 @@
|
|||||||
'<td>' +
|
'<td>' +
|
||||||
status +
|
status +
|
||||||
'</td>' +
|
'</td>' +
|
||||||
(isCurrentUser
|
'<td class="admin-actions">' +
|
||||||
? ''
|
blockBtn +
|
||||||
: '<td class="admin-actions">' + blockBtn + ' ' + deleteBtn + '</td>') +
|
' ' +
|
||||||
|
deleteBtn +
|
||||||
|
'</td>' +
|
||||||
'</tr>'
|
'</tr>'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (adminUser) {
|
users.forEach(function (u) {
|
||||||
html += userRow(adminUser, true);
|
html += userRow(u);
|
||||||
}
|
|
||||||
otherUsers.forEach(function (u) {
|
|
||||||
html += userRow(u, false);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
html += '</tbody></table>';
|
html += '</tbody></table>';
|
||||||
@@ -220,9 +203,10 @@
|
|||||||
var query = search.value.trim().toLowerCase();
|
var query = search.value.trim().toLowerCase();
|
||||||
var users = allUsers.filter(function (u) {
|
var users = allUsers.filter(function (u) {
|
||||||
return (
|
return (
|
||||||
!query ||
|
u.username !== username &&
|
||||||
String(u.username).toLowerCase().includes(query) ||
|
(!query ||
|
||||||
String(u.email).toLowerCase().includes(query)
|
String(u.username).toLowerCase().includes(query) ||
|
||||||
|
String(u.email).toLowerCase().includes(query))
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
renderTable(users);
|
renderTable(users);
|
||||||
|
|||||||
@@ -1401,10 +1401,6 @@
|
|||||||
background: #d4edda;
|
background: #d4edda;
|
||||||
color: #155724;
|
color: #155724;
|
||||||
}
|
}
|
||||||
.admin-badge--admin {
|
|
||||||
background: #dbeafe;
|
|
||||||
color: #1e3a8a;
|
|
||||||
}
|
|
||||||
.admin-badge--blocked {
|
.admin-badge--blocked {
|
||||||
background: #f8d7da;
|
background: #f8d7da;
|
||||||
color: #721c24;
|
color: #721c24;
|
||||||
|
|||||||
Reference in New Issue
Block a user