Skip to content

Commit 8f79c10

Browse files
committed
Now displaying users
1 parent ad8e534 commit 8f79c10

2 files changed

Lines changed: 24 additions & 18 deletions

File tree

dr-controler.js

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,34 @@ async function stateChange(state) {
1515
document.getElementById('please-login').style.visibility = 'hidden';
1616
document.getElementById('data-view').style.visibility = 'visible';
1717
setSharingLink();
18-
await drLib.getPatientsList();
18+
setPatientList();
1919
} else {
2020
document.getElementById('please-login').style.visibility = 'visible';
2121
document.getElementById('data-view').style.visibility = 'hidden';
2222
}
2323
}
2424

25-
async function setSharingLink() {
26-
25+
const rowItems = ['name', 'surname', 'nationality'];
26+
/**
27+
* Update the patient list
28+
*/
29+
async function setPatientList() {
30+
const table = document.getElementById('patients-table');
31+
const patients = await drLib.getPatientsList();
32+
for (const patient of Object.values(patients)) {
33+
const row = table.insertRow(-1);
34+
const cellUsername = row.insertCell(-1);
35+
cellUsername.innerHTML = patient.username;
36+
for (const field of rowItems) {
37+
row.insertCell(-1).innerHTML = patient.formData[field]?.value || '';
38+
}
39+
}
40+
}
2741

42+
/**
43+
* Creates the sharing link on the page
44+
*/
45+
async function setSharingLink() {
2846
const currentPage = window.location.href;
2947
const posDrHTML = currentPage.indexOf('dr.html');
3048
const patientURL = currentPage.substring(0, posDrHTML) + 'patient.html';

dr.html

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,10 @@ <h2 class="card-title">Data</h2>
5151
<th colspan="2"><b>Patients</b></td>
5252
</tr>
5353
<tr>
54-
<th scope="col">Date</th>
54+
<th scope="col">Username</th>
5555
<th scope="col">Name</th>
56-
</tr>
57-
</thead>
58-
<tbody>
59-
</tbody>
60-
</table>
61-
<table id='patients-details-table' class="table">
62-
<thead>
63-
<tr>
64-
<th colspan="3"><b>Blood pressure</b></td>
65-
</tr>
66-
<tr>
67-
<th scope="col">Date</th>
68-
<th scope="col">Systolic</th>
69-
<th scope="col">Diastolic</th>
56+
<th scope="col">Surname</th>
57+
<th scope="col">Nationality</th>
7058
</tr>
7159
</thead>
7260
<tbody>

0 commit comments

Comments
 (0)