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)
|
r.ParseMultipartForm(1024)
|
||||||
input := strings.TrimSpace(strings.Join(r.Form["query"], ""))
|
input := strings.TrimSpace(strings.Join(r.Form["query"], ""))
|
||||||
|
|
||||||
if r.Method != "POST" || input == "" {
|
if r.Method != "POST" {
|
||||||
http.Error(w, "Invalid request", http.StatusBadRequest)
|
http.Error(w, "Invalid request", http.StatusBadRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -79,7 +79,8 @@ func handleDirectorySearch(w http.ResponseWriter, r *http.Request) {
|
||||||
results := []SearchResult{}
|
results := []SearchResult{}
|
||||||
|
|
||||||
for _, values := range sr.Entries {
|
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("displayname"), input) ||
|
||||||
ContainsI(values.GetAttributeValue("mail"), input) {
|
ContainsI(values.GetAttributeValue("mail"), input) {
|
||||||
results = append(results, SearchResult{
|
results = append(results, SearchResult{
|
||||||
|
|
|
@ -2,7 +2,6 @@ var last_id = 0;
|
||||||
|
|
||||||
function searchDirectory() {
|
function searchDirectory() {
|
||||||
var input = document.getElementById("search").value;
|
var input = document.getElementById("search").value;
|
||||||
if(input){
|
|
||||||
last_id++;
|
last_id++;
|
||||||
var request_id = last_id;
|
var request_id = last_id;
|
||||||
|
|
||||||
|
@ -21,4 +20,3 @@ function searchDirectory() {
|
||||||
xhttp.open("POST", "/directory/search", true);
|
xhttp.open("POST", "/directory/search", true);
|
||||||
xhttp.send(data);
|
xhttp.send(data);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -19,5 +19,10 @@
|
||||||
<div id="search-results"></div>
|
<div id="search-results"></div>
|
||||||
|
|
||||||
<script src="/static/javascript/search.js"></script>
|
<script src="/static/javascript/search.js"></script>
|
||||||
|
<script>
|
||||||
|
window.addEventListener("load", function(event) {
|
||||||
|
searchDirectory();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue