Skip to content

Commit

Permalink
Merge pull request #135 from arc12012/bugs
Browse files Browse the repository at this point in the history
Bugs
  • Loading branch information
clj13001 committed Apr 18, 2017
2 parents 734d223 + a8b1ed8 commit bb2dd4a
Show file tree
Hide file tree
Showing 11 changed files with 176 additions and 75 deletions.
3 changes: 2 additions & 1 deletion WebContent/html/webpages/administration/admin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ div.approveConfirm {
<%@ include file="../components/adminsidebar.jsp" %>
</div>
<div class="displayDevice">
<h2>Welcome to the admin page</h2>
<h2>Welcome to The Admin Hub!</h2>
<h3>Select from any option in the sidebar to exert your administrative power!</h3>
<div id="admin"></div>
</div>

Expand Down
43 changes: 36 additions & 7 deletions WebContent/html/webpages/administration/adminDeviceSettings.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,23 @@ pageEncoding="ISO-8859-1"%>
<label for="addName">Device Name *</label>
<input style = "width: 150px;" name = "name" class="form-control" id="addName" placeholder="Device Name" required = "true">
</div>
<div class = "form-group">
<label for="addPos">Locker Position</label>
<input style = "width: 150px;" name = "locker" class="form-control" id="addPos" placeholder="Locker Position">
</div>
<div class = "form-group">
<label for="addDesc">Description</label>
<textarea style = "width: 200px;" name = "description" class="form-control" rows = "5" id="addDesc" placeholder="Description"></textarea>
</div>
<div class = "form-group">
<label for="addcomment">Admin Comments</label>
<textarea style = "width: 200px;" name = "admincomments" class="form-control" rows = "5" id="addcomment" placeholder="Comments"></textarea>
</div>
<div class = "form-group">
<label for="addAvailability">Availability *</label>
<select required style = "width 190px;" name = "status" class="form-control" id="addAvailability">
</select>
</div>
<div class = "form-group">
<label for="addMAC">MAC Address</label>
<input style = "width: 150px;" name = "MAC" class="form-control" id="addMAC" placeholder="MAC Address">
</div>
<div class = "form-group">
<label for="addManu">Manufacturer *</label>
<select required style = "width: 190px;" name = "manu" class="form-control" id="addManu">
Expand All @@ -111,10 +115,18 @@ pageEncoding="ISO-8859-1"%>
<select required style = "width: 160px;" name = "hardware" class="form-control" id="addHardware">
</select>
</div>
<div class = "form-group">
<label for="addOS">Operating System</label>
<input style = "width: 150px;" name = "OS" class="form-control" id="addOS" placeholder="OS">
</div>
<div class = "form-group">
<label for="addModel">Model Name *</label>
<input style = "width: 150px;" name = "model" class="form-control" id="addModel" placeholder="Model Name" required = "true">
</div>
<div class = "form-group">
<label for="addMAC">MAC Address</label>
<input style = "width: 150px;" name = "MAC" class="form-control" id="addMAC" placeholder="MAC Address">
</div>
<div class = "form-group">
<label for="addSerial">Serial Number</label>
<input style = "width: 150px;" name = "serial" class="form-control" id="addSerial" placeholder="Serial Number">
Expand Down Expand Up @@ -143,10 +155,18 @@ pageEncoding="ISO-8859-1"%>
<label for="modifyName">Device Name *</label>
<input style = "width: 150px;" name = "name" class="form-control" id="modifyName" placeholder="Device Name" required = "true">
</div>
<div class = "form-group">
<label for="modifyPos">Locker Position</label>
<input style = "width: 150px;" name = "locker" class="form-control" id="modifyPos" placeholder="Locker Position">
</div>
<div class = "form-group">
<label for="modifyDesc">Description</label>
<textarea style = "width: 200px;" name = "description" class="form-control" rows = "5" id="modifyDesc" placeholder="Description"></textarea>
</div>
<div class = "form-group">
<label for="modifycomment">Admin Comments</label>
<textarea style = "width: 200px;" name = "admincomments" class="form-control" rows = "5" id="modifycomment" placeholder="Comments"></textarea>
</div>
<div class = "form-group">
<label for="modifyAvailability">Availability *</label>
<select required style = "width 190px;" name = "status" class="form-control" id="modifyAvailability">
Expand All @@ -166,6 +186,10 @@ pageEncoding="ISO-8859-1"%>
<select required style = "width: 160px;" name = "hardware" class="form-control" id="modifyHardware">
</select>
</div>
<div class = "form-group">
<label for="modifyOS">Operating System</label>
<input style = "width: 150px;" name = "OS" class="form-control" id="modifyOS" placeholder="OS">
</div>
<div class = "form-group">
<label for="modifyModel">Model Name *</label>
<input style = "width: 150px;" name = "model" class="form-control" id="modifyModel" placeholder="Model Name" required = "true">
Expand All @@ -187,8 +211,7 @@ pageEncoding="ISO-8859-1"%>
</div>
<div class = "displayDevice">
<!-- Main body! -->
<h2>Device Listing</h2>

<h2>Device Hub</h2>
<form onsubmit="return false;" class="form-inline">
<input type="search" class="form-control" name="searchBar" placeholder=" search for devices" autocomplete="off" style="width: 50%; text-align: left; margin: 1%;" />
<button id ="add" class="btn btn-primary">Add Device</button>
Expand All @@ -199,11 +222,14 @@ pageEncoding="ISO-8859-1"%>
<thead>
<tr>
<th>Name</th>
<th>Locker Position</th>
<th class = "column">Description</th>
<th class = "column">Admin Comments</th>
<th>Availability</th>
<th>MAC Address</th>
<th>Manufacturer</th>
<th>Hardware Type</th>
<th>Operating System</th>
<th>Model Name</th>
<th>Serial Number</th>
<th>NFC ID</th>
Expand Down Expand Up @@ -278,7 +304,7 @@ document.getElementById('modifyAvailability').innerHTML = availabilityHTML;
function populateDevices(deviceArray){
var html = "";
for(var i = 0; i < deviceArray.length; i++){
html += "<tr class = 'entry' id = '" + deviceArray[i].id + "'><td>" + deviceArray[i].name + "</td><td>" + deviceArray[i].description + "</td><td>" + deviceArray[i].status + "</td><td>" + deviceArray[i].mac + "</td><td>" + deviceArray[i].manufacturer + "</td><td>" + deviceArray[i].hardware + "</td><td>" + deviceArray[i].model + "</td><td>" + deviceArray[i].serial + "</td><td>" + deviceArray[i].nfc + "</td></tr>";
html += "<tr class = 'entry' id = '" + deviceArray[i].id + "'><td>" + deviceArray[i].name + "</td><td>" + deviceArray[i].locker + "</td><td>" + deviceArray[i].description + "</td><td>" + deviceArray[i].admincomment + "</td><td>" + deviceArray[i].status + "</td><td>" + deviceArray[i].mac + "</td><td>" + deviceArray[i].manufacturer + "</td><td>" + deviceArray[i].hardware + "</td><td>" + deviceArray[i].os + "</td><td>" + deviceArray[i].model + "</td><td>" + deviceArray[i].serial + "</td><td>" + deviceArray[i].nfc + "</td></tr>";
if(findInArray(deviceArray[i].manufacturer,manufacturers) == false){
manufacturers.push(deviceArray[i].manufacturer);
}
Expand Down Expand Up @@ -431,6 +457,9 @@ function modifyModal(){
$("#modifyModel").val(devices[i].model.replace(/&quot;/g,"\""));
$("#modifySerial").val(devices[i].serial);
$("#modifyNFC").val(devices[i].nfc);
$("#modifyOS").val(devices[i].os);
$("#modifycomment").val(devices[i].admincomment);
$("#modifyPos").val(devices[i].locker);
$("#modifyID").val(devices[i].id);
$("#modifyModal").show();
}
Expand Down
51 changes: 47 additions & 4 deletions WebContent/html/webpages/administration/adminLocation.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyCndOcexx4GAOGkRKBeK1E43u_sB9gjcaU">
</script>
<link rel = "stylesheet" type = "text/css" href = "../../css/stylesheet.css">
<link rel = "shortcut icon" href = "../../imgs/synchrony-financial-logo-dlpx_1.ico">
<style>
Expand Down Expand Up @@ -72,7 +75,7 @@
</div>
<div class = "form-group">
<label for="addState">State *</label>
<select required style = "width: 150px;" name = "state" class="form-control">
<select id = "addState" required style = "width: 150px;" name = "state" class="form-control">
<option value="" disabled selected>Choose State</option>
<option value="AL">Alabama</option>
<option value="AK">Alaska</option>
Expand Down Expand Up @@ -131,7 +134,15 @@
<label for="addZip">Zip Code *</label>
<input style = "width: 100px;" name = "zip" type = "number" class="form-control" id="addZip" placeholder="Zip Code" required = "true">
</div>
<button type = "submit" name = "add" value = "Add" class="btn btn-primary">Add</button>
<div class = "form-group">
<label for="addlat">Latitude</label>
<input style = "width: 150px;" type = "text" id = "addlat" class="form-control" name = "lat">
</div>
<div class = "form-group">
<label for="addlng">Longitude</label>
<input style = "width: 150px;" type = "text" id = "addlng" class="form-control" name = "lng">
</div>
<button id = "theaddbutton" type = "submit" name = "add" value = "Add" class="btn btn-primary">Add</button>
</form>
</div>
</div>
Expand Down Expand Up @@ -222,6 +233,14 @@
<label for="modifyZip">Zip Code *</label>
<input style = "width: 100px;" name = "zip" type = "number" class="form-control" id="modifyZip" required = "true">
</div>
<div class = "form-group">
<label for="modifylat">Latitude</label>
<input style = "width: 150px;" type = "text" id = "modifylat" class="form-control" name = "lat">
</div>
<div class = "form-group">
<label for="modifylng">Longitude</label>
<input style = "width: 150px;" type = "text" id = "modifylng" class="form-control" name = "lng">
</div>
<button id = "themodifybutton" type = "submit" name = "modify" value = "Save Changes" class="btn btn-primary">Save Changes</button>
<button id = "thedeletebutton" type = "submit" name = "delete" value = "Delete Entry" class="btn btn-primary" style = "display: inline-block;" title = "hello">Delete</button>
<input type = "text" id = "modifyID" name = "id" style = "display: none;">
Expand Down Expand Up @@ -249,21 +268,22 @@
<button id ="add" class="btn btn-primary">Add Location</button>
</div>
<%
//database query to get locations that all employees can access
Location[] locations = LocationQueries.getAdminLocations();
//string representation of array.
String locationString = Location.arrayToString(locations);
locationString = locationString.replace("'","\\'");
%>

<script type=text/javascript>
//JSON representation of array.
var locations = makeLocationArray();
//Populate locations into table!
populateLocations();
//geocode listeners
$("#addZip").keyup(geocodeTown);
$("#modifyZip").keyup(geocodeTown);
//adds event listeners to all table records
$("tr.entry").click(modifyModal);
//Exits modal when x is clicked.
Expand Down Expand Up @@ -317,6 +337,14 @@ function modifyModal(){
$("#modifyZip").val(locations[i].zip);
$("#modifyID").val(locations[i].id);
var geocoder = new google.maps.Geocoder();
//this function assumes that you are using a proper zip code...
geocoder.geocode({'address':locations[i].zip}, function(results,status)
{if (status == google.maps.GeocoderStatus.OK)
{$("#modifylat").val(results[0].geometry.location.lat());
$("#modifylng").val(results[0].geometry.location.lng());}
});
//if the location has a foreign key constraint, then the delete button should be restricted
if(locations[i].numDevices > 0 || locations[i].numEmployees > 0){
$('#thedeletebutton').attr('disabled',true);
Expand All @@ -334,6 +362,21 @@ function closeModifyModal(){
$("#modifyModal").hide();
}
//generate the lat & long of a location in real time!
function geocodeTown(){
var id = this.getAttribute('id');
var zip = $("#"+id).val();
id = id.replace("Zip","");
var geocoder = new google.maps.Geocoder();
//this function assumes that you are using a proper zip code...
geocoder.geocode({'address':zip}, function(results,status)
{if (status == google.maps.GeocoderStatus.OK)
{$("#" + id + "lat").val(results[0].geometry.location.lat());
$("#" + id + "lng").val(results[0].geometry.location.lng());}
});
return true;
}
</script>
</body>
</html>
6 changes: 3 additions & 3 deletions WebContent/html/webpages/components/adminsidebar.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<div>
<ul class="nav nav-sidebar">
<h4>Admin Options</h4>
<li class="option"><a href="adminApprove.jsp">Approve Devices</a></li>
<li class="option"><a href="adminApprove.jsp">Ticket Hub</a></li>
<!-- will add in when maegan is done <li class="option"><a href="#">Manage Admins</a></li> -->
<li class="option"><a href="adminDeviceSettings.jsp">Manage Devices</a></li>
<li class="option"><a href="adminLocation.jsp">Manage Locations</a></li>
<li class="option"><a href="adminDeviceSettings.jsp">Device Hub</a></li>
<li class="option"><a href="adminLocation.jsp">Location Hub</a></li>
</ul>
</div>
7 changes: 5 additions & 2 deletions WebContent/html/webpages/redirect/deviceRedirect.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ String hardware = request.getParameter("hardware").replace("\"","\\\"");
String model = request.getParameter("model").replace("\"","\\\"");
String serial = request.getParameter("serial");
String nfc = request.getParameter("NFC");
String os = request.getParameter("OS");
String locker = request.getParameter("locker");
String comment = request.getParameter("admincomments");
//add form was submitted
if(request.getParameter("add") != null){
Device device = new Device(name,1,description,hardware,model,manufacturer,status,mac,serial,nfc);
Device device = new Device(name,1,description,hardware,model,manufacturer,status,mac,serial,nfc,locker,os,comment);
DeviceQueries.addDevice(device);
}
Expand All @@ -48,7 +51,7 @@ if(request.getParameter("modify") != null){
String strID = request.getParameter("id");
//turn to int for constructor
int id = Integer.parseInt(strID);
Device device = new Device(name,id,description,hardware,model,manufacturer,status,mac,serial,nfc);
Device device = new Device(name,id,description,hardware,model,manufacturer,status,mac,serial,nfc,locker,os,comment);
DeviceQueries.modifyDevice(device);
}
Expand Down
6 changes: 4 additions & 2 deletions WebContent/html/webpages/redirect/locationRedirect.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@ String address = request.getParameter("address").replace("\"","\\\"");
String town = request.getParameter("town").replace("\"","\\\"");
String state = request.getParameter("state");
String zip = request.getParameter("zip");
String lat = request.getParameter("lat");
String lng = request.getParameter("lng");
int er = 0;
//add form was submitted
if(request.getParameter("add") != null){
Location location = new Location(name,address,town,state,zip,0);
Location location = new Location(0,name,address,town,state,zip,0,lat,lng);
LocationQueries.addLocation(location);
}
//modify form was submitted
Expand All @@ -44,7 +46,7 @@ if(request.getParameter("modify") != null){
String strID = request.getParameter("id");
//turn to int for constructor
int id = Integer.parseInt(strID);
Location location = new Location(id,name,address,town,state,zip);
Location location = new Location(id,name,address,town,state,zip,0,lat,lng);
LocationQueries.modifyLocation(location);
}
//delete form was submitted
Expand Down
11 changes: 7 additions & 4 deletions WebContent/html/webpages/redirect/orderFormHandler.jsp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<%@ page import = "database.*" %>
<%@ page import = "database.*,entities.Location" %>
<%@ page import = "entities.User" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
Expand All @@ -23,13 +23,16 @@ pageEncoding="ISO-8859-1"%>
int location=-1;
if(Integer.parseInt(request.getParameter("location_dropdown"))==0)
{
location = LocationQueries.addLocation(
location = LocationQueries.addLocation(new Location(
0,
request.getParameter("locname"),
request.getParameter("state"),
request.getParameter("address"),
request.getParameter("town"),
request.getParameter("state"),
request.getParameter("zip"),
Integer.parseInt(navsso)
Integer.parseInt(navsso),
"",
"")
);
}
Expand Down
4 changes: 2 additions & 2 deletions src/database/DeviceQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public static void addDevice(Device device) throws SQLException, ClassNotFoundEx
id = results.getInt("Device_ID");
id++;
//tries this statement, otherwise tries again with a new id
String command = "INSERT INTO devices (Device_ID,Device_Name,Device_Description,MAC_Address,Manufacturer,Hardware,Model,Serial_Num,Status,Added_By,NFC_ID) " + "VALUES (" + id +",\"" + device.getName() + "\",\"" + device.getDesc()+ "\",\"" + device.getMAC() + "\",\"" + device.getManufacturer() + "\",\""+device.getHardware()+ "\",\"" + device.getModel() + "\",\"" + device.getSerial() + "\",\"" + device.getStatus() + "\",30,\"" + device.getNFC() + "\");";
String command = "INSERT INTO devices (Device_ID,Device_Name,Device_Description,MAC_Address,Manufacturer,Hardware,Model,Serial_Num,Status,NFC_ID,Locker_Position,Operating_System,Admin_Comments) " + "VALUES (" + id +",\"" + device.getName() + "\",\"" + device.getDesc()+ "\",\"" + device.getMAC() + "\",\"" + device.getManufacturer() + "\",\""+device.getHardware()+ "\",\"" + device.getModel() + "\",\"" + device.getSerial() + "\",\"" + device.getStatus() + "\",\"" + device.getNFC() + "\",\"" + device.getPos() + "\",\"" + device.getOS() + "\",\"" + device.getComment() +"\");";
System.out.println(command);
i = stmt.executeUpdate(command);
}
Expand All @@ -139,7 +139,7 @@ public static void modifyDevice(Device device) throws ClassNotFoundException, SQ
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
stmt.executeUpdate("UPDATE devices SET Device_Name = \"" + device.getName() + "\", Device_Description = \"" + device.getDesc() + "\", MAC_Address = \"" + device.getMAC() + "\", Manufacturer = \"" + device.getManufacturer() + "\", Hardware = \"" + device.getHardware() + "\", Model = \"" + device.getModel() + "\", Serial_Num = \"" + device.getSerial() + "\", Status = \"" + device.getStatus() + "\", NFC_ID = \"" + device.getNFC() + "\" WHERE Device_ID = " + device.getID());
stmt.executeUpdate("UPDATE devices SET Device_Name = \"" + device.getName() + "\", Device_Description = \"" + device.getDesc() + "\", MAC_Address = \"" + device.getMAC() + "\", Manufacturer = \"" + device.getManufacturer() + "\", Hardware = \"" + device.getHardware() + "\", Model = \"" + device.getModel() + "\", Serial_Num = \"" + device.getSerial() + "\", Status = \"" + device.getStatus() + "\", NFC_ID = \"" + device.getNFC() + "\", Admin_Comments = \"" + device.getComment() + "\", Operating_System = \"" + device.getOS() + "\", Locker_Position = \"" + device.getPos() + "\" WHERE Device_ID = " + device.getID());
stmt.close();
connection.close();
}
Expand Down
Loading

0 comments on commit bb2dd4a

Please sign in to comment.