Skip to content

Commit

Permalink
KHARKITEC-15: Perform a merge of Front and Back of the BackOffice page
Browse files Browse the repository at this point in the history
  • Loading branch information
rpkyrych committed Jul 21, 2018
1 parent 19efc55 commit 574c8b0
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 24 deletions.
4 changes: 4 additions & 0 deletions Backoffice/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>

<dependency>
<groupId>mysql</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

Expand All @@ -14,7 +15,7 @@
@Controller
@RequestMapping("/building")
public class BuildingController {
private static final String BUILDING_PAGE = "/building";
private static final String BUILDING_PAGE = "addObject";
private static final Marker DB_MARKER = MarkerManager.getMarker("DATABASE");
private BuildingService buildingService;
private Logger logger;
Expand All @@ -26,6 +27,12 @@ public BuildingController(BuildingService buildingService) {
}

@RequestMapping(value = "/", method = GET)
public String getBuildingPage(Model model) {
model.addAttribute("building", new Building());
return BUILDING_PAGE;
}

@RequestMapping(value = "/all", method = GET)
public String getBuildingsList(Model model) {
model.addAttribute("buildings", buildingService.getBuildings());
return BUILDING_PAGE;
Expand All @@ -42,21 +49,21 @@ public String getBuilding(@PathVariable long id, Model model) {
}

@RequestMapping(value = "/", method = POST)
public String addBuilding(Building newBuilding) {
buildingService.save(newBuilding);
return "redirect:" + BUILDING_PAGE;
public String addBuilding(@ModelAttribute("building") Building building) {
buildingService.save(building);
return "redirect:/" + BUILDING_PAGE;
}

@RequestMapping(value = "/", method = PUT)
public String updateBuilding(Building editedBuilding) {
buildingService.update(editedBuilding);
return "redirect:" + BUILDING_PAGE;
return "redirect:/" + BUILDING_PAGE;
}

@RequestMapping(value = "/{id}", method = DELETE)
public String removeBuilding(@PathVariable long id) {
buildingService.remove(id);
return "redirect:" + BUILDING_PAGE;
return "redirect:/" + BUILDING_PAGE;
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
public class Building {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private long id;
private Long id;
private String name;
private String description;
@OneToMany(fetch = FetchType.LAZY, targetEntity = Photo.class)
Expand Down Expand Up @@ -54,11 +54,11 @@ public boolean addCategory(Category category) {
return categories.add(category);
}

public long getId() {
public Long getId() {
return id;
}

public void setId(long id) {
public void setId(Long id) {
this.id = id;
}

Expand Down Expand Up @@ -99,7 +99,7 @@ public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Building)) return false;
Building building = (Building) o;
return id == building.id &&
return id.equals(building.id) &&
Objects.equals(name, building.name);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
<!DOCTYPE HTML>
<html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Adminka</title>
<title>AddBuilding Page</title>
<!-- Bootstrap -->
<!-- Latest compiled and minified Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link href="css/addObject.css" rel="stylesheet">
<link href="../static/css/addObject.css" rel="stylesheet">
<!-- jQuery library -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
Expand All @@ -26,8 +26,8 @@
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="js/addObject.js"></script>
<link href="css/main.css" rel="stylesheet">
<script src="../static/js/addObject.js"></script>
<link href="../static/css/main.css" rel="stylesheet">
</head>
<body>

Expand Down Expand Up @@ -88,15 +88,15 @@
</nav>

<div class="container">
<form action="#" method="post" enctype="multipart/form-data">
<form action="#" th:action="@{/building/}" th:object="${building}" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="object-name">Название</label>
<input type="text" id="object-name" class="form-control" placeholder="Название" required>
<label for="building-name">Название</label>
<input type="text" th:field="*{name}" id="building-name" class="form-control" placeholder="Название" required/>
</div>

<div class="form-group">
<label for="description">Описание</label>
<textarea id="description" class="form-control" rows="3" maxlength="5000" required></textarea>
<textarea th:field="*{description}" id="description" class="form-control" rows="3" maxlength="5000" required></textarea>
</div>

<div class="image">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Adminka</title>
<title>BackOffice Homepage</title>

<!-- Bootstrap -->
<!-- Latest compiled and minified Bootstrap CSS -->
Expand All @@ -25,7 +25,7 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<link href="css/main.css" rel="stylesheet">
<link href="../static/css/main.css" rel="stylesheet">
</head>

<body>
Expand All @@ -50,7 +50,7 @@
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
<a class="dropdown-item" href="#">View</a>
<a class="dropdown-item" href="addObject.html">Add</a>
<a class="dropdown-item" href="/building/">Add</a>
<a class="dropdown-item" href="#">Edit</a>
<div class="dropdown-divider"></div>
<a class="dropdown-item" href="#">Something else here</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<link href="css/main.css" rel="stylesheet">
<link href="../static/css/main.css" rel="stylesheet">
</head>

<body>
Expand All @@ -35,7 +35,7 @@

<div class="col-xs-12 col-sm-12 col-lg-6">

<form action="admin.html" method="get">
<form action="index.html" method="get">
<div class="form-group">
<label for="email">Email address</label>
<input type="email" class="form-control" id="email"
Expand Down
53 changes: 53 additions & 0 deletions src/main/resources/changeset.db.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd
http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd">
<changeSet id="1" author="ihor">
<createTable tableName="building">
<column name="id_building" type="int" autoIncrement="true">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="name" type="varchar(1024)">
<constraints nullable="false" />
</column>
<column name="description" type="LONGTEXT">
<constraints nullable="true" />
</column>
</createTable>
<createTable tableName="photo">
<column name="id_photo" type="int" autoIncrement="true">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="id.building" type="int">
<constraints nullable="false"
foreignKeyName="fk_photo_building"
references="building(id_building)" />
</column>
<column name="image" type="LONGBLOB">
<constraints nullable="true" />
</column>
</createTable>
<createTable tableName="category">
<column name="id_category" type="int" autoIncrement="true">
<constraints primaryKey="true" nullable="false" />
</column>
<column name="name" type="varchar(50)">
<constraints nullable="false"></constraints>
</column>
</createTable>
<createTable tableName="category_building">
<column name="id_category" type="int">
<constraints nullable="false"
foreignKeyName="fk_category_category_building"
references="category(id_category)" />
</column>
<column name="id_building" type="int">
<constraints nullable="false"
foreignKeyName="fk_category_building_building"
references="building(id_building)" />
</column>
</createTable>
</changeSet>
</databaseChangeLog>

0 comments on commit 574c8b0

Please sign in to comment.