Skip to content
Snippets Groups Projects
Commit 5f42eed2 authored by CachoobiDoobi's avatar CachoobiDoobi
Browse files

fix setup

parent 0edcc5df
No related branches found
No related tags found
1 merge request!4Resolve "Move functionality from frontend to backend"
Pipeline #952450 failed
package server.controller;
import io.sentry.Sentry;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
......@@ -25,10 +15,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import server.csvconverter.CSVService;
import server.entity.Account;
import server.entity.StudentGroup;
import server.model.SetUpRequestDTO;
@Controller
......@@ -56,23 +43,24 @@ public class SetUpController {
}
/**
* API endpoint that receives a file and extracts its content.
* dynamically
* API endpoint that receives a file and extracts its content. dynamically
*
* @return - redirect link to the upload page
*/
@PostMapping("/groups/saveCSV")
public ModelAndView uploadFile(@RequestParam("file") MultipartFile file, @RequestParam("spIndex") Integer spIndex, Model model) throws IOException {
public ModelAndView uploadFile(@RequestParam("file") MultipartFile file,
@RequestParam("spIndex") Integer spIndex, @ModelAttribute SetUpRequestDTO dto, Model model)
throws IOException {
String fileContent = new String(file.getBytes(), StandardCharsets.UTF_8);
SetUpRequestDTO setUpRequestDTO = (SetUpRequestDTO) model.getAttribute("setUpRequestDTO");
setUpRequestDTO.setFileContent(fileContent);
setUpRequestDTO.setSpIndex(spIndex);
// SetUpRequestDTO setUpRequestDTO = (SetUpRequestDTO) model.getAttribute("setUpRequestDTO");
dto.setFileContent(fileContent);
dto.setSpIndex(spIndex);
ModelAndView modelAndViewTAs = new ModelAndView("setUpTAs");
modelAndViewTAs.addObject(setUpRequestDTO);
modelAndViewTAs.addObject(dto);
//TODO move functionality to setupgroups from gitlab controller to a service and link it here
//TODO create TA page and fucntionality
return modelAndViewTAs;
}
}
......@@ -15,7 +15,7 @@
<h2>Groups</h2>
<form method="post" th:action="@{/setUp/saveCSV}" enctype="multipart/form-data">
<form method="post" th:action="@{/setUp/groups/saveCSV}" enctype="multipart/form-data">
<div>Upload CSV</div>
<input type="file" name="file" th:name="file">
<div>Which column contains the groups?</div>
......
......
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" layout:decorate="~{layout}">
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="../css/main.css">
<title>Set Up</title>
</head>
<body>
<div>
oogaa booga
</div>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment