Configurations list
parent
743ceeb07d
commit
48c2faff70
|
|
@ -21,7 +21,15 @@ package org.libreccm.configuration;
|
|||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.NavigableMap;
|
||||
import java.util.Objects;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.TreeMap;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Describes a configuration. Useful for generating user interfaces.
|
||||
|
|
|
|||
|
|
@ -18,12 +18,22 @@
|
|||
*/
|
||||
package org.libreccm.ui.admin.configuration;
|
||||
|
||||
import org.libreccm.configuration.ConfigurationInfo;
|
||||
import org.libreccm.configuration.ConfigurationManager;
|
||||
import org.libreccm.core.CoreConstants;
|
||||
import org.libreccm.l10n.GlobalizationHelper;
|
||||
import org.libreccm.l10n.LocalizedTextsUtil;
|
||||
import org.libreccm.security.AuthorizationRequired;
|
||||
import org.libreccm.security.RequiresPrivilege;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.enterprise.context.RequestScoped;
|
||||
import javax.inject.Inject;
|
||||
import javax.mvc.Controller;
|
||||
import javax.mvc.Models;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
|
|
@ -36,11 +46,45 @@ import javax.ws.rs.Path;
|
|||
@Path("/configuration")
|
||||
public class ConfigurationController {
|
||||
|
||||
@Inject
|
||||
private ConfigurationManager confManager;
|
||||
|
||||
@Inject
|
||||
private GlobalizationHelper globalizationHelper;
|
||||
|
||||
@Inject
|
||||
private Models models;
|
||||
|
||||
@GET
|
||||
@Path("/")
|
||||
@AuthorizationRequired
|
||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||
public String getSettings() {
|
||||
final List<ConfigurationTableEntry> configurationClasses = confManager
|
||||
.findAllConfigurations()
|
||||
.stream()
|
||||
.map(confManager::getConfigurationInfo)
|
||||
.map(this::buildTableEntry)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
models.put("configurationClasses", configurationClasses);
|
||||
|
||||
return "org/libreccm/ui/admin/configuration.xhtml";
|
||||
}
|
||||
|
||||
private ConfigurationTableEntry buildTableEntry(
|
||||
final ConfigurationInfo confInfo
|
||||
) {
|
||||
Objects.requireNonNull(confInfo);
|
||||
final ConfigurationTableEntry entry = new ConfigurationTableEntry();
|
||||
entry.setName(confInfo.getName());
|
||||
final LocalizedTextsUtil util = globalizationHelper
|
||||
.getLocalizedTextsUtil(confInfo.getDescBundle());
|
||||
entry.setTitle(util.getText(confInfo.getTitleKey()));
|
||||
entry.setDescription(util.getText(confInfo.getDescKey()));
|
||||
|
||||
return entry;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* Copyright (C) 2020 LibreCCM Foundation.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
* MA 02110-1301 USA
|
||||
*/
|
||||
package org.libreccm.ui.admin.configuration;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||
*/
|
||||
public class ConfigurationTableEntry
|
||||
implements Comparable<ConfigurationTableEntry> {
|
||||
|
||||
private String name;
|
||||
|
||||
private String title;
|
||||
|
||||
private String description;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(final String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(final String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(final ConfigurationTableEntry other) {
|
||||
int result = Objects.compare(
|
||||
title,
|
||||
Objects.requireNonNull(other).getTitle(),
|
||||
String::compareTo
|
||||
);
|
||||
if (result == 0) {
|
||||
result = Objects.compare(
|
||||
name,
|
||||
Objects.requireNonNull(other).getName(),
|
||||
String::compareTo
|
||||
);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -17,7 +17,48 @@
|
|||
<ui:define name="main">
|
||||
<div class="container">
|
||||
<h1>#{AdminMessages['configuration.label']}</h1>
|
||||
<p>Placeholder</p>
|
||||
<c:forEach items="#{configurationClasses}"
|
||||
var="confClass">
|
||||
<div class="list-group">
|
||||
<a href="#"
|
||||
class="list-group-item list-group-item-action">
|
||||
<div class="d-flex w-100 justify-content-between">
|
||||
<h2 class="mb-1">
|
||||
#{confClass.title}
|
||||
</h2>
|
||||
|
||||
</div>
|
||||
<p class="mb-1">
|
||||
#{confClass.description}
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</c:forEach>
|
||||
<!-- <table class="table">
|
||||
<thead>
|
||||
<th scope="col">
|
||||
#{AdminMessages['configuration.table.headings.title']}
|
||||
</th>
|
||||
<th scope="col">
|
||||
#{AdminMessages['configuration.table.headings.description']}
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="#{configurationClasses}"
|
||||
var="confClass">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="#">
|
||||
#{confClass.title}
|
||||
</a>
|
||||
</td>
|
||||
<td>
|
||||
#{confClass.description}
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>-->
|
||||
<!-- </table>-->
|
||||
</div>
|
||||
</ui:define>
|
||||
|
||||
|
|
|
|||
|
|
@ -206,3 +206,5 @@ usersgroupsroles.users.form.errors.username.empty=The username of a user can't b
|
|||
usersgroupsroles.users.form.errors.username.invalid=The username may only contain the characters a to z, A to Z, 0 to 9, the dash (-) and the underscore (_)
|
||||
usersgroupsroles.users.form.errors.primary_email.empty=The primary email address of a user can't b be empty
|
||||
usersgroupsroles.users.form.errors.primary_email.invalid=The primary email address of a user must be a valid email address
|
||||
configuration.table.headings.title=Configuration
|
||||
configuration.table.headings.description=Description
|
||||
|
|
|
|||
|
|
@ -206,3 +206,5 @@ usersgroupsroles.users.form.errors.username.empty=Der Benutzername eines Benutze
|
|||
usersgroupsroles.users.form.errors.username.invalid=Der Benutzername eines Benutzers darf nur die Zeichen a bis z, A bis Z, 0 bis 9, den Bindestrich (-) und den Unterstrich (_) enthalten
|
||||
usersgroupsroles.users.form.errors.primary_email.empty=Die prim\u00e4re E-Mail-Addresse eines Benutzers darf nicht leer sein.
|
||||
usersgroupsroles.users.form.errors.primary_email.invalid=Die prim\u00e4re E-Mail-Addresse eines Benutzers muss eine valide E-Mail-Addresse sein
|
||||
configuration.table.headings.title=Konfiguration
|
||||
configuration.table.headings.description=Beschreibung
|
||||
|
|
|
|||
Loading…
Reference in New Issue