show everyone in the directory page by default
This commit is contained in:
parent
a187ae72cb
commit
59c29e9c76
3 changed files with 22 additions and 18 deletions
|
@ -43,7 +43,7 @@ func handleDirectorySearch(w http.ResponseWriter, r *http.Request) {
|
|||
r.ParseMultipartForm(1024)
|
||||
input := strings.TrimSpace(strings.Join(r.Form["query"], ""))
|
||||
|
||||
if r.Method != "POST" || input == "" {
|
||||
if r.Method != "POST" {
|
||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
@ -79,7 +79,8 @@ func handleDirectorySearch(w http.ResponseWriter, r *http.Request) {
|
|||
results := []SearchResult{}
|
||||
|
||||
for _, values := range sr.Entries {
|
||||
if ContainsI(values.GetAttributeValue(config.UserNameAttr), input) ||
|
||||
if input == "" ||
|
||||
ContainsI(values.GetAttributeValue(config.UserNameAttr), input) ||
|
||||
ContainsI(values.GetAttributeValue("displayname"), input) ||
|
||||
ContainsI(values.GetAttributeValue("mail"), input) {
|
||||
results = append(results, SearchResult{
|
||||
|
|
|
@ -2,23 +2,21 @@ var last_id = 0;
|
|||
|
||||
function searchDirectory() {
|
||||
var input = document.getElementById("search").value;
|
||||
if(input){
|
||||
last_id++;
|
||||
var request_id = last_id;
|
||||
last_id++;
|
||||
var request_id = last_id;
|
||||
|
||||
var data = new FormData();
|
||||
data.append("query", input);
|
||||
var data = new FormData();
|
||||
data.append("query", input);
|
||||
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (request_id != last_id) return;
|
||||
var xhttp = new XMLHttpRequest();
|
||||
xhttp.onreadystatechange = function() {
|
||||
if (request_id != last_id) return;
|
||||
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
var result_div = document.getElementById("search-results");
|
||||
result_div.innerHTML = xhttp.responseText;
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", "/directory/search", true);
|
||||
xhttp.send(data);
|
||||
}
|
||||
if (this.readyState == 4 && this.status == 200) {
|
||||
var result_div = document.getElementById("search-results");
|
||||
result_div.innerHTML = xhttp.responseText;
|
||||
}
|
||||
};
|
||||
xhttp.open("POST", "/directory/search", true);
|
||||
xhttp.send(data);
|
||||
}
|
||||
|
|
|
@ -19,5 +19,10 @@
|
|||
<div id="search-results"></div>
|
||||
|
||||
<script src="/static/javascript/search.js"></script>
|
||||
<script>
|
||||
window.addEventListener("load", function(event) {
|
||||
searchDirectory();
|
||||
});
|
||||
</script>
|
||||
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in a new issue