From 1a795df1972a11342f812d40675f497fa1bd982f Mon Sep 17 00:00:00 2001 From: Gabriel Copat <copatg@cardiff.ac.uk> Date: Wed, 13 Dec 2023 16:45:58 +0000 Subject: [PATCH] More css, also security fix --- .../security/SecurityConfiguration.java | 4 + .../static/css/landmarkFormStyle.css | 88 +++++++++++++++---- .../templates/landmarks/LandmarkFormTh.html | 34 ++++--- .../Team5/SmartTowns/DatasourceConfig.java | 21 +++-- 4 files changed, 101 insertions(+), 46 deletions(-) diff --git a/src/main/java/Team5/SmartTowns/security/SecurityConfiguration.java b/src/main/java/Team5/SmartTowns/security/SecurityConfiguration.java index eabe292e..f6ef3bd5 100644 --- a/src/main/java/Team5/SmartTowns/security/SecurityConfiguration.java +++ b/src/main/java/Team5/SmartTowns/security/SecurityConfiguration.java @@ -2,9 +2,11 @@ package Team5.SmartTowns.security; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; import org.springframework.security.config.Customizer; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.crypto.password.NoOpPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.provisioning.JdbcUserDetailsManager; @@ -24,9 +26,11 @@ public class SecurityConfiguration { @Bean public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Exception { http + .csrf(AbstractHttpConfigurer::disable) .authorizeHttpRequests((requests) -> requests .requestMatchers("/user/**", "/userProfile").authenticated() .anyRequest().permitAll() + ) .formLogin((login) -> login .loginPage("/login").permitAll() diff --git a/src/main/resources/static/css/landmarkFormStyle.css b/src/main/resources/static/css/landmarkFormStyle.css index 9d638b48..df77f4d4 100644 --- a/src/main/resources/static/css/landmarkFormStyle.css +++ b/src/main/resources/static/css/landmarkFormStyle.css @@ -1,21 +1,77 @@ /*LandmarkFormTh stylesheet*/ -body{ - background: rgb(41, 41, 41); - color: wheat; -} -#landmarkSubmission { - background-color: rgb(206, 153, 253); - color: black; - border-color: white; - align-content: center; - text-align: center; - border-radius: 25px; - max-width: 620px; - margin: 0 auto +@media only screen +and (min-device-width: 640px) { + #landmarkSubmission { + background-color: var(--prim-shade-1); + color: black; + border-color: white; + align-content: center; + text-align: center; + border-radius: 25px; + max-width: 620px; + margin: 0 auto + } + + #landmarkFormTitle { + color: white; + text-align: center; + + } } -#landmarkFormTitle{ - color:white; - text-align: center; +@media only screen +and (max-device-width: 640px) { + /*LandmarkFormTh stylesheet*/ + main { + min-height: 30svh; + } + #landmarkSubmission { + background-color: var(--prim-shade-1); + border-color: white; + align-content: center; + text-align: center; + border-radius: 25px; + max-width: 620px; + margin: 0 auto; + display: flex; + flex-direction: column; + row-gap: 2svh; + align-items: center; + + & h1 { + + } + + & label { + font-weight: 600; + } + & select { + font-size: 1em; + } + + & input { + font-size: 1em; + } + } + + .button { + background-color: var(--prim-shade-3); + border-radius: 20px; + border: var(--prim-shade-2) 5px; + color: #fff; + font-size: xxx-large; + padding: 40px 40px; + font-weight: 600; + letter-spacing: 1px; + text-transform: uppercase; + margin-bottom: 2svh; + cursor: pointer; + box-shadow: rgba(0, 0, 0, 0.2) 0 1svh 1svh; + } + + #landmarkFormTitle { + color: white; + text-align: center; + } } \ No newline at end of file diff --git a/src/main/resources/templates/landmarks/LandmarkFormTh.html b/src/main/resources/templates/landmarks/LandmarkFormTh.html index 0f7879d8..38978f22 100644 --- a/src/main/resources/templates/landmarks/LandmarkFormTh.html +++ b/src/main/resources/templates/landmarks/LandmarkFormTh.html @@ -4,31 +4,31 @@ <meta charset="UTF-8"> <title>Landmark Sign Up</title> <link rel="stylesheet" th:href="@{css/landmarkFormStyle.css}"> - <link rel="stylesheet" th:href="@{css/templatingstyle.css}"> + <link rel="stylesheet" th:href="@{css/mobile-style.css}"> <script src="scripts/landmarkFormThScript.js"></script> </head> <body> -<header th:insert="~{/fragments/Templating.html :: header}"></header> -<hr style="height:20px; visibility:hidden;" /> -<H2 id="landmarkFormTitle"> Interested in joining our trails? Sign up Here! </H2> +<header th:insert="~{/fragments/banners :: header}"></header> + + <main> <!-- Form used to submit potential landmarks for trails--> - <form action="/landmarkSub" id="landmarkSubmission" name="landmarkSubmission" method="post" th:object="${landmarkData}" onsubmit="return landmarkFormValidation()"> - <br> + <form action="/landmarkSub" id="landmarkSubmission" name="landmarkSubmission" method="post" th:object="${landmarkData}" onsubmit="return landmarkFormValidation()"> + <h1 id="landmarkFormTitle"> Interested in joining our trails? Sign up Here! </h1> <label>Business Name: <input type="text" th:field="*{landmarkName}" placeholder="Business name here..."> - </label><br> + </label> <div th:errors="*{landmarkName}" th:if="${#fields.hasErrors('landmarkName')}">ErrorLandmarkName</div> - <br><label>Contact Address: + <label>Contact Address: <input type="text" th:field="*{landmarkEmail}" placeholder="E-mail here..."> - </label><br> + </label> <div th:errors="*{landmarkEmail}" th:if="${#fields.hasErrors('landmarkEmail')}">ErrorEmail</div> - <br><label>Please Describe Your Business:<br> + <label>Please Describe Your Business:<br> <textarea th:field="*{landmarkDescription}" rows="18" cols="70" placeholder="Max 200 words please..."></textarea> - </label><br><br> + </label> <label>Your Location: <select th:field="*{landmarkLocation}"> <option value="" hidden="true">Select Location</option> @@ -37,7 +37,7 @@ <option value="Risca">Risca</option> <option value="Penarth">Penarth</option> </select> - </label><br><br> + </label> <label>Trail: <select th:field="*{trailID}"> <option value=0 hidden="true">Select Trail</option> @@ -48,18 +48,14 @@ <option value=0201>(Risca) Heritage and Culture Trail</option> <option value=0301>(Penarth) Esplanade Trail</option> </select> - - </label><br><br> - - - <input type="submit"> - <hr style="height:0px; visibility:hidden;" /> + </label> + <button class="button" type="submit">Submit</button> </form> <hr style="height:40px; visibility:hidden;" /> </main> -<footer th:insert="~{/fragments/Templating.html :: footer}"></footer> +<footer th:insert="~{/fragments/banners :: footer}"></footer> </body> </html> \ No newline at end of file diff --git a/src/test/java/Team5/SmartTowns/DatasourceConfig.java b/src/test/java/Team5/SmartTowns/DatasourceConfig.java index bbda85b0..eb7623ab 100644 --- a/src/test/java/Team5/SmartTowns/DatasourceConfig.java +++ b/src/test/java/Team5/SmartTowns/DatasourceConfig.java @@ -5,17 +5,16 @@ import org.springframework.context.annotation.Configuration; import org.springframework.jdbc.datasource.DriverManagerDataSource; import javax.sql.DataSource; - @Configuration -public class DatasourceConfig { - @Bean - public DataSource dataSource() { - DriverManagerDataSource dataSource = new DriverManagerDataSource(); - dataSource.setUrl("jdbc:mariadb://localhost:3306/test_towns"); - dataSource.setUsername("root"); - dataSource.setPassword("comsc"); +public class DataSourceConfig { - return dataSource; - } -} + @Bean + public DataSource dataSource(){ + DriverManagerDataSource dataSource = new DriverManagerDataSource(); + dataSource.setUrl("jdbc:mariadb://localhost:3306/test_towns"); + dataSource.setUsername("root"); + dataSource.setPassword("comsc"); + return dataSource; + } +} -- GitLab