Procházet zdrojové kódy

CreateTexController

Andrew Grant před 4 měsíci
rodič
revize
58a0ef42b3

+ 1 - 1
src/main/java/scot/carricksoftware/grantswriter/constants/AttributeConstants.java

@@ -15,6 +15,6 @@ public class AttributeConstants {
     }
 
     public static final String WRITER_FILES = "writerFiles";
-
+    public static final String STATUS = "status";
 
 }

+ 1 - 1
src/main/java/scot/carricksoftware/grantswriter/constants/MappingConstants.java

@@ -16,7 +16,7 @@ public class MappingConstants {
 
     public static final String FILES = "/files";
 
-    public static final String CREATE_TEX = "/tex";
+    public static final String TEX = "/tex";
 
     public static final String BUILD_PDF = "/pdf";
 

+ 1 - 0
src/main/java/scot/carricksoftware/grantswriter/constants/ViewConstants.java

@@ -18,5 +18,6 @@ public class ViewConstants {
 
     @SuppressWarnings("unused")
     public static final String FILES = "files";
+    public static final String TEX = "tex";
 
 }

+ 0 - 9
src/main/java/scot/carricksoftware/grantswriter/controllers/CreateTexController.java

@@ -1,9 +0,0 @@
-/*
- * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
- *
- */
-
-package scot.carricksoftware.grantswriter.controllers;
-
-public interface CreateTexController {
-}

+ 0 - 12
src/main/java/scot/carricksoftware/grantswriter/controllers/CreateTexControllerImpl.java

@@ -1,12 +0,0 @@
-/*
- * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
- *
- */
-
-package scot.carricksoftware.grantswriter.controllers;
-
-import org.springframework.stereotype.Controller;
-
-@Controller
-public class CreateTexControllerImpl implements CreateTexController {
-}

+ 0 - 5
src/main/java/scot/carricksoftware/grantswriter/controllers/IndexController.java

@@ -13,11 +13,6 @@ import scot.carricksoftware.grantswriter.constants.MappingConstants;
 
 public interface IndexController {
 
-
-    @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CREATE_TEX)
-    String createTex(Model model);
-
     @SuppressWarnings("SameReturnValue")
     @GetMapping(MappingConstants.BUILD_PDF)
     String buildPDF(Model model);

+ 0 - 7
src/main/java/scot/carricksoftware/grantswriter/controllers/IndexControllerImpl.java

@@ -20,13 +20,6 @@ public class IndexControllerImpl implements IndexController {
     private static final Logger logger = LogManager.getLogger(IndexControllerImpl.class);
 
 
-    @SuppressWarnings("SameReturnValue")
-    @GetMapping(MappingConstants.CREATE_TEX)
-    @Override
-    public final String createTex(final Model model) {
-        logger.debug("IndexControllerImpl::createTex");
-        return ViewConstants.NOT_AVAILABLE;
-    }
 
     @SuppressWarnings("SameReturnValue")
     @GetMapping(MappingConstants.BUILD_PDF)

+ 14 - 0
src/main/java/scot/carricksoftware/grantswriter/controllers/TexController.java

@@ -0,0 +1,14 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.controllers;
+
+import org.springframework.ui.Model;
+
+public interface TexController {
+
+    @SuppressWarnings({"SameReturnValue", "unused"})
+    String start(Model model);
+}

+ 43 - 0
src/main/java/scot/carricksoftware/grantswriter/controllers/TexControllerImpl.java

@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2025.  Andrew Grant Carrick Software. All rights reserved
+ *
+ */
+
+package scot.carricksoftware.grantswriter.controllers;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.GetMapping;
+import scot.carricksoftware.grantswriter.constants.AttributeConstants;
+import scot.carricksoftware.grantswriter.constants.MappingConstants;
+import scot.carricksoftware.grantswriter.constants.ViewConstants;
+import scot.carricksoftware.grantswriter.files.WriterFiles;
+
+import static java.util.Objects.isNull;
+
+@Controller
+public class TexControllerImpl implements TexController {
+
+    private static final Logger logger = LogManager.getLogger(TexControllerImpl.class);
+
+    private final WriterFiles writerFiles;
+
+    public TexControllerImpl(WriterFiles writerFiles) {
+        this.writerFiles = writerFiles;
+    }
+
+    @GetMapping(MappingConstants.TEX)
+    @Override
+    public String start(Model model) {
+        logger.debug("FilesControllerImpl::getSelectionPage");
+        if (isNull(writerFiles.getLatexFileName())) {
+            writerFiles.init();
+        }
+        model.addAttribute(AttributeConstants.WRITER_FILES, writerFiles);
+        String status = "status";
+        model.addAttribute(AttributeConstants.STATUS, status);
+        return ViewConstants.TEX;
+    }
+}

+ 13 - 4
src/main/resources/templates/fragments/tex.html → src/main/resources/templates/tex.html

@@ -21,20 +21,29 @@
 </div>
 <div class="container border border-info
 rounded-3 text-center p-4">
-    <form th:object="${writerFiles}" th:action="@{/files}" method="post">
+    <form th:object="${writerFiles}" th:action="@{/tex}" method="post">
         <div class="form-group row justify-content-center">
             <div class="col" style="margin-right:20px;">
                 <label for="latexFileName">Latex File (input):</label>
                 <input class="form-control" id="latexFileName"
-                       th:field="*{latexFileName}" type="text">
+                       th:field="*{latexFileName}" type="text" readonly>
             </div>
             <div class="col" style="margin-right:20px;">
                 <label for="pdfFileName">Latex File (input):</label>
                 <input class="form-control" id="pdfFileName"
-                       th:field="*{pdfFileName}" type="text">
+                       th:field="*{pdfFileName}" type="text"
+                       readonly>
             </div>
         </div>
-        <button type="submit" class="btn btn-primary">Commit</button>
+        <div class="form-group row justify-content-center">
+            <div class="col" style="margin-right:20px;">
+                <label for="status">Status:</label>
+                <input class="form-control" id="status"
+                       th:field="*{status}" type="text"
+                       readonly>
+            </div>
+        </div>
+        <button type="submit" class="btn btn-primary">Start</button>
     </form>
 
 </div>

+ 3 - 3
src/test/java/scot/carricksoftware/grantswriter/controllers/CreateTexControllerTest.java → src/test/java/scot/carricksoftware/grantswriter/controllers/TexControllerTest.java

@@ -14,13 +14,13 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 
 @ExtendWith(MockitoExtension.class)
-class CreateTexControllerTest {
+class TexControllerTest {
 
-    private CreateTexController controller;
+    private TexController controller;
 
     @BeforeEach
     void setUp() {
-        controller = new CreateTexControllerImpl();
+        controller = new TexControllerImpl();
     }
 
     @Test