瀏覽代碼

Gestion code et libelle espace

Arthur Brandao 5 年之前
父節點
當前提交
a4845b3cbf

+ 16 - 3
WebContent/scan/index.jsp

@@ -92,15 +92,28 @@
     		const errPopup = M.Modal.getInstance($('#err-popup'));
     		const loader = M.Modal.getInstance($('#loader'));
     		
-    		
     		// Lecteur cookie espace
             const espace = getCookie("microfolies.lens.espace");
     		// Si pas de cookie retour sur la page d'accueil
             if (espace === undefined) {
                 window.location.href = "${base}";
             }
-         // Changement nom titre
-            $('#title').html(espace.capitalize());
+    		
+    		// Recupération du nom reel de l'espace pour le titre
+    		loader.open();
+    		$.ajax({
+                type: "GET",
+                url: "${base}api/espace/get/" + espace,
+                error: () => {
+                	loader.close();
+                	$('#title').html(espace.capitalize());
+                },
+                success: (result) => {
+                	loader.close();
+                	$('#title').html(result.data.libelle.capitalize());
+                },
+            });
+            
             //Scanner QRcode
             const scanner = new Instascan.Scanner({ video: document.getElementById('qr-preview') });
             scanner.addListener('scan', function (content) {

+ 1 - 1
WebContent/settings/index.jsp

@@ -19,7 +19,7 @@
     <link type="text/css" rel="stylesheet" href="<c:url value="/css/material-icons.css"/>" />
     <link type="text/css" rel="stylesheet" href="<c:url value="/css/materialize.min.css"/>" media="screen,projection" />
     <link type="text/css" rel="stylesheet" href="<c:url value="/css/style.min.css"/>" media="screen,projection" />
-    <link rel="icon" href="../img/favicon.ico" />
+    <link rel="icon" href="<c:url value="/img/favicon.ico"/>" />
     <title>Paramétrage - Microfolie Lens</title>
 </head>
 

+ 10 - 0
src/microfolie/entry/rest/EspaceController.java

@@ -4,9 +4,11 @@ import java.util.List;
 
 import javax.ws.rs.GET;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 
 import org.json.JSONArray;
+import org.json.JSONObject;
 
 import microfolie.service.EspaceService;
 import microfolie.service.dto.EspaceDTO;
@@ -25,5 +27,13 @@ public class EspaceController {
 		JSONArray data = new JSONArray(espaces);
 		return JsonUtils.success(data).toString();
 	}
+	
+	@GET
+	@Path("/get/{code}")
+	public String getByCode(@PathParam("code") String code) {
+		EspaceDTO espace = service.getByCode(code);
+		JSONObject data = new JSONObject(espace);
+		return JsonUtils.success(data).toString();
+	}
 
 }

+ 3 - 3
src/microfolie/entry/servlet/Configure.java

@@ -34,16 +34,16 @@ public class Configure extends HttpServlet {
 	protected void doGet(HttpServletRequest request, HttpServletResponse response)
 			throws ServletException, IOException {
 		request.getServletContext().log("configuring tablet");
-		String mySpace = request.getParameter("espace");
+		String espace = request.getParameter("espace");
 		String page;
 
 		/**
 		 * go back to setting
 		 */
- 		if (mySpace == null) {
+ 		if (espace == null) {
 			page = "/settings/";
 		} else {
-			Cookie cookie = new Cookie("microfolies.lens.espace", mySpace);
+			Cookie cookie = new Cookie("microfolies.lens.espace", espace);
 			cookie.setMaxAge(60 * 60 * 24 * 365);
 			page = "/scan/";
 			response.addCookie(cookie);

+ 5 - 0
src/microfolie/service/EspaceService.java

@@ -26,6 +26,11 @@ public class EspaceService {
 		return EspaceTransformer.entityToDto(espaces);
 	}
 	
+	public EspaceDTO getByCode(String code) {
+		Espace espace = table.getByCode(code);
+		return EspaceTransformer.entityToDto(espace);
+	}
+	
 	public static EspaceService getInstance() {
 		if (instance == null) {
 			instance = new EspaceService();