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,7 +2,6 @@ var last_id = 0;
|
|||
|
||||
function searchDirectory() {
|
||||
var input = document.getElementById("search").value;
|
||||
if(input){
|
||||
last_id++;
|
||||
var request_id = last_id;
|
||||
|
||||
|
@ -20,5 +19,4 @@ function searchDirectory() {
|
|||
};
|
||||
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