Slight improvements to admin view

This commit is contained in:
Alex Auvolat 2023-02-08 11:58:46 +01:00
parent ca41c481b1
commit cd41532572
2 changed files with 30 additions and 8 deletions

View File

@ -121,7 +121,8 @@ type AdminLDAPTplData struct {
DN string DN string
Path []PathItem Path []PathItem
Children []Child ChildrenOU []Child
ChildrenOther []Child
CanAddChild bool CanAddChild bool
Props map[string]*PropValues Props map[string]*PropValues
CanDelete bool CanDelete bool
@ -499,17 +500,23 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
sort.Sort(EntryList(sr.Entries)) sort.Sort(EntryList(sr.Entries))
children := []Child{} childrenOU := []Child{}
childrenOther := []Child{}
for _, item := range sr.Entries { for _, item := range sr.Entries {
name := item.GetAttributeValue("displayname") name := item.GetAttributeValue("displayname")
if name == "" { if name == "" {
name = item.GetAttributeValue("description") name = item.GetAttributeValue("description")
} }
children = append(children, Child{ child := Child{
DN: item.DN, DN: item.DN,
Identifier: strings.Split(item.DN, ",")[0], Identifier: strings.Split(item.DN, ",")[0],
Name: name, Name: name,
}) }
if strings.HasPrefix(item.DN, "ou=") {
childrenOU = append(childrenOU, child)
} else {
childrenOther = append(childrenOther, child)
}
} }
// Run template, finally! // Run template, finally!
@ -517,10 +524,11 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
DN: dn, DN: dn,
Path: path, Path: path,
Children: children, ChildrenOU: childrenOU,
ChildrenOther: childrenOther,
Props: props, Props: props,
CanAddChild: dn_last_attr == "ou" || isOrganization, 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, HasMembers: len(members) > 0 || hasMembers,
Members: members, Members: members,

View File

@ -23,7 +23,17 @@
<table class="table mt-4"> <table class="table mt-4">
<tbody> <tbody>
{{range .Children}} {{range .ChildrenOU}}
<tr>
<td>
<a href="/admin/ldap/{{.DN}}">
🗀 {{.Identifier}}
</a>
</td>
<td>{{.Name}}</td>
</tr>
{{end}}
{{range .ChildrenOther}}
<tr> <tr>
<td> <td>
<a href="/admin/ldap/{{.DN}}"> <a href="/admin/ldap/{{.DN}}">
@ -94,8 +104,12 @@
<div class="col-md-3"><strong>{{$key}}</strong></div> <div class="col-md-3"><strong>{{$key}}</strong></div>
<div class="col-md-9"> <div class="col-md-9">
{{range $value.Values}} {{range $value.Values}}
{{if eq $key "creatorsname" "modifiersname" }}
<div><a href="/admin/ldap/{{.}}">{{.}}</a></div>
{{else}}
<div>{{.}}</div> <div>{{.}}</div>
{{end}} {{end}}
{{end}}
</div> </div>
</div> </div>
{{end}} {{end}}