-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
580f78b
commit 778e9ea
Showing
8 changed files
with
316 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
a4--deep-hotel-webpages/src/main/java/com/DeepHotel/WebController/OccupancyController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.DeepHotel.WebController; | ||
|
||
import java.text.DateFormat; | ||
import java.text.ParseException; | ||
import java.text.SimpleDateFormat; | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
import java.util.Date; | ||
import java.util.Locale; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.format.datetime.DateFormatter; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
|
||
import com.DeepHotel.Service.RoomReservationService; | ||
|
||
@Controller | ||
@RequestMapping("/occupancy") | ||
public class OccupancyController { | ||
|
||
@Autowired | ||
RoomReservationService roomReservationService; | ||
|
||
@GetMapping | ||
public String getMethodName(Model model, @RequestParam(required = false) String resDate) { | ||
|
||
Date date = new Date(); | ||
String todaysDate = new String(); | ||
|
||
String finalDate = new String(); | ||
|
||
boolean getAll = false; | ||
|
||
if (resDate != null) { | ||
|
||
try { | ||
// SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd"); | ||
// date = simpleDateFormat.parse(resDate); | ||
|
||
LocalDate date2 = LocalDate.parse(resDate, DateTimeFormatter.ISO_DATE); | ||
|
||
System.err.println(date); | ||
System.out.println("--"); | ||
System.err.println(date2); | ||
finalDate = date2.toString(); | ||
|
||
} catch (Exception e) { | ||
System.err.println("exception caught in parsing date: " + e.getMessage()); | ||
} | ||
} else { | ||
|
||
getAll = true; | ||
todaysDate = LocalDate.now().toString(); | ||
resDate=todaysDate; | ||
finalDate = todaysDate; | ||
} | ||
|
||
System.err.println("1: " + finalDate); | ||
System.err.println("2: " + resDate); | ||
model.addAttribute("date", finalDate); | ||
model.addAttribute("reservations", roomReservationService.getRoomReservationForDate(resDate, getAll)); | ||
|
||
return "occupancy"; | ||
} | ||
|
||
} |
25 changes: 25 additions & 0 deletions
25
a4--deep-hotel-webpages/src/main/java/com/DeepHotel/WebController/RoomController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.DeepHotel.WebController; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
|
||
import com.DeepHotel.Repository.RoomRepo; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
@Controller | ||
@RequestMapping("/room") | ||
public class RoomController { | ||
|
||
@Autowired | ||
RoomRepo roomRepo; | ||
|
||
@GetMapping | ||
public String getMethodName(Model model) { | ||
model.addAttribute("rooms", roomRepo.findAll()); | ||
return "room-list"; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
a4--deep-hotel-webpages/src/main/java/com/DeepHotel/WebController/WelcomeController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.DeepHotel.WebController; | ||
|
||
import org.springframework.stereotype.Controller; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import org.springframework.web.bind.annotation.ResponseBody; | ||
|
||
@Controller | ||
@RequestMapping("/welcome") | ||
public class WelcomeController { | ||
|
||
@GetMapping | ||
@ResponseBody | ||
public String getWelcome(@RequestParam(value = "name", required = false, defaultValue = "Deepak") String name) { | ||
|
||
return "<h1>"+name+" Welcome!! </h1>"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
a4--deep-hotel-webpages/src/main/resources/templates/occupancy.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
<!doctype html> | ||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Thymeleaf | Rooms</title> | ||
<link | ||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" | ||
rel="stylesheet" | ||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" | ||
crossorigin="anonymous"> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-lg bg-body-tertiary"> | ||
<div class="container-fluid"> | ||
|
||
<button class="navbar-toggler" type="button" | ||
data-bs-toggle="collapse" data-bs-target="#navbarNav" | ||
aria-controls="navbarNav" aria-expanded="false" | ||
aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarNav"> | ||
<ul class="navbar-nav"> | ||
|
||
<li class="nav-item"><a class="nav-link " th:href="@{/room}">Room</a> | ||
</li> | ||
<li class="nav-item"><a class="nav-link active " | ||
aria-current="page" th:href="@{/occupancy}">occupancy</a></li> | ||
|
||
|
||
<li class="nav-item"><a class="nav-link disabled" | ||
aria-disabled="true">Disabled</a></li> | ||
</ul> | ||
</div> | ||
<a class="navbar-brand" href="#">Occupancy</a> | ||
</div> | ||
</nav> | ||
|
||
<div class="container"> | ||
|
||
<div class="container"> | ||
<input id="datePicker" class="btn btn-outline-primary" type="date" onchange="handleDate()" | ||
th:value="${date}" /> | ||
|
||
<button type="button" onclick="clearFiler()" | ||
class="btn btn-outline-danger">Clear Filter</button> | ||
|
||
</div> | ||
|
||
<table class="table table-striped table-hover "> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">Room Name</th> | ||
<th scope="col">Guest</th> | ||
<th scope="col">Reservation Date</th> | ||
</tr> | ||
</thead> | ||
<tbody class="table-group-divider"> | ||
<tr th:each="reservation: ${reservations}"> | ||
<th th:text="${reservation.roomNumber}">1</th> | ||
<td th:text="${reservation.roomName}">roomName</td> | ||
<td | ||
th:text="${reservation.lastName}!=null?${reservation.lastName}+' '+${reservation.firstName}:'VACANT'">Guest</td> | ||
<td th:text="${reservation.reservationDate}">reservationDate</td> | ||
</tr> | ||
|
||
</tbody> | ||
|
||
</table> | ||
</div> | ||
|
||
|
||
|
||
|
||
<script | ||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" | ||
crossorigin="anonymous"></script> | ||
<script type="text/javascript"> | ||
function handleDate() { | ||
let date = document.getElementById("datePicker").valueAsDate | ||
let result = date.toISOString().split('T')[0] | ||
if ('URLSearchParams' in window) { | ||
var searchParams = new URLSearchParams(window.location.search); | ||
searchParams.set("resDate", result) | ||
window.location.search = searchParams.toString(); | ||
} else { | ||
console.log("URLSearchParms not present"); | ||
var searchParams = new URLSearchParams(window.location.search); | ||
searchParams.set("resDate", result) | ||
window.location.search = searchParams.toString(); | ||
} | ||
} | ||
|
||
function clearFiler(){ | ||
window.location= window.location.href.replace(window.location.search, '') | ||
} | ||
</script> | ||
</body> | ||
</html> |
72 changes: 72 additions & 0 deletions
72
a4--deep-hotel-webpages/src/main/resources/templates/room-list.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<!doctype html> | ||
<html lang="en" xmlns:th="http://www.thymeleaf.org"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>Thymeleaf | Rooms</title> | ||
<link | ||
href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" | ||
rel="stylesheet" | ||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" | ||
crossorigin="anonymous"> | ||
</head> | ||
<body> | ||
<nav class="navbar navbar-expand-lg bg-body-tertiary"> | ||
<div class="container-fluid"> | ||
|
||
<button class="navbar-toggler" type="button" | ||
data-bs-toggle="collapse" data-bs-target="#navbarNav" | ||
aria-controls="navbarNav" aria-expanded="false" | ||
aria-label="Toggle navigation"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
<div class="collapse navbar-collapse" id="navbarNav"> | ||
<ul class="navbar-nav"> | ||
|
||
<li class="nav-item"> | ||
<a class="nav-link active" aria-current="page" th:href="@{/room}">Room</a> | ||
</li> | ||
<li class="nav-item"> | ||
<a class="nav-link" th:href="@{/occupancy}">occupancy</a> | ||
</li> | ||
|
||
|
||
<li class="nav-item"><a class="nav-link disabled" | ||
aria-disabled="true">Disabled</a></li> | ||
</ul> | ||
</div> | ||
<a class="navbar-brand" href="#">Room</a> | ||
</div> | ||
</nav> | ||
|
||
<div class="container"> | ||
|
||
<table class="table table-striped table-hover "> | ||
<thead> | ||
<tr> | ||
<th scope="col">#</th> | ||
<th scope="col">Room Name</th> | ||
<th scope="col">Bed Info</th> | ||
</tr> | ||
</thead> | ||
<tbody class="table-group-divider"> | ||
<tr th:each="room: ${rooms}"> | ||
<th th:text="${room.roomNumber}">1</th> | ||
<td th:text="${room.name}">Name</td> | ||
<td th:text="${room.bedInfo}">bed Info</td> | ||
|
||
</tr> | ||
|
||
</tbody> | ||
</table> | ||
</div> | ||
|
||
|
||
|
||
|
||
<script | ||
src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" | ||
crossorigin="anonymous"></script> | ||
</body> | ||
</html> |