Merge branch '15-bootstrap' into 'master'
Resolve "Пофиксить bootstrap интерфейс" Closes #15 See merge request romanov73/git-extractor!10merge-requests/11/merge
commit
0e371723c0
@ -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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue