Update header; move 'manage users' to 'settings' sub

This commit is contained in:
Dmitry Isaenko 2024-01-14 22:35:12 +03:00
parent d66ab98e1f
commit eb593e8e28
13 changed files with 149 additions and 70 deletions

View file

@ -23,7 +23,7 @@ import ru.redrise.marinesco.data.UserRepository;
@Slf4j @Slf4j
@Controller @Controller
@RequestMapping("/manage_users") @RequestMapping("/settings/manage_users")
@PreAuthorize("hasRole('ADMIN')") @PreAuthorize("hasRole('ADMIN')")
public class ManageUsersController { public class ManageUsersController {
@ -83,14 +83,14 @@ public class ManageUsersController {
log.error(id, e); log.error(id, e);
} }
return "redirect:/manage_users"; return "redirect:/settings/manage_users";
} }
@PostMapping("/update") @PostMapping("/update")
public String update(UserGenerified userGenerified) { public String update(UserGenerified userGenerified) {
User user = userRepository.findById(userGenerified.getId()).get(); User user = userRepository.findById(userGenerified.getId()).get();
if (user == null) if (user == null)
return "redirect:/manage_users"; return "redirect:/settings/manage_users";
user.setAuthorities(userGenerified.getAthorities()); user.setAuthorities(userGenerified.getAthorities());
user.setDisplayname(userGenerified.getDisplayName()); user.setDisplayname(userGenerified.getDisplayName());
@ -99,7 +99,7 @@ public class ManageUsersController {
user.setPassword(passwordEncoder.encode(userGenerified.getPassword())); user.setPassword(passwordEncoder.encode(userGenerified.getPassword()));
userRepository.save(user); userRepository.save(user);
return "redirect:/manage_users"; return "redirect:/settings/manage_users";
} }
@PostMapping @PostMapping
@ -117,6 +117,6 @@ public class ManageUsersController {
log.info("Added user {} {} {}", user.getId(), user.getUsername(), user.getDisplayname(), log.info("Added user {} {} {}", user.getId(), user.getUsername(), user.getDisplayname(),
user.getAuthorities().get(0)); user.getAuthorities().get(0));
// Reloads page therefore new records appears // Reloads page therefore new records appears
return "redirect:/manage_users"; return "redirect:/settings/manage_users";
} }
} }

View file

@ -75,6 +75,6 @@ public class UserSettingsController {
log.info("{} {}", userSettingsForm.getDisplayname(), userSettingsForm.getNewPassword()); log.info("{} {}", userSettingsForm.getDisplayname(), userSettingsForm.getNewPassword());
userRepo.save(user); userRepo.save(user);
return "user_settings"; return "redirect:/profile/settings";
} }
} }

View file

@ -109,13 +109,22 @@ header {
float: right; float: right;
padding: 0%; padding: 0%;
} }
#header_menu_block{
list-style-type: none;
list-style-image: none;
height: 100%;
margin-right: 0;
right: 0;
float: left;
padding: 0%;
}
.ul_right_block { .ul_right_block {
margin: 0 !important; margin: 0 !important;
padding: 0 !important; padding: 0 !important;
} }
.li_right_block { .li_header_block {
margin-left: 5px; margin-left: 5px;
margin-right: 5px; margin-right: 5px;
height: 100%; height: 100%;
@ -135,6 +144,22 @@ header {
color: #74bfbd; color: #74bfbd;
} }
.header_logo_link:link {
color: #74bfbd;
}
.header_logo_link:visited{
color: #74bfbd;
}
.header_logo_link:hover {
color: #74bfbd;
}
.header_entry_link:link {
color: #74bfbd;
}
.header_entry_link:visited {
color: #74bfbd;
}
.header_entry_link:hover { .header_entry_link:hover {
color: #b6a795; color: #b6a795;
} }
@ -156,6 +181,25 @@ a.entry {
font-size: 1.5em; font-size: 1.5em;
} }
.button-header {
margin: 1em 0;
font-family: sans-serif;
font-style: normal;
font-weight: normal;
text-align: center;
font-variant: small-caps !important;
background-color: #74bfbd !important;
border: none;
border-radius: 2px;
padding: 4px 15px 4px 15px;
color: #4a3c3c;
}
.button-header:hover {
background-color: #c2dac0 !important;
}
hr { hr {
border: 0; border: 0;
border-bottom: 1px dashed; border-bottom: 1px dashed;

View file

@ -10,7 +10,7 @@
<body> <body>
<div class="page"> <div class="page">
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header-anon'}"></div>
<div class="container base"> <div class="container base">
<span class="validationError" th:if="${Error} != null" th:text="${Error}"></span> <span class="validationError" th:if="${Error} != null" th:text="${Error}"></span>
<div th:if="${author} != null"> <div th:if="${author} != null">

View file

@ -10,7 +10,7 @@
<body> <body>
<div class="page"> <div class="page">
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header-anon'}"></div>
<div class="container base"> <div class="container base">
<span class="validationError" th:if="${Error} != null" th:text="${Error}"></span> <span class="validationError" th:if="${Error} != null" th:text="${Error}"></span>
<div th:if="${book} != null"> <div th:if="${book} != null">

View file

@ -1,8 +1,38 @@
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head></head> <head></head>
<body> <body>
<div th:fragment="header" class="header_wrapper" > <div th:fragment="header-anon" class="header_wrapper">
<div class="container">
<header>
<div class="header_branding block_inner">
<img height="65px" th:src="@{/images/s_logo.svg}" alt="Marinesco">
</div>
<nav id="header_right_block" class="block">
<div class="block_inner">
<ul class="ul_right_block">
<li class="li_header_block">
<a class="entry" href="/login" th:href="@{/login}">
<span class="header_entry header_entry_link">Sign in</span>
</a>
</li>
</ul>
</div>
</nav>
<nav id="header_menu_block" class="header_entry">
<ul class="ul_right_block">
<li class="li_header_block header_title">
Marinesco
</li>
</ul>
</nav>
</header>
</div>
</div>
<div th:fragment="header-auth" class="header_wrapper">
<div class="container"> <div class="container">
<header> <header>
<div class="header_branding block_inner"> <div class="header_branding block_inner">
@ -13,12 +43,16 @@
<nav id="header_right_block" class="block"> <nav id="header_right_block" class="block">
<div class="block_inner"> <div class="block_inner">
<ul class="ul_right_block"> <ul class="ul_right_block">
<li class="li_right_block" th:if="${#authorization.expression('!isAuthenticated()')}"> <li class="li_header_block" th:if="${#authentication.principal.isAdmin()}">
<a class="entry" href="/login" th:href="@{/login}"> <a class="header_entry header_entry_link" href="/settings">Settings</a>
<span class="header_entry header_entry_link">Sign in</span>
</a>
</li> </li>
<li class="li_right_block" th:if="${#authorization.expression('isAuthenticated()')}"> <li class="li_header_block">
<a class="header_entry header_entry_link" href="/profile">Profile</a>
</li>
<li class="li_header_block">
<span class="header_entry">|</span>
</li>
<li class="li_header_block">
<a class="entry" href="/logout"> <a class="entry" href="/logout">
<span class="header_entry header_entry_link">Logout</span> <span class="header_entry header_entry_link">Logout</span>
</a> </a>
@ -28,18 +62,29 @@
</div> </div>
</nav> </nav>
<div class="header_entry header_title"> <nav id="header_menu_block" class="header_entry">
Marinesco <ul class="ul_right_block">
</div> <li class="li_header_block">
<form action="/search" method="get">
<input type="text" name="search">
<button class="button-header" type="submit">Search</button>
</form>
</li>
</ul>
</nav>
</header> </header>
</div> </div>
</div> </div>
<!-- <!--
<div th:replace="~{fragments/header :: ${#authentication.principal.isAdmin()} ? 'header-admin' : 'header'}"></div> <div th:replace="~{fragments/header :: ${#authentication.principal.isAdmin()} ? 'header-admin' : 'header'}"></div>
<div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header'}"></div>
--> -->
<div th:fragment="header-content-admin"> <div th:fragment="header-content-admin">
</div> </div>
</body> </body>
</html> </html>

View file

@ -10,7 +10,7 @@
<body> <body>
<div class="page"> <div class="page">
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header-anon'}"></div>
<div class="container base"> <div class="container base">
<form method="POST" th:action="@{/settings/genres}" th:object="${genresHolder}"> <form method="POST" th:action="@{/settings/genres}" th:object="${genresHolder}">
<div class="wrapper_centred" th:each="genre, itemStat : ${genresHolder.genres}"> <div class="wrapper_centred" th:each="genre, itemStat : ${genresHolder.genres}">

View file

@ -9,7 +9,7 @@
</head> </head>
<body> <body>
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: 'header-anon'}"></div>
<div class="page"> <div class="page">
<div class="center"> <div class="center">
<div class="container base"> <div class="container base">

View file

@ -10,12 +10,12 @@
<body> <body>
<div class="page"> <div class="page">
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header'}"></div>
<div class="container base"> <div class="container base">
<h1 th:text="${header_text}"></h1> <h1 th:text="${header_text}"></h1>
<p> <p>
<div th:each="user : ${users}"> <div th:each="user : ${users}">
<form method="POST" th:action="@{/manage_users/update}" th:object="${userGenerified}"> <form method="POST" th:action="@{/settings/manage_users/update}" th:object="${userGenerified}">
<span th:text="${user.id + '. '}"></span> <span th:text="${user.id + '. '}"></span>
<span th:text="${user.name}"></span> <span th:text="${user.name}"></span>
<input type="hidden" th:value="${user.id}" name="id" /> <input type="hidden" th:value="${user.id}" name="id" />
@ -37,14 +37,14 @@
<span th:text="${athorities.name}"></span><br /> <span th:text="${athorities.name}"></span><br />
</div> </div>
<button>Update</button><a th:href="'/manage_users/delete/' + ${user.id}">Delete</a> <button>Update</button><a th:href="'/settings/manage_users/delete/' + ${user.id}">Delete</a>
</form> </form>
<br /> <br />
<hr> <hr>
</div> </div>
<hr> <hr>
<b>Add user</b> <b>Add user</b>
<form method="POST" th:action="@{/manage_users}" th:object="${administatorAddUserForm}"> <form method="POST" th:action="@{/settings/manage_users}" th:object="${administatorAddUserForm}">
<span class="validationError" th:if="${loginOccupied} != null" th:text="${loginOccupied}">pew</span> <span class="validationError" th:if="${loginOccupied} != null" th:text="${loginOccupied}">pew</span>
<span class="validationError" th:if="${#fields.hasErrors('username')}" <span class="validationError" th:if="${#fields.hasErrors('username')}"
th:errors="*{username}">Error</span> th:errors="*{username}">Error</span>

View file

@ -10,21 +10,13 @@
<body> <body>
<div class="page"> <div class="page">
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header-anon'}"></div>
<div class="container base"> <div class="container base">
<br /><a href="/login">Login</a>
<br /><a href="/profile">/profile</a>
<br /><a href="/manage_users">/manage_users</a>
<br /><a href="/settings">/settings</a>
<br /><a href="/book/59992766">/book/59992766</a> <br /><a href="/book/59992766">/book/59992766</a>
<br /><a href="/author/1">/author/1</a> <br /><a href="/author/1">/author/1</a>
<br /><a href="/h2">H2</a> <br /><a href="/h2">H2</a>
<br /> <br />
<br />
<form action='/search' method='get'>
<input type='text' name='search'>
<button class="sign" type='submit'>Search</button>
</form>
</div> </div>
</div> </div>
<div th:replace="~{fragments/footer :: 'footer'}"></div> <div th:replace="~{fragments/footer :: 'footer'}"></div>

View file

@ -10,12 +10,8 @@
<body> <body>
<div class="page"> <div class="page">
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header-anon'}"></div>
<div class="container base"> <div class="container base">
<form action='' method='get'>
<input type='text' name='search'>
<button class="sign" type='submit'>Search</button>
</form>
<div th:if="${books} != null"> <div th:if="${books} != null">
<hr> <hr>
<h3>Titles</h3> <h3>Titles</h3>

View file

@ -10,14 +10,16 @@
<body> <body>
<div class="page"> <div class="page">
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: ${#authorization.expression('isAuthenticated()')} ? 'header-auth' : 'header-anon'}"></div>
<div class="container base"> <div class="container base">
<span <span
th:text="${'New users registration is now ' + (allowRegistration ? 'enabled. ' : 'disabled. ' )}"></span> th:text="${'New users registration is now ' + (allowRegistration ? 'enabled. ' : 'disabled. ' )}"></span>
<a th:href="${'/settings/allow_registration/' + !allowRegistration }" <a th:href="${'/settings/allow_registration/' + !allowRegistration }"
th:text="${'Click here to ' + (allowRegistration ? 'disable' : 'enable' )}"></a> th:text="${'Click here to ' + (allowRegistration ? 'disable' : 'enable' )}"></a>
<p> <br />
<br />
<a href="/settings/manage_users">Manage users</a>
<br />
<span class="validationError" th:if="${rescanError} != null" th:text="${rescanError}"></span> <span class="validationError" th:if="${rescanError} != null" th:text="${rescanError}"></span>
<span class="validationPass" th:if="${rescanOk} != null" th:text="${rescanOk}"></span> <span class="validationPass" th:if="${rescanOk} != null" th:text="${rescanOk}"></span>
<br /> <br />

View file

@ -10,7 +10,7 @@
<body> <body>
<div class="page"> <div class="page">
<div th:replace="~{fragments/header :: 'header'}"></div> <div th:replace="~{fragments/header :: 'header-auth'}"></div>
<div class="container base"> <div class="container base">
<h1 th:text="${header_text}">welcome</h1> <h1 th:text="${header_text}">welcome</h1>
<form method="POST" th:action="@{/profile/settings}" th:object="${userSettingsForm}"> <!-- --> <form method="POST" th:action="@{/profile/settings}" th:object="${userSettingsForm}"> <!-- -->