Skip to content
Snippets Groups Projects
Commit 2d7a638c authored by Connor Brock's avatar Connor Brock
Browse files

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/74-as-a-user-i-want-to-see-a-page-of-local-authorities-so-that-i-can-easily-source-contact-details' into businesses

# Conflicts:
#	src/main/java/Team5/SmartTowns/Organisation/organisationControllers.java
#	src/main/resources/WorkWith/local-authorities.html
#	src/main/resources/data.sql
#	src/main/resources/schema.sql
#	src/main/resources/templates/fragments/Templating.html
parents 25c1564a 65fb5939
No related branches found
No related tags found
2 merge requests!38Draft: Businesses,!31Resolve "As a user, I want to see a page of local authorities so that I can easily source contact details for a variety of different local authorities."
package Team5.SmartTowns.localauthority;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.net.URL;
@AllArgsConstructor
@NoArgsConstructor
@Data
public class localAuthority {
private String localAuthorityName;
private String address1;
private String address2;
private String city;
private String county;
private String postcode;
private URL website;
@Override
public String toString() {
return "Local Authority:" + " " +
localAuthorityName + '\'' + " " +
address1 + '\'' + " " +
address2 + '\'' + " " +
city + '\'' + " " +
county + '\'' + " " +
postcode + '\'' + " " +
website +
" ";
}
public String getLocalAuthorityName() {
return localAuthorityName;
}
public String getAddress1() { return address1; }
public String getAddress2() {
return address2;
}
public String getCity() {
return city;
}
public String getCounty() {
return county;
}
public String getPostcode() {
return postcode;
}
public URL getWebsite() {
return website;
}
}
package Team5.SmartTowns.localauthority;
import java.util.List;
public interface localAuthorityRepository {
List<localAuthority> getAllLocalAuthority();
void addLocalAuthority(localAuthority loc);
}
package Team5.SmartTowns.localauthority;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public class localAuthorityRepositoryJDBC implements localAuthorityRepository {
private JdbcTemplate jdbc;
private RowMapper<localAuthority> localAuthorityMapper;
public localAuthorityRepositoryJDBC(JdbcTemplate ajdbc){
this.jdbc = ajdbc;
setlocalauthorityMapper();
}
private void setlocalauthorityMapper(){
localAuthorityMapper = (rs, i) -> new localAuthority(
rs.getString("localAuthorityName"),
rs.getString("address1"),
rs.getString("address2"),
rs.getString("city"),
rs.getString("county"),
rs.getString("postcode"),
rs.getURL("website")
);
}
public List<localAuthority> getAllLocalAuthority(){
String sql = "SELECT * FROM localAuthority";
return jdbc.query(sql, localAuthorityMapper);
}
@Override
public void addLocalAuthority(localAuthority loc){
String sql = "INSERT INTO localAuthority( localAuthorityName, address1, address2, city, county, postcode, website) values (?, ?, ?, ?, ?, ?, ?)";
jdbc.update(sql, loc.getLocalAuthorityName(),loc.getAddress1(),loc.getAddress2(),loc.getCity(),loc.getCounty(),loc.getPostcode(),loc.getWebsite());
}
}
/* DELETES AND RECREATES DATABASE EVERY TIME THE SYSTEM IS BOOTED*/ drop table if exists trails;
DROP DATABASE IF EXISTS towns; create table if not exists trails
CREATE DATABASE IF NOT EXISTS towns; (
USE towns;
/****************************************************************/
/* DROPS ALL TABLES IF THEY EXIST (they wont but just in case) */
DROP TABLE IF EXISTS trails;
DROP TABLE IF EXISTS locations;
DROP TABLE IF EXISTS users;
DROP TABLE IF EXISTS stickers;
DROP TABLE IF EXISTS packs;
DROP TABLE IF EXISTS stickerProgress;
/****************************************************************/
/* CREATES ALL TABLES */
CREATE TABLE IF NOT EXISTS trails (
trailID bigint auto_increment primary key, trailID bigint auto_increment primary key,
name varchar(128), name varchar(128)
tru boolean
) engine=InnoDB; ) engine=InnoDB;
drop table if exists locationCoordinates;
drop table if exists locations; drop table if exists locations;
create table if not exists locations create table if not exists locations
( (
locationID bigint auto_increment primary key, locationID bigint auto_increment primary key,
...@@ -30,84 +14,60 @@ create table if not exists locations ...@@ -30,84 +14,60 @@ create table if not exists locations
locationEmail varchar(128), locationEmail varchar(128),
locationDescription longtext, locationDescription longtext,
locationPlace varchar(255), locationPlace varchar(255),
locationTrailID varchar(128), locationTrailID varchar(128)
locationApproved boolean
) engine=InnoDB; ) engine=InnoDB;
drop table if exists users;
CREATE TABLE IF NOT EXISTS users ( create table if not exists users
username varchar(30) primary key NOT NULL, (
id bigint auto_increment unique, /*DEPRECATED COLUMN, LEFT IN WHILE SOME OTHER FUNCTIONS STILL USE IT*/ userID bigint auto_increment primary key,
email varchar(128), email varchar(128),
password varchar(30) NOT NULL, name varchar(128),
enabled boolean default true dragonProgress int
); ) engine=InnoDB;
CREATE TABLE IF NOT EXISTS authorities (
id bigint primary key auto_increment NOT NULL,
username varchar(30) NOT NULL ,
authority varchar(45) NOT NULL
);
CREATE TABLE IF NOT EXISTS packs (
id bigint auto_increment primary key,
name varchar(20) NOT NULL,
description text
);
CREATE TABLE IF NOT EXISTS stickers (
id bigint auto_increment primary key,
packID bigint NOT NULL,
FOREIGN KEY (packID) REFERENCES packs(id)
ON DELETE CASCADE
ON UPDATE RESTRICT,
stickerID bigint NOT NULL, /*STICKER ID NUMBER WITHIN ITS OWN PACK*/
name varchar(30) NOT NULL,
description text NOT NULL,
rarity tinyint
);
CREATE TABLE IF NOT EXISTS stickerProgress (
id bigint auto_increment primary key,
username varchar(30) NOT NULL,
FOREIGN KEY (username) REFERENCES users(username)
ON DELETE CASCADE
ON UPDATE RESTRICT,
packID bigint NOT NULL,
FOREIGN KEY (packID) REFERENCES packs(id)
ON DELETE CASCADE
ON UPDATE RESTRICT,
stickerID bigint NOT NULL,
FOREIGN KEY (stickerID) REFERENCES stickers(id)
ON DELETE CASCADE
ON UPDATE RESTRICT
);
create table if not exists locationCoordinates drop table if exists badges;
create table if not exists badges
( (
locationCoordID bigint auto_increment primary key, badgeID bigint auto_increment primary key,
locationID bigint, name varchar(128),
Foreign Key (locationID) REFERENCES locations(locationID) description varchar(128),
ON DELETE CASCADE difficulty bigint
ON UPDATE RESTRICT, ) engine=InnoDB;
locationCoordsLat DECIMAL(8,6),
locationCoordsLong DECIMAL(8,6)
)engine=InnoDB;
drop table if exists stickers;
create table if not exists stickers
(
stickerID bigint auto_increment primary key,
name varchar(128),
description varchar(128),
rarity bigint
) engine=InnoDB;
drop table if exists townsWithTrails; drop table if exists badgeProgress;
create table if not exists townsWithTrails create table if not exists badgeProgress
( (
townID bigint auto_increment primary key, userID bigint,
townName varchar(128), badgeID bigint,
townCentreCoordsLat varchar(128), progress int /*0-100*/
townCentreCoordsLong varchar(128), ) engine=InnoDB;
townUppermostCoordsLat varchar(128),
townLowermostCoordsLat varchar(128),
townLeftmostCoordsLong varchar(128),
townRightmostCoordsLong varchar(128)
)engine=InnoDB; create table if not exists stickerProgress
(
userID bigint,
stickerID bigint,
hasSticker boolean /*Has sticker or not*/
) engine=InnoDB;
drop table if exists localAuthority;
create table if not exists localAuthority
(
localAuthorityID bigint auto_increment primary key,
localAuthorityName varchar(250),
address1 varchar(250),
address2 varchar(250),
city varchar(100),
county varchar(75),
postcode varchar(15),
website varchar(250)
) engine=InnoDB;
\ No newline at end of file
* { /** {*/
box-sizing: border-box; /* box-sizing: border-box;*/
} /*}*/
body { /*body {*/
background-color: rgb(41, 41, 41); /* background-color: rgb(41, 41, 41);*/
margin: 0; /* margin: 0;*/
display: flex; /* display: flex;*/
flex-direction: column; /* flex-direction: column;*/
min-height: 100svh; /* min-height: 100svh;*/
} /*}*/
main { /*main {*/
} /*}*/
.centerFlex { /*.centerFlex {*/
display: flex; /* display: flex;*/
justify-content: center; /* justify-content: center;*/
} /*}*/
#allTrailsBar { /*#allTrailsBar {*/
width: 100%; /* width: 100%;*/
height: auto; /* height: auto;*/
/*margin: 1svh auto;*/ /* !*margin: 1svh auto;*!*/
padding: 0 5svh; /* padding: 0 5svh;*/
display: flex; /* display: flex;*/
flex-wrap: wrap; /* flex-wrap: wrap;*/
justify-content: space-evenly; /* justify-content: space-evenly;*/
} /*}*/
.trailsImages { /*.trailsImages {*/
margin: 1svh auto; /* margin: 1svh auto;*/
height: 12svh; /* height: 12svh;*/
width: auto; /* width: auto;*/
border-radius: 20px; /* border-radius: 20px;*/
border: solid grey 2px; /* border: solid grey 2px;*/
transition: 0.5s ease-out 100ms; /* transition: 0.5s ease-out 100ms;*/
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.85); /* box-shadow: 0 10px 20px rgba(0, 0, 0, 0.85);*/
} /*}*/
.trailsImages:hover { /*.trailsImages:hover {*/
box-shadow: 0 0 20px 10px #bbbb00; /* box-shadow: 0 0 20px 10px #bbbb00;*/
transform: scale(1.2,1.2); /* transform: scale(1.2,1.2);*/
} /*}*/
.selected { /*.selected {*/
box-shadow: 0 0 20px 10px #bbbb00; /* box-shadow: 0 0 20px 10px #bbbb00;*/
} /*}*/
@keyframes fadeIn { /*@keyframes fadeIn {*/
0% { opacity: 0; } /* 0% { opacity: 0; }*/
100% { opacity: 1; } /* 100% { opacity: 1; }*/
} /*}*/
main { /*main {*/
margin: 0; /* margin: 0;*/
} /*}*/
#trailInfoContainer { /*#trailInfoContainer {*/
overflow: scroll; /* overflow: scroll;*/
} /*}*/
.trailInfoFrag { /*.trailInfoFrag {*/
background-color: rgb(84, 33, 128); /* background-color: rgb(84, 33, 128);*/
border: #000000 solid 2px; /* border: #000000 solid 2px;*/
border-radius: 10px; /* border-radius: 10px;*/
box-shadow: 0 5px 20px 0 #000000; /* box-shadow: 0 5px 20px 0 #000000;*/
margin: 2svh auto; /* margin: 2svh auto;*/
padding-bottom: 2svw; /* padding-bottom: 2svw;*/
width: 70vw; /* width: 70vw;*/
height: auto; /* height: auto;*/
min-height: 30svh; /* min-height: 30svh;*/
animation: fadeIn 3s; /* animation: fadeIn 3s;*/
display: grid; /* display: grid;*/
grid-template-areas: /* grid-template-areas:*/
"header header header" /* "header header header"*/
"image text text"; /* "image text text";*/
grid-template-columns: 30% 30% auto; /* grid-template-columns: 30% 30% auto;*/
grid-template-rows: 10% auto; /* grid-template-rows: 10% auto;*/
grid-column-gap: 2vw; /* grid-column-gap: 2vw;*/
grid-row-gap: 2svh; /* grid-row-gap: 2svh;*/
& .trailInfoHeader { /* & .trailInfoHeader {*/
grid-area: header; /* grid-area: header;*/
width: 100%; /* width: 100%;*/
height: 100%; /* height: 100%;*/
margin-top: 1svh; /* margin-top: 1svh;*/
padding: 0; /* padding: 0;*/
& h1 { /* & h1 {*/
color: white; /* color: white;*/
padding:0; /* padding:0;*/
margin:0 25%; /* margin:0 25%;*/
font-size: 2vw; /* font-size: 2vw;*/
text-align: center; /* text-align: center;*/
box-shadow: 0 10px 10px -10px black; /* box-shadow: 0 10px 10px -10px black;*/
} /* }*/
} /* }*/
& img { /* & img {*/
grid-area: image; /* grid-area: image;*/
border-radius: 10px; /* border-radius: 10px;*/
border: black solid 1px; /* border: black solid 1px;*/
margin-left: 2vw; /* margin-left: 2vw;*/
margin-right: 2vw; /* margin-right: 2vw;*/
width: 100%; /* width: 100%;*/
height: auto; /* height: auto;*/
box-shadow: 0 10px 20px -10px black; /* box-shadow: 0 10px 20px -10px black;*/
} /* }*/
& p { /* & p {*/
grid-area: text; /* grid-area: text;*/
color: white; /* color: white;*/
margin: 0; /* margin: 0;*/
padding: 0 2vw; /* padding: 0 2vw;*/
font-size: 1.3vw; /* font-size: 1.3vw;*/
text-align: justify; /* text-align: justify;*/
text-justify: inter-character; /* text-justify: inter-character;*/
line-height: 1.5; /* line-height: 1.5;*/
width: fit-content; /* width: fit-content;*/
height: fit-content; /* height: fit-content;*/
overflow: scroll; /* overflow: scroll;*/
} /* }*/
} /*}*/
#trailFragContent { /*#trailFragContent {*/
margin: 0; /* margin: 0;*/
padding: 0; /* padding: 0;*/
display: flex; /* display: flex;*/
min-height: 40svh; /* min-height: 40svh;*/
flex-wrap: wrap; /* flex-wrap: wrap;*/
} /*}*/
header { /*header {*/
box-shadow: #1e1e1e 0 0 10px 10px; /* box-shadow: #1e1e1e 0 0 10px 10px;*/
font-size: 1vw; /* font-size: 1vw;*/
} /*}*/
body{
background-color: rgb(41, 41, 41)
}
h1{
color: wheat;
}
h3{
color: wheat;
}
ul{
list-style: none;
}
ul li{
color: wheat;
list-style: none;
}
\ No newline at end of file
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/html">
<head>
<meta charset="UTF-8">
<title>Local Authority</title>
<link rel="stylesheet" th:href="@{css/landmarkFormStyle.css}">
<link rel="stylesheet" th:href="@{css/templatingstyle.css}">
</head>
<header th:insert="~{/towns/Templating.html::header}"></header>
<body>
<div id="container1">
<h2>Enter your Local authority</h2>
<form action="/local-auth-data" id="data" name="data" method="post" th:object="${localAuthority}">
<br>
<label>Enter your local authority
<input type="text" th:field="*{localAuthorityName}">
</label><br><br>
<label>Please enter first line of your address
<input type="text" th:field="*{address1}">
</label><br><br>
<label>Please enter second line of your address (optional)
<input type="text" th:field="*{address2}">
</label><br><br>
<label>Please enter the City/Town
<input type="text" th:field="*{city}">
</label><br><br>
<label>Please enter you county (optional)
<input type="text" th:field="*{county}">
</label><br><br>
<label>Please enter your postcode
<input type="text" th:field="*{postcode}">
</label><br><br>
<label>Please enter your website address
<input type="text" th:field="*{website}">
</label><br><br>
<input type="submit">
</form>
</div>
</body>
<footer th:insert="~{/towns/Templating.html::footer}"></footer>
</html>
\ No newline at end of file
...@@ -3,19 +3,18 @@ ...@@ -3,19 +3,18 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Local Authorities</title> <title>Local Authorities</title>
<link rel="stylesheet" th:href="@{/css/templatingstyle.css}"> <link rel="stylesheet" th:href="@{css/localAuthorityPageStyle.css}">
<link rel="stylesheet" th:href="@{css/templatingstyle.css}">
</head> </head>
<header th:insert="~{/towns/Templating.html::header}"></header> <header th:insert="~{/towns/Templating.html::header}"></header>
<body> <body>
<h1>Local Authorities</h1> <h1>Local Authorities</h1>
<div id="councils"> <div id="councils">
<p>Caerphilly County Borough Council,<br>Tredomen Park,<br> Ystrad Mynach,<br> Hengoed,<br> CF82 7PG</p> <ul th:each="local:${localAuth}">
<a href="https://www.caerphilly.gov.uk/main.aspx?lang=en-GB">Caerphilly County Borough Council Website</a> <li th:text="${local}"></li>
<p>Risca Town Council,<br>Risca Palace Library,<br>Unit B,<br>75 Tredegar Street,<br>Risca,<br>NP11 6BW</p> </ul>
<a href="https://www.riscatowncouncil.org.uk/">Risca Town Council Website</a>
<p>Penarth Town Council West House,<br>Stanwell Road,<br>Penarth,<br> CF64 2YG</p>
<a href="https://www.penarthtowncouncil.gov.uk/your-council/">Penarth Town Council Website</a>
</div> </div>
<button><a href="/localForm" id="authority">Local Authorities please enter here</a></button>
<footer th:insert="~{/towns/Templating.html::footer}"></footer> <footer th:insert="~{/towns/Templating.html::footer}"></footer>
</body> </body>
</html> </html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment