admin ui changes
This commit is contained in:
@@ -20,6 +20,49 @@ function doAccountAction(requestData, successMessage, failureMessage, silent=fal
|
||||
});
|
||||
}
|
||||
|
||||
function displayList(data, element_id, delete_function=null) {
|
||||
const tableContainer = document.getElementById(element_id);
|
||||
tableContainer.innerHTML = ""; // Clear previous content
|
||||
|
||||
const table = document.createElement("table");
|
||||
table.classList.add("list-table");
|
||||
|
||||
// Create header row
|
||||
const headerRow = table.insertRow(0);
|
||||
for (const key in data[0]) {
|
||||
const th = document.createElement("th");
|
||||
th.appendChild(document.createTextNode(key));
|
||||
headerRow.appendChild(th);
|
||||
}
|
||||
|
||||
if(typeof delete_function === "function") {
|
||||
const th = document.createElement("th");
|
||||
th.appendChild(document.createTextNode("Delete"));
|
||||
headerRow.appendChild(th);
|
||||
}
|
||||
|
||||
// Create data rows
|
||||
for (const line of data) {
|
||||
const dataRow = table.insertRow();
|
||||
for (const key in line) {
|
||||
const td = document.createElement("td");
|
||||
td.appendChild(document.createTextNode(line[key]));
|
||||
dataRow.appendChild(td);
|
||||
}
|
||||
if(typeof delete_function === "function") {
|
||||
const td = document.createElement("td");
|
||||
let delete_button = document.createElement('button');
|
||||
delete_button.onclick = function (){
|
||||
delete_function(line.ID);
|
||||
}
|
||||
td.appendChild(delete_button);
|
||||
dataRow.appendChild(td);
|
||||
}
|
||||
}
|
||||
|
||||
tableContainer.appendChild(table);
|
||||
}
|
||||
|
||||
function handleResponse(data, SuccessMessage, failureMessage) {
|
||||
const StatusMessageElement = document.getElementById("StatusMessage");
|
||||
|
||||
@@ -33,11 +76,11 @@ function handleResponse(data, SuccessMessage, failureMessage) {
|
||||
StatusMessageElement.style.display = "block";
|
||||
setTimeout(() => {
|
||||
// Hide the status message after 3 seconds
|
||||
StatusMessageElement.style.opacity = 0;
|
||||
StatusMessageElement.style.opacity = "0";
|
||||
setTimeout(() => {
|
||||
StatusMessageElement.style.display = "none";
|
||||
// Reset opacity for future messages
|
||||
StatusMessageElement.style.opacity = 1;
|
||||
StatusMessageElement.style.opacity = "1";
|
||||
}, 500);
|
||||
}, 3000);
|
||||
}
|
||||
@@ -46,6 +89,9 @@ function logout() {
|
||||
const data = new URLSearchParams();
|
||||
data.append("action", "logout");
|
||||
|
||||
doAccountAction(data, "Logout Successful!", "Logout failed.");
|
||||
doAccountAction(data, "Logout Successful!", "Logout failed.").then(() => {
|
||||
location.reload();
|
||||
// Expected output: "Success!"
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -224,6 +224,9 @@ header ul li {
|
||||
transition: opacity 0.5s ease-in-out;
|
||||
}
|
||||
|
||||
.list-table{
|
||||
border: 2px solid var(--primary) ;
|
||||
}
|
||||
|
||||
/* <DASHBOARD STYLING> */
|
||||
/* ZAČÍNAJ VŠETKO S ".dashboard" */
|
||||
|
Reference in New Issue
Block a user