Merge branch 'master' into 18-statistics-page
commit
26942c6e88
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.controller;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class Route {
|
||||
public static final String LIST_INDEXED_REPOSITORIES = "listRepositories";
|
||||
public static final String LIST_REPOSITORY_BRANCHES = "listBranches";
|
||||
public static final String INDEXING_NEW_REPOSITORY = "indexNewRepository";
|
||||
public static final String FILTER_COMMITS = "filterCommits";
|
||||
|
||||
public static String getLIST_INDEXED_REPOSITORIES() {
|
||||
return LIST_INDEXED_REPOSITORIES;
|
||||
}
|
||||
|
||||
public static String getLIST_REPOSITORY_BRANCHES() {
|
||||
return LIST_REPOSITORY_BRANCHES;
|
||||
}
|
||||
|
||||
public static String getINDEXING_NEW_REPOSITORY() {
|
||||
return INDEXING_NEW_REPOSITORY;
|
||||
}
|
||||
|
||||
public static String getFILTER_COMMITS() {
|
||||
return FILTER_COMMITS;
|
||||
}
|
||||
}
|
@ -1,13 +1,61 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
* You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
*/
|
||||
|
||||
package ru.ulstu.extractor.service;
|
||||
|
||||
import com.sun.istack.NotNull;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.stereotype.Service;
|
||||
import ru.ulstu.extractor.model.Commit;
|
||||
import ru.ulstu.extractor.repository.AuthorRepository;
|
||||
import ru.ulstu.extractor.repository.CommitRepository;
|
||||
import ru.ulstu.extractor.repository.RepositoryRepository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class FilteringService {
|
||||
private final AuthorRepository authorRepository;
|
||||
private final CommitRepository commitRepository;
|
||||
private final RepositoryRepository repositoryRepository;
|
||||
|
||||
public FilteringService(AuthorRepository authorRepository,
|
||||
CommitRepository commitRepository,
|
||||
RepositoryRepository repositoryRepository) {
|
||||
this.authorRepository = authorRepository;
|
||||
this.commitRepository = commitRepository;
|
||||
this.repositoryRepository = repositoryRepository;
|
||||
}
|
||||
|
||||
private final IndexService indexService;
|
||||
public List<String> getRepositoryAuthors(@NotNull String repositoryUrl,
|
||||
@NotNull String branchName) {
|
||||
return authorRepository.findByRepositoryAndBranch(
|
||||
repositoryRepository.findByUrl(repositoryUrl),
|
||||
branchName
|
||||
);
|
||||
}
|
||||
|
||||
public Page<Commit> getCommits(@NotNull String repositoryUrl,
|
||||
@NotNull String branchName,
|
||||
Pageable pageable) {
|
||||
return commitRepository.findByRepositoryAndBranch(
|
||||
pageable,
|
||||
repositoryRepository.findByUrl(repositoryUrl),
|
||||
branchName
|
||||
);
|
||||
}
|
||||
|
||||
public FilteringService(IndexService indexService) {
|
||||
this.indexService = indexService;
|
||||
/* @PostMapping("/sendFilter")
|
||||
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) throws GitAPIException, IOException {
|
||||
List<Commit> list = gitRepositoryService.getCommits(filterForm.getUrl(), filterForm.getBranch());
|
||||
model.addAttribute("commits", list);
|
||||
if (filterForm.getFilter() == null || filterForm.getFilter().isEmpty()) {
|
||||
model.addAttribute("error", "'Строка' не должно быть пустым");
|
||||
return "filtering";
|
||||
}
|
||||
return "resultRepo";
|
||||
}*/
|
||||
}
|
||||
|
@ -0,0 +1,105 @@
|
||||
<!--
|
||||
~ Copyright (C) 2021 Anton Romanov - All Rights Reserved
|
||||
~ You may use, distribute and modify this code, please write to: romanov73@gmail.com.
|
||||
-->
|
||||
|
||||
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<div class="container" layout:fragment="content">
|
||||
<style>
|
||||
.pagination {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.pagination a {
|
||||
color: black;
|
||||
float: left;
|
||||
padding: 5px 5px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.pagination a.active {
|
||||
background-color: gray;
|
||||
color: white;
|
||||
border-radius: 2px;
|
||||
}
|
||||
</style>
|
||||
<form action="#" th:action="${@route.FILTER_COMMITS}" th:object="${filterForm}" method="post">
|
||||
<div class="row">
|
||||
<div class="col-md-1 col-sm-12">
|
||||
Автор
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-12">
|
||||
<select id="select-author" class="selectpicker" data-live-search="true" th:field="*{author}"
|
||||
data-width="90%">
|
||||
<option th:each="author : ${authors}"
|
||||
th:value="${author}"
|
||||
th:utext="${author}">
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-1 col-sm-12">
|
||||
Дата:
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-12">
|
||||
<select class="selectpicker" data-live-search="true">
|
||||
<option data-tokens="day">день</option>
|
||||
<option data-tokens="month">месяц</option>
|
||||
<option data-tokens="age">год</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-1 col-sm-12">
|
||||
-
|
||||
</div>
|
||||
<div class="col-md-3 col-sm-12">
|
||||
<select class="selectpicker" data-live-search="true">
|
||||
<option data-tokens="day">день</option>
|
||||
<option data-tokens="month">месяц</option>
|
||||
<option data-tokens="age">год</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md-2 col-sm-12">
|
||||
Искать по тексту:
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<input type="text" class="form-control" size="40" th:field="*{filter}">
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-12">
|
||||
<input type="submit" class="btn btn-outline-success w-100" value="Применить фильтр"/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" th:field="*{url}">
|
||||
<table class="table table-striped">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th scope="col">Автор</th>
|
||||
<th scope="col" style="width: 30%">Дата</th>
|
||||
<th scope="col">Сообщение</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="commit: ${filterForm.commitsPage.content}">
|
||||
<td th:text="${commit.author.name}"></td>
|
||||
<td th:text="${commit.date}"></td>
|
||||
<td th:text="${commit.message}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
|
||||
</p>
|
||||
</form>
|
||||
Страницы:
|
||||
<div th:if="${filterForm.commitsPage.totalPages > 0}" class="pagination"
|
||||
th:each="pageNumber : ${pageNumbers}">
|
||||
<a th:href="@{/filterCommits(size=${filterForm.commitsPage.size}, page=${pageNumber}, repositoryUrl=${filterForm.url}, branchName=${filterForm.branch})}"
|
||||
th:text=${pageNumber}
|
||||
th:class="${pageNumber == filterForm.commitsPage.number} ? active"></a>
|
||||
</div>
|
||||
</div>
|
||||
</html>
|
@ -1,32 +0,0 @@
|
||||
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
|
||||
<html xmlns:th="http://www.thymeleaf.org"
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
<title>Простая обработка формы на Spring MVC</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<div class="container" layout:fragment="content">
|
||||
<h1>Форма</h1>
|
||||
<form action="#" th:action="@{/sendEmail}" th:object="${emailForm}" method="post">
|
||||
<p style="color:red" th:text="${error}"></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Тема:</td>
|
||||
<td><input type="text" th:field="*{subject}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Кому:</td>
|
||||
<td><input type="text" th:field="*{to}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Сообщение:</td>
|
||||
<td><textarea th:field="*{message}"/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><input type="submit" value="Отправить"/></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</div>
|
||||
</html>
|
@ -1,18 +0,0 @@
|
||||
<!DOCTYPE html SYSTEM "http://www.thymeleaf.org/dtd/xhtml1-strict-thymeleaf-spring4-4.dtd">
|
||||
<html
|
||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
||||
layout:decorate="~{default}">
|
||||
<head>
|
||||
<title>Простая обработка формы на Spring MVC</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
|
||||
</head>
|
||||
<div class="container" layout:fragment="content">
|
||||
<body>
|
||||
<form oninput="result">
|
||||
<p>Данные репозитория:</p>
|
||||
<p>
|
||||
<output name="result"></output>
|
||||
</form>
|
||||
</body>
|
||||
</div>
|
||||
</html>
|
Loading…
Reference in New Issue