diff --git a/prototype/src/main/java/org/hso/ecommerce/app/Config.java b/prototype/src/main/java/org/hso/ecommerce/app/Config.java index 22006ab..70d46c0 100644 --- a/prototype/src/main/java/org/hso/ecommerce/app/Config.java +++ b/prototype/src/main/java/org/hso/ecommerce/app/Config.java @@ -1,5 +1,6 @@ package org.hso.ecommerce.app; +import org.hso.ecommerce.components.InfoDemoInterceptor; import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; @@ -15,5 +16,6 @@ public class Config implements WebMvcConfigurer { public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(new LoginIntercepter()); registry.addInterceptor(new ErrorDemoInterceptor()); + registry.addInterceptor(new InfoDemoInterceptor()); } } diff --git a/prototype/src/main/java/org/hso/ecommerce/components/InfoDemoInterceptor.java b/prototype/src/main/java/org/hso/ecommerce/components/InfoDemoInterceptor.java new file mode 100644 index 0000000..ff76464 --- /dev/null +++ b/prototype/src/main/java/org/hso/ecommerce/components/InfoDemoInterceptor.java @@ -0,0 +1,28 @@ +package org.hso.ecommerce.components; + +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; +import org.springframework.web.servlet.ModelAndView; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@Component +public class InfoDemoInterceptor implements HandlerInterceptor { + @Override + public boolean preHandle( + HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { + + request.setAttribute("info", request.getParameter("info")); + return true; + } + @Override + public void postHandle( + HttpServletRequest request, HttpServletResponse response, Object handler, + ModelAndView modelAndView) throws Exception { + } + + @Override + public void afterCompletion(HttpServletRequest request, HttpServletResponse response, + Object handler, Exception exception) throws Exception {} +} diff --git a/prototype/src/main/java/org/hso/ecommerce/contoller/Login.java b/prototype/src/main/java/org/hso/ecommerce/contoller/Login.java index e545de8..00f08df 100644 --- a/prototype/src/main/java/org/hso/ecommerce/contoller/Login.java +++ b/prototype/src/main/java/org/hso/ecommerce/contoller/Login.java @@ -3,6 +3,7 @@ package org.hso.ecommerce.contoller; import org.hso.ecommerce.db.CustomerRepository; import org.hso.ecommerce.entities.Customer; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.Cookie; import java.util.List; diff --git a/prototype/src/main/resources/static/css/ecom.css b/prototype/src/main/resources/static/css/ecom.css index 693b2f7..1d8f125 100644 --- a/prototype/src/main/resources/static/css/ecom.css +++ b/prototype/src/main/resources/static/css/ecom.css @@ -765,6 +765,12 @@ input[type="number"]:focus { font-size: var(--u0); } +.info { + background-color: var(--c-secondary); + text-align: center; + font-size: var(--u0); +} + /* * Impov */ diff --git a/prototype/src/main/resources/templates/fragments/header.html b/prototype/src/main/resources/templates/fragments/header.html index 133fb74..84e8d56 100644 --- a/prototype/src/main/resources/templates/fragments/header.html +++ b/prototype/src/main/resources/templates/fragments/header.html @@ -40,7 +40,21 @@ <a class="secondary button error" href="javascript:void(0)" onclick="toggle('error-msg');">X</a> </div> </div> - + </div> + <div th:if="${info}" class="info" id="info-msg"> + <div class="content-width bar-flex"> + <div th:text="${info}" class="spacer info"> + Info + </div> + <div class=""> + <script> + function toggle(id) { + document.getElementById(id).classList.toggle("invisible"); + } + </script> + <a class="secondary button info" href="javascript:void(0)" onclick="toggle('info-msg');">X</a> + </div> + </div> </div> </nav> </body>