#2 - change filtering

This commit is contained in:
Anton Romanov 2021-03-18 11:08:56 +04:00
parent 62db77c82e
commit 3de5950389
5 changed files with 55 additions and 15 deletions

View File

@ -5,6 +5,7 @@ import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import ru.ulstu.extractor.mvc.model.FilterForm;
import ru.ulstu.extractor.mvc.model.RepoForm;
@Controller
@ -16,12 +17,28 @@ public class GitExtractorController {
return "newRepo";
}
@GetMapping("/filtering")
public String filter(Model model) {
model.addAttribute("filterForm", new FilterForm());
return "filtering";
}
@PostMapping("/sendRepo")
public String sendRepo(@ModelAttribute RepoForm repoForm, Model model) {
model.addAttribute("filterForm", new FilterForm());
if (repoForm.getRepo() == null || repoForm.getRepo().isEmpty()) {
model.addAttribute("error", "'Git' не должно быть пустым");
return "newRepo";
}
return "filtering";
}
@PostMapping("/sendFilter")
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) {
if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) {
model.addAttribute("error", "'Строка' не должно быть пустым");
return "filtering";
}
return "resultRepo";
}
}

View File

@ -0,0 +1,20 @@
package ru.ulstu.extractor.mvc.model;
public class FilterForm {
private String filter;
public String getFilter() {
return filter;
}
public void setFilter(String filter) {
this.filter = filter;
}
@Override
public String toString() {
return "FilterForm{" +
"subject='" + filter +
'}';
}
}

View File

@ -13,7 +13,7 @@ public class RepoForm {
@Override
public String toString() {
return "EmailForm{" +
return "RepoForm{" +
"subject='" + repo +
'}';
}

View File

@ -32,14 +32,16 @@
</a>
</p>
<div class="collapse" id="collapseExample">
<div class="card card-body">
<p class="card card-body">
<div th:utext="'Failed URL: ' + ${url}" th:remove="tag">${url}</div>
<p th:if="${exception}">
<div th:utext="'Exception: ' + ${exception.message}" th:remove="tag">${exception.message}</div>
</p>
<ul th:remove="tag">
<li th:each="ste : ${exception.stackTrace}" th:remove="tag"><span
th:utext="${ste}" th:remove="tag">${ste}</span></li>
</ul>
</div>
</div>
</div>
</div>
</html>

View File

@ -1,5 +1,5 @@
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
<html
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}">
<head>
@ -8,7 +8,7 @@
</head>
<div class="container" layout:fragment="content">
<body>
<form name="filtering">
<form action="#" th:action="@{/sendFilter}" th:object="${filterForm}" method="post">
<p><b>Фильтровать данные:</b><Br></p>
По автору
<select class="selectpicker" data-live-search="true">
@ -26,10 +26,11 @@
<option data-tokens="age">год</option>
</select>
<p>Строки:<br>
<input type="text" size="40">
<input type="text" size="40" th:field="*{filter}">
</p>
<p style="color:red" th:text="${error}"></p>
<p>
<input type="button" value="Отправить" onClick='location.href="result.html"'>
<input type="submit" value="Отправить"/>
</p>
</form>
</body>