From db1d9c87d37ff36e64907e17944186dc82ad37e5 Mon Sep 17 00:00:00 2001 From: Luc Everse <luc@wukl.net> Date: Tue, 23 Aug 2022 11:00:19 +0200 Subject: [PATCH] Add a Submit report generator --- .../core/report/SubmitAppReportGenerator.java | 38 +++++++++++++ .../auta/core/ui/submit/submit-report.ftlh | 56 +++++++++++++++++++ 2 files changed, 94 insertions(+) create mode 100644 core/src/main/java/nl/tudelft/ewi/auta/core/report/SubmitAppReportGenerator.java create mode 100644 core/src/main/resources/nl/tudelft/ewi/auta/core/ui/submit/submit-report.ftlh diff --git a/core/src/main/java/nl/tudelft/ewi/auta/core/report/SubmitAppReportGenerator.java b/core/src/main/java/nl/tudelft/ewi/auta/core/report/SubmitAppReportGenerator.java new file mode 100644 index 000000000..960c4f8c9 --- /dev/null +++ b/core/src/main/java/nl/tudelft/ewi/auta/core/report/SubmitAppReportGenerator.java @@ -0,0 +1,38 @@ +package nl.tudelft.ewi.auta.core.report; + +import nl.tudelft.ewi.auta.core.authentication.UserProvider; +import org.springframework.stereotype.Service; +import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer; + +/** + * Generates reports for consumption by Submit. + * + * Follows a Markdown-like style. + */ +@Service +public class SubmitAppReportGenerator extends GenericReportGenerator { + /** + * Creates a new Submit report generator. + * + * @param configurer the freemarker configurer + * @param reportAuthorizationFilter the report authorization filter + * @param userProvider the user provider to determine the current authorization level + */ + public SubmitAppReportGenerator( + final FreeMarkerConfigurer configurer, + final ReportAuthorizationFilter reportAuthorizationFilter, + final UserProvider userProvider + ) { + super(configurer, reportAuthorizationFilter, userProvider); + } + + /** + * Returns the template name. + * + * @return the template name + */ + @Override + public String getTemplateName() { + return "submit/submit-report.ftlh"; + } +} diff --git a/core/src/main/resources/nl/tudelft/ewi/auta/core/ui/submit/submit-report.ftlh b/core/src/main/resources/nl/tudelft/ewi/auta/core/ui/submit/submit-report.ftlh new file mode 100644 index 000000000..695366d89 --- /dev/null +++ b/core/src/main/resources/nl/tudelft/ewi/auta/core/ui/submit/submit-report.ftlh @@ -0,0 +1,56 @@ +<#-- @ftlvariable name="error" type="String" --> +<#-- @ftlvariable name="tips" type="java.util.Map<String, java.util.List>" --> +<#-- @ftlvariable name="warnings" type="java.util.Map<String, java.util.List>" --> +<#-- @ftlvariable name="failures" type="java.util.Map<String, java.util.List>" --> +<#if error??> +## A server-side error occurred. Please show this message to your TA +${error} +<#else> +<#list tips as tip, entityNames> +## Tip +${tip} + +This applies to: +<#list entityNames as entityName> +* ${entityName} +</#list> +</#list> + +<#if failures?has_content> +## Failures +<#list failures as entityName, failureMessages> +<#if failureMessages?has_content> + ### ${entityName} +<#list failureMessages as msg> + ${msg} +</#list> +</#if> +</#list> +</#if> + +<#if warnings?has_content> +## Warnings +<#list warnings as entityName, warningMessages> +<#if warningMessages?has_content> + ### ${entityName} +<#list warningMessages as msg> + ${msg} +</#list> +</#if> +</#list> +</#if> + +<#if info?has_content> +## Info +<#list info as entityName, infoMessage> +<#if infoMessage?has_content> + ### ${entityName} +<#list infoMessage as msg> +<#noautoesc> + #### ${msg} +</#noautoesc> +</#list> +</#if> +</#list> +</#if> +</#if> -- GitLab