#17 - Show indexed repositories

merge-requests/12/head
Anton Romanov 3 years ago
parent d2f67a8a75
commit ec209e8fe8

@ -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"; 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";
}
}
} }

@ -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 + '\'' +
'}';
}
}

@ -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">Репозиторий</th>
<th scope="col" style="width: 30%">Url</th> </tr>
</tr> </thead>
</thead> <tbody>
<tbody> <tr th:each="repo: ${repositories}">
<tr th:each="url: ${urls}"> <td><a th:href="@{'/details?repositoryId='+${repo.id}}" th:text="${repo.url}"></td>
<td th:text="${commit.url}"></td> </tr>
</tr> </tbody>
</tbody> </table>
</table>
</form>
</div> </div>
</html> </html>

Loading…
Cancel
Save