#15 -- Fix filtering table
This commit is contained in:
parent
11f3b93b9d
commit
4b56058835
@ -5,17 +5,13 @@ import org.springframework.data.domain.Page;
|
|||||||
import org.springframework.data.domain.PageRequest;
|
import org.springframework.data.domain.PageRequest;
|
||||||
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.ModelAttribute;
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
||||||
import ru.ulstu.extractor.model.Branch;
|
|
||||||
import ru.ulstu.extractor.model.Commit;
|
import ru.ulstu.extractor.model.Commit;
|
||||||
import ru.ulstu.extractor.mvc.model.FilterForm;
|
import ru.ulstu.extractor.mvc.model.FilterForm;
|
||||||
import ru.ulstu.extractor.mvc.model.RepoForm;
|
|
||||||
import ru.ulstu.extractor.service.CommitService;
|
import ru.ulstu.extractor.service.CommitService;
|
||||||
import ru.ulstu.extractor.service.FilteringService;
|
import ru.ulstu.extractor.service.FilteringService;
|
||||||
import ru.ulstu.extractor.service.GitRepositoryService;
|
import ru.ulstu.extractor.service.GitRepositoryService;
|
||||||
@ -27,12 +23,12 @@ import java.util.stream.Collectors;
|
|||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class GitExtractorController {
|
public class GitFilteringController {
|
||||||
private final FilteringService filteringService;
|
private final FilteringService filteringService;
|
||||||
private final GitRepositoryService gitRepositoryService;
|
private final GitRepositoryService gitRepositoryService;
|
||||||
private final CommitService commitService;
|
private final CommitService commitService;
|
||||||
|
|
||||||
public GitExtractorController(FilteringService filteringService,
|
public GitFilteringController(FilteringService filteringService,
|
||||||
GitRepositoryService gitRepositoryService,
|
GitRepositoryService gitRepositoryService,
|
||||||
CommitService commitService) {
|
CommitService commitService) {
|
||||||
this.filteringService = filteringService;
|
this.filteringService = filteringService;
|
||||||
@ -40,12 +36,6 @@ public class GitExtractorController {
|
|||||||
this.commitService = commitService;
|
this.commitService = commitService;
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/newRepo")
|
|
||||||
public String indexNewRepo(Model model) {
|
|
||||||
model.addAttribute("repoForm", new RepoForm());
|
|
||||||
return "newRepo";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/sendFilter")
|
@PostMapping("/sendFilter")
|
||||||
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) throws GitAPIException, IOException {
|
public String sendFilter(@ModelAttribute FilterForm filterForm, Model model) throws GitAPIException, IOException {
|
||||||
List<Commit> list = gitRepositoryService.getCommits(filterForm.getUrl());
|
List<Commit> list = gitRepositoryService.getCommits(filterForm.getUrl());
|
||||||
@ -57,31 +47,6 @@ public class GitExtractorController {
|
|||||||
return "resultRepo";
|
return "resultRepo";
|
||||||
}
|
}
|
||||||
|
|
||||||
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "send")
|
|
||||||
public String getBranch(@ModelAttribute RepoForm repoForm, Model model) {
|
|
||||||
try {
|
|
||||||
gitRepositoryService.cloneOrUpdateRepo(repoForm.getRepo());
|
|
||||||
List<Branch> list = gitRepositoryService.getBranches(repoForm.getRepo());
|
|
||||||
model.addAttribute("branches", list);
|
|
||||||
return "newRepo";
|
|
||||||
} catch (Exception ex) {
|
|
||||||
model.addAttribute("error", ex.getMessage());
|
|
||||||
return "newRepo";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "next")
|
|
||||||
public String setBranch(@ModelAttribute RepoForm repoForm, Model model, RedirectAttributes redirectAttributes) {
|
|
||||||
model.addAttribute("filterForm", new FilterForm(repoForm.getRepo()));
|
|
||||||
if (repoForm.getBranch() == null) {
|
|
||||||
return "newRepo";
|
|
||||||
} else {
|
|
||||||
redirectAttributes.addAttribute("url", repoForm.getRepo());
|
|
||||||
redirectAttributes.addAttribute("branch", repoForm.getBranch());
|
|
||||||
return "redirect:/filtering";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@RequestMapping(value = "/filtering", method = RequestMethod.GET)
|
@RequestMapping(value = "/filtering", method = RequestMethod.GET)
|
||||||
public String listCommits(
|
public String listCommits(
|
||||||
Model model,
|
Model model,
|
@ -0,0 +1,55 @@
|
|||||||
|
package ru.ulstu.extractor.mvc;
|
||||||
|
|
||||||
|
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 org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
||||||
|
import ru.ulstu.extractor.model.Branch;
|
||||||
|
import ru.ulstu.extractor.mvc.model.FilterForm;
|
||||||
|
import ru.ulstu.extractor.mvc.model.RepoForm;
|
||||||
|
import ru.ulstu.extractor.service.GitRepositoryService;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class GitIndexingController {
|
||||||
|
private final GitRepositoryService gitRepositoryService;
|
||||||
|
|
||||||
|
public GitIndexingController(GitRepositoryService gitRepositoryService) {
|
||||||
|
this.gitRepositoryService = gitRepositoryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/newRepo")
|
||||||
|
public String indexNewRepo(Model model) {
|
||||||
|
model.addAttribute(new RepoForm());
|
||||||
|
return "newRepo";
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "send")
|
||||||
|
public String getBranch(@ModelAttribute RepoForm repoForm, Model model) {
|
||||||
|
try {
|
||||||
|
gitRepositoryService.cloneOrUpdateRepo(repoForm.getRepo());
|
||||||
|
List<Branch> branches = gitRepositoryService.getBranches(repoForm.getRepo());
|
||||||
|
model.addAttribute("branches", branches);
|
||||||
|
return "newRepo";
|
||||||
|
} catch (Exception ex) {
|
||||||
|
model.addAttribute("error", ex.getMessage());
|
||||||
|
return "newRepo";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value = "/newRepo", method = RequestMethod.POST, params = "next")
|
||||||
|
public String setBranch(@ModelAttribute RepoForm repoForm, Model model, RedirectAttributes redirectAttributes) {
|
||||||
|
model.addAttribute("filterForm", new FilterForm(repoForm.getRepo()));
|
||||||
|
if (repoForm.getBranch() == null) {
|
||||||
|
return "newRepo";
|
||||||
|
} else {
|
||||||
|
redirectAttributes.addAttribute("url", repoForm.getRepo());
|
||||||
|
redirectAttributes.addAttribute("branch", repoForm.getBranch());
|
||||||
|
return "redirect:/filtering";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -25,7 +25,6 @@ public class CommitService {
|
|||||||
int currentPage = pageable.getPageNumber();
|
int currentPage = pageable.getPageNumber();
|
||||||
int startItem = currentPage * pageSize;
|
int startItem = currentPage * pageSize;
|
||||||
List<Commit> commits = gitRepositoryService.getCommits(url);
|
List<Commit> commits = gitRepositoryService.getCommits(url);
|
||||||
;
|
|
||||||
|
|
||||||
if (commits.size() < startItem) {
|
if (commits.size() < startItem) {
|
||||||
commits = Collections.emptyList();
|
commits = Collections.emptyList();
|
||||||
|
@ -29,12 +29,12 @@
|
|||||||
<input type="hidden" th:field="*{url}">
|
<input type="hidden" th:field="*{url}">
|
||||||
</p>
|
</p>
|
||||||
<p style="color:red" th:text="${error}"></p>
|
<p style="color:red" th:text="${error}"></p>
|
||||||
<table border="1">
|
<table class="table table-striped">
|
||||||
<thead>
|
<thead class="thead-dark">
|
||||||
<tr>
|
<tr>
|
||||||
<th>Author</th>
|
<th scope="col">Author</th>
|
||||||
<th>Date</th>
|
<th scope="col" style="width: 30%">Date</th>
|
||||||
<th>Commit</th>
|
<th scope="col">Commit</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
Loading…
Reference in New Issue
Block a user