Add breadcrumbs; stuff

This commit is contained in:
Alex 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
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" {

View file

@ -6,6 +6,17 @@
<a class="ml-auto btn btn-info" href="/">Retour</a>
</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}}
<div class="alert alert-danger mt-4">Impossible de créer l'objet.
<div style="font-size: 0.8em">{{ .Error }}</div>
@ -13,10 +24,12 @@
{{end}}
<form method="POST" class="mt-4">
<!--
<div class="form-group">
<label>Parent:</label>
<input type="text" disabled="true" class="form-control" value="{{ .SuperDN }}" />
</div>
-->
<div class="form-group">
<label for="idvalue">Identifiant:</label>
<input type="text" id="idvalue" name="idvalue" class="form-control" value="{{ .IdValue }}" />

View file

@ -21,14 +21,6 @@
</nav>
</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">
<tbody>
{{range .Children}}
@ -44,6 +36,17 @@
</tbody>
</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}}
<div class="alert alert-success mt-2">Modification enregistrée.</div>
{{end}}