Add breadcrumbs; stuff

This commit is contained in:
Alex Auvolat 2020-02-09 23:13:33 +01:00
parent a85ffdfc80
commit 54eb5d6239
3 changed files with 49 additions and 8 deletions

View File

@ -126,6 +126,7 @@ type AdminLDAPTplData struct {
Path []PathItem Path []PathItem
Children []Child Children []Child
CanAddChild bool
Props map[string]*PropValues Props map[string]*PropValues
HasMembers bool HasMembers bool
@ -443,6 +444,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
Path: path, Path: path,
Children: children, Children: children,
Props: props, Props: props,
CanAddChild: dn_last_attr == "ou",
HasMembers: len(members) > 0 || hasMembers, HasMembers: len(members) > 0 || hasMembers,
Members: members, Members: members,
@ -456,6 +458,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
type CreateData struct { type CreateData struct {
SuperDN string SuperDN string
Path []PathItem
IdType string IdType string
IdValue string IdValue string
@ -477,8 +480,27 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
template := mux.Vars(r)["template"] template := mux.Vars(r)["template"]
super_dn := mux.Vars(r)["super_dn"] 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{ data := &CreateData{
SuperDN: super_dn, SuperDN: super_dn,
Path: path,
} }
if template == "user" { if template == "user" {
data.IdType = config.UserNameAttr data.IdType = config.UserNameAttr
@ -488,6 +510,9 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
data.IdType = config.UserNameAttr data.IdType = config.UserNameAttr
data.StructuralObjectClass = "groupOfNames" data.StructuralObjectClass = "groupOfNames"
data.ObjectClass = "groupOfNames\ntop" data.ObjectClass = "groupOfNames\ntop"
} else {
data.IdType = "cn"
data.ObjectClass = "top"
} }
if r.Method == "POST" { if r.Method == "POST" {

View File

@ -6,6 +6,17 @@
<a class="ml-auto btn btn-info" href="/">Retour</a> <a class="ml-auto btn btn-info" href="/">Retour</a>
</div> </div>
<div class="mt-4">
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
{{range .Path}}
<li class="breadcrumb-item"><a href="/admin/ldap/{{.DN}}">{{.Identifier}}</a></li>
{{end}}
<li class="breadcrumb-item active" aria-current="page">Nouvel objet</li>
</ol>
</nav>
</div>
{{if .Error}} {{if .Error}}
<div class="alert alert-danger mt-4">Impossible de créer l'objet. <div class="alert alert-danger mt-4">Impossible de créer l'objet.
<div style="font-size: 0.8em">{{ .Error }}</div> <div style="font-size: 0.8em">{{ .Error }}</div>
@ -13,10 +24,12 @@
{{end}} {{end}}
<form method="POST" class="mt-4"> <form method="POST" class="mt-4">
<!--
<div class="form-group"> <div class="form-group">
<label>Parent:</label> <label>Parent:</label>
<input type="text" disabled="true" class="form-control" value="{{ .SuperDN }}" /> <input type="text" disabled="true" class="form-control" value="{{ .SuperDN }}" />
</div> </div>
-->
<div class="form-group"> <div class="form-group">
<label for="idvalue">Identifiant:</label> <label for="idvalue">Identifiant:</label>
<input type="text" id="idvalue" name="idvalue" class="form-control" value="{{ .IdValue }}" /> <input type="text" id="idvalue" name="idvalue" class="form-control" value="{{ .IdValue }}" />

View File

@ -21,14 +21,6 @@
</nav> </nav>
</div> </div>
<div class="mt-4">
<div class="d-flex">
<a class="ml-auto btn btn-sm btn-success" href="/admin/create/user/{{.DN}}">+utilisateur</a>
<a class="ml-4 btn btn-sm btn-success" href="/admin/create/group/{{.DN}}">+groupe</a>
<a class="ml-4 btn btn-sm btn-success" href="/admin/create/generic/{{.DN}}">+objet</a>
</div>
</div>
<table class="table mt-4"> <table class="table mt-4">
<tbody> <tbody>
{{range .Children}} {{range .Children}}
@ -44,6 +36,17 @@
</tbody> </tbody>
</table> </table>
{{if .CanAddChild}}
<div class="mt-4">
<div class="d-flex">
<a class="ml-auto btn btn-sm btn-success" href="/admin/create/user/{{.DN}}">+utilisateur</a>
<a class="ml-4 btn btn-sm btn-success" href="/admin/create/group/{{.DN}}">+groupe</a>
<a class="ml-4 btn btn-sm btn-success" href="/admin/create/generic/{{.DN}}">+objet</a>
</div>
</div>
<hr class="mt-4" />
{{end}}
{{if .Success}} {{if .Success}}
<div class="alert alert-success mt-2">Modification enregistrée.</div> <div class="alert alert-success mt-2">Modification enregistrée.</div>
{{end}} {{end}}