Resolve "Создать новые html страницы" #41

Merged
BarminaA merged 1 commits from 17-create-new-html into master 2021-03-31 13:36:42 +04:00
3 changed files with 56 additions and 0 deletions
Showing only changes of commit bbdfb91b1d - Show all commits

View File

@ -0,0 +1,28 @@
package ru.ulstu.extractor.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import ru.ulstu.extractor.repository.BranchRepository;
import ru.ulstu.extractor.repository.RepositoryRepository;
@Controller
public class BranchController {
private final RepositoryRepository repositoryRepository;
private final BranchRepository branchRepository;
public BranchController(RepositoryRepository repositoryRepository, BranchRepository branchRepository) {
this.repositoryRepository = repositoryRepository;
this.branchRepository = branchRepository;
}
@GetMapping("/details")
public String indexBranch(
Model model,
@RequestParam int repositoryId) {
model.addAttribute("branches", branchRepository.findByRepositoryId(repositoryId));
model.addAttribute("repository", repositoryRepository.findById(repositoryId).get());
return "indexBranch";
}
}

View File

@ -4,6 +4,10 @@ import org.springframework.data.jpa.repository.JpaRepository;
import ru.ulstu.extractor.model.Branch; import ru.ulstu.extractor.model.Branch;
import ru.ulstu.extractor.model.Repository; import ru.ulstu.extractor.model.Repository;
import java.util.List;
public interface BranchRepository extends JpaRepository<Branch, Integer> { public interface BranchRepository extends JpaRepository<Branch, Integer> {
Branch findByRepositoryAndName(Repository repository, String name); Branch findByRepositoryAndName(Repository repository, String name);
List<Branch> findByRepositoryId(Integer repositoryId);
} }

View File

@ -0,0 +1,24 @@
<!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>Проиндексированные репозитории</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<div class="container" layout:fragment="content">
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th scope="col">Ветки</th>
</tr>
</thead>
<tbody>
<tr th:each="branch: ${branches}">
<td><a th:href="@{'/filtering?branchName='+${branch.name}+'&repositoryUrl='+${repository.url}}"
th:text="${branch.name}"/></td>
</tr>
</tbody>
</table>
</div>
</html>