From ec6b726c0942b50aaedaa6637b5e5bd75caa9be6 Mon Sep 17 00:00:00 2001
From: BEAUVAIS ANTOINE <antoine.beauvais@etu.unistra.fr>
Date: Sun, 26 Sep 2021 21:39:03 +0200
Subject: [PATCH] Added Thymeleaf and sample template for Web interface.

---
 build.gradle                                  |  8 +++--
 .../fr/unistra/sil/erp/back/WebMvcConfig.java |  4 +++
 .../back/controller/web/LoginController.java  | 32 +++++++++++++++++++
 src/main/resources/templates/login.html       | 12 +++++++
 4 files changed, 53 insertions(+), 3 deletions(-)
 create mode 100644 src/main/java/fr/unistra/sil/erp/back/controller/web/LoginController.java
 create mode 100644 src/main/resources/templates/login.html

diff --git a/build.gradle b/build.gradle
index c670d26..a85e402 100644
--- a/build.gradle
+++ b/build.gradle
@@ -19,9 +19,11 @@ dependencies {
 
     implementation group: 'com.google.code.gson', name: 'gson', version: '2.8.8'
 
-	implementation 'org.springframework.boot:spring-boot-starter-web'
-	providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
-	testImplementation 'org.springframework.boot:spring-boot-starter-test'
+    implementation 'org.springframework.boot:spring-boot-starter-web'
+    providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
+    testImplementation 'org.springframework.boot:spring-boot-starter-test'
+
+    implementation 'org.thymeleaf:thymeleaf-spring5'
 }
 
 javadoc {
diff --git a/src/main/java/fr/unistra/sil/erp/back/WebMvcConfig.java b/src/main/java/fr/unistra/sil/erp/back/WebMvcConfig.java
index 2b7e9cc..ac9009f 100644
--- a/src/main/java/fr/unistra/sil/erp/back/WebMvcConfig.java
+++ b/src/main/java/fr/unistra/sil/erp/back/WebMvcConfig.java
@@ -71,6 +71,10 @@ public class WebMvcConfig implements WebMvcConfigurer {
     public static final String MAPPING_GETSTOCKS = API_FULL_PREFIX +
             "/retrieveStocks";
     
+    /**
+     * Web mapping for the login page.
+     */
+    public static final String MAPPING_LOGIN = "/login";
     
     /*
     // TODO: Define default servlet.
diff --git a/src/main/java/fr/unistra/sil/erp/back/controller/web/LoginController.java b/src/main/java/fr/unistra/sil/erp/back/controller/web/LoginController.java
new file mode 100644
index 0000000..fc1e5e7
--- /dev/null
+++ b/src/main/java/fr/unistra/sil/erp/back/controller/web/LoginController.java
@@ -0,0 +1,32 @@
+/*
+ * CONTRAT DE LICENCE DE LOGICIEL LIBRE CeCILL-B
+ * https://cecill.info/licences/Licence_CeCILL-B_V1-fr.html
+ */
+package fr.unistra.sil.erp.back.controller.web;
+
+import static fr.unistra.sil.erp.back.WebMvcConfig.MAPPING_LOGIN;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+
+/**
+ * Controller for the Web login interface.
+ * 
+ * This controller handles the connection process of the user 
+ * upon his arrival.
+ * 
+ * @author BEAUVAIS ANTOINE
+ */
+@Controller
+public class LoginController {
+    
+    /**
+     * Logic for handling login.
+     * 
+     * TODO: Actual implementation.
+     */
+    @GetMapping(MAPPING_LOGIN)
+    public void login()
+    {
+    }
+    
+}
diff --git a/src/main/resources/templates/login.html b/src/main/resources/templates/login.html
new file mode 100644
index 0000000..7e121e1
--- /dev/null
+++ b/src/main/resources/templates/login.html
@@ -0,0 +1,12 @@
+<!DOCTYPE html>
+<html lang="fr" xmlns:th="http://www.thymeleaf.org">
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+        <title>Connexion - SIL ERP</title>
+    </head>
+
+    <body>
+        <h1>Connexion</h1>
+        <p>TODO</p>
+    </body>
+</html>
\ No newline at end of file
-- 
GitLab