From b33a42726fd85a18a1aecc7adff5d3b49faac5a8 Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Mon, 17 Apr 2017 16:55:03 -0400 Subject: [PATCH 1/2] Device Hub now supports some extra fields --- .../html/webpages/administration/admin.jsp | 3 +- .../administration/adminDeviceSettings.jsp | 43 ++++++++++++++++--- .../html/webpages/components/adminsidebar.jsp | 6 +-- .../html/webpages/redirect/deviceRedirect.jsp | 7 ++- src/database/DeviceQueries.java | 4 +- src/entities/Device.java | 15 +++++++ 6 files changed, 63 insertions(+), 15 deletions(-) diff --git a/WebContent/html/webpages/administration/admin.jsp b/WebContent/html/webpages/administration/admin.jsp index 6719058..c36986e 100644 --- a/WebContent/html/webpages/administration/admin.jsp +++ b/WebContent/html/webpages/administration/admin.jsp @@ -74,7 +74,8 @@ div.approveConfirm { <%@ include file="../components/adminsidebar.jsp" %>
-

Welcome to the admin page

+

Welcome to The Admin Hub!

+

Select from any option in the sidebar to exert your administrative power!

diff --git a/WebContent/html/webpages/administration/adminDeviceSettings.jsp b/WebContent/html/webpages/administration/adminDeviceSettings.jsp index f19c36f..28ae345 100644 --- a/WebContent/html/webpages/administration/adminDeviceSettings.jsp +++ b/WebContent/html/webpages/administration/adminDeviceSettings.jsp @@ -88,19 +88,23 @@ pageEncoding="ISO-8859-1"%> +
+ + +
+
+ + +
-
- - -
+
+ + +
+
+ + +
@@ -143,10 +155,18 @@ pageEncoding="ISO-8859-1"%>
+
+ + +
+
+ + +
+
+ + +
@@ -187,8 +211,7 @@ pageEncoding="ISO-8859-1"%>
-

Device Listing

- +

Device Hub

@@ -199,11 +222,14 @@ pageEncoding="ISO-8859-1"%> Name + Locker Position Description + Admin Comments Availability MAC Address Manufacturer Hardware Type + Operating System Model Name Serial Number NFC ID @@ -278,7 +304,7 @@ document.getElementById('modifyAvailability').innerHTML = availabilityHTML; function populateDevices(deviceArray){ var html = ""; for(var i = 0; i < deviceArray.length; i++){ - html += "" + deviceArray[i].name + "" + deviceArray[i].description + "" + deviceArray[i].status + "" + deviceArray[i].mac + "" + deviceArray[i].manufacturer + "" + deviceArray[i].hardware + "" + deviceArray[i].model + "" + deviceArray[i].serial + "" + deviceArray[i].nfc + ""; + html += "" + deviceArray[i].name + "" + deviceArray[i].locker + "" + deviceArray[i].description + "" + deviceArray[i].admincomment + "" + deviceArray[i].status + "" + deviceArray[i].mac + "" + deviceArray[i].manufacturer + "" + deviceArray[i].hardware + "" + deviceArray[i].os + "" + deviceArray[i].model + "" + deviceArray[i].serial + "" + deviceArray[i].nfc + ""; if(findInArray(deviceArray[i].manufacturer,manufacturers) == false){ manufacturers.push(deviceArray[i].manufacturer); } @@ -431,6 +457,9 @@ function modifyModal(){ $("#modifyModel").val(devices[i].model.replace(/"/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(); } diff --git a/WebContent/html/webpages/components/adminsidebar.jsp b/WebContent/html/webpages/components/adminsidebar.jsp index 10b20d6..0caa9bc 100644 --- a/WebContent/html/webpages/components/adminsidebar.jsp +++ b/WebContent/html/webpages/components/adminsidebar.jsp @@ -2,9 +2,9 @@
\ No newline at end of file diff --git a/WebContent/html/webpages/redirect/deviceRedirect.jsp b/WebContent/html/webpages/redirect/deviceRedirect.jsp index 1c2273b..cc1f993 100644 --- a/WebContent/html/webpages/redirect/deviceRedirect.jsp +++ b/WebContent/html/webpages/redirect/deviceRedirect.jsp @@ -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); } @@ -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); } diff --git a/src/database/DeviceQueries.java b/src/database/DeviceQueries.java index f6ca830..3e779c5 100644 --- a/src/database/DeviceQueries.java +++ b/src/database/DeviceQueries.java @@ -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); } @@ -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(); } diff --git a/src/entities/Device.java b/src/entities/Device.java index 593fead..ad0eb56 100644 --- a/src/entities/Device.java +++ b/src/entities/Device.java @@ -42,13 +42,16 @@ public String toString(){ StringBuilder sb = new StringBuilder(); String comma = ", "; sb.append("{\"name\": \"").append(Device_Name).append("\"").append(comma); + sb.append("\"locker\": \"").append(locker_position).append("\"").append(comma); sb.append("\"id\": \"").append(Device_ID).append("\"").append(comma); sb.append("\"description\": \"").append(Device_Description).append("\"").append(comma); + sb.append("\"admincomment\": \"").append(Admin_Comments).append("\"").append(comma); sb.append("\"hardware\": \"").append(Hardware).append("\"").append(comma); sb.append("\"status\": \"").append(Status).append("\"").append(comma); sb.append("\"model\": \"").append(Model).append("\"").append(comma); sb.append("\"manufacturer\": \"").append(Manu).append("\"").append(comma); sb.append("\"mac\": \"").append(MAC).append("\"").append(comma); + sb.append("\"os\": \"").append(OS).append("\"").append(comma); sb.append("\"serial\": \"").append(Serial).append("\"").append(comma); sb.append("\"nfc\": \"").append(NFC).append("\""); sb.append("}"); @@ -112,4 +115,16 @@ public String getNFC() { public String getStatus(){ return Status; } + + public String getPos(){ + return locker_position; + } + + public String getOS(){ + return OS; + } + + public String getComment(){ + return Admin_Comments; + } } From a8b1ed8f989ba3225fa7137819e33fe61fe47af2 Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Tue, 18 Apr 2017 09:50:23 -0400 Subject: [PATCH 2/2] Latitude and Longitude Support --- .../webpages/administration/adminLocation.jsp | 51 +++++++++++++-- .../webpages/redirect/locationRedirect.jsp | 6 +- .../webpages/redirect/orderFormHandler.jsp | 11 ++-- src/database/LocationQueries.java | 40 ++++++++---- src/entities/Location.java | 65 ++++++++----------- 5 files changed, 113 insertions(+), 60 deletions(-) diff --git a/WebContent/html/webpages/administration/adminLocation.jsp b/WebContent/html/webpages/administration/adminLocation.jsp index 76d6d88..a4bc324 100644 --- a/WebContent/html/webpages/administration/adminLocation.jsp +++ b/WebContent/html/webpages/administration/adminLocation.jsp @@ -15,6 +15,9 @@ +