Commit deabfae99b6cbd65447f3364a1882c61781e89cd

Authored by sfeutrie
1 parent 072e7fc2

ajout d'une classe qui contiendra les paramètres d'une mise à jour si l'utilisat…

…eur souhaite la stocker
PFE06/src/main/java/com/PFE/ServerManager/MainController.java
@@ -46,6 +46,17 @@ public class MainController { @@ -46,6 +46,17 @@ public class MainController {
46 return modelAndView; 46 return modelAndView;
47 } 47 }
48 48
  49 + @GetMapping(value="/session")
  50 + public ModelAndView session() {
  51 + ModelAndView modelAndView = new ModelAndView();
  52 + Authentication auth = SecurityContextHolder.getContext().getAuthentication();
  53 + Customer customer = customerRepository.findByEmail(auth.getName());
  54 + modelAndView.addObject("customerName", customer.getEmail().split("@")[0]);
  55 + modelAndView.addObject("customerRole", customer.getRole());
  56 + modelAndView.setViewName("session");
  57 + return modelAndView;
  58 + }
  59 +
49 @GetMapping(path="/registration") 60 @GetMapping(path="/registration")
50 public ModelAndView registration() { 61 public ModelAndView registration() {
51 ModelAndView modelAndView = new ModelAndView(); 62 ModelAndView modelAndView = new ModelAndView();
@@ -175,4 +186,16 @@ public class MainController { @@ -175,4 +186,16 @@ public class MainController {
175 public String success(){ 186 public String success(){
176 return "success"; 187 return "success";
177 } 188 }
  189 +
  190 + @GetMapping(path="/test")
  191 + public String testGet() {
  192 + return "test";
  193 + }
  194 +
  195 + @PostMapping(path="/test")
  196 + public String test() {
  197 + //ModelAndView modelAndView = new ModelAndView();
  198 + //modelAndView.setViewName("test");
  199 + return "test";
  200 + }
178 } 201 }
179 \ No newline at end of file 202 \ No newline at end of file
PFE06/src/main/java/com/PFE/ServerManager/Maj.java 0 → 100644
@@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
  1 +package com.PFE.ServerManager;
  2 +
  3 +import javax.persistence.*;
  4 +
  5 +@Entity
  6 +@Table(name = "maj")
  7 +public class Maj {
  8 + @Id
  9 + @Column(name = "maj_id", columnDefinition = "serial")
  10 + @GeneratedValue(strategy = GenerationType.AUTO)
  11 + private Integer maj_id;
  12 +
  13 + @Column(name = "maj")
  14 + private String maj;
  15 +
  16 + @Column(name = "date")
  17 + private String date;
  18 +
  19 + @Column(name = "nodes")
  20 + private String nodes;
  21 +
  22 + @Column(name = "file")
  23 + private String file;
  24 +
  25 + public void setMaj_id(Integer maj_id) { this.maj_id = maj_id; }
  26 + public Integer getMaj_id() { return maj_id; }
  27 +
  28 + public void setMaj(String maj) {
  29 + this.maj = maj;
  30 + }
  31 + public String getMaj() { return maj; }
  32 +
  33 +
  34 +
  35 +}
PFE06/src/main/resources/application.properties
@@ -8,9 +8,9 @@ spring.jpa.hibernate.ddl-auto=create @@ -8,9 +8,9 @@ spring.jpa.hibernate.ddl-auto=create
8 #"update" met à jour la base données 8 #"update" met à jour la base données
9 9
10 #Postgres config : 10 #Postgres config :
11 -spring.datasource.url=jdbc:postgresql://localhost:3306/sql_only 11 +spring.datasource.url=jdbc:postgresql://localhost:5432/sql_only
12 spring.datasource.username=postgres 12 spring.datasource.username=postgres
13 -spring.datasource.password=admin 13 +spring.datasource.password=idalurf123
14 14
15 15
16 # montre les communications JPA avec la BDD 16 # montre les communications JPA avec la BDD
PFE06/src/main/resources/static/js/home.js
@@ -21,6 +21,17 @@ $(document).ready(function() { @@ -21,6 +21,17 @@ $(document).ready(function() {
21 nodeSet.delete(rowData[0]); 21 nodeSet.delete(rowData[0]);
22 } ); 22 } );
23 23
  24 + document.getElementById("save_maj").addEventListener('click', function() {
  25 + var req = new XMLHttpRequest();
  26 + req.open('POST','/test',true);
  27 + req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  28 + req.onreadystatechange = function() {//Call a function when the state changes.
  29 + if(req.readyState == 4 && req.status == 200) {
  30 + alert(req.responseText);
  31 + }
  32 + }
  33 + req.send("salut");
  34 + });
24 /********** Drop Zone **********/ 35 /********** Drop Zone **********/
25 36
26 var formData = new FormData(); 37 var formData = new FormData();
PFE06/src/main/resources/templates/home.html
@@ -33,8 +33,11 @@ @@ -33,8 +33,11 @@
33 <div th:case="'ADMIN'"> 33 <div th:case="'ADMIN'">
34 <a class="dropdown-item" th:href="@{/registration}">Enregistrer des utilisateurs</a> 34 <a class="dropdown-item" th:href="@{/registration}">Enregistrer des utilisateurs</a>
35 <a class="dropdown-item" th:href="@{/all}">Listes des utilisateurs</a> 35 <a class="dropdown-item" th:href="@{/all}">Listes des utilisateurs</a>
  36 + <a class="dropdown-item" th:href="@{/session}">Paramétrer une mise à jour</a>
  37 + </div>
  38 + <div th:case="'USER'">
  39 + <a class="dropdown-item" th:href="@{/session}">Paramétrer une mise à jour</a>
36 </div> 40 </div>
37 - <div th:case="'USER'"></div>  
38 </div> 41 </div>
39 <a class="dropdown-item" href="#">A ajouter...</a> 42 <a class="dropdown-item" href="#">A ajouter...</a>
40 </div> 43 </div>
@@ -45,113 +48,6 @@ @@ -45,113 +48,6 @@
45 </nav> 48 </nav>
46 49
47 <div class="container" style="padding-bottom: 50px;"> 50 <div class="container" style="padding-bottom: 50px;">
48 - <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;">Choix des noeuds</h1>  
49 - <table id="nodes-table" class="table table-striped table-bordered dt-responsive nowrap">  
50 - <thead>  
51 - <tr>  
52 - <th>Nom</th>  
53 - <th>IP</th>  
54 - <th>Architecture</th>  
55 - </tr>  
56 - </thead>  
57 - <tbody>  
58 - <tr>  
59 - <td>Nixon</td>  
60 - <td>System Architect</td>  
61 - <td>Edinburgh</td>  
62 - </tr>  
63 - <tr>  
64 - <td>Winters</td>  
65 - <td>Accountant</td>  
66 - <td>Tokyo</td>  
67 - </tr>  
68 - <tr>  
69 - <td>Cox</td>  
70 - <td>Junior Technical Author</td>  
71 - <td>San Francisco</td>  
72 - </tr>  
73 - <tr>  
74 - <td>Kelly</td>  
75 - <td>Senior Javascript Developer</td>  
76 - <td>Edinburgh</td>  
77 - </tr>  
78 - <tr>  
79 - <td>Satou</td>  
80 - <td>Accountant</td>  
81 - <td>Tokyo</td>  
82 - </tr>  
83 - <tr>  
84 - <td>Williamson</td>  
85 - <td>Integration Specialist</td>  
86 - <td>New York</td>  
87 - </tr>  
88 - <tr>  
89 - <td>Chandler</td>  
90 - <td>Sales Assistant</td>  
91 - <td>San Francisco</td>  
92 - </tr>  
93 - <tr>  
94 - <td>Davidson</td>  
95 - <td>Integration Specialist</td>  
96 - <td>Tokyo</td>  
97 - </tr>  
98 - <tr>  
99 - <td>Hurst</td>  
100 - <td>Javascript Developer</td>  
101 - <td>San Francisco</td>  
102 - </tr>  
103 - <tr>  
104 - <td>Frost</td>  
105 - <td>Software Engineer</td>  
106 - <td>Edinburgh</td>  
107 - </tr>  
108 - <tr>  
109 - <td>Gaines</td>  
110 - <td>Office Manager</td>  
111 - <td>London</td>  
112 - </tr>  
113 - <tr>  
114 - <td>Flynn</td>  
115 - <td>Support Lead</td>  
116 - <td>Edinburgh</td>  
117 - </tr>  
118 - <tr>  
119 - <td>Marshall</td>  
120 - <td>Regional Director</td>  
121 - <td>San Francisco</td>  
122 - </tr>  
123 - <tr>  
124 - <td>Kennedy</td>  
125 - <td>Senior Marketing Designer</td>  
126 - <td>London</td>  
127 - </tr>  
128 - <tr>  
129 - <td>Fitzpatrick</td>  
130 - <td>Regional Director</td>  
131 - <td>London</td>  
132 - </tr>  
133 - <tr>  
134 - <td>Silva</td>  
135 - <td>Marketing Designer</td>  
136 - <td>London</td>  
137 - </tr>  
138 - <tr>  
139 - <td>Byrd</td>  
140 - <td>Chief Financial Officer (CFO)</td>  
141 - <td>New York</td>  
142 - </tr>  
143 - <tr>  
144 - <td>Little</td>  
145 - <td>Systems Administrator</td>  
146 - <td>New York</td>  
147 - </tr>  
148 - <tr>  
149 - <td>Greer</td>  
150 - <td>Software Engineer</td>  
151 - <td>London</td>  
152 - </tr>  
153 - </tbody>  
154 - </table>  
155 <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;">Uploader un fichier</h1> 51 <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;">Uploader un fichier</h1>
156 <div class="panel panel-default"> 52 <div class="panel panel-default">
157 <h4>Choix du fichier</h4> 53 <h4>Choix du fichier</h4>
PFE06/src/main/resources/templates/session.html 0 → 100644
@@ -0,0 +1,180 @@ @@ -0,0 +1,180 @@
  1 +<!DOCTYPE html>
  2 +<html xmlns:th="http://www.thymeleaf.org">
  3 +<html lang="en">
  4 +<head>
  5 +
  6 + <meta charset="utf-8">
  7 + <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  8 + <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
  9 + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
  10 +
  11 + <link rel="stylesheet" href="https://cdn.datatables.net/1.10.19/css/dataTables.bootstrap4.min.css">
  12 + <link rel="stylesheet" href="https://cdn.datatables.net/select/1.2.7/css/select.dataTables.min.css">
  13 + <link rem="stylesheet" href="https://cdn.datatables.net/responsive/2.2.3/css/responsive.dataTables.min.css">
  14 + <link rel="stylesheet" th:href="@{/css/home.css}">
  15 + <title>Session</title>
  16 +</head>
  17 +
  18 +<body>
  19 +<div id="app">
  20 + <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  21 + <span class="navbar-brand"> ID : <span th:text="${customerName}" th:remove="tag">Documentations</span></span>
  22 + <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNavAltMarkup" aria-controls="navbarNavAltMarkup" aria-expanded="false" aria-label="Toggle navigation">
  23 + <span class="navbar-toggler-icon"></span>
  24 + </button>
  25 + <div class="collapse navbar-collapse" id="navbarNavAltMarkup">
  26 + <div class="navbar-nav">
  27 + <a class="nav-item nav-link active" th:href="@{/home}">Création d'une mise à jour <span class="sr-only">(current)</span></a>
  28 + <a class="nav-item nav-link" th:href="@{/logout}">Déconnexion</a>
  29 + <li class="nav-item dropdown">
  30 + <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> Options</a>
  31 + <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
  32 + <div th:switch="${customerRole}">
  33 + <div th:case="'ADMIN'">
  34 + <a class="dropdown-item" th:href="@{/registration}">Enregistrer des utilisateurs</a>
  35 + <a class="dropdown-item" th:href="@{/all}">Listes des utilisateurs</a>
  36 + <a class="dropdown-item" th:href="@{/home}">Ajouter un novueau fichier au serveur</a>
  37 + </div>
  38 + <div th:case="'USER'">
  39 + <a class="dropdown-item" th:href="@{/home}">Ajouter un novueau fichier au serveur</a>
  40 + </div>
  41 + </div>
  42 + <a class="dropdown-item" href="#">A ajouter...</a>
  43 + </div>
  44 + </li>
  45 + <a class="nav-item nav-link disabled" href="#">Documentations</a>
  46 + </div>
  47 + </div>
  48 + </nav>
  49 +
  50 + <div class="container" style="padding-bottom: 50px;">
  51 + <h1 style="margin-bottom:50px; margin-top:50px; border-bottom:1px solid #CCC; padding-bottom:20px;">Choix des noeuds</h1>
  52 + <table id="nodes-table" class="table table-striped table-bordered dt-responsive nowrap">
  53 + <thead>
  54 + <tr>
  55 + <th>Nom</th>
  56 + <th>IP</th>
  57 + <th>Architecture</th>
  58 + </tr>
  59 + </thead>
  60 + <tbody>
  61 + <tr>
  62 + <td>Nixon</td>
  63 + <td>System Architect</td>
  64 + <td>Edinburgh</td>
  65 + </tr>
  66 + <tr>
  67 + <td>Winters</td>
  68 + <td>Accountant</td>
  69 + <td>Tokyo</td>
  70 + </tr>
  71 + <tr>
  72 + <td>Cox</td>
  73 + <td>Junior Technical Author</td>
  74 + <td>San Francisco</td>
  75 + </tr>
  76 + <tr>
  77 + <td>Kelly</td>
  78 + <td>Senior Javascript Developer</td>
  79 + <td>Edinburgh</td>
  80 + </tr>
  81 + <tr>
  82 + <td>Satou</td>
  83 + <td>Accountant</td>
  84 + <td>Tokyo</td>
  85 + </tr>
  86 + <tr>
  87 + <td>Williamson</td>
  88 + <td>Integration Specialist</td>
  89 + <td>New York</td>
  90 + </tr>
  91 + <tr>
  92 + <td>Chandler</td>
  93 + <td>Sales Assistant</td>
  94 + <td>San Francisco</td>
  95 + </tr>
  96 + <tr>
  97 + <td>Davidson</td>
  98 + <td>Integration Specialist</td>
  99 + <td>Tokyo</td>
  100 + </tr>
  101 + <tr>
  102 + <td>Hurst</td>
  103 + <td>Javascript Developer</td>
  104 + <td>San Francisco</td>
  105 + </tr>
  106 + <tr>
  107 + <td>Frost</td>
  108 + <td>Software Engineer</td>
  109 + <td>Edinburgh</td>
  110 + </tr>
  111 + <tr>
  112 + <td>Gaines</td>
  113 + <td>Office Manager</td>
  114 + <td>London</td>
  115 + </tr>
  116 + <tr>
  117 + <td>Flynn</td>
  118 + <td>Support Lead</td>
  119 + <td>Edinburgh</td>
  120 + </tr>
  121 + <tr>
  122 + <td>Marshall</td>
  123 + <td>Regional Director</td>
  124 + <td>San Francisco</td>
  125 + </tr>
  126 + <tr>
  127 + <td>Kennedy</td>
  128 + <td>Senior Marketing Designer</td>
  129 + <td>London</td>
  130 + </tr>
  131 + <tr>
  132 + <td>Fitzpatrick</td>
  133 + <td>Regional Director</td>
  134 + <td>London</td>
  135 + </tr>
  136 + <tr>
  137 + <td>Silva</td>
  138 + <td>Marketing Designer</td>
  139 + <td>London</td>
  140 + </tr>
  141 + <tr>
  142 + <td>Byrd</td>
  143 + <td>Chief Financial Officer (CFO)</td>
  144 + <td>New York</td>
  145 + </tr>
  146 + <tr>
  147 + <td>Little</td>
  148 + <td>Systems Administrator</td>
  149 + <td>New York</td>
  150 + </tr>
  151 + <tr>
  152 + <td>Greer</td>
  153 + <td>Software Engineer</td>
  154 + <td>London</td>
  155 + </tr>
  156 + </tbody>
  157 + </table>
  158 + <div class="form-group">
  159 + <input type="email" class="form-control" id="maj" placeholder="Nom de la maj" name="maj">
  160 + </div>
  161 + <div class="form-group">
  162 + <input type="password" class="form-control" id="date" placeholder="date de la mise à jour" name="date">
  163 + </div>
  164 + <!-- Ajouter une liste qui montre les differents fichiers disponibles -->
  165 + <button id="save_maj" type="submit" class="btn btn-primary">sauvegarder la mise à jour</button>
  166 + <button id="run_maj" type="submit" class="btn btn-primary">lancer la mise à jour</button>
  167 + </div>
  168 +</div>
  169 +
  170 +</div>
  171 +<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  172 +<script src="https://cdn.jsdelivr.net/npm/vue@2.5.16/dist/vue.js"></script>
  173 +<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
  174 +<script src="https://cdn.datatables.net/1.10.19/js/jquery.dataTables.min.js" charset="utf-8"></script>
  175 +<script src="https://cdn.datatables.net/select/1.2.7/js/dataTables.select.min.js" charset="utf-8"></script>
  176 +<script src="https://cdn.datatables.net/1.10.19/js/dataTables.bootstrap4.min.js" charset="utf-8"></script>
  177 +<script src="https://cdn.datatables.net/responsive/2.2.3/js/dataTables.responsive.min.js" charset="utf-8"></script>
  178 +<script th:src="@{/js/home.js}"></script>
  179 +</body>
  180 +</html>
PFE06/src/main/resources/templates/test.html 0 → 100644
@@ -0,0 +1,12 @@ @@ -0,0 +1,12 @@
  1 +<!DOCTYPE html>
  2 +<html lang="en">
  3 +<head>
  4 + <meta charset="UTF-8">
  5 + <title>Data from js test</title>
  6 +</head>
  7 +<body>
  8 + <div>
  9 +
  10 + </div>
  11 +</body>
  12 +</html>
0 \ No newline at end of file 13 \ No newline at end of file