parent
54b7b6ec56
commit
911955e6b8
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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.applications;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public interface ApplicationController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,98 @@
|
||||||
|
/*
|
||||||
|
* 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.applications;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class ApplicationTypeInfoItem implements
|
||||||
|
Comparable<ApplicationTypeInfoItem> {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
private boolean singleton;
|
||||||
|
|
||||||
|
private long numberOfInstances;
|
||||||
|
|
||||||
|
protected ApplicationTypeInfoItem() {
|
||||||
|
// Nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setName(final String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setTitle(final String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDescription(final String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSingleton() {
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSingleton(final boolean singleton) {
|
||||||
|
this.singleton = singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getNumberOfInstances() {
|
||||||
|
return numberOfInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setNumberOfInstances(final long numberOfInstances) {
|
||||||
|
this.numberOfInstances = numberOfInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int compareTo(final ApplicationTypeInfoItem other) {
|
||||||
|
if (other == null) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int result = Objects.compare(title, other.getTitle(), String::compareTo);
|
||||||
|
if (result == 0) {
|
||||||
|
result = Objects.compare(name, other.getName(), String::compareTo);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -19,13 +19,25 @@
|
||||||
package org.libreccm.ui.admin.applications;
|
package org.libreccm.ui.admin.applications;
|
||||||
|
|
||||||
import org.libreccm.core.CoreConstants;
|
import org.libreccm.core.CoreConstants;
|
||||||
|
import org.libreccm.l10n.GlobalizationHelper;
|
||||||
|
import org.libreccm.l10n.LocalizedTextsUtil;
|
||||||
import org.libreccm.security.AuthorizationRequired;
|
import org.libreccm.security.AuthorizationRequired;
|
||||||
import org.libreccm.security.RequiresPrivilege;
|
import org.libreccm.security.RequiresPrivilege;
|
||||||
|
import org.libreccm.web.ApplicationManager;
|
||||||
|
import org.libreccm.web.ApplicationRepository;
|
||||||
|
import org.libreccm.web.ApplicationType;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import javax.enterprise.context.RequestScoped;
|
import javax.enterprise.context.RequestScoped;
|
||||||
|
import javax.inject.Inject;
|
||||||
import javax.mvc.Controller;
|
import javax.mvc.Controller;
|
||||||
|
import javax.mvc.Models;
|
||||||
import javax.ws.rs.GET;
|
import javax.ws.rs.GET;
|
||||||
import javax.ws.rs.Path;
|
import javax.ws.rs.Path;
|
||||||
|
import javax.ws.rs.PathParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
@ -36,11 +48,63 @@ import javax.ws.rs.Path;
|
||||||
@Path("/applications")
|
@Path("/applications")
|
||||||
public class ApplicationsController {
|
public class ApplicationsController {
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ApplicationManager appManager;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private ApplicationRepository appRepository;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private GlobalizationHelper globalizationHelper;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Models models;
|
||||||
|
|
||||||
@GET
|
@GET
|
||||||
@Path("/")
|
@Path("/")
|
||||||
@AuthorizationRequired
|
@AuthorizationRequired
|
||||||
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
public String getApplications() {
|
public String getApplicationTypes() {
|
||||||
return "org/libreccm/ui/admin/applications.xhtml";
|
final List<ApplicationTypeInfoItem> appTypes = appManager
|
||||||
|
.getApplicationTypes()
|
||||||
|
.entrySet()
|
||||||
|
.stream()
|
||||||
|
.map(Map.Entry::getValue)
|
||||||
|
.map(this::buildTypeInfoItem)
|
||||||
|
.sorted()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
models.put("applicationTypes", appTypes);
|
||||||
|
|
||||||
|
return "org/libreccm/ui/admin/applications/applicationtypes.xhtml";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GET
|
||||||
|
@Path("/{type}")
|
||||||
|
@AuthorizationRequired
|
||||||
|
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
|
||||||
|
public String getApplicationInstances(
|
||||||
|
@PathParam("type") final String type
|
||||||
|
) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ApplicationTypeInfoItem buildTypeInfoItem(
|
||||||
|
final ApplicationType applicationType
|
||||||
|
) {
|
||||||
|
final ApplicationTypeInfoItem item = new ApplicationTypeInfoItem();
|
||||||
|
item.setName(applicationType.name());
|
||||||
|
|
||||||
|
final LocalizedTextsUtil textsUtil = globalizationHelper
|
||||||
|
.getLocalizedTextsUtil(applicationType.descBundle());
|
||||||
|
item.setTitle(textsUtil.getText(applicationType.titleKey()));
|
||||||
|
item.setDescription(textsUtil.getText(applicationType.descKey()));
|
||||||
|
item.setSingleton(applicationType.singleton());
|
||||||
|
item.setNumberOfInstances(
|
||||||
|
appRepository.findByType(applicationType.name()).size()
|
||||||
|
);
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ public class ApplicationsPage implements AdminPage {
|
||||||
@Override
|
@Override
|
||||||
public String getUriIdentifier() {
|
public String getUriIdentifier() {
|
||||||
return String.format(
|
return String.format(
|
||||||
"%s#getApplications", ApplicationsController.class.getSimpleName()
|
"%s#getApplicationTypes", ApplicationsController.class.getSimpleName()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
/*
|
||||||
|
* 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.applications;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
|
||||||
|
*/
|
||||||
|
public class DefaultApplicationController implements ApplicationController {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -23,8 +23,12 @@ import com.arsdigita.ui.admin.applications.AbstractAppSettingsPane;
|
||||||
import com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm;
|
import com.arsdigita.ui.admin.applications.DefaultApplicationInstanceForm;
|
||||||
import com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane;
|
import com.arsdigita.ui.admin.applications.DefaultApplicationSettingsPane;
|
||||||
|
|
||||||
|
import org.libreccm.ui.admin.applications.ApplicationController;
|
||||||
|
import org.libreccm.ui.admin.applications.DefaultApplicationController;
|
||||||
|
|
||||||
import javax.servlet.annotation.WebServlet;
|
import javax.servlet.annotation.WebServlet;
|
||||||
import javax.servlet.http.HttpServlet;
|
import javax.servlet.http.HttpServlet;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
|
||||||
|
|
@ -111,10 +115,13 @@ public @interface ApplicationType {
|
||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("rawtypes") // Can't specify type here, otherwise problems in using classes.
|
||||||
Class<? extends ApplicationCreator> creator();
|
Class<? extends ApplicationCreator> creator();
|
||||||
|
|
||||||
Class<? extends AbstractAppInstanceForm> instanceForm() default DefaultApplicationInstanceForm.class;
|
Class<? extends AbstractAppInstanceForm> instanceForm() default DefaultApplicationInstanceForm.class;
|
||||||
|
|
||||||
|
Class<? extends ApplicationController> adminController() default DefaultApplicationController.class;
|
||||||
|
|
||||||
Class<? extends AbstractAppSettingsPane> settingsPane() default DefaultApplicationSettingsPane.class;
|
Class<? extends AbstractAppSettingsPane> settingsPane() default DefaultApplicationSettingsPane.class;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
|
||||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
|
||||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
|
||||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
|
||||||
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
|
|
||||||
|
|
||||||
<ui:param name="activePage" value="applications" />
|
|
||||||
<ui:param name="title" value="#{AdminMessages['applications.label']}" />
|
|
||||||
|
|
||||||
<ui:define name="breadcrumb">
|
|
||||||
<li class="breadcrumb-item active">
|
|
||||||
#{AdminMessages['applications.label']}
|
|
||||||
</li>
|
|
||||||
</ui:define>
|
|
||||||
|
|
||||||
<ui:define name="main">
|
|
||||||
<div class="container">
|
|
||||||
<h1>#{AdminMessages['applications.label']}</h1>
|
|
||||||
<p>Placeholder</p>
|
|
||||||
</div>
|
|
||||||
</ui:define>
|
|
||||||
|
|
||||||
</ui:composition>
|
|
||||||
</html>
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||||
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||||
|
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
|
||||||
|
|
||||||
|
<ui:param name="activePage" value="applications" />
|
||||||
|
<ui:param name="title" value="#{AdminMessages['applications.label']}" />
|
||||||
|
|
||||||
|
<ui:define name="breadcrumb">
|
||||||
|
<li class="breadcrumb-item active">
|
||||||
|
#{AdminMessages['applications.label']}
|
||||||
|
</li>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
<ui:define name="main">
|
||||||
|
<div class="container">
|
||||||
|
<h1>#{AdminMessages['applications.label']}</h1>
|
||||||
|
|
||||||
|
<ul class="list-group">
|
||||||
|
<c:forEach items="#{applicationTypes}" var="type">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<div class="d-flex w-100 justify-content-between align-items-center">
|
||||||
|
<h2>
|
||||||
|
<a href="#{mvc.uri('ApplicationsController#getApplicationInstances', {'type': type.name})}">${type.title}</a>
|
||||||
|
</h2>
|
||||||
|
<small class="badge badge-info badge-pill">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="#{type.singleton}">
|
||||||
|
#{AdminMessages['applications.types.singleton']}
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
#{AdminMessages.getMessage('applications.number_of_instances', [type.numberOfInstances])}
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</small>
|
||||||
|
</div>
|
||||||
|
<p>
|
||||||
|
${type.description}
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
|
</c:forEach>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</ui:define>
|
||||||
|
|
||||||
|
</ui:composition>
|
||||||
|
</html>
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
<!DOCTYPE html [<!ENTITY times '×'>]>
|
<!DOCTYPE html [<!ENTITY times '×'>]>
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml"
|
<html xmlns="http://www.w3.org/1999/xhtml"
|
||||||
|
xmlns:bootstrap="http://xmlns.jcp.org/jsf/composite/components/bootstrap"
|
||||||
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
|
||||||
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
xmlns:h="http://xmlns.jcp.org/jsf/html"
|
||||||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
|
||||||
xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
||||||
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
|
<ui:composition template="/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml">
|
||||||
|
|
||||||
<ui:param name="activePage" value="categories" />
|
<ui:param name="activePage" value="categories" />
|
||||||
|
|
@ -28,12 +28,7 @@
|
||||||
<div class="text-right mb-2">
|
<div class="text-right mb-2">
|
||||||
<a class="btn btn-secondary"
|
<a class="btn btn-secondary"
|
||||||
href="#{mvc.uri('CategorySystemsController#newCategorySystem')}">
|
href="#{mvc.uri('CategorySystemsController#newCategorySystem')}">
|
||||||
<svg class="bi"
|
<bootstrap:svgIcon icon="plus-circle" />
|
||||||
width="1em"
|
|
||||||
height="1em"
|
|
||||||
fill="currentColor">
|
|
||||||
<use xlink:href="#{request.contextPath}/assets/bootstrap/bootstrap-icons.svg#plus-circle" />
|
|
||||||
</svg>
|
|
||||||
<span>#{AdminMessages['categorysystems.add']}</span>
|
<span>#{AdminMessages['categorysystems.add']}</span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -60,12 +55,7 @@
|
||||||
<td>
|
<td>
|
||||||
<a class="btn btn-info"
|
<a class="btn btn-info"
|
||||||
href="#{mvc.uri('CategorySystemsController#getCategorySystemDetails', { 'categorySystemIdentifier': categorySystem.identifier })}">
|
href="#{mvc.uri('CategorySystemsController#getCategorySystemDetails', { 'categorySystemIdentifier': categorySystem.identifier })}">
|
||||||
<svg class="bi"
|
<bootstrap:svgIcon icon="pen"/>
|
||||||
width="1em"
|
|
||||||
height="1em"
|
|
||||||
fill="currentColor">
|
|
||||||
<use xlink:href="#{request.contextPath}/assets/bootstrap/bootstrap-icons.svg#pen" />
|
|
||||||
</svg>
|
|
||||||
#{AdminMessages['categorysystems.table.actions.edit']}
|
#{AdminMessages['categorysystems.table.actions.edit']}
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
|
|
@ -74,12 +64,7 @@
|
||||||
data-target="#confirm-delete-#{categorySystem.identifier}"
|
data-target="#confirm-delete-#{categorySystem.identifier}"
|
||||||
data-toggle="modal"
|
data-toggle="modal"
|
||||||
type="button">
|
type="button">
|
||||||
<svg class="bi"
|
<bootstrap:svgIcon icon="x-circle" />
|
||||||
width="1em"
|
|
||||||
height="1em"
|
|
||||||
fill="currentColor">
|
|
||||||
<use xlink:href="#{request.contextPath}/assets/bootstrap/bootstrap-icons.svg#x-circle" />
|
|
||||||
</svg>
|
|
||||||
#{AdminMessages['categorysystems.table.actions.delete']}
|
#{AdminMessages['categorysystems.table.actions.delete']}
|
||||||
</button>
|
</button>
|
||||||
<div class="modal"
|
<div class="modal"
|
||||||
|
|
|
||||||
|
|
@ -490,3 +490,5 @@ sites.form.defaulttheme.label=Default Theme
|
||||||
sites.form.buttons.cancel=Cancel
|
sites.form.buttons.cancel=Cancel
|
||||||
sites.form.buttons.create=Create Site
|
sites.form.buttons.create=Create Site
|
||||||
sites.form.buttons.save=Save
|
sites.form.buttons.save=Save
|
||||||
|
applications.types.singleton=Singleton
|
||||||
|
applications.number_of_instances={0} instances
|
||||||
|
|
|
||||||
|
|
@ -490,3 +490,5 @@ sites.form.defaulttheme.label=Standard Theme
|
||||||
sites.form.buttons.cancel=Abbrechen
|
sites.form.buttons.cancel=Abbrechen
|
||||||
sites.form.buttons.create=Site anlegen
|
sites.form.buttons.create=Site anlegen
|
||||||
sites.form.buttons.save=Speichern
|
sites.form.buttons.save=Speichern
|
||||||
|
applications.types.singleton=Singleton
|
||||||
|
applications.number_of_instances={0} Instanzen
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue