Change formatting
This commit is contained in:
parent
5aebef7be4
commit
4eeb7bb5ae
1 changed files with 7 additions and 7 deletions
|
@ -40,9 +40,9 @@ function getDataFromEndpoint(url, callback) {
|
||||||
parsedData = JSON.parse(this.response);
|
parsedData = JSON.parse(this.response);
|
||||||
callback(parsedData);
|
callback(parsedData);
|
||||||
} else {
|
} else {
|
||||||
console.log("GET FAILURE!");
|
console.error("GET FAILURE!");
|
||||||
console.log(`Server status: ${this.status}`);
|
console.error(`Server status: ${this.status}`);
|
||||||
console.log(`Server response:\n${this.response}`);
|
console.error(`Server response:\n${this.response}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -55,10 +55,10 @@ function getDataFromEndpoint(url, callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function displayListOfReports(listOfReports) {
|
function displayListOfReports(parsedData) {
|
||||||
const cardBody = document.querySelector(".card-body");
|
const cardBody = document.querySelector(".card-body");
|
||||||
const table = document.createElement("table");
|
const table = document.createElement("table");
|
||||||
const reports = listOfReports.reports;
|
const reports = parsedData.reports;
|
||||||
let reportsAdded = 0;
|
let reportsAdded = 0;
|
||||||
|
|
||||||
// Create report table
|
// Create report table
|
||||||
|
@ -85,6 +85,7 @@ function displayListOfReports(listOfReports) {
|
||||||
actionButton.innerHTML = "View";
|
actionButton.innerHTML = "View";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Insert data into the table object
|
||||||
let bodyRow = table.insertRow(i);
|
let bodyRow = table.insertRow(i);
|
||||||
bodyRow.insertCell(0).innerHTML = title;
|
bodyRow.insertCell(0).innerHTML = title;
|
||||||
bodyRow.insertCell(1).innerHTML = dateCreated;
|
bodyRow.insertCell(1).innerHTML = dateCreated;
|
||||||
|
@ -93,7 +94,6 @@ function displayListOfReports(listOfReports) {
|
||||||
stateCell.innerHTML = state;
|
stateCell.innerHTML = state;
|
||||||
stateCell.classList.add("d-none", "d-lg-table-cell"); // Column visible only on large displays
|
stateCell.classList.add("d-none", "d-lg-table-cell"); // Column visible only on large displays
|
||||||
|
|
||||||
|
|
||||||
let dateSubmittedCell = bodyRow.insertCell(3);
|
let dateSubmittedCell = bodyRow.insertCell(3);
|
||||||
dateSubmittedCell.innerHTML = dateSubmitted;
|
dateSubmittedCell.innerHTML = dateSubmitted;
|
||||||
dateSubmittedCell.classList.add("d-none", "d-md-table-cell"); // Column visible on medium and larger displays
|
dateSubmittedCell.classList.add("d-none", "d-md-table-cell"); // Column visible on medium and larger displays
|
||||||
|
@ -111,7 +111,6 @@ function displayListOfReports(listOfReports) {
|
||||||
// Report list exists and table rows have been created
|
// Report list exists and table rows have been created
|
||||||
// Create table header, add it to the table, and append the result to the card body
|
// Create table header, add it to the table, and append the result to the card body
|
||||||
|
|
||||||
const thead = document.createElement("thead");
|
|
||||||
const tr = document.createElement("tr");
|
const tr = document.createElement("tr");
|
||||||
|
|
||||||
const headTitle = document.createElement("th");
|
const headTitle = document.createElement("th");
|
||||||
|
@ -136,6 +135,7 @@ function displayListOfReports(listOfReports) {
|
||||||
headAction.innerHTML = "Action";
|
headAction.innerHTML = "Action";
|
||||||
tr.appendChild(headAction);
|
tr.appendChild(headAction);
|
||||||
|
|
||||||
|
const thead = document.createElement("thead");
|
||||||
thead.appendChild(tr);
|
thead.appendChild(tr);
|
||||||
table.prepend(thead);
|
table.prepend(thead);
|
||||||
table.classList.add("table", "table-striped", "table-responsive-sm");
|
table.classList.add("table", "table-striped", "table-responsive-sm");
|
||||||
|
|
Loading…
Reference in a new issue