diff options
author | MrArmonius <mrarmonius@gmail.com> | 2021-07-21 21:19:36 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2021-08-16 12:54:08 +0200 |
commit | fa5476e963371a6e4b26ee60887f7bc356914728 (patch) | |
tree | 3e4bc1478dba62ba6c85677b9f12ed0a4baa49f1 /static/javascript/search.js | |
parent | 0a1ac27efbc046f2dc7ed8ba62473ac42d35a374 (diff) | |
download | guichet-fa5476e963371a6e4b26ee60887f7bc356914728.tar.gz guichet-fa5476e963371a6e4b26ee60887f7bc356914728.zip |
Little JS to find the users with visibility = all
Diffstat (limited to 'static/javascript/search.js')
-rw-r--r-- | static/javascript/search.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/static/javascript/search.js b/static/javascript/search.js new file mode 100644 index 0000000..ea1e155 --- /dev/null +++ b/static/javascript/search.js @@ -0,0 +1,36 @@ +function searchDirectory() { + var input = document.getElementById("search").value; + + var xhttp = new XMLHttpRequest(); + xhttp.onreadystatechange = function() { + 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); + + //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"); + + for (let i =0; i < Object.keys(jsonResponse).length; i++) { + var row = table.insertRow(0); + var identifiant = row.insertCell(0); + var name = row.insertCell(1); + var email = row.insertCell(2); + identifiant.innerHTML = `<a href="/admin/ldap/${jsonResponse[i].dn}">${jsonResponse[i].identifiant}</a>` + name.innerHTML = jsonResponse[i].name + email.innerHTML = jsonResponse[i].email + + } + old_table.parentNode.replaceChild(table, old_table) + } + }; + xhttp.overrideMimeType("application/json"); + xhttp.open("GET", "/search/".concat(input), true); + xhttp.send(); + + + +}
\ No newline at end of file |