diff options
author | Alex Auvolat <alex@adnab.me> | 2023-02-08 11:58:46 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-02-08 11:58:46 +0100 |
commit | cd415325729fddea26c816291bb33171b9cc4879 (patch) | |
tree | b47c3b255d1e9293033d238002c5a6ab1256b1bf | |
parent | ca41c481b189092843cfb8c4382501037131a69a (diff) | |
download | guichet-cd415325729fddea26c816291bb33171b9cc4879.tar.gz guichet-cd415325729fddea26c816291bb33171b9cc4879.zip |
Slight improvements to admin view
-rw-r--r-- | admin.go | 20 | ||||
-rw-r--r-- | templates/admin_ldap.html | 18 |
2 files changed, 30 insertions, 8 deletions
@@ -121,7 +121,8 @@ type AdminLDAPTplData struct { DN string Path []PathItem - Children []Child + ChildrenOU []Child + ChildrenOther []Child CanAddChild bool Props map[string]*PropValues CanDelete bool @@ -499,17 +500,23 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { sort.Sort(EntryList(sr.Entries)) - children := []Child{} + childrenOU := []Child{} + childrenOther := []Child{} for _, item := range sr.Entries { name := item.GetAttributeValue("displayname") if name == "" { name = item.GetAttributeValue("description") } - children = append(children, Child{ + child := Child{ DN: item.DN, Identifier: strings.Split(item.DN, ",")[0], Name: name, - }) + } + if strings.HasPrefix(item.DN, "ou=") { + childrenOU = append(childrenOU, child) + } else { + childrenOther = append(childrenOther, child) + } } // Run template, finally! @@ -517,10 +524,11 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { DN: dn, Path: path, - Children: children, + ChildrenOU: childrenOU, + ChildrenOther: childrenOther, Props: props, CanAddChild: dn_last_attr == "ou" || isOrganization, - CanDelete: dn != config.BaseDN && len(children) == 0, + CanDelete: dn != config.BaseDN && len(childrenOU) == 0 && len(childrenOther) == 0, HasMembers: len(members) > 0 || hasMembers, Members: members, diff --git a/templates/admin_ldap.html b/templates/admin_ldap.html index 5867209..57ef0f4 100644 --- a/templates/admin_ldap.html +++ b/templates/admin_ldap.html @@ -23,7 +23,17 @@ <table class="table mt-4"> <tbody> - {{range .Children}} + {{range .ChildrenOU}} + <tr> + <td> + <a href="/admin/ldap/{{.DN}}"> + 🗀 {{.Identifier}} + </a> + </td> + <td>{{.Name}}</td> + </tr> + {{end}} + {{range .ChildrenOther}} <tr> <td> <a href="/admin/ldap/{{.DN}}"> @@ -94,7 +104,11 @@ <div class="col-md-3"><strong>{{$key}}</strong></div> <div class="col-md-9"> {{range $value.Values}} - <div>{{.}}</div> + {{if eq $key "creatorsname" "modifiersname" }} + <div><a href="/admin/ldap/{{.}}">{{.}}</a></div> + {{else}} + <div>{{.}}</div> + {{end}} {{end}} </div> </div> |