From 8134d85a1607447d800997f3f85268042d945558 Mon Sep 17 00:00:00 2001 From: sfeutrie Date: Fri, 1 Mar 2019 00:20:18 +0100 Subject: [PATCH] Affichage des des valeurs des capteurs --- PFE06/src/main/java/com/PFE/ServerManager/MainController.java | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- PFE06/src/main/resources/static/js/update.js | 12 ++++++++++++ PFE06/src/main/resources/templates/all.html | 12 +++++++----- PFE06/src/main/resources/templates/history.html | 12 +++++++----- PFE06/src/main/resources/templates/home.html | 12 +++++++----- PFE06/src/main/resources/templates/registration.html | 12 +++++++----- PFE06/src/main/resources/templates/result.html | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ PFE06/src/main/resources/templates/update.html | 12 +++++++----- PFE06/src/main/resources/templates/upload.html | 12 +++++++----- 9 files changed, 183 insertions(+), 31 deletions(-) create mode 100644 PFE06/src/main/resources/templates/result.html diff --git a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java index c301729..fdf0689 100644 --- a/PFE06/src/main/java/com/PFE/ServerManager/MainController.java +++ b/PFE06/src/main/java/com/PFE/ServerManager/MainController.java @@ -1,6 +1,5 @@ package com.PFE.ServerManager; -import org.omg.CORBA.SystemException; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; import org.springframework.http.HttpStatus; @@ -25,6 +24,7 @@ import org.springframework.security.core.Authentication; import org.yaml.snakeyaml.Yaml; import org.yaml.snakeyaml.constructor.Constructor; +import javax.persistence.EntityNotFoundException; import javax.servlet.annotation.MultipartConfig; import com.fasterxml.jackson.databind.ObjectMapper; @@ -451,4 +451,70 @@ public class MainController { return new ResponseEntity(HttpStatus.OK); } + @GetMapping(path="/result") + public ModelAndView displayResults() { + ModelAndView modelAndView = new ModelAndView(); + modelAndView.setViewName("result"); + Authentication auth = SecurityContextHolder.getContext().getAuthentication(); + Customer customer = customerRepository.findByEmail(auth.getName()); + modelAndView.addObject("customerName", customer.getEmail().split("@")[0]); + modelAndView.addObject("customerRole", customer.getRole()); + + List> files = new ArrayList<>(); + File dir = new File("results"); + if(dir.isDirectory()){ + List experiments = Arrays.asList(dir.list()); + for(String experiment : experiments) { + //System.out.println(experiment); + File experimentDir = new File("results/" + experiment+"/"); + if(experimentDir.isDirectory()) { + List raspberrys = Arrays.asList(experimentDir.list()); + for (String raspberry : raspberrys) { + //System.out.println(raspberry); + File raspberryDir = new File("results/" + experiment + "/" + raspberry + "/"); + if(raspberryDir.isDirectory()) { + List results = Arrays.asList(raspberryDir.list()); + //System.out.println(results); + for (String result : results) { + //System.out.println(result); + String line = null; + FileReader fileReader = null; + try { + fileReader = new FileReader("results/" + experiment + "/" + raspberry + "/" + result); + } catch (FileNotFoundException e) { + e.printStackTrace(); + } + BufferedReader bufferedReader = new BufferedReader(fileReader); + try { + List listString = new ArrayList<>(); + //System.out.println((result.split("_")[2]).split("\\.")[0]); + try { + listString.add((updateRepository.getOne(Integer.parseInt(experiment.split("_")[1]))).getUpdate()); + listString.add(result.split("_")[2].split("\\.")[0]); + String s = ""; + while ((line = bufferedReader.readLine()) != null) { + //System.out.println(line); + s+=line+"\n"; + } + listString.add(s); + files.add(listString); + } + catch(EntityNotFoundException e){ + e.printStackTrace(); + } + } catch (IOException ex) { + ex.printStackTrace(); + } + + } + } + } + } + } + } + modelAndView.addObject("files", files); + + return modelAndView; + } + } \ No newline at end of file diff --git a/PFE06/src/main/resources/static/js/update.js b/PFE06/src/main/resources/static/js/update.js index 4e64182..f1436fc 100644 --- a/PFE06/src/main/resources/static/js/update.js +++ b/PFE06/src/main/resources/static/js/update.js @@ -141,6 +141,14 @@ $(document).ready(function() { var majTime = document.getElementById("majTime").value; var majFile = document.getElementById("file_choice").value; + var majNameExisting = document.getElementById("maj_name").options; + var error = 0; + for(var i=0;i diff --git a/PFE06/src/main/resources/templates/history.html b/PFE06/src/main/resources/templates/history.html index a558996..a86925f 100644 --- a/PFE06/src/main/resources/templates/history.html +++ b/PFE06/src/main/resources/templates/history.html @@ -21,13 +21,15 @@ diff --git a/PFE06/src/main/resources/templates/home.html b/PFE06/src/main/resources/templates/home.html index adf02f7..83c90bc 100644 --- a/PFE06/src/main/resources/templates/home.html +++ b/PFE06/src/main/resources/templates/home.html @@ -26,13 +26,15 @@ diff --git a/PFE06/src/main/resources/templates/registration.html b/PFE06/src/main/resources/templates/registration.html index 2e43b80..2667903 100644 --- a/PFE06/src/main/resources/templates/registration.html +++ b/PFE06/src/main/resources/templates/registration.html @@ -20,13 +20,15 @@ diff --git a/PFE06/src/main/resources/templates/result.html b/PFE06/src/main/resources/templates/result.html new file mode 100644 index 0000000..0c8db75 --- /dev/null +++ b/PFE06/src/main/resources/templates/result.html @@ -0,0 +1,62 @@ + + + + + + + + Listes des utilisateurs dans la base de données + + + + + + + +
+

Résultats des expérimentations

+ +
+
+

+ +
+
+
+ + + + + + diff --git a/PFE06/src/main/resources/templates/update.html b/PFE06/src/main/resources/templates/update.html index 1a74470..ff0d7e1 100644 --- a/PFE06/src/main/resources/templates/update.html +++ b/PFE06/src/main/resources/templates/update.html @@ -26,13 +26,15 @@
diff --git a/PFE06/src/main/resources/templates/upload.html b/PFE06/src/main/resources/templates/upload.html index 6f7a55e..59f3c4d 100644 --- a/PFE06/src/main/resources/templates/upload.html +++ b/PFE06/src/main/resources/templates/upload.html @@ -26,13 +26,15 @@
-- libgit2 0.21.2