2021-07-26 14:54:51 +00:00
|
|
|
var perso_id = 0;
|
2021-07-29 08:55:44 +00:00
|
|
|
var last_id = 0;
|
2021-07-26 14:54:51 +00:00
|
|
|
|
2021-07-21 19:19:36 +00:00
|
|
|
function searchDirectory() {
|
|
|
|
var input = document.getElementById("search").value;
|
2021-07-21 19:22:29 +00:00
|
|
|
if(input){
|
|
|
|
var xhttp = new XMLHttpRequest();
|
|
|
|
xhttp.onreadystatechange = function() {
|
2021-07-21 19:19:36 +00:00
|
|
|
if (this.readyState == 4 && this.status == 201) {
|
|
|
|
// Typical action to be performed when the document is ready:
|
|
|
|
//Response from Request Ajax
|
|
|
|
var jsonResponse = JSON.parse(xhttp.responseText);
|
|
|
|
|
2021-07-29 08:55:44 +00:00
|
|
|
if (last_id < jsonResponse.id) {
|
|
|
|
last_id = jsonResponse.id
|
2021-07-26 14:54:51 +00:00
|
|
|
//We get the old table element, we create an new table element then we increment this new table.
|
|
|
|
//After the new add, we replace the old table by the new one.
|
|
|
|
var old_table = document.getElementById("users");
|
|
|
|
var table = document.createElement('tbody');
|
|
|
|
table.setAttribute("id","users");
|
2021-07-21 19:19:36 +00:00
|
|
|
|
2021-07-26 14:54:51 +00:00
|
|
|
for (let i =0; i < Object.keys(jsonResponse.search).length; i++) {
|
|
|
|
var row = table.insertRow(0);
|
2021-07-29 22:04:17 +00:00
|
|
|
var urlName = row.insertCell(0);
|
|
|
|
var identifiant = row.insertCell(1);
|
2021-07-30 14:30:15 +00:00
|
|
|
var displayname = row.insertCell(2);
|
2021-07-29 22:04:17 +00:00
|
|
|
var email = row.insertCell(3);
|
|
|
|
var description = row.insertCell(4);
|
2021-07-26 21:01:48 +00:00
|
|
|
description.setAttribute("style", "word-break: break-all;");
|
|
|
|
|
2021-07-29 22:04:17 +00:00
|
|
|
if (jsonResponse.search[i].dn.localeCompare("")!=0) {
|
2021-07-30 14:30:15 +00:00
|
|
|
urlName.innerText = `<object data="/image/${jsonResponse.search[i].dn}/little" class=".img-thumbnail"><image src="/image/unknown_profile/little" class=".img-thumbnail"></object>`
|
2021-07-29 22:04:17 +00:00
|
|
|
}else {
|
2021-07-30 14:30:15 +00:00
|
|
|
urlName.innerText=""
|
2021-07-29 22:04:17 +00:00
|
|
|
}
|
2021-07-30 14:30:15 +00:00
|
|
|
identifiant.innerText = `<a href="/admin/ldap/${jsonResponse.search[i].dn}">${jsonResponse.search[i].id}</a>`
|
|
|
|
displayname.innerText = jsonResponse.search[i].displayname
|
|
|
|
email.innerText = jsonResponse.search[i].email
|
|
|
|
description.innerText = jsonResponse.search[i].description
|
2021-07-21 19:19:36 +00:00
|
|
|
|
2021-07-26 14:54:51 +00:00
|
|
|
}
|
|
|
|
old_table.parentNode.replaceChild(table, old_table)
|
2021-07-21 19:19:36 +00:00
|
|
|
}
|
|
|
|
}
|
2021-07-21 19:22:29 +00:00
|
|
|
};
|
2021-07-29 08:55:44 +00:00
|
|
|
perso_id += 1
|
2021-07-21 19:22:29 +00:00
|
|
|
xhttp.overrideMimeType("application/json");
|
2021-07-29 08:55:44 +00:00
|
|
|
xhttp.open("POST", "/search/".concat(input), true);
|
|
|
|
xhttp.send(JSON.stringify({"id": perso_id}));
|
2021-07-21 19:22:29 +00:00
|
|
|
}
|
2021-07-21 19:19:36 +00:00
|
|
|
}
|