Compare commits
No commits in common. "d66ab98e1ff5bce3c2e3bed36d524c7dcf968b27" and "509d31e1d874c1f74883eb72c5cc1f27b25219c7" have entirely different histories.
d66ab98e1f
...
509d31e1d8
5 changed files with 1 additions and 110 deletions
|
@ -1,61 +0,0 @@
|
|||
package ru.redrise.marinesco.library.settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import ru.redrise.marinesco.data.GenreRepository;
|
||||
import ru.redrise.marinesco.library.Genre;
|
||||
|
||||
@Slf4j
|
||||
@Controller
|
||||
@RequestMapping("/settings/genres")
|
||||
@PreAuthorize("hasRole('ADMIN')")
|
||||
public class GenreSettingsController {
|
||||
|
||||
private GenreRepository genreRepository;
|
||||
|
||||
public GenreSettingsController(GenreRepository genreRepository) {
|
||||
this.genreRepository = genreRepository;
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
public String getPage(@ModelAttribute("rescanError") String err) {
|
||||
return "genres_settings";
|
||||
}
|
||||
|
||||
@ModelAttribute(name = "genresHolder")
|
||||
public GenresHolder setRegistrationSetting() {
|
||||
List<Genre> genres = new ArrayList<>();
|
||||
|
||||
genreRepository.findAll()
|
||||
.iterator()
|
||||
.forEachRemaining(element -> genres.add(element));
|
||||
|
||||
return new GenresHolder(genres);
|
||||
}
|
||||
|
||||
@PostMapping
|
||||
public String getGenresUpdated(@ModelAttribute GenresHolder genreHolder) {
|
||||
|
||||
for (Genre genre : genreHolder.getGenres())
|
||||
genreRepository.save(genre);
|
||||
|
||||
return "genres_settings";
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
private class GenresHolder {
|
||||
private List<Genre> genres;
|
||||
}
|
||||
}
|
|
@ -238,21 +238,3 @@ button:hover {
|
|||
.book_title{
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.wrapper_centred{
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
justify-content: center;
|
||||
}
|
||||
.item0{
|
||||
padding-right: 5px;
|
||||
padding-left: 5px;
|
||||
flex-grow: 0;
|
||||
flex-basis: 15%;
|
||||
}
|
||||
.item1{
|
||||
flex-grow: 0;
|
||||
padding-right: 5px;
|
||||
padding-left: 5px;
|
||||
flex-basis: 350px;
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<title>Marinesco - Genre settings</title>
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||
<link rel="alternate icon" href="/favicon.png" type="image/png">
|
||||
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="page">
|
||||
<div th:replace="~{fragments/header :: 'header'}"></div>
|
||||
<div class="container base">
|
||||
<form method="POST" th:action="@{/settings/genres}" th:object="${genresHolder}">
|
||||
<div class="wrapper_centred" th:each="genre, itemStat : ${genresHolder.genres}">
|
||||
<label for="displayname" th:text="${genre.genreId}" class="item0"></label>
|
||||
<input type="hidden" th:value="${genre.genreId}" th:field="*{genres[__${itemStat.index}__].genreId}" />
|
||||
<input class="item1" type="text" th:field="*{genres[__${itemStat.index}__].humanReadableDescription}"
|
||||
th:value="${genre.humanReadableDescription}" size="25%" />
|
||||
</div>
|
||||
<div class="wrapper_centred"><button class="sign" type="submit">Save Changes</button></div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div th:replace="~{fragments/footer :: 'footer'}"></div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -2,7 +2,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
|
||||
|
||||
<head>
|
||||
<title>Marinesco - Login</title>
|
||||
<title>Marinesco</title>
|
||||
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
|
||||
<link rel="alternate icon" href="/favicon.png" type="image/png">
|
||||
<link rel="stylesheet" th:href="@{/styles/styles.css}" />
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
<br />
|
||||
<span class="validationError" th:if="${lastScanErrors} != ''" th:text="${lastScanErrors}"></span>
|
||||
</p>
|
||||
<a href="/settings/genres">Edit genre descriptions</a>
|
||||
</div>
|
||||
</div>
|
||||
<div th:replace="~{fragments/footer :: 'footer'}"></div>
|
||||
|
|
Loading…
Reference in a new issue