#3 -- fix buttons visibility

This commit is contained in:
Anton Romanov 2022-03-10 10:14:42 +04:00
parent 2e5880f1a6
commit e3d5e4e595
4 changed files with 16 additions and 10 deletions

Binary file not shown.

View File

@ -7,11 +7,9 @@
package ru.ulstu.configuration;
import nz.net.ultraq.thymeleaf.LayoutDialect;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.MessageSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.thymeleaf.extras.springsecurity5.dialect.SpringSecurityDialect;
import org.thymeleaf.spring5.SpringTemplateEngine;
import org.thymeleaf.templateresolver.ITemplateResolver;
@ -19,10 +17,11 @@ import org.thymeleaf.templateresolver.ITemplateResolver;
public class TemplateConfiguration {
@Bean
public SpringTemplateEngine templateEngine(ITemplateResolver templateResolver) {
public SpringTemplateEngine templateEngine(ITemplateResolver templateResolver, SpringSecurityDialect sec) {
final SpringTemplateEngine templateEngine = new SpringTemplateEngine();
templateEngine.addTemplateResolver(templateResolver);
templateEngine.addDialect(new LayoutDialect());
templateEngine.addDialect(sec);
return templateEngine;
}
}

View File

@ -5,8 +5,9 @@
-->
<!DOCTYPE html>
<html lang="ru"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml">
<html lang="ru" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8"/>
<title th:text="#{messages.app-name}">app-name</title>
@ -43,6 +44,12 @@
<li class="nav-item">
<a class="nav-link" href="/admin">Администратору</a>
</li>
<li>
<div sec:authorize="isAuthenticated()">
<a class="nav-link" href="/logout">Выход</a>
</div>
</li>
</ul>
</div>
</nav>

View File

@ -5,9 +5,9 @@
-->
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
layout:decorate="~{default}">
<html xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.w3.org/1999/xhtml"
xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
layout:decorate="~{default}">
<div class="container" layout:fragment="content">
<div th:each="n : ${news}" class="news">
<div class="row">
@ -19,7 +19,7 @@
<div class="col-md-10">
<a th:href="@{'/news/' + ${n.id}}" class="link-dark"><h5 th:text="${n.title}"/></a>
</div>
<div class="col-md-2" style="text-align: right">
<div sec:authorize="hasRole('ROLE_ADMIN')" class="col-md-2" style="text-align: right">
<a th:href="@{'/editNews/' + ${n.id}}" class="link-dark">
<i class="fa fa-pencil" aria-hidden="true"></i>
</a>