Adding support for data of entry
This commit is contained in:
@@ -113,6 +113,7 @@
|
||||
<th>Brand</th>
|
||||
<th>Model</th>
|
||||
<th>Status</th>
|
||||
<th>Date of entry</th>
|
||||
<th>State</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
@@ -122,6 +123,7 @@
|
||||
<input type="text" id="brand" name="brand" placeholder="Brand" required>
|
||||
<input type="text" id="model" name="model" placeholder="Model" required>
|
||||
<input type="text" id="status" name="status" placeholder="Status" required>
|
||||
<input type="text" id="dateOfEntry" name="dateOfEntry" placeholder="Date of entry" required>
|
||||
<input type="text" id="state" name="state" placeholder="State" required>
|
||||
<button class="add-button" onclick="addComputer()">Add Computer</button>
|
||||
</div>
|
||||
@@ -139,7 +141,7 @@
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
const table = document.querySelector('.computer-table');
|
||||
table.innerHTML = '<tr><th>ID</th><th>Brand</th><th>Model</th><th>Status</th><th>State</th><th>Actions</th></tr>';
|
||||
table.innerHTML = '<tr><th>ID</th><th>Brand</th><th>Model</th><th>Status</th><th>Date of entry</th><th>State</th><th>Actions</th></tr>';
|
||||
data.forEach(computer => {
|
||||
const row = document.createElement('tr');
|
||||
row.innerHTML = `
|
||||
@@ -147,6 +149,7 @@
|
||||
<td>${computer.brand}</td>
|
||||
<td>${computer.model}</td>
|
||||
<td>${computer.status}</td>
|
||||
<td>${computer.dateOfEntry}</td>
|
||||
<td>${computer.state}</td>
|
||||
<td>
|
||||
<button class="edit-button" onclick="editComputer(${computer.id})">Edit</button>
|
||||
@@ -227,7 +230,8 @@
|
||||
brand: values[0],
|
||||
model: values[1],
|
||||
status: values[2],
|
||||
state: values[3]
|
||||
dateOfEntry: values[3],
|
||||
state: values[4]
|
||||
})
|
||||
})
|
||||
.then(response => {
|
||||
@@ -278,6 +282,7 @@
|
||||
const brand = document.getElementById('brand').value;
|
||||
const model = document.getElementById('model').value;
|
||||
const status = document.getElementById('status').value;
|
||||
const dateOfEntry = document.getElementById('dateOfEntry').value;
|
||||
const state = document.getElementById('state').value;
|
||||
|
||||
// Send a POST request to add the computer
|
||||
@@ -291,6 +296,7 @@
|
||||
brand: brand,
|
||||
model: model,
|
||||
status: status,
|
||||
dateOfEntry: dateOfEntry,
|
||||
state: state
|
||||
})
|
||||
})
|
||||
@@ -300,6 +306,7 @@
|
||||
document.getElementById('brand').value = '';
|
||||
document.getElementById('model').value = '';
|
||||
document.getElementById('status').value = '';
|
||||
document.getElementById('dateOfEntry').value = '';
|
||||
document.getElementById('state').value = '';
|
||||
} else {
|
||||
alert('Failed to add computer');
|
||||
|
||||
Reference in New Issue
Block a user