Minor UI changes

This commit is contained in:
Alex 2020-02-10 09:44:18 +01:00
parent a6114cda7c
commit 9f891bdb9a
6 changed files with 30 additions and 13 deletions

View file

@ -50,6 +50,7 @@ func (d EntryList) Less(i, j int) bool {
type AdminUsersTplData struct { type AdminUsersTplData struct {
Login *LoginStatus Login *LoginStatus
UserNameAttr string UserNameAttr string
UserBaseDN string
Users EntryList Users EntryList
} }
@ -77,6 +78,7 @@ func handleAdminUsers(w http.ResponseWriter, r *http.Request) {
data := &AdminUsersTplData{ data := &AdminUsersTplData{
Login: login, Login: login,
UserNameAttr: config.UserNameAttr, UserNameAttr: config.UserNameAttr,
UserBaseDN: config.UserBaseDN,
Users: EntryList(sr.Entries), Users: EntryList(sr.Entries),
} }
sort.Sort(data.Users) sort.Sort(data.Users)
@ -87,6 +89,7 @@ func handleAdminUsers(w http.ResponseWriter, r *http.Request) {
type AdminGroupsTplData struct { type AdminGroupsTplData struct {
Login *LoginStatus Login *LoginStatus
GroupNameAttr string GroupNameAttr string
GroupBaseDN string
Groups EntryList Groups EntryList
} }
@ -114,6 +117,7 @@ func handleAdminGroups(w http.ResponseWriter, r *http.Request) {
data := &AdminGroupsTplData{ data := &AdminGroupsTplData{
Login: login, Login: login,
GroupNameAttr: config.GroupNameAttr, GroupNameAttr: config.GroupNameAttr,
GroupBaseDN: config.GroupBaseDN,
Groups: EntryList(sr.Entries), Groups: EntryList(sr.Entries),
} }
sort.Sort(data.Groups) sort.Sort(data.Groups)
@ -439,7 +443,7 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
if val, ok := props["objectclass"]; ok { if val, ok := props["objectclass"]; ok {
objectClass = val.Values objectClass = val.Values
} }
hasMembers, hasGroups := false, false hasMembers, hasGroups, isOrganization := false, false, false
for _, oc := range objectClass { for _, oc := range objectClass {
if strings.EqualFold(oc, "organizationalperson") || strings.EqualFold(oc, "person") { if strings.EqualFold(oc, "organizationalperson") || strings.EqualFold(oc, "person") {
hasGroups = true hasGroups = true
@ -447,6 +451,9 @@ func handleAdminLDAP(w http.ResponseWriter, r *http.Request) {
if strings.EqualFold(oc, "groupOfNames") { if strings.EqualFold(oc, "groupOfNames") {
hasMembers = true hasMembers = true
} }
if strings.EqualFold(oc, "organization") {
isOrganization = true
}
} }
templateAdminLDAP.Execute(w, &AdminLDAPTplData{ templateAdminLDAP.Execute(w, &AdminLDAPTplData{
@ -455,7 +462,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", CanAddChild: dn_last_attr == "ou" || isOrganization,
CanDelete: dn != config.BaseDN && len(children) == 0, CanDelete: dn != config.BaseDN && len(children) == 0,
HasMembers: len(members) > 0 || hasMembers, HasMembers: len(members) > 0 || hasMembers,
@ -477,6 +484,7 @@ type CreateData struct {
DisplayName string DisplayName string
StructuralObjectClass string StructuralObjectClass string
ObjectClass string ObjectClass string
IsTemplated bool
Error string Error string
} }
@ -518,10 +526,12 @@ func handleAdminCreate(w http.ResponseWriter, r *http.Request) {
data.IdType = config.UserNameAttr data.IdType = config.UserNameAttr
data.StructuralObjectClass = "inetOrgPerson" data.StructuralObjectClass = "inetOrgPerson"
data.ObjectClass = "inetOrgPerson\norganizationalPerson\nperson\ntop" data.ObjectClass = "inetOrgPerson\norganizationalPerson\nperson\ntop"
data.IsTemplated = true
} else if template == "group" { } else if template == "group" {
data.IdType = config.UserNameAttr data.IdType = config.UserNameAttr
data.StructuralObjectClass = "groupOfNames" data.StructuralObjectClass = "groupOfNames"
data.ObjectClass = "groupOfNames\ntop" data.ObjectClass = "groupOfNames\ntop"
data.IsTemplated = true
} else { } else {
data.IdType = "cn" data.IdType = "cn"
data.ObjectClass = "top" data.ObjectClass = "top"

View file

@ -3,7 +3,7 @@
{{define "body"}} {{define "body"}}
<div class="d-flex"> <div class="d-flex">
<h4>Créer un objet</h4> <h4>Créer un objet</h4>
<a class="ml-auto btn btn-info" href="/">Retour</a> <a class="ml-auto btn btn-info" href="/">Menu principal</a>
</div> </div>
<div class="mt-4"> <div class="mt-4">
@ -36,7 +36,7 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="idtype">Type d'identifiant:</label> <label for="idtype">Type d'identifiant:</label>
<input type="text" id="idtype" name="idtype" class="form-control" value="{{ .IdType }}" /> <input type="text" {{if .IsTemplated}}disabled="disabled"{{end}} id="idtype" name="idtype" class="form-control" value="{{ .IdType }}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="displayname">Nom:</label> <label for="displayname">Nom:</label>
@ -44,11 +44,11 @@
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="soc">StructuralObjectClass:</label> <label for="soc">StructuralObjectClass:</label>
<input type="text" id="soc" name="soc" class="form-control" value="{{ .StructuralObjectClass }}" /> <input type="text" {{if .IsTemplated}}disabled="disabled"{{end}} id="soc" name="soc" class="form-control" value="{{ .StructuralObjectClass }}" />
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="oc">ObjectClass:</label> <label for="oc">ObjectClass:</label>
<textarea rows="5" id="oc" name="oc" class="form-control">{{ .ObjectClass }}</textarea> <textarea rows="5" {{if .IsTemplated}}disabled="disabled"{{end}} id="oc" name="oc" class="form-control">{{ .ObjectClass }}</textarea>
</div> </div>
<button type="submit" class="btn btn-primary">Créer l'objet</button> <button type="submit" class="btn btn-primary">Créer l'objet</button>
</form> </form>

View file

@ -4,7 +4,8 @@
<div class="d-flex"> <div class="d-flex">
<h4>Liste des groupes</h4> <h4>Liste des groupes</h4>
<a class="ml-auto btn btn-info" href="/">Retour</a> <a class="ml-auto btn btn-success" href="/admin/create/group/{{.GroupBaseDN}}">Nouveau groupe</a>
<a class="ml-4 btn btn-info" href="/">Menu principal</a>
</div> </div>
<table class="table mt-4"> <table class="table mt-4">

View file

@ -4,7 +4,7 @@
<div class="d-flex"> <div class="d-flex">
<h4>Explorateur LDAP</h4> <h4>Explorateur LDAP</h4>
<a class="ml-auto btn btn-info" href="/">Retour</a> <a class="ml-auto btn btn-info" href="/">Menu principal</a>
</div> </div>
<div class="mt-4"> <div class="mt-4">
@ -37,13 +37,11 @@
</table> </table>
{{if .CanAddChild}} {{if .CanAddChild}}
<div class="mt-4"> <div class="mt-2">
<div class="d-flex"> <a class="btn btn-sm btn-success" href="/admin/create/user/{{.DN}}">+utilisateur</a>
<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/group/{{.DN}}">+groupe</a>
<a class="ml-4 btn btn-sm btn-success" href="/admin/create/generic/{{.DN}}">+objet</a> <a class="ml-4 btn btn-sm btn-success" href="/admin/create/generic/{{.DN}}">+objet</a>
</div> </div>
</div>
<hr class="mt-4" /> <hr class="mt-4" />
{{end}} {{end}}

View file

@ -4,7 +4,8 @@
<div class="d-flex"> <div class="d-flex">
<h4>Liste des utilisateurs</h4> <h4>Liste des utilisateurs</h4>
<a class="ml-auto btn btn-info" href="/">Retour</a> <a class="ml-auto btn btn-success" href="/admin/create/user/{{.UserBaseDN}}">Nouvel utilisateur</a>
<a class="ml-4 btn btn-info" href="/">Menu principal</a>
</div> </div>
<table class="table mt-4"> <table class="table mt-4">

View file

@ -19,4 +19,11 @@
</div> </div>
<button type="submit" class="btn btn-primary">Se connecter</button> <button type="submit" class="btn btn-primary">Se connecter</button>
</form> </form>
<hr class="mt-4" />
<p><strong>Mot de passe oublié ?</strong>
Écrivez à <code>coucou at deuxfleurs point fr</code>
ou contactez directement votre administrateur favori.</p>
{{end}} {{end}}