Implement message for info

This commit is contained in:
CodeSteak 2020-03-05 20:34:59 +01:00
parent 230d71944f
commit 96e8b19f41
5 changed files with 52 additions and 1 deletions

View File

@ -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());
}
}

View File

@ -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 {}
}

View File

@ -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;

View File

@ -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
*/

View File

@ -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>