Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
arc12012 committed Apr 16, 2017
2 parents 20f7ba5 + b77ee75 commit 488daa8
Show file tree
Hide file tree
Showing 33 changed files with 529 additions and 152 deletions.
41 changes: 36 additions & 5 deletions WebContent/adminLogin.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,62 @@
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ page import = "java.sql.*" %>
<%@ page import = "java.security.MessageDigest" %>
<%@ page import = "java.security.NoSuchAlgorithmException" %>
<%
int ssoNum;
String pass;
Cookie adminCookie;
ssoNum = Integer.parseInt(request.getParameter("ssoNum2"));
pass = request.getParameter("pass");
String generatedPass = null;
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(pass.getBytes());
byte[] bytes = md.digest();
StringBuilder sb = new StringBuilder();
for(int i = 0; i<bytes.length; i++)
sb.append(Integer.toString((bytes[i] & 0xff) + 0x100, 16).substring(1));
generatedPass = sb.toString();
}
catch (NoSuchAlgorithmException e){
}
String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317";
String user = "b372dfe7409692";
String password = "74f6e317";
System.getenv("VCAP_SERVICES");
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
ResultSet result;
result = stmt.executeQuery("select * FROM admin where Admin_ID='" + ssoNum + "' AND Password='" + pass + "'");
result = stmt.executeQuery("select * FROM admin where Admin_ID='" + ssoNum + "' AND Password='" + generatedPass + "'");
if (result.next()){
request.getSession();
session.setAttribute("ssoNum", ssoNum);
adminCookie = new Cookie("ssoNum", Integer.toString(ssoNum));
adminCookie.setMaxAge(30*60);
adminCookie.setPath("/");
response.addCookie(adminCookie);
stmt.close();
connection.close();
response.sendRedirect("html/webpages/admin.jsp");
Cookie adminCookie2 = new Cookie("admin", Integer.toString(ssoNum));
adminCookie2.setPath("/");
response.addCookie(adminCookie2);
if(result.getInt("Password_Flag") == 1){
stmt.close();
connection.close();
response.sendRedirect("html/webpages/administration/admin.jsp");
return;
}
else{
stmt.close();
connection.close();
response.sendRedirect("html/webpages/administration/adminpassword.jsp");
return;
}
} else {
stmt.close();
connection.close();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" type="text/css" href="../css/stylesheet.css">
<link rel="stylesheet" type="text/css" href="../../css/stylesheet.css">
<link rel="shortcut icon"
href="../imgs/synchrony-financial-logo-dlpx_1.ico">
href="../../imgs/synchrony-financial-logo-dlpx_1.ico">
<style>
div.deviceContainer {
border: solid;
Expand Down Expand Up @@ -67,24 +67,19 @@ div.approveConfirm {

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
<%@ include file="../components/adminnavbar.jsp"%>
</nav>

<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<h4>Admin Options</h4>
<li class="option"><a href="../webpages/adminApprove.jsp">Approve Devices</a></li>
<li class="option"><a href="#">Manage Admins</a></li>
<li class="option"><a href="#">Manage Devices</a></li>
</ul>
<%@ include file="../components/adminsidebar.jsp" %>
</div>
<div class="displayDevice">
<h2>Welcome to the admin page</h2>
<div id="admin"></div>
</div>


<script src="../javascript/admin.js"></script>
<script src="../javascript/nhpup_1.1.js"></script>
<script src="../../javascript/admin.js"></script>
<script src="../../javascript/nhpup_1.1.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<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/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel = "stylesheet" type = "text/css" href = "../css/stylesheet.css">
<link rel = "shortcut icon" href = "../imgs/synchrony-financial-logo-dlpx_1.ico">
<link rel = "stylesheet" type = "text/css" href = "../../css/stylesheet.css">
<link rel = "shortcut icon" href = "../../imgs/synchrony-financial-logo-dlpx_1.ico">
<style>
div.deviceContainer{
border: solid;
Expand Down Expand Up @@ -56,9 +56,6 @@
border-color: #3B3C43;
border-radius: 5px;
}
div.displayDevice{
left: 0px;
}
.form-control{
margin: auto;
text-align: center;
Expand All @@ -76,14 +73,22 @@
tbody{
text-align: left;
}
.btn{
margin-top: 15px;
}
</style>
</head>

<body>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
<%@ include file="../components/adminnavbar.jsp"%>
</nav>

<div class="col-sm-3 col-md-2 sidebar">
<%@ include file="../components/adminsidebar.jsp" %>
</div>

<!-- Modal for choosing ticket action. -->
<div id="Modal" class="modal">
<div class="modal-content">
Expand All @@ -93,8 +98,8 @@
</div><br>
<div class="modal-body">
<!-- Where new information is added. -->
<form ACTION = "ticketAdminRedirect.jsp" METHOD = "POST">
<table class="table table-bordered table-hover">
<form ACTION = "../redirect/ticketAdminRedirect.jsp" METHOD = "POST">
<table style = 'margin: 0 auto;' class="table table-bordered table-hover">
<thead>
<tr>
<th>Ticket ID</th>
Expand Down Expand Up @@ -136,16 +141,17 @@
</table>
</div>

<%TicketQueries query = new TicketQueries();
Ticket[] tickets = query.getTickets();
User[] users = EmployeeQueries.getAllUsers();
Location[] locations = LocationQueries.getAllLocations();
Device[] devices = DeviceQueries.getAllDevices();
String ticketStr = Ticket.arrayToString(tickets);
String userStr = User.arrayToString(users);
String locationStr = Location.arrayToString(locations).replace("'","\\'");
String deviceStr = Device.arrayToString(devices);
%>
<%
TicketQueries query = new TicketQueries();
Ticket[] tickets = query.getTickets();
User[] users = EmployeeQueries.getAllUsers();
Location[] locations = LocationQueries.getAllLocations();
Device[] devices = DeviceQueries.getAllDevices();
String ticketStr = Ticket.arrayToString(tickets);
String userStr = User.arrayToString(users);
String locationStr = Location.arrayToString(locations).replace("'","\\'");
String deviceStr = Device.arrayToString(devices);
%>

<script>
window.json = '<%=ticketStr%>';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,11 @@ pageEncoding="ISO-8859-1"%>
<meta name="author" content="">

<title>Synchrony Financial</title>

<link rel="stylesheet" type="text/css" href="http://ajax.aspnetcdn.com/ajax/jquery.dataTables/1.9.4/css/jquery.dataTables.css">
<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>
<link rel = "stylesheet" type = "text/css" href = "../css/stylesheet.css">
<link rel = "shortcut icon" href = "../imgs/synchrony-financial-logo-dlpx_1.ico">
<!-- Can later determine which style tags are not needed! -->
<link rel = "stylesheet" type = "text/css" href = "../../css/stylesheet.css">
<link rel = "shortcut icon" href = "../../imgs/synchrony-financial-logo-dlpx_1.ico">
<style>
/* Elements inside forms */
.form-control{
Expand Down Expand Up @@ -68,19 +65,14 @@ pageEncoding="ISO-8859-1"%>
</style>
<!-- Header -->
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
<%@ include file="../components/adminnavbar.jsp"%>
</nav>
</head>
<body>
<!-- Side bar -->
<div class="col-sm-3 col-md-2 sidebar">
<ul class="nav nav-sidebar">
<h4>Admin Options</h4>
<li class="option"><a href="../webpages/adminApprove.html">Approve Devices</a></li>
<li class="option"><a href="#">Manage Admins</a></li>
<li class="option"><a href="#">Manage Devices</a></li>
</ul>
</div>
<%@ include file = "../components/adminsidebar.jsp" %>
</div>

<!-- Modal for adding new device. -->
<div id="addModal" class="modal">
Expand All @@ -91,7 +83,7 @@ pageEncoding="ISO-8859-1"%>
</div><br>
<div class="modal-body">
<!-- Where new information is added. -->
<form ACTION = "deviceRedirect.jsp" METHOD = "POST">
<form ACTION = "../redirect/deviceRedirect.jsp" METHOD = "POST">
<div class = "form-group">
<label for="addName">Device Name *</label>
<input style = "width: 150px;" name = "name" class="form-control" id="addName" placeholder="Device Name" required = "true">
Expand Down Expand Up @@ -129,7 +121,7 @@ pageEncoding="ISO-8859-1"%>
</div>
<div class = "form-group">
<label for="addNFC">NFC ID</label>
<input style = "width: 75px;" name = "NFC" class="form-control" type = "number" id="addNFC" placeholder="ID">
<input style = "width: 75px;" name = "NFC" class="form-control" id="addNFC" placeholder="ID">
</div><br>
<button type = "submit" name = "add" value = "Add" class="btn btn-primary">Add</button>
</form>
Expand All @@ -146,7 +138,7 @@ pageEncoding="ISO-8859-1"%>
</div><br>
<div class="modal-body">
<!-- Where information is modified. -->
<form ACTION = "deviceRedirect.jsp" METHOD = "POST">
<form ACTION = "../redirect/deviceRedirect.jsp" METHOD = "POST">
<div class = "form-group">
<label for="modifyName">Device Name *</label>
<input style = "width: 150px;" name = "name" class="form-control" id="modifyName" placeholder="Device Name" required = "true">
Expand Down Expand Up @@ -184,7 +176,7 @@ pageEncoding="ISO-8859-1"%>
</div>
<div class = "form-group">
<label for="modifyNFC">NFC ID</label>
<input style = "width: 75px;" name = "NFC" class="form-control" type = "number" id="modifyNFC" placeholder="ID">
<input style = "width: 75px;" name = "NFC" class="form-control" id="modifyNFC" placeholder="ID">
</div><br>
<button type = "submit" name = "modify" value = "Save Changes" class="btn btn-primary">Save Changes</button>
<button style = "display: inline-block;" type = "submit" name = "delete" value = "Delete Entry" class="btn btn-primary">Delete</button>
Expand Down Expand Up @@ -261,6 +253,7 @@ $("#closeAddForm").click(closeAddModal);
window.onkeydown = function(e){if (e.keyCode == 27){closeAddModal();closeModifyModal();}}
//Event listener exits modal when click outside modal.
window.onclick = function(e){var add = document.getElementById('addModal'); var modify = document.getElementById('modifyModal'); if(e.target == add || e.target == modify) {closeAddModal();closeModifyModal();}}
//set up options in modals
var manuHTML = '<option value="" disabled selected>Choose Manufacturer</option>';
var hardwareHTML = '<option value="" disabled selected>Choose Hardware</option>';
Expand Down Expand Up @@ -428,6 +421,7 @@ function modifyModal(){
if(id == devices[i].id)
break;
}
//autofill modal
$("#modifyName").val(devices[i].name.replace(/&quot;/g,"\""));
$("#modifyDesc").val(devices[i].description.replace(/&quot;/g,"\""));
$("#modifyAvailability").val(devices[i].status);
Expand All @@ -441,10 +435,12 @@ function modifyModal(){
$("#modifyModal").show();
}
//close modify modal
function closeModifyModal(){
$("#modifyModal").hide();
}
//find if a string is in the array
function findInArray(string,array){
if (array.length == 0)
return false
Expand All @@ -456,6 +452,6 @@ function findInArray(string,array){
}
</script>
<script src="../javascript/lib/fuzzy.js"></script>
<script src="../../javascript/lib/fuzzy.js"></script>
</body>
</html>
Loading

0 comments on commit 488daa8

Please sign in to comment.