Skip to content

Commit

Permalink
Bug pushes
Browse files Browse the repository at this point in the history
  • Loading branch information
clj13001 committed Apr 6, 2017
1 parent f93a61c commit eeb1fcd
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 60 deletions.
2 changes: 1 addition & 1 deletion WebContent/html/css/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ div.modal-content{
padding: 10px;
border: 1px solid #888;
width: 80%;
max-height: 80%;
max-height: 100%;
text-align: center;
vertical-align: center;
align-items: center;
Expand Down
29 changes: 0 additions & 29 deletions WebContent/html/javascript/request.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,6 @@ var devices = makeDeviceArray();
//get all the option buttons
var hardwareOptions = document.getElementsByClassName('hw-data-type');
var softwareOptions = document.getElementsByClassName('sw-data-type');
function ajaxFunction(){
var request;
try {
request = new XMLHttpRequest();
}
catch(e){
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e){
try {
request = new ActiveXObject(Microsoft.XMLHTTP);
} catch(e) {
alert("Something is wrong with your browser");
return false;
}
}
}
request.onreadystatechange = function(){
if(request.readyState == 4){
var display = document.getElementById('ajaxDiv');
display.innerHTML = request.responseText;
}
}
}
//add event listeners to the options in the left sidebar
for(var a = 0; a < hardwareOptions.length; a++){
hardwareOptions[a].addEventListener('click', refresh);
Expand Down
22 changes: 21 additions & 1 deletion WebContent/html/webpages/navbar.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%@ page import = "database.*,entities.User" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
Expand All @@ -7,7 +9,9 @@
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../webpages/admin.jsp">
<img src="../imgs/synchrony-financial-logo-dlpx_1.png" style = "height: 100%;">
<img src="../imgs/synchrony-financial-logo-dlpx_1.png" style = "height: 100%; display: inline-block;">
&nbsp;&nbsp;&nbsp;&nbsp;
<p style = "display: inline-block" id = "user"></p>
</a>
</div>
<div id="navbar" class="navbar-collapse collapse" aria-expanded="false">
Expand All @@ -19,4 +23,20 @@
<li><a href="shoppingCart.jsp">Shopping Cart</a></li>
</ul>
</div>
<%
Cookie[] cookies = request.getCookies();
int sso = 0;
for(Cookie c : cookies){
if(c.getName().equals("ssoNum")){
sso = Integer.ParseInt(c.getValue());
break;
}
}
User self = EmployeeQueries.getEmployeeID(sso);
String name = self.getName();
%>
</div>
<script>
var name = '<%=name%>';
$('#user').val("Hello " + name + "!");
</script>
42 changes: 42 additions & 0 deletions WebContent/html/webpages/navbar.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<%@ page import = "database.*,entities.User" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="../webpages/admin.jsp">
<img src="../imgs/synchrony-financial-logo-dlpx_1.png" style = "height: 100%; display: inline-block;">
&nbsp;&nbsp;&nbsp;&nbsp;
<p style = "display: inline-block" id = "user"></p>
</a>
</div>
<div id="navbar" class="navbar-collapse collapse" aria-expanded="false">
<ul class="nav navbar-nav navbar-right">
<li><a href="../webpages/">Home</a></li>
<li><a href="requestPage.jsp">Request Device</a></li>
<li><a href="returnPage.jsp">Return Device</a></li>
<li><a href="listingPage.jsp">Device Listing</a></li>
<li><a href="shoppingCart.jsp">Shopping Cart</a></li>
</ul>
</div>
<%
Cookie[] usercookies = request.getCookies();
int navsso = 0;
for(Cookie c : usercookies){
if(c.getName().equals("ssoNum")){
navsso = Integer.parseInt(c.getValue());
break;
}
}
User self = EmployeeQueries.getEmployeeByID(navsso);
String name = self.getName();
%>
</div>
<script>
var name = '<%=name%>';
document.getElementById('user').innerHTML = "Hi " + name + "!";
</script>
5 changes: 3 additions & 2 deletions WebContent/html/webpages/returnComplete.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,13 @@
<body>
<h2>Returning Devices</h2>
<p>Thanks for returning some devices!</p>

<form action = "returnPage.jsp">
<button type = "submit" class = "btn btn-primary">Go Back</button>
</form>
<%
//get string from request form
String devices = request.getParameter("devicesToReturn");
DeviceQueries.returnDevices(devices);
%>
<!-- Navbar generation. -->
</body>
</html>
62 changes: 45 additions & 17 deletions WebContent/html/webpages/returnPage.jsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ page import = "database.*,entities.RentedDevice" %>
<%@ page import = "database.*,entities.Device" %>
<%@ 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">
Expand Down Expand Up @@ -75,7 +75,7 @@
}
</style>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.html"%>
<%@ include file="navbar.jsp"%>
</nav>
</head>
<body>
Expand All @@ -98,39 +98,43 @@
</thread>
<tbody id = "tablebody">
</tbody>
</table><br>
</table>
<form ACTION = "returnComplete.jsp" METHOD = "POST">
<input type = "text" id = "deviceArray" style = "display: none;" name = "devicesToReturn"></input>
<input type = "submit" value = "Submit">
<button type = "submit" class = "btn btn-primary">Submit</button>
</form>
</div>
</div>
</div>
<!-- Sidebar. -->
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<h4>Filter by Time Ordered</h4>
<li class = "option" id = "all"><a href="#">All devices</a></li>
<li class = "option" id = "1month"><a href="#">Past month</a></li>
<li class = "option" id = "1-3months"><a href="#">1-3 months ago</a></li>
<li class = "option" id = "3-5months"><a href="#">3-5 months ago</a></li>
<li class = "option" id = "5+months"n><a href="#">5+ months ago</a></li>
<h4>Return Page Options</h4>
<li class = "option" id = "returnbutton"><a href="#">Return Selected</a></li>
<li class = "option" id = "returnall"><a href="#">Return All</a></li>
</ul>
</div>
<div class="displayDevice">
<h2>Devices to Be Returned</h2>
<!-- Device information boxes placed here. -->
<div id = "devContainer">
</div>
<button id ="returnbutton">Return</button>
</div>

<%
//String userID = cookie implementation exists here.
//19 is just for testing purposes. Replaced by userID later.
RentedDevice[] mydevices = DeviceQueries.getUserDevices("19");
//get user information
Cookie[] cookies = request.getCookies();
String sso = "";
for(Cookie c : cookies){
if(c.getName().equals("ssoNum")){
sso = c.getValue();
break;
}
}
Device[] mydevices = DeviceQueries.getUserDevices(sso);
//string representation of array.
String deviceString = RentedDevice.arrayToString(mydevices);
String deviceString = Device.arrayToString(mydevices);
%>

<script type=text/javascript>
Expand All @@ -146,8 +150,10 @@ populateDeviceList();
//Event listeners for divs.
$('div.deviceContainer').click(fireCheck);
$('input.deviceCheckbox').click(selectBox);
//Event listener for return button.
//Event listener for return selected.
$('#returnbutton').click(returnDevice);
//Event listener for return all.
$('#returnall').click(returnAll);
//Event listener for modal x button.
$('#closeOrderForm').click(hidePopup);
//Event listener exits modal when esc key pressed.
Expand Down Expand Up @@ -221,7 +227,7 @@ function populateDeviceList(){
//HTML representation in divs
htmlString+="<div class=\"deviceContainer\" data-num=\"" + i +"\">";
htmlString+="<input class=\"deviceCheckbox\" type = \"checkbox\" data-num=\"" + i + "\">";
htmlString+="<div><div class=\"imgContainer\"><img src=\"../imgs/my-icons-collection-devices/png/";
htmlString+="<div><div class=\"imgContainer\"><img onerror=\"this.src='../imgs/synchrony-financial-logo-dlpx_1.png';\" src=\"../imgs/my-icons-collection-devices/png/";
htmlString+=hardware;
htmlString+=".png\" class=\"device\">";
htmlString+=name;
Expand Down Expand Up @@ -252,6 +258,28 @@ function returnDevice()
$('#orderInfoModal').show();
}
//Initiates model to popup for review
function returnAll(){
var checkboxes = document.getElementsByClassName('deviceCheckbox');
for(var i = 0; i < checkboxes.length; i++){
//get id
var id = checkboxes[i].getAttribute('data-num');
//Create query to get checkbox
var query = 'input[data-num="'+id+'"]';
var query2 = 'div[data-num="'+id+'"]';
//Determine if it's checked
var checked = $(query).prop('checked');
//Check it off
if(checked === false){
$(query).prop('checked',true);
$(query2).css("background-color","#C2C3C4");
//add to toReturned array
toReturn.push(id);
}
}
returnDevice();
}
//Call to exit modal
function hidePopup(){
$('#orderInfoModal').hide();
Expand Down
5 changes: 0 additions & 5 deletions WebContent/html/webpages/shoppingCart.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -497,11 +497,6 @@ function selectAllDevices() {
}
}
/**
This function takes all devices in the shopping cart and orders them.
**/
function orderAll(){}
/**
This function takes all devices in the shopping cart and deletes them.
**/
Expand Down
9 changes: 4 additions & 5 deletions src/database/DeviceQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,32 @@
import java.sql.*;

import entities.Device;
import entities.RentedDevice;

public class DeviceQueries {

private static String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317";
private static String user = "b372dfe7409692";
private static String password = "74f6e317";

public static RentedDevice[] getUserDevices(String userID) throws SQLException, ClassNotFoundException{
public static Device[] getUserDevices(String userID) throws SQLException, ClassNotFoundException{
//Not sure how to get cookie information (if that is how we choose to accomplish this...) ? But this should be a passed parameter
System.getenv("VCAP_SERVICES");
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
ResultSet resultSet = stmt.executeQuery("SELECT Device_ID, Device_Name, Device_Description, Ticket_ID, Hardware, Model, Borrow_Date FROM devices WHERE Renter = " + userID + " AND Status <> \"Available\" AND Status <> \"Returning \"");
ResultSet resultSet = stmt.executeQuery("SELECT * FROM devices WHERE Renter = " + userID + " AND Status <> \"Available\" AND Status <> \"Returning \"");
int counter = 0;

resultSet.last();
int rows = resultSet.getRow();
resultSet.beforeFirst();

//Covers amount of rows, and 6 attributes (indices 0-5)
RentedDevice[] devices = new RentedDevice[rows];
Device[] devices = new Device[rows];

//iterate result set
while(resultSet.next()){
devices[counter] = new RentedDevice(resultSet.getInt("Device_ID") + "",resultSet.getString("Device_Name"),resultSet.getString("Device_Description"),resultSet.getInt("Ticket_ID") + "",resultSet.getString("Hardware"),resultSet.getString("Model"),resultSet.getString("Borrow_Date"));
devices[counter] = new Device(resultSet.getString("Device_Name"),resultSet.getInt("Device_ID"),resultSet.getString("Device_Description"),resultSet.getString("Hardware"), resultSet.getString("Model"), resultSet.getString("Manufacturer"), resultSet.getString("Status"), resultSet.getString("MAC_Address"), resultSet.getString("Serial_Num"), resultSet.getInt("NFC_ID"));
counter++;
}
stmt.close();
Expand Down

0 comments on commit eeb1fcd

Please sign in to comment.