From f397ee926de421ec3c3b4e685d38a0b858b11b9b Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Sat, 1 Apr 2017 16:15:59 -0400 Subject: [PATCH] Device Settings Page Now Works. --- .classpath | 1 + ....eclipse.wst.common.project.facet.core.xml | 1 + WebContent/html/javascript/listing.jsp | 5 +- WebContent/html/javascript/request.jsp | 40 ++--------- .../html/webpages/adminDeviceSettings.jsp | 36 +++++++--- WebContent/html/webpages/deviceRedirect.jsp | 23 +++--- src/database/DeviceQueries.java | 71 +++++++++++++------ src/database/MySQLAccess.java | 6 +- src/entities/Device.java | 28 ++------ src/main/Main.java | 2 - 10 files changed, 104 insertions(+), 109 deletions(-) diff --git a/.classpath b/.classpath index 09ba841..3cc104c 100644 --- a/.classpath +++ b/.classpath @@ -22,5 +22,6 @@ + diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml index a3bf73b..3b1bc05 100644 --- a/.settings/org.eclipse.wst.common.project.facet.core.xml +++ b/.settings/org.eclipse.wst.common.project.facet.core.xml @@ -1,6 +1,7 @@ + diff --git a/WebContent/html/javascript/listing.jsp b/WebContent/html/javascript/listing.jsp index 94fda82..b8bd152 100644 --- a/WebContent/html/javascript/listing.jsp +++ b/WebContent/html/javascript/listing.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess,entities.Device" %> +<%@ page import = "database.MySQLAccess,entities.Device,database.DeviceQueries" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -8,8 +8,7 @@ <% -MySQLAccess myaccess = new MySQLAccess(); -Device[] mydevices = myaccess.getAllDevices(); +Device[] mydevices = DeviceQueries.getAllDevices(); //string representation of array. String deviceString = Device.arrayToString(mydevices); diff --git a/WebContent/html/javascript/request.jsp b/WebContent/html/javascript/request.jsp index 086c24f..7e7ba73 100644 --- a/WebContent/html/javascript/request.jsp +++ b/WebContent/html/javascript/request.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.*,entities.ListedDevice" %> +<%@ page import = "database.*,entities.Device" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -8,10 +8,10 @@ <% -ListedDevice[] mydevices = DeviceQueries.getAllDevices(); +Device[] mydevices = DeviceQueries.getAllDevices(); //string representation of array. -String deviceString = ListedDevice.arrayToString(mydevices); +String deviceString = Device.arrayToString(mydevices); //out.println(description); //out.println(hardware); @@ -26,37 +26,6 @@ var devices = makeDeviceArray(); 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', show); @@ -115,8 +84,7 @@ function show(){ } - if(hardwareMatch == true && softwareMatch == true){ - //if((hw_type.localeCompare(devices[i].hardware) == 0 && sw_type.localeCompare(devices[i].software) == 0) && !isUnavailable(i)){ + if(hardwareMatch == true && softwareMatch == true && devices[i].status.localeCompare("Available") == 0){ html += '
' + devices[i].name + '

' + devices[i].description + '



' } } diff --git a/WebContent/html/webpages/adminDeviceSettings.jsp b/WebContent/html/webpages/adminDeviceSettings.jsp index 5036700..35a010d 100644 --- a/WebContent/html/webpages/adminDeviceSettings.jsp +++ b/WebContent/html/webpages/adminDeviceSettings.jsp @@ -1,4 +1,4 @@ -<%@ page import = "database.MySQLAccess,entities.Device" %> +<%@ page import = "database.*,entities.Device" %> <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -68,10 +68,11 @@ - +