#17 - Show indexed repositories

This commit is contained in:
Anton Romanov 2021-03-29 17:21:42 +04:00
parent d2f67a8a75
commit ec209e8fe8
3 changed files with 18 additions and 55 deletions

View File

@ -3,34 +3,19 @@ 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.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import ru.ulstu.extractor.model.mvc.IndexRepoForm;
import ru.ulstu.extractor.model.mvc.RepoForm;
import ru.ulstu.extractor.service.GitRepositoryService;
import ru.ulstu.extractor.repository.RepositoryRepository;
@Controller
public class BaseIndexingController {
private final GitRepositoryService gitRepositoryService;
private final RepositoryRepository repositoryRepository;
public BaseIndexingController(GitRepositoryService gitRepositoryService) {
this.gitRepositoryService = gitRepositoryService;
public BaseIndexingController(RepositoryRepository repositoryRepository) {
this.repositoryRepository = repositoryRepository;
}
@GetMapping("/indexRepo")
public String indexNewRepo(Model model) {
model.addAttribute(new RepoForm());
return "indexRepo";
}
@RequestMapping(value = "/indexRepo", method = RequestMethod.POST, params = "send")
public String getBranch(@ModelAttribute IndexRepoForm indexRepoForm, Model model) {
try {
return "indexRepo";
} catch (Exception ex) {
model.addAttribute("error", ex.getMessage());
model.addAttribute("repositories", repositoryRepository.findAll());
return "indexRepo";
}
}
}

View File

@ -1,20 +0,0 @@
package ru.ulstu.extractor.model.mvc;
public class IndexRepoForm {
private String repo;
public String getRepo() {
return repo;
}
public void setRepo(String repo) {
this.repo = repo;
}
@Override
public String toString() {
return "IndexRepoForm{" +
"repo='" + repo + '\'' +
'}';
}
}

View File

@ -3,23 +3,21 @@
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}">
<head>
<title>Индексировать новый репозиторий</title>
<title>Проиндексированные репозитории</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<div class="container" layout:fragment="content">
<form action="#" th:action="@{/indexRepo}" th:object="${indexRepoForm}" method="post">
<table class="table table-striped">
<thead class="thead-dark">
<tr>
<th scope="col" style="width: 30%">Url</th>
<th scope="col">Репозиторий</th>
</tr>
</thead>
<tbody>
<tr th:each="url: ${urls}">
<td th:text="${commit.url}"></td>
<tr th:each="repo: ${repositories}">
<td><a th:href="@{'/details?repositoryId='+${repo.id}}" th:text="${repo.url}"></td>
</tr>
</tbody>
</table>
</form>
</div>
</html>