impl error in header
This commit is contained in:
		@ -6,6 +6,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
 | 
			
		||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
 | 
			
		||||
 | 
			
		||||
import org.hso.ecommerce.components.LoginIntercepter;
 | 
			
		||||
import org.hso.ecommerce.components.ErrorDemoInterceptor;
 | 
			
		||||
 | 
			
		||||
@Configuration
 | 
			
		||||
public class Config implements WebMvcConfigurer {
 | 
			
		||||
@ -13,5 +14,6 @@ public class Config implements WebMvcConfigurer {
 | 
			
		||||
    @Override
 | 
			
		||||
    public void addInterceptors(InterceptorRegistry registry) {
 | 
			
		||||
        registry.addInterceptor(new LoginIntercepter());
 | 
			
		||||
        registry.addInterceptor(new ErrorDemoInterceptor());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -0,0 +1,31 @@
 | 
			
		||||
package org.hso.ecommerce.components;
 | 
			
		||||
 | 
			
		||||
import org.springframework.boot.web.servlet.server.Session;
 | 
			
		||||
import org.springframework.stereotype.Component;
 | 
			
		||||
import org.springframework.ui.Model;
 | 
			
		||||
import org.springframework.web.servlet.HandlerInterceptor;
 | 
			
		||||
import org.springframework.web.servlet.ModelAndView;
 | 
			
		||||
 | 
			
		||||
import javax.servlet.http.Cookie;
 | 
			
		||||
import javax.servlet.http.HttpServletRequest;
 | 
			
		||||
import javax.servlet.http.HttpServletResponse;
 | 
			
		||||
 | 
			
		||||
@Component
 | 
			
		||||
public class ErrorDemoInterceptor implements HandlerInterceptor {
 | 
			
		||||
    @Override
 | 
			
		||||
    public boolean preHandle(
 | 
			
		||||
            HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
 | 
			
		||||
 | 
			
		||||
        request.setAttribute("error", request.getParameter("error"));
 | 
			
		||||
        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 {}
 | 
			
		||||
}
 | 
			
		||||
@ -759,6 +759,12 @@ input[type="number"]:focus {
 | 
			
		||||
   padding: var(--u0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
.error {
 | 
			
		||||
   background-color: var(--c-error);
 | 
			
		||||
   text-align: center;
 | 
			
		||||
   font-size: var(--u0);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Impov
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
@ -1,29 +1,48 @@
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html lang="de" dir="ltr" xmlns:th="http://www.thymeleaf.org">
 | 
			
		||||
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="utf-8">
 | 
			
		||||
    <title>eCommerce</title>
 | 
			
		||||
   <meta charset="utf-8">
 | 
			
		||||
   <title>eCommerce</title>
 | 
			
		||||
</head>
 | 
			
		||||
 | 
			
		||||
<body>
 | 
			
		||||
    <nav class='hero header' th:fragment="header">
 | 
			
		||||
        <div class='content-width bar-flex'>
 | 
			
		||||
           <a class="button no-padding" href="/"><img class="logo" th:src="@{/img/ecom-logo-base.svg}"></a>
 | 
			
		||||
            <form class='spacer input-icon secondary' th:action="@{/shop/search}" method="GET">
 | 
			
		||||
                <input type="text" placeholder="Nach Produkten suchen..."/>
 | 
			
		||||
                <button>Finden</button>
 | 
			
		||||
            </form>
 | 
			
		||||
            <a th:unless="${customer}" class="button" th:href="@{/login}">Login</a>
 | 
			
		||||
            <div th:if="${customer}" class="dropdown">
 | 
			
		||||
               <a class="dropdown-button button">Mein Konto</a>
 | 
			
		||||
               <div class="dropdown-content">
 | 
			
		||||
                  <a class="black button"  th:href="@{/user/notifications/}">Benachrichtigungen</a>
 | 
			
		||||
                  <a class="black button"  th:href="@{/user/}">Einstellungen</a>
 | 
			
		||||
                  <a class="black button"  th:href="@{/user/orders/}">Meine Bestellungen</a>
 | 
			
		||||
                  <form th:if="${customer}" method="post" th:action="@{/logout}" class="no-margin"><button class="bg-black no-margin full-width">Abmelden</button></form>
 | 
			
		||||
               </div>
 | 
			
		||||
   <nav class='hero header' th:fragment="header">
 | 
			
		||||
      <div class='content-width bar-flex'>
 | 
			
		||||
         <a class="button no-padding" href="/"><img class="logo" th:src="@{/img/ecom-logo-base.svg}"></a>
 | 
			
		||||
         <form class='spacer input-icon secondary' th:action="@{/shop/search}" method="GET">
 | 
			
		||||
            <input type="text" placeholder="Nach Produkten suchen..." />
 | 
			
		||||
            <button>Finden</button>
 | 
			
		||||
         </form>
 | 
			
		||||
         <a th:unless="${customer}" class="button" th:href="@{/login}">Login</a>
 | 
			
		||||
         <div th:if="${customer}" class="dropdown">
 | 
			
		||||
            <a class="dropdown-button button">Mein Konto</a>
 | 
			
		||||
            <div class="dropdown-content">
 | 
			
		||||
               <a class="black button" th:href="@{/user/notifications/}">Benachrichtigungen</a>
 | 
			
		||||
               <a class="black button" th:href="@{/user/}">Einstellungen</a>
 | 
			
		||||
               <a class="black button" th:href="@{/user/orders/}">Meine Bestellungen</a>
 | 
			
		||||
               <form th:if="${customer}" method="post" th:action="@{/logout}" class="no-margin"><button class="bg-black no-margin full-width">Abmelden</button></form>
 | 
			
		||||
            </div>
 | 
			
		||||
            <a th:if="${customer}" class="button" th:href="@{/shop/checkout}">Warenkorb</a>
 | 
			
		||||
        </div>
 | 
			
		||||
    </nav>
 | 
			
		||||
         </div>
 | 
			
		||||
         <a th:if="${customer}" class="button" th:href="@{/shop/checkout}">Warenkorb</a>
 | 
			
		||||
      </div>
 | 
			
		||||
      <div th:if="${error}" class="error" id="error-msg">
 | 
			
		||||
         <div class="content-width bar-flex">
 | 
			
		||||
            <div th:text="${error}" class="spacer error">
 | 
			
		||||
               Error
 | 
			
		||||
            </div>
 | 
			
		||||
            <div class="">
 | 
			
		||||
               <script>
 | 
			
		||||
                  function toggle(id) {
 | 
			
		||||
                     document.getElementById(id).classList.toggle("invisible");
 | 
			
		||||
                  }
 | 
			
		||||
               </script>
 | 
			
		||||
               <a class="secondary button error" href="javascript:void(0)" onclick="toggle('error-msg');">X</a>
 | 
			
		||||
            </div>
 | 
			
		||||
         </div>
 | 
			
		||||
 | 
			
		||||
      </div>
 | 
			
		||||
   </nav>
 | 
			
		||||
</body>
 | 
			
		||||
 | 
			
		||||
</html>
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user