diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/CinemasController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/CinemasController.kt index f1f97bd9a37ab52478720c9bdb97ad6a4ed96ab8..7d6f4a938ff4621c66f54926ffab3b310bb9d2b4 100644 --- a/src/main/kotlin/com/s3ai/corporate_app2/controllers/CinemasController.kt +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/CinemasController.kt @@ -1,41 +1,45 @@ package com.s3ai.corporate_app2.controllers -import com.s3ai.corporate_app2.entities.Cinema -import com.s3ai.corporate_app2.repos.CinemaRepository -import com.s3ai.corporate_app2.services.CinemaService +import com.s3ai.corporate_app2.Cinema +import com.s3ai.corporate_app2.CinemaService import org.springframework.beans.factory.annotation.Autowired import org.springframework.stereotype.Controller import org.springframework.ui.Model -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestParam +import org.springframework.web.bind.annotation.* +import org.springframework.web.servlet.view.RedirectView import java.util.UUID.fromString import java.util.UUID.randomUUID @Controller +@RequestMapping("/cinemas") class CinemasController { @Autowired - var cinemaService: CinemaService? = null + lateinit var cinemaService: CinemaService - @Autowired - var cinemaRepository: CinemaRepository? = null - - - @GetMapping("/cinemas") + @GetMapping("/list") fun getCinemasBrowsePage(model: Model): String? { - model.addAttribute("cinemas", cinemaService?.findAll()) + model.addAttribute("cinemas", cinemaService.findAll()) return "cinemas/list" } - @GetMapping("/cinema") + @GetMapping("/edit") fun getCinemaEditPage(@RequestParam(name = "id", required = false, defaultValue = "") id: String, model: Model): String? { - var cinema: Cinema? = null + val cinema: Cinema? if (id.isEmpty()) { cinema = Cinema() cinema.id = randomUUID() + model.addAttribute("action", "Create") } else { - cinema = cinemaService?.findOne(fromString(id)) + cinema = cinemaService.findById(fromString(id)) + model.addAttribute("action", "Edit") } model.addAttribute("cinema", cinema) return "cinemas/edit" } + + @PostMapping("/update") + fun updateCinema(@ModelAttribute cinema: Cinema): RedirectView { + cinemaService.save(cinema) + return RedirectView("/cinemas/list") + } } \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/TicketsController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/TicketsController.kt new file mode 100644 index 0000000000000000000000000000000000000000..9949bd55a40a9262bffd97a70370ad11a327606d --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/TicketsController.kt @@ -0,0 +1,53 @@ +package com.s3ai.corporate_app2.controllers; + +import com.s3ai.corporate_app2.CinemaService +import com.s3ai.corporate_app2.Ticket +import com.s3ai.corporate_app2.TicketService +import com.s3ai.corporate_app2.UserService +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Controller +import org.springframework.ui.Model +import org.springframework.web.bind.annotation.* +import org.springframework.web.servlet.view.RedirectView +import java.util.* + +@Controller +@RequestMapping("/tickets") +class TicketsController { + @Autowired + lateinit var ticketService: TicketService + @Autowired + lateinit var userService: UserService + @Autowired + lateinit var cinemaService: CinemaService + + @GetMapping("/list") + fun getTicketsBrowsePage(model: Model): String? { + model.addAttribute("tickets", ticketService.findAll()) + return "tickets/list" + } + + @GetMapping("/edit") + fun getTicketEditPage(@RequestParam(name = "id", required = false, defaultValue = "") id: String, model: Model): String? { + val ticket: Ticket? + if (id.isEmpty()) { + ticket = Ticket() + ticket.id = UUID.randomUUID() + model.addAttribute("action", "Create") + } else { + ticket = ticketService.findById(UUID.fromString(id)) + model.addAttribute("action", "Edit") + } + model.addAttribute("ticket", ticket) + model.addAttribute("users", userService.findAll()) + model.addAttribute("cinemas", cinemaService.findAll()) + return "tickets/edit" + } + + @PostMapping("/update") + fun updateCinema(@ModelAttribute ticket: Ticket): RedirectView { + ticketService.save(ticket) + return RedirectView("/tickets/list") + } + +} diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/UserController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/UserController.kt deleted file mode 100644 index 260fbaa6016c1ac348eb27f6f50f36d25bc2a11f..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/controllers/UserController.kt +++ /dev/null @@ -1,20 +0,0 @@ -package com.s3ai.corporate_app2.controllers - -import org.springframework.stereotype.Controller -import org.springframework.web.bind.annotation.GetMapping -import org.springframework.web.bind.annotation.RequestMapping - -@Controller -@RequestMapping("/users") -class UserController { - - @GetMapping("/list") - fun getUsersList(): String? { - return "index" - } - - @GetMapping("/edit") - fun getUsersEditPage(): String? { - return "index" - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/UsersController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/UsersController.kt new file mode 100644 index 0000000000000000000000000000000000000000..7a86adc52a63ad1dfa3221a80ffc5acf72c50dec --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/UsersController.kt @@ -0,0 +1,44 @@ +package com.s3ai.corporate_app2.controllers + +import com.s3ai.corporate_app2.User +import com.s3ai.corporate_app2.UserService +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.stereotype.Controller +import org.springframework.ui.Model +import org.springframework.web.bind.annotation.* +import org.springframework.web.servlet.view.RedirectView +import java.util.* + +@Controller +@RequestMapping("/users") +class UsersController { + @Autowired + lateinit var userService: UserService + + @GetMapping("/list") + fun getUsersBrowsePage(model: Model): String? { + model.addAttribute("users", userService.findAll()) + return "users/list" + } + + @GetMapping("/edit") + fun getUSerEditPage(@RequestParam(name = "id", required = false, defaultValue = "") id: String, model: Model): String? { + val user: User? + if (id.isEmpty()) { + user = User() + user.id = UUID.randomUUID() + model.addAttribute("action", "Create") + } else { + user = userService.findById(UUID.fromString(id)) + model.addAttribute("action", "Edit") + } + model.addAttribute("user", user) + return "users/edit" + } + + @PostMapping("/update") + fun updateCinema(@ModelAttribute user: User): RedirectView { + userService.save(user) + return RedirectView("/users/list") + } +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/controllerUtils.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/controllerUtils.kt new file mode 100644 index 0000000000000000000000000000000000000000..74018cd1127b9b8f5a01fcd3b1c83c48c5a38887 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/controllerUtils.kt @@ -0,0 +1,23 @@ +package com.s3ai.corporate_app2.controllers + +import com.s3ai.corporate_app2.CinemaServices +import org.springframework.ui.Model +import java.util.* +import javax.servlet.http.HttpServletResponse + +fun <T> deleteInstance(id: String, instanceName: String, jpaService: CinemaServices<T>, response: HttpServletResponse): String? { + var responseString: String? = null + try { + val itemId = UUID.fromString(id) + val user = jpaService.findById(itemId) + if (null != user) jpaService.delete(user) + else { + response.status = HttpServletResponse.SC_NOT_FOUND + responseString = "$instanceName was not Found" + } + } catch (e: IllegalArgumentException) { + response.status = HttpServletResponse.SC_BAD_REQUEST + responseString = e.localizedMessage + } + return responseString +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/CinemaApiController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/CinemaApiController.kt new file mode 100644 index 0000000000000000000000000000000000000000..c563ba15e501de38f058369e56af12d4795c0156 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/CinemaApiController.kt @@ -0,0 +1,40 @@ +package com.s3ai.corporate_app2.controllers.rest + +import com.s3ai.corporate_app2.Cinema +import com.s3ai.corporate_app2.CinemaService +import com.s3ai.corporate_app2.controllers.deleteInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.web.bind.annotation.* +import java.util.* +import javax.servlet.http.HttpServletResponse +import kotlin.random.Random + +@RestController +@RequestMapping("/api/cinemas") +class CinemaApiController { + @Autowired + lateinit var cinemaService: CinemaService + + @GetMapping("/fill") + fun fillCinemas(): String? { + val locations: List<String> = listOf("Samara", "Izhevsk", "NeoTokyo", "Bangladesh", "Moscow", "Grozny"); + val names: List<String> = listOf("Nol", "Tcelkoviy", "Polushka", "Chekushka", "Osmushka", "Pudovichok", "Mediachok", "Silverchok", "Goldenchok", "Deviatichek", "Desatichek"); + val generatedNames: MutableList<String> = mutableListOf() + for (i in 0..300) { + val cinema = Cinema(); + cinema.id = UUID.randomUUID(); + cinema.name = names.random(); + generatedNames.add(cinema.name.toString()) + cinema.seatsCount = Random.nextInt(50, 300); + cinema.location = locations.random(); + cinemaService.save(cinema); + } + return generatedNames.toString() + } + + @DeleteMapping("/delete") + fun deleteUser(@RequestParam(name = "id", required = true) id: String, response: HttpServletResponse): String? { + return deleteInstance(id, "Cinema", cinemaService, response) + } + +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/TicketApiController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/TicketApiController.kt new file mode 100644 index 0000000000000000000000000000000000000000..439a0457d82fc3b887801b85d25936567c1394b1 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/TicketApiController.kt @@ -0,0 +1,50 @@ +package com.s3ai.corporate_app2.controllers.rest; + +import com.s3ai.corporate_app2.CinemaService +import com.s3ai.corporate_app2.Ticket +import com.s3ai.corporate_app2.TicketService +import com.s3ai.corporate_app2.UserService +import com.s3ai.corporate_app2.controllers.deleteInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.web.bind.annotation.* +import java.util.* +import javax.servlet.http.HttpServletResponse + +@RestController +@RequestMapping("/api/tickets") +class TicketApiController { + @Autowired + lateinit var userService: UserService + @Autowired + lateinit var ticketService: TicketService + @Autowired + lateinit var cinemaService: CinemaService + + @GetMapping("/fill") + fun fillTickets(): String? { + val wordsFirst = arrayOf("Pirates", "Ladies", "Goblins", "Gangsters", "Programmers", "Hackers", "Wrestlers", "Animals", "Guardians") + val wordsSecond = arrayOf("of the", "in", "from") + val wordsThird = arrayOf("Galaxy", "America", "Russia", "Japan", "Ocean", "Deep", "Caribbean", "Matrix", "Internet", "Woods", "Caves") + + val users = userService.findAll() + val cinemas = cinemaService.findAll() + + val generatedNames: MutableList<String> = mutableListOf() + for (i in 0..300) { + val ticket = Ticket(); + ticket.id = UUID.randomUUID(); + ticket.movie = "${wordsFirst.random()} ${wordsSecond.random()} ${wordsThird.random()}"; + generatedNames.add(ticket.movie.toString()) + ticket.user = users.random() + ticket.cinema = cinemas.random() + ticketService.save(ticket); + } + return generatedNames.toString() + } + + @DeleteMapping("/delete") + fun deleteUser(@RequestParam(name = "id", required = true) id: String, response: HttpServletResponse): String? { + return deleteInstance(id, "Ticket", ticketService, response) + } + +} diff --git a/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/UserApiController.kt b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/UserApiController.kt new file mode 100644 index 0000000000000000000000000000000000000000..b9a0a8ca1612c25436ca6f78f8441506a585c79e --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/controllers/rest/UserApiController.kt @@ -0,0 +1,38 @@ +package com.s3ai.corporate_app2.controllers.rest; + +import com.s3ai.corporate_app2.User +import com.s3ai.corporate_app2.UserService +import com.s3ai.corporate_app2.controllers.deleteInstance +import org.springframework.beans.factory.annotation.Autowired +import org.springframework.web.bind.annotation.* +import java.util.* +import javax.servlet.http.HttpServletResponse +import kotlin.random.Random + +@RestController +@RequestMapping("/api/users") +class UserApiController { + @Autowired + lateinit var userService: UserService + + @GetMapping("/fill") + fun fillCinemas(): String? { + val names = arrayOf("Jane", "Mary", "Paul", "Jason", "Keanu", "Andrew", "Joseph", "Jotaro", "Ivan", "Jolyne", "Walther"); + val surnames = arrayOf("Doe", "Reeves", "Statham", "Bourne", "Joestar", "Kujoh", "White", "Van Hallen", "Black", "Smith"); + val generatedNames: MutableList<String> = mutableListOf() + for (i in 0..300) { + val user = User(); + user.id = UUID.randomUUID(); + user.name = "${names.random()} ${surnames.random()}"; + generatedNames.add(user.name.toString()) + user.age = Random.nextInt(15, 70); + userService.save(user); + } + return generatedNames.toString() + } + + @DeleteMapping("/delete") + fun deleteUser(@RequestParam(name = "id", required = true) id: String, response: HttpServletResponse): String? { + return deleteInstance(id, "User", userService, response) + } +} diff --git a/src/main/kotlin/com/s3ai/corporate_app2/entities.kt b/src/main/kotlin/com/s3ai/corporate_app2/entities.kt new file mode 100644 index 0000000000000000000000000000000000000000..c84b767c4d32aa4b2f9c0b95d054c0d39f6a076f --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/entities.kt @@ -0,0 +1,65 @@ +package com.s3ai.corporate_app2 + +import org.hibernate.annotations.OnDelete +import org.hibernate.annotations.OnDeleteAction +import java.util.* +import javax.persistence.* + +@Entity +@Table(name = "cinema") +class Cinema { + @Id + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.AUTO) + var id: UUID? = null + @Column(name = "name") + var name: String? = null + @Column(name = "seats_count") + var seatsCount: Int? = null + @Column(name = "location") + var location: String? = null + + override fun toString(): String { + return "Cinema{id=$id, name='$name', seatsCount=$seatsCount, location='$location'}" + } + +} + +@Entity +@Table(name = "cinema_user") +class User { + @Id + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.AUTO) + var id: UUID? = null + @Column(name = "name") + var name: String? = null + @Column(name = "age") + var age: Int? = null + + override fun toString(): String { + return "User{id=$id, name='$name', age=$age}" + } +} + +@Entity +@Table(name = "ticket") +class Ticket { + @Id + @Column(name = "ID") + @GeneratedValue(strategy = GenerationType.AUTO) + var id: UUID? = null + @OneToOne + @OnDelete(action = OnDeleteAction.CASCADE) + var user: User? = null + @OneToOne + @OnDelete(action = OnDeleteAction.CASCADE) + var cinema: Cinema? = null + @Column(name = "movie") + var movie: String? = null + + override fun toString(): String { + return "Ticket{id=$id, user=$user, cinema=$cinema, movie='$movie'}" + } +} + diff --git a/src/main/kotlin/com/s3ai/corporate_app2/entities/Cinema.kt b/src/main/kotlin/com/s3ai/corporate_app2/entities/Cinema.kt deleted file mode 100644 index 582729c19e32c67b90ed79e12ca17e999ddb2dc8..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/entities/Cinema.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.s3ai.corporate_app2.entities - -import java.util.* -import javax.persistence.* - -@Entity -@Table(name = "cinema") -class Cinema { - @Id - @Column(name = "ID") - @GeneratedValue(strategy = GenerationType.AUTO) - var id: UUID? = null - @Column(name = "name") - var name: String? = null - @Column(name = "seats_count") - var seatsCount: Int? = null - @Column(name = "location") - var location: String? = null - - override fun toString(): String { - return "Cinema{id=$id, name='$name', seatsCount=$seatsCount, location='$location'}" - } - -} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/entities/Ticket.kt b/src/main/kotlin/com/s3ai/corporate_app2/entities/Ticket.kt deleted file mode 100644 index 0a2417942d17b4edd0370f8cbbe1a96dde2a0be8..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/entities/Ticket.kt +++ /dev/null @@ -1,24 +0,0 @@ -package com.s3ai.corporate_app2.entities - -import java.util.* -import javax.persistence.* - -@Entity -@Table(name = "ticket") -class Ticket { - @Id - @Column(name = "ID") - @GeneratedValue(strategy = GenerationType.AUTO) - var id: UUID? = null - @OneToOne - private var user: User? = null - @OneToOne - var cinema: Cinema? = null - @Column(name = "movie") - var movie: String? = null - - override fun toString(): String { - return "Ticket{id=$id, user=$user, cinema=$cinema, movie='$movie'}" - } -} - diff --git a/src/main/kotlin/com/s3ai/corporate_app2/entities/User.kt b/src/main/kotlin/com/s3ai/corporate_app2/entities/User.kt deleted file mode 100644 index a9b7fe0256e63e8e9879dbbd24b09a9b412f9703..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/entities/User.kt +++ /dev/null @@ -1,21 +0,0 @@ -package com.s3ai.corporate_app2.entities - -import java.util.* -import javax.persistence.* - -@Entity -@Table(name = "cinema_user") -class User { - @Id - @Column(name = "ID") - @GeneratedValue(strategy = GenerationType.AUTO) - var id: UUID? = null - @Column(name = "name") - var name: String? = null - @Column(name = "age") - var age: Int? = null - - override fun toString(): String { - return "User{id=$id, name='$name', age=$age}" - } -} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/repos/TicketRepository.kt b/src/main/kotlin/com/s3ai/corporate_app2/repos/TicketRepository.kt deleted file mode 100644 index 02b5fda8f5ee542c353ad2b349e55fb17bed22b9..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/repos/TicketRepository.kt +++ /dev/null @@ -1,11 +0,0 @@ -package com.s3ai.corporate_app2.repos - -import com.s3ai.corporate_app2.entities.Ticket -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.stereotype.Repository -import java.util.* - -@Repository -interface TicketRepository : JpaRepository<Ticket, UUID> { - -} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/repos/UserRepository.kt b/src/main/kotlin/com/s3ai/corporate_app2/repos/UserRepository.kt deleted file mode 100644 index 3677813b906b3280da1a12f1c9ba683046ba9339..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/repos/UserRepository.kt +++ /dev/null @@ -1,12 +0,0 @@ -package com.s3ai.corporate_app2.repos - -import com.s3ai.corporate_app2.entities.User -import org.springframework.data.jpa.repository.JpaRepository -import org.springframework.stereotype.Repository -import java.util.* - - -@Repository -interface UserRepository : JpaRepository<User, UUID> { - -} diff --git a/src/main/kotlin/com/s3ai/corporate_app2/repos/CinemaRepository.kt b/src/main/kotlin/com/s3ai/corporate_app2/repositories.kt similarity index 52% rename from src/main/kotlin/com/s3ai/corporate_app2/repos/CinemaRepository.kt rename to src/main/kotlin/com/s3ai/corporate_app2/repositories.kt index cccc402833d74139e978599b09629681775ef5c4..6077d0af27e30232e62504301f20b3cf4d1769ac 100644 --- a/src/main/kotlin/com/s3ai/corporate_app2/repos/CinemaRepository.kt +++ b/src/main/kotlin/com/s3ai/corporate_app2/repositories.kt @@ -1,6 +1,5 @@ -package com.s3ai.corporate_app2.repos +package com.s3ai.corporate_app2 -import com.s3ai.corporate_app2.entities.Cinema import org.springframework.data.jpa.repository.JpaRepository import org.springframework.stereotype.Repository import java.util.* @@ -9,4 +8,15 @@ import java.util.* @Repository interface CinemaRepository : JpaRepository<Cinema, UUID> { -} \ No newline at end of file +} + +@Repository +interface TicketRepository : JpaRepository<Ticket, UUID> { + +} + + +@Repository +interface UserRepository : JpaRepository<User, UUID> { + +} diff --git a/src/main/kotlin/com/s3ai/corporate_app2/services.kt b/src/main/kotlin/com/s3ai/corporate_app2/services.kt new file mode 100644 index 0000000000000000000000000000000000000000..51cf0fbcd93065f44c259907c8861916d8f35ad9 --- /dev/null +++ b/src/main/kotlin/com/s3ai/corporate_app2/services.kt @@ -0,0 +1,36 @@ +package com.s3ai.corporate_app2 + +import org.springframework.stereotype.Service +import java.util.* + + +interface CinemaServices<T> { + fun findAll(): MutableList<T> + fun findById(id: UUID): T? + fun save(item: T): T + fun delete(item: T) +} + +@Service +class CinemaService(private val cinemaRepository: CinemaRepository) : CinemaServices<Cinema> { + override fun findAll(): MutableList<Cinema> = cinemaRepository.findAll() + override fun findById(id: UUID): Cinema? = cinemaRepository.findById(id).orElse(null) + override fun save(item: Cinema): Cinema = cinemaRepository.save(item) + override fun delete(item: Cinema) = cinemaRepository.delete(item) +} + +@Service +class UserService(private val userRepository: UserRepository) : CinemaServices<User> { + override fun findAll(): MutableList<User> = userRepository.findAll() + override fun findById(id: UUID): User? = userRepository.findById(id).orElse(null) + override fun save(item: User): User = userRepository.save(item) + override fun delete(item: User) = userRepository.delete(item) +} + +@Service +class TicketService(private val ticketRepository: TicketRepository) : CinemaServices<Ticket> { + override fun findAll(): MutableList<Ticket> = ticketRepository.findAll() + override fun findById(id: UUID): Ticket? = ticketRepository.findById(id).orElse(null) + override fun save(item: Ticket): Ticket = ticketRepository.save(item) + override fun delete(item: Ticket) = ticketRepository.delete(item) +} \ No newline at end of file diff --git a/src/main/kotlin/com/s3ai/corporate_app2/services/CinemaService.kt b/src/main/kotlin/com/s3ai/corporate_app2/services/CinemaService.kt deleted file mode 100644 index 9a1b8fd27dc89557ff90659cfbf8863f4fbc0350..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/services/CinemaService.kt +++ /dev/null @@ -1,19 +0,0 @@ -package com.s3ai.corporate_app2.services - -import com.s3ai.corporate_app2.entities.Cinema -import com.s3ai.corporate_app2.repos.CinemaRepository -import org.springframework.stereotype.Service -import java.util.* - - -@Service -class CinemaService(private val cinemaRepository: CinemaRepository) { - - fun findAll(): MutableList<Cinema> = cinemaRepository.findAll() - - fun findOne(id: UUID): Cinema? = cinemaRepository.findById(id).orElse(null) - - fun save(cinema: Cinema) = cinemaRepository.save(cinema) - - fun delete(cinema: Cinema) = cinemaRepository.delete(cinema) -} diff --git a/src/main/kotlin/com/s3ai/corporate_app2/services/TicketService.kt b/src/main/kotlin/com/s3ai/corporate_app2/services/TicketService.kt deleted file mode 100644 index 36f201638c442d4cf281bf34462ac7b23db3c2aa..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/services/TicketService.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.s3ai.corporate_app2.services - -import com.s3ai.corporate_app2.entities.Ticket -import com.s3ai.corporate_app2.repos.TicketRepository -import org.springframework.stereotype.Service -import java.util.* - -@Service -class TicketService(private val ticketRepository: TicketRepository) { - - fun findAll(): MutableList<Ticket> = ticketRepository.findAll() - - fun findOne(id: UUID): Ticket? = ticketRepository.findById(id).orElse(null) - - fun save(ticket: Ticket) = ticketRepository.save(ticket) - - fun delete(ticket: Ticket) = ticketRepository.delete(ticket) -} diff --git a/src/main/kotlin/com/s3ai/corporate_app2/services/UserService.kt b/src/main/kotlin/com/s3ai/corporate_app2/services/UserService.kt deleted file mode 100644 index fa212be334160c5f9f4fe443fc767bda9c31d11b..0000000000000000000000000000000000000000 --- a/src/main/kotlin/com/s3ai/corporate_app2/services/UserService.kt +++ /dev/null @@ -1,18 +0,0 @@ -package com.s3ai.corporate_app2.services - -import com.s3ai.corporate_app2.entities.User -import com.s3ai.corporate_app2.repos.UserRepository -import org.springframework.stereotype.Service -import java.util.* - -@Service -class UserService(private val userRepository: UserRepository) { - - fun findAll(): MutableList<User> = userRepository.findAll() - - fun findOne(id: UUID): User? = userRepository.findById(id).orElse(null) - - fun save(user: User) = userRepository.save(user) - - fun delete(user: User) = userRepository.delete(user) -} \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 4870cd859b37719de78c88e25902686a74985dbb..2b046747b6b61873c2a783b6c5240ea6750b4f25 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,6 +1,6 @@ spring.thymeleaf.cache=false spring.datasource.driver-class-name=org.postgresql.Driver -spring.datasource.url=jdbc:postgresql://corporate_db2:5432/cinema?useSSL=false +spring.datasource.url=jdbc:postgresql://corporate_db2:5432/cinema spring.datasource.username=postgres spring.datasource.password=postgres spring.datasource.platform=postgres diff --git a/src/main/resources/static/coffee/cinemas.coffee b/src/main/resources/static/coffee/cinemas.coffee index 6c22ba16dfd0ab22f8da0f56a69d4e7f30f5f1e6..1bfc976f7858b3c65534856153b83e817b6c6dab 100644 --- a/src/main/resources/static/coffee/cinemas.coffee +++ b/src/main/resources/static/coffee/cinemas.coffee @@ -10,15 +10,19 @@ fill_modal = (event) -> hrefToEdit = (event) -> cinema_id = $("#modal_id").text() - window.location.replace "#{context_url}/cinema/?id=#{cinema_id}" + window.location.replace "/cinemas/edit?id=#{cinema_id}" removeCinema = (event) -> cinema_id = $("#modal_id").text() $.ajax - url: "#{context_url}/cinema/?id=#{cinema_id}", + url: "/api/cinemas/delete?id=#{cinema_id}", type: 'DELETE' error: (jqXHR, textStatus, errorThrown) -> - console.log "AJAX Error: #{textStatus}" + $.toast + icon: 'error', + hideAfter: 5000, + heading: "Cannot delete cinema", + text: "#{jqXHR.responseText}" success: (data, textStatus, jqXHR) -> $("tr[cinema_id='#{cinema_id}").remove() $("#cinemaModal").modal('toggle') diff --git a/src/main/resources/static/coffee/tickets.coffee b/src/main/resources/static/coffee/tickets.coffee new file mode 100644 index 0000000000000000000000000000000000000000..c643493bb6e5a13c0760fe8770206a53bae0e633 --- /dev/null +++ b/src/main/resources/static/coffee/tickets.coffee @@ -0,0 +1,35 @@ +fill_modal = (event) -> + target = $(this) + ticket_id = target.attr 'ticket_id' + if undefined != ticket_id and "" != ticket_id + $("#modal_id").text ticket_id + $("#modal_movie").text target.find("[attr_name='movie']").text() + $("#modal_cinema_id").text target.find("[attr_name='cinema_id']").text() + $("#modal_user_id").text target.find("[attr_name='user_id']").text() + $("#ticketModal").modal('toggle') + +hrefToEdit = (event) -> + ticket_id = $("#modal_id").text() + window.location.replace "/tickets/edit?id=#{ticket_id}" + +removeCinema = (event) -> + ticket_id = $("#modal_id").text() + $.ajax + url: "/api/tickets/delete?id=#{ticket_id}", + type: 'DELETE' + error: (jqXHR, textStatus, errorThrown) -> + $.toast + icon: 'error', + hideAfter: 5000, + heading: "Cannot delete ticket", + text: "#{jqXHR.responseText}" + success: (data, textStatus, jqXHR) -> + $("tr[ticket_id='#{ticket_id}").remove() + $("#ticketModal").modal('toggle') + +addListeners = -> + $('tr').on 'click', fill_modal + $('#edit_ticket').on 'click', hrefToEdit + $('#delete_ticket').on 'click', removeCinema + +$(document).ready(addListeners) \ No newline at end of file diff --git a/src/main/resources/static/coffee/users.coffee b/src/main/resources/static/coffee/users.coffee index fb94baab59719ba3595ae0589893b349314f50ce..f9f187903ec8aa65bc073e2781c2f5aeb40843ca 100644 --- a/src/main/resources/static/coffee/users.coffee +++ b/src/main/resources/static/coffee/users.coffee @@ -9,12 +9,12 @@ fill_modal = (event) -> hrefToEdit = (event) -> user_id = $("#modal_id").text() - window.location.replace "#{context_url}/user/?id=#{user_id}" + window.location.replace "/users/edit?id=#{user_id}" removeCinema = (event) -> user_id = $("#modal_id").text() $.ajax - url: "#{context_url}/user/?id=#{user_id}", + url: "/api/users/delete?id=#{user_id}", type: 'DELETE' error: (jqXHR, textStatus, errorThrown) -> $.toast diff --git a/src/main/resources/static/css/index.css b/src/main/resources/static/css/index.css index 0d8791aa278c2eebbf7a3f654016ea9d3fecbd08..79b008c550bff37ac8c7db2abae76b27120068cc 100644 --- a/src/main/resources/static/css/index.css +++ b/src/main/resources/static/css/index.css @@ -1 +1 @@ -.projects-section{padding:10rem 0;background:linear-gradient(to top, #161616 0%, rgba(22, 22, 22, 0.9) 75%, rgba(22, 22, 22, 0.8) 100%)}.projects-section .featured-text{padding:2rem}@media(min-width: 992px){.projects-section .featured-text{padding:0 0 0 2rem;border-left:.5rem solid #64a19d}}.projects-section .project-text{padding:3rem;font-size:90%}@media(min-width: 992px){.projects-section .project-text{padding:5rem}.projects-section .project-text hr{border-color:#64a19d;border-width:.25rem;width:30%}}.masthead{object-fit:cover !important;text-align:center !important;background-repeat:no-repeat !important;background-attachment:fixed !important;background-position:center !important}.masthead .white{color:#fff}.hide-y{overflow-y:hidden}.landing-info-row{height:100px}.landing-info-row .landing-info-image{height:100px;object-fit:cover;width:100%;text-align:center;background-repeat:no-repeat;background-attachment:fixed;background-position:center}.masthead{position:relative;width:100%;height:auto;min-height:35rem;padding:15rem 0;background-position:center;background-repeat:no-repeat;background-attachment:scroll;background-size:cover}.masthead h1{font-family:"Varela Round";font-size:2.5rem;line-height:2.5rem;letter-spacing:.8rem;background:-webkit-linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));-webkit-text-fill-color:transparent;-webkit-background-clip:text}.masthead h2{max-width:20rem;font-size:1rem}@media(min-width: 768px){.masthead h1{font-size:4rem;line-height:4rem}}@media(min-width: 992px){.masthead{height:100vh;padding:0}.masthead h1{font-size:6.5rem;line-height:6.5rem;letter-spacing:.8rem}.masthead h2{max-width:30rem;font-size:1.25rem}}.contact-section{padding:5rem 0 0}.contact-section .card{border:0;border-bottom:.25rem solid #64a19d}.contact-section .card h4{font-size:.8rem;font-family:"Varela Round";text-transform:uppercase;letter-spacing:.15rem}.contact-section .card hr{border-color:#64a19d;border-width:.25rem;width:3rem}.contact-section .social{margin-top:5rem}.contact-section .social a{text-align:center;height:3rem;width:3rem;background:rgba(255,255,255,.1);border-radius:100%;line-height:3rem;color:rgba(255,255,255,.3)}.contact-section .social a:hover{color:rgba(255,255,255,.5)}.contact-section .social a:active{color:#fff}.btn{box-shadow:0 .1875rem .1875rem 0 rgba(0,0,0,.1) !important;padding:1.25rem 2rem;font-family:"Varela Round";font-size:80%;text-transform:uppercase;letter-spacing:.15rem;border:0}.btn-primary{background-color:#64a19d}.btn-primary:hover{background-color:#4f837f}.btn-primary:focus{background-color:#4f837f;color:#fff}.btn-primary:active{background-color:#467370 !important}.about-section{padding-top:10rem;background:linear-gradient(to bottom, #161616 0%, rgba(22, 22, 22, 0.9) 75%, rgba(22, 22, 22, 0.8) 100%)}.about-section p{margin-bottom:5rem}/*# sourceMappingURL=index.css.map */ +.index-gradient{background:linear-gradient(to bottom, #283048 0%, #859398 100%)}.projects-section{padding:10rem 0}.projects-section .featured-text{padding:2rem}@media(min-width: 992px){.projects-section .featured-text{padding:0 0 0 2rem;border-left:.5rem solid #64a19d}}.projects-section .project-text{padding:3rem;font-size:90%}@media(min-width: 992px){.projects-section .project-text{padding:5rem}.projects-section .project-text hr{border-color:#64a19d;border-width:.25rem;width:30%}}.masthead{object-fit:cover !important;text-align:center !important;background-repeat:no-repeat !important;background-attachment:fixed !important;background-position:center !important}.masthead .white{color:#fff}.hide-y{overflow-y:hidden}.landing-info-row{height:100px}.landing-info-row .landing-info-image{height:100px;object-fit:cover;width:100%;text-align:center;background-repeat:no-repeat;background-attachment:fixed;background-position:center}.masthead{position:relative;width:100%;height:auto;min-height:35rem;padding:15rem 0;background-position:center;background-repeat:no-repeat;background-attachment:scroll;background-size:cover}.masthead h1{font-family:"Varela Round";font-size:2.5rem;line-height:2.5rem;letter-spacing:.8rem;background:-webkit-linear-gradient(rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0));-webkit-text-fill-color:transparent;-webkit-background-clip:text}.masthead h2{max-width:20rem;font-size:1rem}@media(min-width: 768px){.masthead h1{font-size:4rem;line-height:4rem}}@media(min-width: 992px){.masthead{height:100vh;padding:0}.masthead h1{font-size:6.5rem;line-height:6.5rem;letter-spacing:.8rem}.masthead h2{max-width:30rem;font-size:1.25rem}}.contact-section{padding:5rem 0 0}.contact-section .card{border:0;border-bottom:.25rem solid #64a19d}.contact-section .card h4{font-size:.8rem;font-family:"Varela Round";text-transform:uppercase;letter-spacing:.15rem}.contact-section .card hr{border-color:#64a19d;border-width:.25rem;width:3rem}.contact-section .social{margin-top:5rem}.contact-section .social a{text-align:center;height:3rem;width:3rem;background:rgba(255,255,255,.1);border-radius:100%;line-height:3rem;color:rgba(255,255,255,.3)}.contact-section .social a:hover{color:rgba(255,255,255,.5)}.contact-section .social a:active{color:#fff}.btn{box-shadow:0 .1875rem .1875rem 0 rgba(0,0,0,.1) !important;padding:1.25rem 2rem;font-family:"Varela Round";font-size:80%;text-transform:uppercase;letter-spacing:.15rem;border:0}.btn-primary{background-color:#64a19d}.btn-primary:hover{background-color:#4f837f}.btn-primary:focus{background-color:#4f837f;color:#fff}.btn-primary:active{background-color:#467370 !important}.about-section{padding-top:10rem}.about-section p{margin-bottom:5rem}/*# sourceMappingURL=index.css.map */ diff --git a/src/main/resources/static/css/index.css.map b/src/main/resources/static/css/index.css.map index f94fd252f1eb925e65c4561e0e865d903de7cdd3..9ac3852f1b4d1977e141e9a81bcddcabe1af39ee 100644 --- a/src/main/resources/static/css/index.css.map +++ b/src/main/resources/static/css/index.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../scss/index.scss","../scss/_variables.scss"],"names":[],"mappings":"AAEA,kBACE,gBACA,sGAEA,iCACE,aACA,yBAFF,iCAGI,mBACA,iCAIJ,gCACE,aACA,cACA,yBAHF,gCAII,aACA,mCACE,aCRE,QDSF,oBACA,WAOR,UACE,4BACA,6BACA,uCACA,uCACA,sCAEA,iBACE,WAKJ,QACE,kBAGF,kBACE,aAEA,sCACE,aACA,iBACA,WACA,kBACA,4BACA,4BACA,2BAIJ,UACE,kBACA,WACA,YACA,iBACA,gBACA,2BACA,4BACA,6BACA,sBAEA,aACE,2BACA,iBACA,mBACA,qBACA,qFACA,oCACA,6BAGF,aACE,gBACA,eAGF,yBACE,aACE,eACA,kBAGJ,yBAhCF,UAiCI,aACA,UACA,aACE,iBACA,mBACA,qBAEF,aACE,gBACA,mBAKN,iBACE,iBAEA,uBACE,SACA,mCAEA,0BACE,gBACA,2BACA,yBACA,sBAGF,0BACE,aC9GI,QD+GJ,oBACA,WAIJ,yBACE,gBAEA,2BACE,kBACA,YACA,WACA,gCACA,mBACA,iBACA,2BAEA,iCACE,2BAGF,kCACE,MCjJA,KDuJR,KACE,2DACA,qBACA,2BACA,cACA,yBACA,sBACA,SAGF,aACE,iBCtJQ,QDwJR,mBACE,yBAGF,mBACE,yBACA,WAGF,oBACE,oCAIJ,eACE,kBACA,yGAEA,iBACE","file":"index.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../scss/index.scss","../scss/_variables.scss"],"names":[],"mappings":"AAEA,gBACE,gEAGF,kBACE,gBAEA,iCACE,aACA,yBAFF,iCAGI,mBACA,iCAIJ,gCACE,aACA,cACA,yBAHF,gCAII,aACA,mCACE,aCXE,QDYF,oBACA,WAOR,UACE,4BACA,6BACA,uCACA,uCACA,sCAEA,iBACE,WAKJ,QACE,kBAGF,kBACE,aAEA,sCACE,aACA,iBACA,WACA,kBACA,4BACA,4BACA,2BAIJ,UACE,kBACA,WACA,YACA,iBACA,gBACA,2BACA,4BACA,6BACA,sBAEA,aACE,2BACA,iBACA,mBACA,qBACA,qFACA,oCACA,6BAGF,aACE,gBACA,eAGF,yBACE,aACE,eACA,kBAGJ,yBAhCF,UAiCI,aACA,UACA,aACE,iBACA,mBACA,qBAEF,aACE,gBACA,mBAKN,iBACE,iBAEA,uBACE,SACA,mCAEA,0BACE,gBACA,2BACA,yBACA,sBAGF,0BACE,aCjHI,QDkHJ,oBACA,WAIJ,yBACE,gBAEA,2BACE,kBACA,YACA,WACA,gCACA,mBACA,iBACA,2BAEA,iCACE,2BAGF,kCACE,MCpJA,KD0JR,KACE,2DACA,qBACA,2BACA,cACA,yBACA,sBACA,SAGF,aACE,iBCzJQ,QD2JR,mBACE,yBAGF,mBACE,yBACA,WAGF,oBACE,oCAIJ,eACE,kBAEA,iBACE","file":"index.css"} \ No newline at end of file diff --git a/src/main/resources/static/js/cinemas.js b/src/main/resources/static/js/cinemas.js index 46c7d97974aeef1b8445a536bb46bdca77d3f12c..09e31cbaae521b51fd8b75ed26f92a466660cf81 100644 --- a/src/main/resources/static/js/cinemas.js +++ b/src/main/resources/static/js/cinemas.js @@ -18,17 +18,22 @@ hrefToEdit = function(event) { var cinema_id; cinema_id = $("#modal_id").text(); - return window.location.replace(`${context_url}/cinema/?id=${cinema_id}`); + return window.location.replace(`/cinemas/edit?id=${cinema_id}`); }; removeCinema = function(event) { var cinema_id; cinema_id = $("#modal_id").text(); return $.ajax({ - url: `${context_url}/cinema/?id=${cinema_id}`, + url: `/api/cinemas/delete?id=${cinema_id}`, type: 'DELETE', error: function(jqXHR, textStatus, errorThrown) { - return console.log(`AJAX Error: ${textStatus}`); + return $.toast({ + icon: 'error', + hideAfter: 5000, + heading: "Cannot delete cinema", + text: `${jqXHR.responseText}` + }); }, success: function(data, textStatus, jqXHR) { $(`tr[cinema_id='${cinema_id}`).remove(); diff --git a/src/main/resources/static/js/tickets.js b/src/main/resources/static/js/tickets.js new file mode 100644 index 0000000000000000000000000000000000000000..14c63cf4764c9413ec5431a2f85239f63a1e1653 --- /dev/null +++ b/src/main/resources/static/js/tickets.js @@ -0,0 +1,53 @@ +// Generated by CoffeeScript 2.4.1 +(function() { + var addListeners, fill_modal, hrefToEdit, removeCinema; + + fill_modal = function(event) { + var target, ticket_id; + target = $(this); + ticket_id = target.attr('ticket_id'); + if (void 0 !== ticket_id && "" !== ticket_id) { + $("#modal_id").text(ticket_id); + $("#modal_movie").text(target.find("[attr_name='movie']").text()); + $("#modal_cinema_id").text(target.find("[attr_name='cinema_id']").text()); + $("#modal_user_id").text(target.find("[attr_name='user_id']").text()); + return $("#ticketModal").modal('toggle'); + } + }; + + hrefToEdit = function(event) { + var ticket_id; + ticket_id = $("#modal_id").text(); + return window.location.replace(`/tickets/edit?id=${ticket_id}`); + }; + + removeCinema = function(event) { + var ticket_id; + ticket_id = $("#modal_id").text(); + return $.ajax({ + url: `/api/tickets/delete?id=${ticket_id}`, + type: 'DELETE', + error: function(jqXHR, textStatus, errorThrown) { + return $.toast({ + icon: 'error', + hideAfter: 5000, + heading: "Cannot delete ticket", + text: `${jqXHR.responseText}` + }); + }, + success: function(data, textStatus, jqXHR) { + $(`tr[ticket_id='${ticket_id}`).remove(); + return $("#ticketModal").modal('toggle'); + } + }); + }; + + addListeners = function() { + $('tr').on('click', fill_modal); + $('#edit_ticket').on('click', hrefToEdit); + return $('#delete_ticket').on('click', removeCinema); + }; + + $(document).ready(addListeners); + +}).call(this); diff --git a/src/main/resources/static/js/users.js b/src/main/resources/static/js/users.js index 6bc7f754a0d4a2def305abe22354942902baf284..c21c7c44077e2f74162c8584fcb12cdd5bab8ca6 100644 --- a/src/main/resources/static/js/users.js +++ b/src/main/resources/static/js/users.js @@ -17,14 +17,14 @@ hrefToEdit = function(event) { var user_id; user_id = $("#modal_id").text(); - return window.location.replace(`${context_url}/user/?id=${user_id}`); + return window.location.replace(`/users/edit?id=${user_id}`); }; removeCinema = function(event) { var user_id; user_id = $("#modal_id").text(); return $.ajax({ - url: `${context_url}/user/?id=${user_id}`, + url: `/api/users/delete?id=${user_id}`, type: 'DELETE', error: function(jqXHR, textStatus, errorThrown) { return $.toast({ diff --git a/src/main/resources/static/scss/index.scss b/src/main/resources/static/scss/index.scss index 3e5d20116f7c568be6ec380feb282823fbf17cc8..df6e51780e4d1801df654d68371a509334e2e200 100644 --- a/src/main/resources/static/scss/index.scss +++ b/src/main/resources/static/scss/index.scss @@ -1,8 +1,11 @@ @import "variables"; +.index-gradient { + background: linear-gradient(to bottom, #283048 0%, #859398 100%); +} + .projects-section { padding: 10rem 0; - background: linear-gradient(to top, $black 0%, #{fade-out($black, .1)} 75%, #{fade-out($black, .2)} 100%); .featured-text { padding: 2rem; @@ -178,7 +181,6 @@ .about-section { padding-top: 10rem; - background: linear-gradient(to bottom, $black 0%, #{fade-out($black, .1)} 75%, #{fade-out($black, .2)} 100%); p { margin-bottom: 5rem; diff --git a/src/main/resources/templates/cinemas/edit.html b/src/main/resources/templates/cinemas/edit.html index 3ed52e3b8424d5298e876982c6d502e87da45db6..2607fe439dfa7c354ebc5cc51d43ca6057fb616c 100644 --- a/src/main/resources/templates/cinemas/edit.html +++ b/src/main/resources/templates/cinemas/edit.html @@ -1,10 +1,77 @@ -<!DOCTYPE html> -<html lang="en"> +<html xmlns:th="http://www.thymeleaf.org"> <head> - <meta charset="UTF-8"> - <title>Cinema edit</title> + <title>Edit cinema</title> + <head th:include="commons/imports"></head> + <link rel="stylesheet" href="/css/cinemas.css"> + <script src="/js/cinemas.js"></script> </head> -<body> -Editing +<body class="themed-gradient"> + +<!-- Navigation --> +<body th:include="commons/header"></body> + +<div class="editing"> + <div class="container justify-content-center"> + + <form id="cinemaForm" class="d-flex justify-content-center" th:object="${cinema}" method="post" action="/cinemas/update"> + <fieldset> + + <legend> + <div class="text-center"><h2><b class="white" th:text="${action} + ' cinema'"></b></h2></div> + </legend> + <br> + <input type="hidden" name="id" th:field="*{id}"> + + <div class="form-group"> + <div class="inputGroupContainer"> + <div class="input-group"> + <div class="input-group-prepend"> + <div class="input-group-text"><i class="fas fa-align-left"></i></div> + </div> + <input type="text" + class="form-control validate" + id="cinemaName" + name="name" + placeholder="Cinema's name" th:field="*{name}" required> + </div> + </div> + </div> + <div class="form-group"> + <div class="inputGroupContainer"> + <div class="input-group"> + <div class="input-group-prepend"> + <div class="input-group-text"><i class="fas fa-chair"></i></div> + </div> + <input type="number" + class="form-control validate" + id="cinemaSeats" + name="seatsCount" + placeholder="Cinema's seats count" + th:field="*{seatsCount}" required> + </div> + </div> + </div> + <div class="form-group"> + <div class="inputGroupContainer"> + <div class="input-group"> + <div class="input-group-prepend"> + <div class="input-group-text"><i class="fas fa-globe-americas"></i></div> + </div> + <input type="text" + class="form-control validate" + id="cinemaLocation" + name="location" + placeholder="Cinema's location" + th:field="*{location}" required> + </div> + </div> + </div> + <div class="justify-content-center"> + <button type="submit" class="btn btn-primary w-100"><i class="fas fa-check"></i>Submit</button> + </div> + </fieldset> + </form> + </div> +</div> </body> -</html> \ No newline at end of file +</html> diff --git a/src/main/resources/templates/cinemas/list.html b/src/main/resources/templates/cinemas/list.html index 6976b4dd23be241e2ca8ca8c6df804ae61c579a7..3993917cce3846009fbc086868b58efb1df6756d 100644 --- a/src/main/resources/templates/cinemas/list.html +++ b/src/main/resources/templates/cinemas/list.html @@ -1,10 +1,77 @@ -<!DOCTYPE html> -<html lang="en"> +<html xmlns:th="http://www.thymeleaf.org"> <head> - <meta charset="UTF-8"> - <title>Title</title> + <title>Cinemas list</title> + <link rel="stylesheet" href="/css/cinemas.css"> + <head th:include="commons/imports"></head> </head> -<body> -Listing +<body class="themed-gradient"> +<body th:include="commons/header"></body> +<div class="container-fluid"> + <div class="row table-padding justify-content-center"> + <table class="table shadow col-6 table-striped table-dark"> + <thead> + <tr> + <th scope="col">#</th> + <th scope="col">Name</th> + <th scope="col">Location</th> + <th scope="col">Seats count</th> + </tr> + </thead> + <tbody> + <tr th:attr="cinema_id=${cinema.getId()}" th:each="cinema, counter : ${cinemas}"> + <td th:text="${counter.count}" >#</td> + <td attr_name="name" th:text="${cinema.getName()}">Name</td> + <td attr_name="location" th:text="${cinema.getLocation()}">Location</td> + <td attr_name="seats" th:text="${cinema.getSeatsCount()}">Seats</td> + </tr> + </tbody> + </table> + </div> + <div class="modal fade" id="cinemaModal" tabindex="-1" role="dialog" + aria-labelledby="cinemaModalTitle" aria-hidden="true"> + <div class="modal-dialog modal-dialog-centered" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="exampleModalLongTitle">Cinema info</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body"> + <div class="d-flex flex-column"> + <div class="d-flex flex-row justify-content-between"> + <p>ID:</p> + <p id="modal_id"></p> + </div> + <div class="d-flex flex-row justify-content-between"> + <p>Name:</p> + <p id="modal_name"></p> + </div> + <div class="d-flex flex-row justify-content-between"> + <p>Location:</p> + <p id="modal_location">value</p> + </div> + <div class="d-flex flex-row justify-content-between"> + <p>Seats count:</p> + <p id="modal_seats">value</p> + </div> + </div> + </div> + <div class="modal-footer"> + <button type="button" id="edit_cinema" class="btn btn-primary"><i class="fas fa-edit"></i> Edit + cinema + </button> + <button type="button" id="delete_cinema" class="btn btn-danger"><i class="fas fa-trash-alt"></i> + Delete cinema + </button> + <button type="button" class="btn btn-secondary" data-dismiss="modal"><i class="fas fa-times"></i> + Close + </button> + </div> + </div> + </div> + </div> +</div> </body> -</html> \ No newline at end of file +<script src="/js/cinemas.js"></script> +</html> diff --git a/src/main/resources/templates/commons/header.html b/src/main/resources/templates/commons/header.html index 5d8d23e9f39ac111c521dd833e8cd0e2f24bd147..29055b77bc3599e4aac2cb74403e865cc11ceebf 100644 --- a/src/main/resources/templates/commons/header.html +++ b/src/main/resources/templates/commons/header.html @@ -16,8 +16,8 @@ Cinemas </a> <div class="dropdown-menu" aria-labelledby="navbarDropdownCinema"> - <a class="dropdown-item" href="/cinema">Create</a> - <a class="dropdown-item" href="/cinemas">View</a> + <a class="dropdown-item" href="/cinemas/edit">Create</a> + <a class="dropdown-item" href="/cinemas/list">View</a> </div> </li> @@ -27,8 +27,8 @@ Tickets </a> <div class="dropdown-menu" aria-labelledby="navbarDropdownTicket"> - <a class="dropdown-item" href="/ticket">Create</a> - <a class="dropdown-item" href="/tickets">View</a> + <a class="dropdown-item" href="/tickets/edit">Create</a> + <a class="dropdown-item" href="/tickets/list">View</a> </div> </li> @@ -38,8 +38,8 @@ Users </a> <div class="dropdown-menu" aria-labelledby="navbarDropdownUser"> - <a class="dropdown-item" href="/user">Create</a> - <a class="dropdown-item" href="/users">View</a> + <a class="dropdown-item" href="/users/edit">Create</a> + <a class="dropdown-item" href="/users/list">View</a> </div> </li> </ul> diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 9a98bb81fdee4961596fcdd4a5bea82985653feb..119d32b32265537faec8f5577c97b2e52edad740 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -21,80 +21,85 @@ </div> </header> -<!-- About Section --> -<section id="about" class="about-section text-center"> - <div class="container"> - <div class="row"> - <div class="col-lg-8 mx-auto"> - <h2 class="text-white mb-4">Built for Cinema lovers from Cinema lovers</h2> - <p class="text-white-50">Grayscale is a free Bootstrap theme created by Start Bootstrap. It can be yours - right now, simply download the template on - <a href="http://startbootstrap.com/template-overviews/grayscale/">the preview page</a>. The theme is - open source, and you can use it for any purpose, personal or commercial.</p> +<div class="index-gradient"> + <!-- About Section --> + <section id="about" class="about-section text-center"> + <div class="container"> + <div class="row"> + <div class="col-lg-8 mx-auto"> + <h2 class="text-white mb-4">Built for Cinema lovers from Cinema lovers</h2> + <p class="text-white-50">Grayscale is a free Bootstrap theme created by Start Bootstrap. It can be + yours + right now, simply download the template on + <a href="http://startbootstrap.com/template-overviews/grayscale/">the preview page</a>. The + theme is + open source, and you can use it for any purpose, personal or commercial.</p> + </div> </div> </div> - </div> -</section> + </section> -<!-- Projects Section --> -<section id="projects" class="projects-section pt-3 pb-3"> - <div class="container"> + <!-- Projects Section --> + <section id="projects" class="projects-section pt-3 pb-3"> + <div class="container"> - <!-- Featured Project Row --> - <div class="row align-items-center no-gutters mb-4 mb-lg-5 landing-info-row"> - <div class="col-xl-8 col-lg-7"> - <img class="img-fluid mb-3 mb-lg-0 landing-info-image pr-3" - src="/images/landing_tickets.jpg" alt=""> - </div> - <div class="col-xl-4 col-lg-5"> - <div class="featured-text text-center text-lg-left"> - <h4 class="text-white">Tickets management</h4> - <p class="text-white-50 mb-0">Manage your tickets with our self-hosted solution and make your - business profitable.</p> + <!-- Featured Project Row --> + <div class="row align-items-center no-gutters mb-4 mb-lg-5 landing-info-row"> + <div class="col-xl-8 col-lg-7"> + <img class="img-fluid mb-3 mb-lg-0 landing-info-image pr-3" + src="/images/landing_tickets.jpg" alt=""> + </div> + <div class="col-xl-4 col-lg-5"> + <div class="featured-text text-center text-lg-left"> + <h4 class="text-white">Tickets management</h4> + <p class="text-white-50 mb-0">Manage your tickets with our self-hosted solution and make your + business profitable.</p> + </div> </div> </div> - </div> - <!-- Project One Row --> - <div class="row justify-content-center no-gutters mb-5 mb-lg-0"> - <div class="col-lg-6"> - <img class="img-fluid landing-info-image pr-3" - src="/images/landing_cinemas.jpg" alt=""> - </div> - <div class="col-lg-6"> - <div class="bg-black text-center h-100 project"> - <div class="d-flex h-100"> - <div class="project-text w-100 my-auto text-center text-lg-left"> - <h4 class="text-white">Cinemas management</h4> - <p class="mb-0 text-white-50">Manage your remotely</p> + <!-- Project One Row --> + <div class="row justify-content-center no-gutters mb-5 mb-lg-0"> + <div class="col-lg-6"> + <img class="img-fluid landing-info-image pr-3" + src="/images/landing_cinemas.jpg" alt=""> + </div> + <div class="col-lg-6"> + <div class="bg-black text-center h-100 project"> + <div class="d-flex h-100"> + <div class="project-text w-100 my-auto text-center text-lg-left"> + <h4 class="text-white">Cinemas management</h4> + <p class="mb-0 text-white-50">Manage your remotely</p> + </div> </div> </div> </div> </div> - </div> - <!-- Project Two Row --> - <div class="row justify-content-center hide-y no-gutters"> - <div class="col-lg-6"> - <img class="pl-3 img-fluid landing-info-image" - src="/images/landing_users.jpg" alt=""> - </div> - <div class="col-lg-6 order-lg-first"> - <div class="bg-black text-center h-100 project"> - <div class="d-flex h-100"> - <div class="project-text w-100 my-auto text-center text-lg-right"> - <h4 class="text-white">User management</h4> - <p class="mb-0 text-white-50">Another example of a project usage its user management. Our - tool provides you the best interface to add and delete and edit your customers.</p> - <hr class="d-none d-lg-block mb-0 mr-0"> + <!-- Project Two Row --> + <div class="row justify-content-center hide-y no-gutters"> + <div class="col-lg-6"> + <img class="pl-3 img-fluid landing-info-image" + src="/images/landing_users.jpg" alt=""> + </div> + <div class="col-lg-6 order-lg-first"> + <div class="bg-black text-center h-100 project"> + <div class="d-flex h-100"> + <div class="project-text w-100 my-auto text-center text-lg-right"> + <h4 class="text-white">User management</h4> + <p class="mb-0 text-white-50">Another example of a project usage its user management. + Our + tool provides you the best interface to add and delete and edit your customers.</p> + <hr class="d-none d-lg-block mb-0 mr-0"> + </div> </div> </div> </div> </div> - </div> - </div> -</section> + </div> + </section> +</div> <!-- Contact Section --> <section class="contact-section mt-3 bg-black"> diff --git a/src/main/resources/templates/tickets/edit.html b/src/main/resources/templates/tickets/edit.html new file mode 100644 index 0000000000000000000000000000000000000000..45cda4f1407218695b1f0f9bc8a46952f66d7561 --- /dev/null +++ b/src/main/resources/templates/tickets/edit.html @@ -0,0 +1,78 @@ +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <title>Edit ticket</title> + <link rel="stylesheet" href="/css/tickets.css"> + <head th:include="commons/imports"></head> + <script src="/js/tickets.js"></script> +</head> +<body class="themed-gradient"> + +<!-- Navigation --> +<body th:include="commons/header"></body> + +<div class="editing"> + <div class="container justify-content-center"> + + <form id="ticketForm" class="d-flex justify-content-center" method="post" th:object="${ticket}" + action="/tickets/update"> + <fieldset> + + <legend> + <div class="text-center"><h2><b class="white" th:text="${action} + ' ticket'"></b></h2></div> + </legend> + <br> + <input type="hidden" name="id" th:field="*{id}"> + + <div class="form-group"> + <div class="inputGroupContainer"> + <div class="input-group"> + <div class="input-group-prepend"> + <div class="input-group-text"><i class="fas fa-film"></i></div> + </div> + <input type="text" + class="form-control validate" + id="ticketMovie" + name="movie" + placeholder="Movie" th:field="*{movie}" required> + </div> + </div> + </div> + <div class="form-group"> + <div class="inputGroupContainer"> + <div class="input-group"> + <div class="input-group-prepend"> + <div class="input-group-text"><i class="fas fa-kaaba"></i></div> + </div> + <select class="form-control" id="exampleFormControlSelect2" name="cinemaId" + th:field="*{cinema}" required> + <option value="">Cinema</option> + <option th:each="cinemaItem: ${cinemas}" th:value="${cinemaItem.getId()}" + th:text="${cinemaItem.getName()} + ' in ' + ${cinemaItem.getLocation()}"></option> + </select> + </div> + </div> + </div> + <div class="form-group"> + <div class="inputGroupContainer"> + <div class="input-group"> + <div class="input-group-prepend"> + <div class="input-group-text"><i class="fas fa-user-circle"></i></div> + </div> + <select class="form-control" id="userSelect" name="userId" th:field="*{user}" required> + <option value="">User</option> + <option th:each="userItem: ${users}" th:value="${userItem.getId()}" + th:text="${userItem.getName()} + ' aged ' + ${userItem.getAge()}"></option> + </select> + </div> + </div> + </div> + + <div class="justify-content-center"> + <button type="submit" class="btn btn-primary w-100"><i class="fas fa-check"></i>Submit</button> + </div> + </fieldset> + </form> + </div> +</div> +</body> +</html> diff --git a/src/main/resources/templates/tickets/list.html b/src/main/resources/templates/tickets/list.html new file mode 100644 index 0000000000000000000000000000000000000000..2c8cdd943c8c526ae8ab7a899feaec096db3261f --- /dev/null +++ b/src/main/resources/templates/tickets/list.html @@ -0,0 +1,77 @@ +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <title>Tickets list</title> + <link rel="stylesheet" href="/css/tickets.css"> + <head th:include="commons/imports"></head> +</head> +<body class="themed-gradient"> +<body th:include="commons/header"></body> +<div class="container-fluid"> + <div class="row table-padding justify-content-center"> + <table class="table shadow col-6 table-striped table-dark"> + <thead> + <tr> + <th scope="col">#</th> + <th scope="col">Movie</th> + <th scope="col">Cinema</th> + <th scope="col">User</th> + </tr> + </thead> + <tbody th:with="mycounter = 0"> + <tr th:attr="ticket_id=${ticket.getId()}" th:each="ticket, counter: ${tickets}"> + <td th:text="${counter.count}">#</td> + <td attr_name="movie" th:text="${ticket.getMovie()}">Movie</td> + <td attr_name="cinema_id" th:text="${ticket.getCinema().getName()} + ' in ' + ${ticket.getCinema().getLocation()}">Cinema</td> + <td attr_name="user_id" th:text="${ticket.getUser().getName()} + ' aged ' + ${ticket.getUser().getAge()}">User</td> + </tr> + </tbody> + </table> + </div> + <div class="modal fade" id="ticketModal" tabindex="-1" role="dialog" + aria-labelledby="ticketModalTitle" aria-hidden="true"> + <div class="modal-dialog modal-dialog-centered" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="exampleModalLongTitle">Ticket info</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body"> + <div class="d-flex flex-column"> + <div class="d-flex flex-row justify-content-between"> + <p>ID:</p> + <p id="modal_id"></p> + </div> + <div class="d-flex flex-row justify-content-between"> + <p>Movie:</p> + <p id="modal_movie"></p> + </div> + <div class="d-flex flex-row justify-content-between"> + <p>User:</p> + <p id="modal_user_id">value</p> + </div> + <div class="d-flex flex-row justify-content-between"> + <p>Cinema:</p> + <p id="modal_cinema_id">value</p> + </div> + </div> + </div> + <div class="modal-footer"> + <button type="button" id="edit_ticket" class="btn btn-primary"><i class="fas fa-edit"></i> Edit + ticket + </button> + <button type="button" id="delete_ticket" class="btn btn-danger"><i class="fas fa-trash-alt"></i> + Delete ticket + </button> + <button type="button" class="btn btn-secondary" data-dismiss="modal"><i class="fas fa-times"></i> + Close + </button> + </div> + </div> + </div> + </div> +</div> +</body> +<script src="/js/tickets.js"></script> +</html> diff --git a/src/main/resources/templates/users/edit.html b/src/main/resources/templates/users/edit.html new file mode 100644 index 0000000000000000000000000000000000000000..d3e506b081e84fcf5211e49b5c75c6e4a96afc77 --- /dev/null +++ b/src/main/resources/templates/users/edit.html @@ -0,0 +1,62 @@ +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <title>Edit ticket</title> + <head th:include="commons/imports"></head> + <link rel="stylesheet" href="/css/tickets.css"> + <script src="/js/tickets.js"></script> +</head> +<body class="themed-gradient"> + +<!-- Navigation --> +<body th:include="commons/header"></body> +<div class="editing"> + <div class="container justify-content-center"> + + <form id="ticketForm" class="d-flex justify-content-center" method="post" th:object="${user}" + action="/users/update"> + <fieldset> + + <legend> + <div class="text-center"><h2><b class="white" th:text="${action} + ' user'"></b></h2></div> + </legend> + <br> + <input type="hidden" name="id" th:field="*{id}"> + + <div class="form-group"> + <div class="inputGroupContainer"> + <div class="input-group"> + <div class="input-group-prepend"> + <div class="input-group-text"><i class="fas fa-user-circle"></i></div> + </div> + <input type="text" + class="form-control validate" + id="userName" + name="name" + placeholder="Users's name" th:field="*{name}" required> + </div> + </div> + </div> + <div class="form-group"> + <div class="inputGroupContainer"> + <div class="input-group"> + <div class="input-group-prepend"> + <div class="input-group-text"><i class="far fa-calendar"></i></div> + </div> + <input type="number" + class="form-control validate" + id="userAge" + name="age" + placeholder="User's age" + th:field="*{age}" required> + </div> + </div> + </div> + <div class="justify-content-center"> + <button type="submit" class="btn btn-primary w-100"><i class="fas fa-check"></i>Submit</button> + </div> + </fieldset> + </form> + </div> +</div> +</body> +</html> diff --git a/src/main/resources/templates/users/list.html b/src/main/resources/templates/users/list.html new file mode 100644 index 0000000000000000000000000000000000000000..9bf337062c95ecae4100894dea94ec75cc9bb405 --- /dev/null +++ b/src/main/resources/templates/users/list.html @@ -0,0 +1,72 @@ +<html xmlns:th="http://www.thymeleaf.org"> +<head> + <title>Users list</title> + <link rel="stylesheet" href="/css/users.css"> + <head th:include="commons/imports"></head> +</head> +<body class="themed-gradient"> +<body th:include="commons/header"></body> + +<div class="container-fluid"> + <div class="row table-padding justify-content-center"> + <table class="table col-4 table-striped table-dark"> + <thead> + <tr> + <th scope="col">#</th> + <th scope="col">Name</th> + <th scope="col">Age</th> + </tr> + </thead> + <tbody> + <tr th:attr="user_id=${user.getId()}" th:each="user, counter : ${users}"> + <td th:text="${counter.count}">#</td> + <td attr_name="name" th:text="${user.getName()}">Name</td> + <td attr_name="age" th:text="${user.getAge()}">Age</td> + </tr> + </tbody> + </table> + </div> + <div class="modal fade" id="userModal" tabindex="-1" role="dialog" + aria-labelledby="userModalTitle" aria-hidden="true"> + <div class="modal-dialog modal-dialog-centered" role="document"> + <div class="modal-content"> + <div class="modal-header"> + <h5 class="modal-title" id="exampleModalLongTitle">User info</h5> + <button type="button" class="close" data-dismiss="modal" aria-label="Close"> + <span aria-hidden="true">×</span> + </button> + </div> + <div class="modal-body"> + <div class="d-flex flex-column"> + <div class="d-flex flex-row justify-content-between"> + <p>ID:</p> + <p id="modal_id"></p> + </div> + <div class="d-flex flex-row justify-content-between"> + <p>Name:</p> + <p id="modal_name"></p> + </div> + <div class="d-flex flex-row justify-content-between"> + <p>Age:</p> + <p id="modal_age"></p> + </div> + </div> + </div> + <div class="modal-footer"> + <button type="button" id="edit_user" class="btn btn-primary"><i class="fas fa-edit"></i> + Edit User + </button> + <button type="button" id="delete_user" class="btn btn-danger"><i class="fas fa-trash-alt"></i> + Delete User + </button> + <button type="button" class="btn btn-secondary" data-dismiss="modal"><i class="fas fa-times"></i> + Close + </button> + </div> + </div> + </div> + </div> +</div> +</body> +<script src="/js/users.js"></script> +</html>