-
Notifications
You must be signed in to change notification settings - Fork 4
/
admin.jsp
100 lines (90 loc) · 3.13 KB
/
admin.jsp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="https://java.sun.com/jsp/jstl/core"%>
<%@ page isELIgnored="false" %>
<%--
<%@ taglib prefix="sec" uri="https://www.springframework.org/security/tags" %>
--%>
<html>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var val = $('#val1').val();
console.log(val);
if (val == "failure")
alert("Book Cannot be deleted. It is checked out by a patron.");
else if (val == "exception")
alert("Something went wrong. Please try again.");
else if(val=="Success")
alert("Book Deleted successfully.")
$('#btnSearch').click( function() {
console.log("button clicked");
var bookId = $('#txtSearch').val();
console.log(bookId);
var url = "https://localhost:8080/Cmpe275-Library-Management-System/search-book-"+bookId;
window.location.replace(url);
});
});
</script>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Admin page</title>
<link href="<c:url value='/static/css/bootstrap.css' />" rel="stylesheet"></link>
<link href="<c:url value='/static/css/app.css' />" rel="stylesheet"></link>
</head>
<body>
<div class="col-md-12">
<div class="col-md-8">
<h3>Welcome <strong>${user}</strong></h3>
</div>
<div class="col-md-4">
<a href="<c:url value="/logout" />" class="btn btn-default" style="margin: 20px 0px 0px 300px;">Logout</a>
</div>
</div>
<div class="panel panel-default">
<div class="form-group row">
<div class="col-xs-6">
<input type="hidden" id="val1" value="${val1 }">
<input class="form-control" type="text" id="txtSearch" placeholder="Search Book Name" name="txtSearch">
<input type="button" class="btn btn-primary" value="Search" id="btnSearch" name="btnSearch" style="margin:10px 0px 0px 0px;">
</div>
</div>
<div class="panel-heading"><span class="lead">List of Books</span></div>
<!-- Default Panel Contents -->
<table class="table table-hover">
<thead>
<tr>
<th>Publication Year</th>
<th>Location</th>
<th>Availability</th>
<th>Author</th>
<th>Title</th>
<th>Publisher</th>
<sec:authorize access="hasRole('ADMIN')">
<th width="100"></th>
</sec:authorize>
</tr>
</thead>
<tbody>
<c:forEach items="${books}" var="book">
<tr>
<td id="idField" style="display:none;">${book.id}</td>
<td>${book.publicationYear}</td>
<td>${book.libraryLocation}</td>
<td>${book.availability}</td>
<td>${book.author}</td>
<td>${book.title}</td>
<td>${book.publisher}</td>
<td><a href="<c:url value='/edit-book-${book.id}'/>" class="btn btn-success custom-width">Edit</a></td>
<td><a href="<c:url value='/delete-book-${book.id}'/>" class="btn btn-danger custom-width">Delete</a></td>
</tr>
</c:forEach>
</tbody>
</table>
</div>
<sec:authorize access="hasRole('ADMIN')">
<div class="well">
<a href="<c:url value='/newBook' />" class="btn btn-primary" >Add New Book</a>
</div>
</sec:authorize>
</body>
</html>