fix aws
This commit is contained in:
@@ -575,35 +575,33 @@ require_once __DIR__ . '/includes/header.php';
|
||||
|
||||
<?php
|
||||
// Set additional scripts to be loaded AFTER app.js
|
||||
$additionalScripts = <<<SCRIPT
|
||||
<script>
|
||||
$additionalScripts = '<script>
|
||||
// Initialize settings page
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const currentTab = '{$currentTab}';
|
||||
SCRIPT;
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const currentTab = "' . $currentTab . '";
|
||||
|
||||
// Load data for the current tab
|
||||
switch(currentTab) {
|
||||
case 'integrations':
|
||||
case "integrations":
|
||||
loadAwsSettings();
|
||||
loadIpRegistrySettings();
|
||||
loadWebhookSettings();
|
||||
loadWebhookQueueStatus();
|
||||
break;
|
||||
case 'users':
|
||||
case "users":
|
||||
loadUsers();
|
||||
break;
|
||||
case 'audit':
|
||||
case "audit":
|
||||
loadAuditLog();
|
||||
break;
|
||||
case 'advanced':
|
||||
case "advanced":
|
||||
loadShortnames();
|
||||
loadLogosGrid();
|
||||
break;
|
||||
case 'whitelabel':
|
||||
case "whitelabel":
|
||||
loadWhitelabelSettings();
|
||||
break;
|
||||
case 'developer':
|
||||
case "developer":
|
||||
loadSystemInfo();
|
||||
loadErrorLogs();
|
||||
break;
|
||||
@@ -613,45 +611,45 @@ SCRIPT;
|
||||
// User Management Functions
|
||||
async function loadUsers() {
|
||||
try {
|
||||
const response = await fetch('api.php?action=admin_users_list', {
|
||||
headers: { 'X-CSRF-Token': CSRF_TOKEN }
|
||||
const response = await fetch("api.php?action=admin_users_list", {
|
||||
headers: { "X-CSRF-Token": CSRF_TOKEN }
|
||||
});
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.success) {
|
||||
throw new Error(data.error || 'Failed to load users');
|
||||
throw new Error(data.error || "Failed to load users");
|
||||
}
|
||||
|
||||
const tbody = document.getElementById('usersTableBody');
|
||||
const tbody = document.getElementById("usersTableBody");
|
||||
if (data.users.length === 0) {
|
||||
tbody.innerHTML = '<tr><td colspan="6" style="text-align: center; padding: 40px; color: var(--text-tertiary);">No users found. Add a user above.</td></tr>';
|
||||
tbody.innerHTML = \'<tr><td colspan="6" style="text-align: center; padding: 40px; color: var(--text-tertiary);">No users found. Add a user above.</td></tr>\';
|
||||
return;
|
||||
}
|
||||
|
||||
tbody.innerHTML = data.users.map(user => `
|
||||
<tr data-user-id="${user.id}">
|
||||
<td>${escapeHtml(user.email)}</td>
|
||||
<td>${user.display_name ? escapeHtml(user.display_name) : '<span style="color: var(--text-tertiary);">-</span>'}</td>
|
||||
<td>${user.display_name ? escapeHtml(user.display_name) : \'<span style="color: var(--text-tertiary);">-</span>\'}</td>
|
||||
<td>
|
||||
<span class="badge ${user.role === 'admin' ? 'badge-purple' : 'badge-blue'}">
|
||||
${user.role === 'admin' ? 'Admin' : 'Staff'}
|
||||
<span class="badge ${user.role === \'admin\' ? \'badge-purple\' : \'badge-blue\'}">
|
||||
${user.role === \'admin\' ? \'Admin\' : \'Staff\'}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge ${user.active == 1 ? 'badge-success' : 'badge-warning'}">
|
||||
${user.active == 1 ? 'Active' : 'Inactive'}
|
||||
<span class="badge ${user.active == 1 ? \'badge-success\' : \'badge-warning\'}">
|
||||
${user.active == 1 ? \'Active\' : \'Inactive\'}
|
||||
</span>
|
||||
</td>
|
||||
<td>${formatDate(user.created_at)}</td>
|
||||
<td>
|
||||
<div style="display: flex; gap: 8px;">
|
||||
<button class="btn btn-secondary btn-sm" onclick="toggleUser(${user.id})" title="${user.active == 1 ? 'Deactivate' : 'Activate'}">
|
||||
<button class="btn btn-secondary btn-sm" onclick="toggleUser(${user.id})" title="${user.active == 1 ? \'Deactivate\' : \'Activate\'}">
|
||||
${user.active == 1 ?
|
||||
'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>' :
|
||||
'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>'
|
||||
\'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M17.94 17.94A10.07 10.07 0 0 1 12 20c-7 0-11-8-11-8a18.45 18.45 0 0 1 5.06-5.94M9.9 4.24A9.12 9.12 0 0 1 12 4c7 0 11 8 11 8a18.5 18.5 0 0 1-2.16 3.19m-6.72-1.07a3 3 0 1 1-4.24-4.24"/><line x1="1" y1="1" x2="23" y2="23"/></svg>\' :
|
||||
\'<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg>\'
|
||||
}
|
||||
</button>
|
||||
<button class="btn btn-danger btn-sm" onclick="deleteUser(${user.id}, '${escapeHtml(user.email)}')" title="Delete">
|
||||
<button class="btn btn-danger btn-sm" onclick="deleteUser(${user.id}, \'${escapeHtml(user.email)}\')" title="Delete">
|
||||
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
|
||||
<polyline points="3 6 5 6 21 6"/>
|
||||
<path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"/>
|
||||
@@ -660,29 +658,29 @@ async function loadUsers() {
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
`).join('');
|
||||
`).join(\'\');
|
||||
} catch (error) {
|
||||
console.error('Error loading users:', error);
|
||||
showNotification('Failed to load users: ' + error.message, 'error');
|
||||
console.error("Error loading users:", error);
|
||||
showNotification("Failed to load users: " + error.message, "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function addUser() {
|
||||
const email = document.getElementById('newUserEmail').value.trim();
|
||||
const displayName = document.getElementById('newUserDisplayName').value.trim();
|
||||
const role = document.getElementById('newUserRole').value;
|
||||
const email = document.getElementById("newUserEmail").value.trim();
|
||||
const displayName = document.getElementById("newUserDisplayName").value.trim();
|
||||
const role = document.getElementById("newUserRole").value;
|
||||
|
||||
if (!email) {
|
||||
showNotification('Please enter an email address', 'error');
|
||||
showNotification("Please enter an email address", "error");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('api.php?action=admin_user_save', {
|
||||
method: 'POST',
|
||||
const response = await fetch("api.php?action=admin_user_save", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': CSRF_TOKEN
|
||||
"Content-Type": "application/json",
|
||||
"X-CSRF-Token": CSRF_TOKEN
|
||||
},
|
||||
body: JSON.stringify({
|
||||
email: email,
|
||||
@@ -694,27 +692,27 @@ async function addUser() {
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.success) {
|
||||
throw new Error(data.error || 'Failed to add user');
|
||||
throw new Error(data.error || "Failed to add user");
|
||||
}
|
||||
|
||||
showNotification('User added successfully', 'success');
|
||||
document.getElementById('newUserEmail').value = '';
|
||||
document.getElementById('newUserDisplayName').value = '';
|
||||
document.getElementById('newUserRole').value = 'staff';
|
||||
showNotification("User added successfully", "success");
|
||||
document.getElementById("newUserEmail").value = "";
|
||||
document.getElementById("newUserDisplayName").value = "";
|
||||
document.getElementById("newUserRole").value = "staff";
|
||||
loadUsers();
|
||||
} catch (error) {
|
||||
console.error('Error adding user:', error);
|
||||
showNotification('Failed to add user: ' + error.message, 'error');
|
||||
console.error("Error adding user:", error);
|
||||
showNotification("Failed to add user: " + error.message, "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function toggleUser(userId) {
|
||||
try {
|
||||
const response = await fetch('api.php?action=admin_user_toggle', {
|
||||
method: 'POST',
|
||||
const response = await fetch("api.php?action=admin_user_toggle", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': CSRF_TOKEN
|
||||
"Content-Type": "application/json",
|
||||
"X-CSRF-Token": CSRF_TOKEN
|
||||
},
|
||||
body: JSON.stringify({ id: userId })
|
||||
});
|
||||
@@ -722,28 +720,28 @@ async function toggleUser(userId) {
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.success) {
|
||||
throw new Error(data.error || 'Failed to toggle user status');
|
||||
throw new Error(data.error || "Failed to toggle user status");
|
||||
}
|
||||
|
||||
showNotification('User status updated', 'success');
|
||||
showNotification("User status updated", "success");
|
||||
loadUsers();
|
||||
} catch (error) {
|
||||
console.error('Error toggling user:', error);
|
||||
showNotification('Failed to toggle user: ' + error.message, 'error');
|
||||
console.error("Error toggling user:", error);
|
||||
showNotification("Failed to toggle user: " + error.message, "error");
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteUser(userId, email) {
|
||||
if (!confirm(`Are you sure you want to delete the user "${email}"? This action cannot be undone.`)) {
|
||||
if (!confirm("Are you sure you want to delete the user \"" + email + "\"? This action cannot be undone.")) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('api.php?action=admin_user_delete', {
|
||||
method: 'POST',
|
||||
const response = await fetch("api.php?action=admin_user_delete", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': CSRF_TOKEN
|
||||
"Content-Type": "application/json",
|
||||
"X-CSRF-Token": CSRF_TOKEN
|
||||
},
|
||||
body: JSON.stringify({ id: userId })
|
||||
});
|
||||
@@ -751,38 +749,37 @@ async function deleteUser(userId, email) {
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.success) {
|
||||
throw new Error(data.error || 'Failed to delete user');
|
||||
throw new Error(data.error || "Failed to delete user");
|
||||
}
|
||||
|
||||
showNotification('User deleted successfully', 'success');
|
||||
showNotification("User deleted successfully", "success");
|
||||
loadUsers();
|
||||
} catch (error) {
|
||||
console.error('Error deleting user:', error);
|
||||
showNotification('Failed to delete user: ' + error.message, 'error');
|
||||
console.error("Error deleting user:", error);
|
||||
showNotification("Failed to delete user: " + error.message, "error");
|
||||
}
|
||||
}
|
||||
|
||||
function escapeHtml(text) {
|
||||
if (!text) return '';
|
||||
const div = document.createElement('div');
|
||||
if (!text) return "";
|
||||
const div = document.createElement("div");
|
||||
div.textContent = text;
|
||||
return div.innerHTML;
|
||||
}
|
||||
|
||||
function formatDate(dateStr) {
|
||||
if (!dateStr) return '-';
|
||||
if (!dateStr) return "-";
|
||||
const date = new Date(dateStr);
|
||||
return date.toLocaleDateString('en-GB', {
|
||||
day: '2-digit',
|
||||
month: 'short',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit'
|
||||
return date.toLocaleDateString("en-GB", {
|
||||
day: "2-digit",
|
||||
month: "short",
|
||||
year: "numeric",
|
||||
hour: "2-digit",
|
||||
minute: "2-digit"
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</script>';
|
||||
|
||||
<?php
|
||||
// Include footer
|
||||
require_once __DIR__ . '/includes/footer.php';
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user