From 26b7b31d940d79459aecdbfc961e1fe8ebad169f Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Sun, 20 Sep 2020 13:18:59 +0200 Subject: [PATCH] Base template for ccm-admin --- ccm-core/package-lock.json | 5 ++ ccm-core/package.json | 1 + .../java/org/libreccm/ui/admin/AdminPage.java | 22 ++++- .../org/libreccm/ui/admin/AdminPageModel.java | 67 ++++++++++++++++ .../libreccm/ui/admin/AdminPagesModel.java | 80 +++++++++++++++++++ .../SystemInformationModel.java | 2 - .../SystemInformationPage.java | 10 +++ .../org/libreccm/ui/admin/ccm-admin.xhtml | 64 +++++++++++++++ .../libreccm/ui/admin/systeminformation.xhtml | 40 +++++----- .../assets/bootstrap/bootstrap-icons.svg | 1 + ccm-core/src/main/scss/ccm-admin/_custom.scss | 60 ++++++++++++++ .../src/main/scss/ccm-admin/ccm-admin.scss | 1 + 12 files changed, 329 insertions(+), 24 deletions(-) create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java create mode 100644 ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java create mode 100644 ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml create mode 100644 ccm-core/src/main/resources/assets/bootstrap/bootstrap-icons.svg create mode 100644 ccm-core/src/main/scss/ccm-admin/_custom.scss diff --git a/ccm-core/package-lock.json b/ccm-core/package-lock.json index 6106947ac..140618336 100644 --- a/ccm-core/package-lock.json +++ b/ccm-core/package-lock.json @@ -1571,6 +1571,11 @@ "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-4.5.2.tgz", "integrity": "sha512-vlGn0bcySYl/iV+BGA544JkkZP5LB3jsmkeKLFQakCOwCM3AOk7VkldBz4jrzSe+Z0Ezn99NVXa1o45cQY4R6A==" }, + "bootstrap-icons": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/bootstrap-icons/-/bootstrap-icons-1.0.0.tgz", + "integrity": "sha512-PaQm3VtSqbUnWuyqGmFJG5iF9UMieDuk8raPOmKOtKeyWyiVshgLoKa+9EWGolGU/nvyBLEBWhZoQqhu9ccNBg==" + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", diff --git a/ccm-core/package.json b/ccm-core/package.json index 4f5daf16a..7f8459185 100644 --- a/ccm-core/package.json +++ b/ccm-core/package.json @@ -18,6 +18,7 @@ }, "dependencies": { "bootstrap": "^4.5.2", + "bootstrap-icons": "^1.0.0", "jquery": "^3.5.1", "popper.js": "^1.16.1" } diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java index 3aba8dbd8..27e1ab4b4 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPage.java @@ -18,6 +18,7 @@ */ package org.libreccm.ui.admin; +import java.util.ResourceBundle; import java.util.Set; /** @@ -33,6 +34,16 @@ public interface AdminPage { */ Set> getControllerClasses(); + /** + * The entry point for the admin module. Used to generate the URL for an + * admin page in the navigation etc. For example, with the return value will + * {@code systeminformation} the generated link is + * {@code #{contextPath}/@admin/#{path}}. + * + * @return The path fragment of the entry point of the admin page/module. + */ + String getPath(); + /** * Gets the resourcebundle which provides the label of the admin page. * @@ -63,8 +74,15 @@ public interface AdminPage { String getDescriptionKey(); /** - * Gets the position of the page in the admin nav bar. - * + * Name of icon to use. + * + * @return The icon to use for the page. + */ + String getIcon(); + + /** + * Gets the position of the page in the admin nav bar. + * * @return The position of the page in the admin navigation. */ int getPosition(); diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java new file mode 100644 index 000000000..706fa3342 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPageModel.java @@ -0,0 +1,67 @@ +/* + * 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; + +/** + * + * @author Jens Pelzetter + */ +public class AdminPageModel { + + private String path; + + private String label; + + private String description; + + private String icon; + + public String getPath() { + return path; + } + + public void setPath(String path) { + this.path = path; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getIcon() { + return icon; + } + + public void setIcon(String icon) { + this.icon = icon; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java new file mode 100644 index 000000000..0335d7b32 --- /dev/null +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/AdminPagesModel.java @@ -0,0 +1,80 @@ +/* + * 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.List; +import java.util.ResourceBundle; +import java.util.stream.Collectors; + +import javax.enterprise.context.RequestScoped; +import javax.enterprise.inject.Instance; +import javax.inject.Inject; +import javax.inject.Named; + +/** + * + * @author Jens Pelzetter + */ +@RequestScoped +@Named("AdminPagesModel") +public class AdminPagesModel { + + @Inject + private Instance adminPages; + + @Inject + private GlobalizationHelper globalizationHelper; + + public List getAdminPages() { + return adminPages + .stream() + .sorted( + (page1, page2) -> Integer.compare( + page1.getPosition(), page2.getPosition() + ) + ) + .map(this::buildAdminPageModel) + .collect(Collectors.toList()); + } + + private AdminPageModel buildAdminPageModel(final AdminPage fromAdminPage) { + final ResourceBundle labelBundle = ResourceBundle.getBundle( + fromAdminPage.getLabelBundle(), + globalizationHelper.getNegotiatedLocale() + ); + final ResourceBundle descriptionBundle = ResourceBundle.getBundle( + fromAdminPage.getDescriptionBundle(), + globalizationHelper.getNegotiatedLocale() + ); + + final AdminPageModel model = new AdminPageModel(); + model.setPath(fromAdminPage.getPath()); + model.setLabel(labelBundle.getString(fromAdminPage.getLabelKey())); + model.setDescription( + descriptionBundle.getString( + fromAdminPage.getDescriptionKey() + ) + ); + model.setIcon(fromAdminPage.getIcon()); + return model; + } + +} diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java index 4151afdcc..99b0b3b58 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationModel.java @@ -18,7 +18,6 @@ */ package org.libreccm.ui.admin.systeminformation; -import com.arsdigita.util.SystemInformation; import com.arsdigita.util.UncheckedWrapperException; import java.io.IOException; @@ -26,7 +25,6 @@ import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.Properties; -import java.util.stream.Collectors; import javax.enterprise.context.RequestScoped; import javax.inject.Named; diff --git a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java index 130bbab34..1b8144474 100644 --- a/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java +++ b/ccm-core/src/main/java/org/libreccm/ui/admin/systeminformation/SystemInformationPage.java @@ -40,6 +40,11 @@ public class SystemInformationPage implements AdminPage { return classes; } + @Override + public String getPath() { + return "systeminformation"; + } + @Override public String getLabelBundle() { return AdminConstants.ADMIN_BUNDLE; @@ -60,6 +65,11 @@ public class SystemInformationPage implements AdminPage { return "systeminformation.description"; } + @Override + public String getIcon() { + return "info-circle-fill"; + } + @Override public int getPosition() { return 80; diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml new file mode 100644 index 000000000..233030774 --- /dev/null +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/ccm-admin.xhtml @@ -0,0 +1,64 @@ + + + + #{title} - LibreCCM Admin + + + +
+ +
+
+ +
+ + + diff --git a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml index 5de79a01c..eb0301220 100644 --- a/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml +++ b/ccm-core/src/main/resources/WEB-INF/views/org/libreccm/ui/admin/systeminformation.xhtml @@ -1,24 +1,24 @@ - - System Information - - - -

System Information

-

LibreCCM System Information

-
- -
-
#{prop.key}
-
#{prop.value}
-
-
-
- -
+ xmlns:h="http://xmlns.jcp.org/jsf/html" + xmlns:ui="http://xmlns.jcp.org/jsf/facelets"> + + + +
+

System Information

+

LibreCCM System Information

+
+ +
+
#{prop.key}
+
#{prop.value}
+
+
+
+
+
+
diff --git a/ccm-core/src/main/resources/assets/bootstrap/bootstrap-icons.svg b/ccm-core/src/main/resources/assets/bootstrap/bootstrap-icons.svg new file mode 100644 index 000000000..f7731a14b --- /dev/null +++ b/ccm-core/src/main/resources/assets/bootstrap/bootstrap-icons.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/ccm-core/src/main/scss/ccm-admin/_custom.scss b/ccm-core/src/main/scss/ccm-admin/_custom.scss new file mode 100644 index 000000000..ba3e0c8f6 --- /dev/null +++ b/ccm-core/src/main/scss/ccm-admin/_custom.scss @@ -0,0 +1,60 @@ + +$grid-breakpoints: ( + xs: 0, + sm: 36rem, + md: 48rem, + lg: 62rem, + xl: 75rem +); + +$container-max-widths: ( + sm: 33.75rem, + md: 45rem, + lg: 60rem, + xl: 71.25rem +); + +$grid-gutter-width: 1.875rem; + +$form-grid-gutter-width: 0.625rem; + +$tooltip-max-width: 12.5rem; + +$popover-maxwidth: 17.25rem; + +$toast-max-width: 21.875rem; + +$modal-xl: 71.25rem; +$modal-lg: 50rem; +$modal-md: 31.25rem; +$modal-sm: 18.75rem; + +$modal-fade-transform: translate(0, -3.125rem); + +$carousel-indicator-width: 1.875rem; +$carousel-control-icon-width: 1.25rem; + +$pre-scrollable-max-height: 21.25rem; + +// Navbar default colors have insufficient contrast +$navbar-dark-color: #fff; + +table.users-table, +table.groups-table, +table.roles-table { + tbody { + td.action-col { + width: 8em; + } + } +} + +table.group-members, +table.group-roles, +table.role-members { + tbody { + td.action-col { + width: 8em; + } + } +} diff --git a/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss b/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss index a35964e3e..4c04ef71d 100644 --- a/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss +++ b/ccm-core/src/main/scss/ccm-admin/ccm-admin.scss @@ -1 +1,2 @@ +@import "custom"; @import "../../../../node_modules/bootstrap/scss/bootstrap"; \ No newline at end of file