Skip to content

Commit

Permalink
Merge Resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
clj13001 committed Apr 7, 2017
2 parents 5590ded + 36ab9f9 commit b56d511
Show file tree
Hide file tree
Showing 10 changed files with 680 additions and 141 deletions.
2 changes: 1 addition & 1 deletion WebContent/html/webpages/admin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ div.approveConfirm {
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<h4>Admin Options</h4>
<li class="option"><a href="../webpages/adminApprove.html">Approve Devices</a></li>
<li class="option"><a href="../webpages/adminApprove.jsp">Approve Devices</a></li>
<li class="option"><a href="#">Manage Admins</a></li>
<li class="option"><a href="#">Manage Devices</a></li>
</ul>
Expand Down
169 changes: 155 additions & 14 deletions WebContent/html/webpages/adminApprove.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<%@ page import = "database.*,entities.*" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta charset="utf-8">
Expand All @@ -22,27 +26,22 @@
background-color: #E9EAEB;
display: inline-block;
}
div.imgContainer{
display: inline-block;
text-align: center;
}
img.device{
display: block;
}
div.deviceDescp{
display: inline-block;
width: 200px;
text-align: center;
}
button.approvebutton{
display: block;
margin: auto;
}
div.approveConfirm{
display: none;
top: 50%;
Expand All @@ -57,27 +56,169 @@
border-color: #3B3C43;
border-radius: 5px;
}
div.displayDevice{
left: 0px;
}
.form-control{
margin: auto;
text-align: center;
}
tr.entry{
cursor: pointer;
}
.table{
width: auto;
background-color: #E9EAEB;
}
tbody{
text-align: left;
}
</style>
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
</nav>

<!-- Modal for choosing ticket action. -->
<div id="Modal" class="modal">
<div class="modal-content">
<div class="modal-head">
<span id="closeForm" class="close">&times;</span>
<h4>View Ticket Below</h4>
</div><br>
<div class="modal-body">
<!-- Where new information is added. -->
<form ACTION = "ticketAdminRedirect.jsp" METHOD = "POST">
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Ticket ID</th>
<th>Requestor Name</th>
<th>Location Name</th>
<th>Device Name</th>
<th>Status</th>
<th>Return Date</th>
</tr>
</thead>
<tbody id="tablemodal">
</tbody>
</table>
<button type = "submit" name = "approve" value = "Approve" class="btn btn-primary">Approve</button>
<button type = "submit" name = "reject" value = "Reject" class="btn btn-primary">Reject</button>
<input type = "text" id = "ticketIDfield" name = "ticketid" style = "display: none;">
<input type = "text" id = "deviceIDfield" name = "deviceid" style = "display: none;">
<input type = "text" id = "locationIDfield" name = "locationid" style = "display: none;">
</form>
</div>
</div>
</div>

<div class = "displayDevice">
<h2>Admin View Approvals</h2>
<div id = "devContainer"></div>
<table class="table table-bordered table-hover">
<thead>
<tr>
<th>Ticket ID</th>
<th>Requestor Name</th>
<th>Location Name</th>
<th>Device Name</th>
<th>Status</th>
<th>Return Date</th>
</tr>
</thead>
<tbody id="tablebodymain">
</tbody>
</table>
</div>

<div class = "approveConfirm" id = "approved">
<p>Approved!</p>
</div>

<script src="../javascript/admin.js"></script>
<%TicketQueries query = new TicketQueries();
Ticket[] tickets = query.getTickets();
User[] users = EmployeeQueries.getAllUsers();
Location[] locations = LocationQueries.getAllLocations();
Device[] devices = DeviceQueries.getAllDevices();
String ticketStr = Ticket.arrayToString(tickets);
String userStr = User.arrayToString(users);
String locationStr = Location.arrayToString(locations).replace("'","\\'");
String deviceStr = Device.arrayToString(devices);
%>

<script>
window.json = '<%=ticketStr%>';
var tickets = JSON.parse(window.json);
window.json = '<%=userStr%>';
var users = JSON.parse(window.json);
window.json = '<%=locationStr%>';
var locations = JSON.parse(window.json);
window.json = '<%=deviceStr%>';
var devices = JSON.parse(window.json);
populateTickets();
//adds event listeners to all table records
$("tr.entry").click(ticketAction);
//Exits modal when x is clicked.
$("#closeForm").click(closeModal);
//Event listener exits modal when esc key pressed.
window.onkeydown = function(e){if (e.keyCode == 27){closeModal();}}
//Event listener exits modal when click outside modal.
window.onclick = function(e){var modal = document.getElementById('Modal'); if(e.target == modal) {closeModal();}}
//Places all tickets from query into page
function populateTickets(){
var html = "";
for(var i = 0; i < tickets.length; i++){
var requestor = getRequestor(tickets[i].requestor);
var location = getLocation(tickets[i].location);
var device = getDevice(tickets[i].deviceID);
//NEED TO ADD IN RETURN DATE AT END BUT THAT WOULD BREAK THINGS AT THE MOMENT
html += "<tr class = 'entry' id = '" + i + "'><td>" + tickets[i].id + "</td><td>" + requestor + "</td><td>" + location + "</td><td>" + device + "</td><td>" + tickets[i].status + "</td><td>" + tickets[i].return + "</td></tr>";
}
document.getElementById("tablebodymain").innerHTML = html;
}
function getRequestor(id){
for(var i = 0; i < users.length; i++){
if(id == users[i].id)
return users[i].name;
}
}
function getLocation(id){
for(var i = 0; i < locations.length; i++){
if(id == locations[i].id)
return locations[i].name;
}
}
function getDevice(id){
for(var i = 0; i < devices.length; i++){
if(id == devices[i].id)
return devices[i].name;
}
}
function ticketAction(){
var id = this.id;
var requestor = getRequestor(tickets[id].requestor);
var location = getLocation(tickets[id].location);
var device = getDevice(tickets[id].deviceID);
var html = "<tr><td>" + tickets[id].id + "</td><td>" + requestor + "</td><td>" + location + "</td><td>" + device + "</td><td>" + tickets[id].status + "</td><td>" + tickets[id].return + "</td></tr>";
document.getElementById("tablemodal").innerHTML = html;
$("#ticketIDfield").val(tickets[id].id);
$("#deviceIDfield").val(tickets[id].deviceID);
$("#locationIDfield").val(tickets[id].location);
$("#Modal").show();
}
function closeModal(){
$("#Modal").hide();
}
</script>
</body>
</html>
Loading

0 comments on commit b56d511

Please sign in to comment.