From 54eb5d623979c2fe4765d20c5683eb853fd29285 Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Sun, 9 Feb 2020 23:13:33 +0100 Subject: [PATCH] Add breadcrumbs; stuff --- admin.go | 25 +++++++++++++++++++++++++ templates/admin_create.html | 13 +++++++++++++ templates/admin_ldap.html | 19 +++++++++++-------- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/admin.go b/admin.go index a786a1e..a28c266 100644 --- a/admin.go +++ b/admin.go @@ -126,6 +126,7 @@ type AdminLDAPTplData struct { Path []PathItem Children []Child + CanAddChild bool Props map[string]*PropValues HasMembers bool @@ -443,6 +444,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { Path: path, Children: children, Props: props, + CanAddChild: dn_last_attr == "ou", HasMembers: len(members) > 0 || hasMembers, Members: members, @@ -456,6 +458,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) { type CreateData struct { SuperDN string + Path []PathItem IdType string IdValue string @@ -477,8 +480,27 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) { template := mux.Vars(r)["template"] super_dn := mux.Vars(r)["super_dn"] + // Build path + path := []PathItem{ + PathItem{ + DN: config.BaseDN, + Identifier: config.BaseDN, + }, + } + + len_base_dn := len(strings.Split(config.BaseDN, ",")) + dn_split := strings.Split(super_dn, ",") + for i := len_base_dn + 1; i <= len(dn_split); i++ { + path = append(path, PathItem{ + DN: strings.Join(dn_split[len(dn_split)-i:len(dn_split)], ","), + Identifier: dn_split[len(dn_split)-i], + }) + } + + // Handle data data := &CreateData{ SuperDN: super_dn, + Path: path, } if template == "user" { data.IdType = config.UserNameAttr @@ -488,6 +510,9 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) { data.IdType = config.UserNameAttr data.StructuralObjectClass = "groupOfNames" data.ObjectClass = "groupOfNames\ntop" + } else { + data.IdType = "cn" + data.ObjectClass = "top" } if r.Method == "POST" { diff --git a/templates/admin_create.html b/templates/admin_create.html index 94dee5b..3e636a5 100644 --- a/templates/admin_create.html +++ b/templates/admin_create.html @@ -6,6 +6,17 @@ Retour +
+ +
+ {{if .Error}}
Impossible de créer l'objet.
{{ .Error }}
@@ -13,10 +24,12 @@ {{end}}
+
diff --git a/templates/admin_ldap.html b/templates/admin_ldap.html index 53570fe..3ceed7d 100644 --- a/templates/admin_ldap.html +++ b/templates/admin_ldap.html @@ -21,14 +21,6 @@
- - {{range .Children}} @@ -44,6 +36,17 @@
+{{if .CanAddChild}} + +
+{{end}} + {{if .Success}}
Modification enregistrée.
{{end}}