Skip to content

Commit

Permalink
Device Hub now supports some extra fields
Browse files Browse the repository at this point in the history
  • Loading branch information
clj13001 committed Apr 17, 2017
1 parent dd292c9 commit b33a427
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 15 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
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
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
15 changes: 15 additions & 0 deletions src/entities/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -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("}");
Expand Down Expand Up @@ -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;
}
}

0 comments on commit b33a427

Please sign in to comment.