Serving HTML and resources for Admin UI

Jens Pelzetter 2020-08-25 20:34:58 +02:00
parent a0ae1d1c64
commit fa7a74080d
10 changed files with 251 additions and 9 deletions

View File

@ -200,6 +200,7 @@
<type>jar</type>
<includes>
<include>assets/</include>
<include>_admin/</include>
</includes>
</overlay>
<overlay>

View File

@ -308,7 +308,8 @@
<filtering>true</filtering>
</resource>
<resource>
<directory>target/generated-resources/@admin</directory>
<directory>target/generated-resources/_admin</directory>
<targetPath>_admin</targetPath>
</resource>
</resources>

View File

@ -4,7 +4,7 @@
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build --dest ../../target/generated-resources/@admin/systeminformation",
"build": "vue-cli-service build --dest ../../target/generated-resources/_admin/systeminformation",
"lint": "vue-cli-service lint"
},
"dependencies": {
@ -35,6 +35,9 @@
"typescript": "~3.9.3",
"vue-template-compiler": "^2.6.11"
},
"vue": {
"filenameHashing": false
},
"eslintConfig": {
"root": true,
"env": {

View File

@ -35,6 +35,7 @@ import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.servlet.ServletContext;
@ -61,9 +62,10 @@ public class AdminUi {
@Inject
private ServletContext servletContext;
private final Configuration configuration;
private Configuration configuration;
public AdminUi() {
@PostConstruct
private void init() {
configuration = new Configuration(Configuration.VERSION_2_3_30);
configuration.setDefaultEncoding("UTF-8");
configuration
@ -84,6 +86,15 @@ public class AdminUi {
);
}
@GET
@Path("/")
@Produces(MediaType.TEXT_HTML)
@AuthorizationRequired
@RequiresPrivilege(CoreConstants.PRIVILEGE_ADMIN)
public String getDashboard() {
return getApp("dashboard");
}
@GET
@Path("/{appName}")
@Produces(MediaType.TEXT_HTML)
@ -113,7 +124,7 @@ public class AdminUi {
final Map<String, Object> data = new HashMap<>();
data.put("adminUiApps", adminUiApps.getAdminUiApps());
data.put("activeApp", appName);
data.put("activeApp", app);
final StringWriter writer = new StringWriter();
try {

View File

@ -55,13 +55,20 @@ public interface AdminUiApp {
int getOrder();
/**
* Path portion of the URL of the JavaScript file providing the Admin UI
* Path portion of the URL of the JavaScript file(s) providing the Admin UI
* App.
*
* @return
*/
String getJsFileUrl();
String[] getJsFilesUrls();
/**
* Path portion of the URL of the CSS file(s) of the application.
*
* @return
*/
String[] getCssFilesUrls();
/**
* Name of the icon from the Bootstrap Icons set
*

View File

@ -0,0 +1,89 @@
/*
* 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;
import org.libreccm.l10n.GlobalizationHelper;
import java.util.Optional;
import java.util.ResourceBundle;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class DashboardApp implements AdminUiApp {
private ResourceBundle adminBundle;
@Inject
private GlobalizationHelper globalizationHelper;
@PostConstruct
private void init() {
adminBundle = ResourceBundle.getBundle(
"org.libreccm.ui.admin", globalizationHelper.getNegotiatedLocale()
);
}
@Override
public String getName() {
return "dashboard";
}
@Override
public String getLabel() {
return adminBundle.getString("dashboard.label");
}
@Override
public String getDescription() {
return adminBundle.getString("dashboard.description");
}
@Override
public int getOrder() {
return 1;
}
@Override
public String[] getJsFilesUrls() {
return new String[]{};
}
@Override
public String[] getCssFilesUrls() {
return new String[]{};
}
@Override
public Optional<String> getIconName() {
return Optional.of("house-fill");
}
@Override
public Optional<String> getSymbolUrl() {
return Optional.empty();
}
}

View File

@ -0,0 +1,92 @@
/*
* 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;
import org.libreccm.l10n.GlobalizationHelper;
import java.util.Optional;
import java.util.ResourceBundle;
import javax.annotation.PostConstruct;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
/**
*
* @author <a href="mailto:jens.pelzetter@googlemail.com">Jens Pelzetter</a>
*/
@RequestScoped
public class SystemInformationApp implements AdminUiApp {
private ResourceBundle adminBundle;
@Inject
private GlobalizationHelper globalizationHelper;
@PostConstruct
private void init() {
adminBundle = ResourceBundle.getBundle(
"org.libreccm.ui.admin", globalizationHelper.getNegotiatedLocale()
);
}
@Override
public String getName() {
return "systeminformation";
}
@Override
public String getLabel() {
return adminBundle.getString("systeminformation.label");
}
@Override
public String getDescription() {
return adminBundle.getString("systeminformation.description");
}
@Override
public int getOrder() {
return 20;
}
@Override
public String[] getJsFilesUrls() {
return new String[]{
"/@admin/systeminformation/js/app.js",
"/@admin/systeminformation/js/chunk-vendors.js",};
}
@Override
public String[] getCssFilesUrls() {
return new String[]{
"/@admin/systeminformation/css/app.css",};
}
@Override
public Optional<String> getIconName() {
return Optional.of("info-circle");
}
@Override
public Optional<String> getSymbolUrl() {
return Optional.empty();
}
}

View File

@ -0,0 +1,19 @@
# 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
systeminformation.label=System Information
systeminformation.description=Shows several system properties

View File

@ -0,0 +1,19 @@
# 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
systeminformation.label=System Informationen
systeminformation.description=Zeigt verschiedene Eigenschaften des Systems

View File

@ -6,8 +6,8 @@
<body>
<h1>Admin UI</h1>
<ul>
<#list adminUis as adminUi>
<li>{{adminUi.name}}</li>
<#list adminUiApps as app>
<li>${app.name}</li>
</#list>
</ul>
</body>