#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.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute; import ru.ulstu.extractor.repository.RepositoryRepository;
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;
@Controller @Controller
public class BaseIndexingController { public class BaseIndexingController {
private final GitRepositoryService gitRepositoryService; private final RepositoryRepository repositoryRepository;
public BaseIndexingController(GitRepositoryService gitRepositoryService) { public BaseIndexingController(RepositoryRepository repositoryRepository) {
this.gitRepositoryService = gitRepositoryService; this.repositoryRepository = repositoryRepository;
} }
@GetMapping("/indexRepo") @GetMapping("/indexRepo")
public String indexNewRepo(Model model) { public String indexNewRepo(Model model) {
model.addAttribute(new RepoForm()); model.addAttribute("repositories", repositoryRepository.findAll());
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());
return "indexRepo"; 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" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
layout:decorate="~{default}"> layout:decorate="~{default}">
<head> <head>
<title>Индексировать новый репозиторий</title> <title>Проиндексированные репозитории</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head> </head>
<div class="container" layout:fragment="content"> <div class="container" layout:fragment="content">
<form action="#" th:action="@{/indexRepo}" th:object="${indexRepoForm}" method="post">
<table class="table table-striped"> <table class="table table-striped">
<thead class="thead-dark"> <thead class="thead-dark">
<tr> <tr>
<th scope="col" style="width: 30%">Url</th> <th scope="col">Репозиторий</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr th:each="url: ${urls}"> <tr th:each="repo: ${repositories}">
<td th:text="${commit.url}"></td> <td><a th:href="@{'/details?repositoryId='+${repo.id}}" th:text="${repo.url}"></td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
</form>
</div> </div>
</html> </html>