2020-03-15 19:02:37 +00:00
|
|
|
|
2020-03-16 18:51:17 +00:00
|
|
|
rootKontext = ""
|
2020-03-15 19:02:37 +00:00
|
|
|
|
2020-03-16 18:51:17 +00:00
|
|
|
function getJSON(url, callback) {
|
2020-03-15 19:02:37 +00:00
|
|
|
var xhr = new XMLHttpRequest();
|
2020-03-16 18:51:17 +00:00
|
|
|
xhr.open('GET', url, true);
|
2020-03-15 19:02:37 +00:00
|
|
|
xhr.responseType = 'json';
|
2020-03-16 18:51:17 +00:00
|
|
|
xhr.onload = function () {
|
|
|
|
|
var status = xhr.status;
|
|
|
|
|
if (status < 400) {
|
|
|
|
|
callback(null, xhr.response);
|
|
|
|
|
} else {
|
|
|
|
|
console.log("failed getting");
|
|
|
|
|
console.log(status);
|
|
|
|
|
}
|
2020-03-15 19:02:37 +00:00
|
|
|
};
|
|
|
|
|
xhr.send();
|
|
|
|
|
};
|
|
|
|
|
|
2020-03-16 18:51:17 +00:00
|
|
|
function putJSON(url, data, callback) {
|
2020-03-15 19:02:37 +00:00
|
|
|
var xhr = new XMLHttpRequest();
|
2020-03-16 18:51:17 +00:00
|
|
|
xhr.open('PUT', url, true);
|
2020-03-15 19:02:37 +00:00
|
|
|
xhr.responseType = 'json';
|
|
|
|
|
xhr.setRequestHeader('Content-Type', 'application/json');
|
2020-03-16 18:51:17 +00:00
|
|
|
xhr.onload = function () {
|
|
|
|
|
var status = xhr.status;
|
|
|
|
|
if (status < 400) {
|
|
|
|
|
callback(null, xhr.response);
|
|
|
|
|
} else {
|
|
|
|
|
console.log("failed posting");
|
|
|
|
|
console.log(status);
|
|
|
|
|
}
|
2020-03-15 19:02:37 +00:00
|
|
|
};
|
|
|
|
|
xhr.send(data);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2020-03-16 18:51:17 +00:00
|
|
|
function loadData() {
|
|
|
|
|
getJSON(rootKontext + "/api/v1/person/",
|
|
|
|
|
function (error, data) {
|
|
|
|
|
console.log(data)
|
|
|
|
|
data = data["data"]
|
|
|
|
|
let el = document.getElementById('list');
|
|
|
|
|
data.forEach(function (item) {
|
|
|
|
|
string = `
|
|
|
|
|
<div class="card border-light">
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<h4 class="card-title">${item["fname"]} ${item["lname"]}</h4>
|
|
|
|
|
<h6 class="card-subtitle mb-2 text-muted">${item["timestamp"]}</h6>
|
|
|
|
|
|
|
|
|
|
<p class="card-text container">
|
|
|
|
|
<img class="listImg" src="${item["face"]}"></img>
|
|
|
|
|
<div class="personalInfo">
|
|
|
|
|
${item["gender"]} <br>
|
|
|
|
|
${item["yob"]} <br>
|
|
|
|
|
${item["fingerprints"].length} <br>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`
|
|
|
|
|
el.innerHTML += string;
|
|
|
|
|
})
|
2020-03-15 19:02:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|