-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Admin add/removal update from meagan
- Loading branch information
Showing
3 changed files
with
467 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!-- The purpose of this file is to capture order form submissions and forward them to MySQLAccess --> | ||
|
||
<%@ page import = "database.*,entities.*" %> | ||
<%@ page import = "java.util.Random" %> | ||
<%@ page import = "database.*" %> | ||
<%@ 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" %> | ||
|
||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel = "stylesheet" type = "text/css" href = "../../css/stylesheet.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> | ||
</head> | ||
<body> | ||
|
||
<script type="text/javascript"> | ||
<% | ||
// If location id is 0, it is a custom location which must be added to the database before employee preffered location can be updated | ||
//Now update employee | ||
int sso = Integer.parseInt(request.getParameter("SSO")); | ||
// User self = EmployeeQueries.getEmployeeByID(sso); | ||
String decision = request.getParameter("thing"); | ||
if(decision == "add") | ||
{ | ||
String alphabet = "0123456789ABCDE"; | ||
int N = alphabet.length(); | ||
String password = ""; | ||
String generatedPass = null; | ||
Random r = new Random(); | ||
for (int i = 0; i < 10; i++) { | ||
password += alphabet.charAt(r.nextInt(N)); | ||
} | ||
try { | ||
MessageDigest md = MessageDigest.getInstance("MD5"); | ||
md.update(password.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){ | ||
} | ||
AdminQuery.addAdmin(sso, password); | ||
} | ||
if(decision == "remove") | ||
{ | ||
//AdminQuery.fingerCheck(sso); | ||
if(AdminQuery.fingerCheck(sso)==false) | ||
{ | ||
%> | ||
alert("You cannot remove an admin until their fingerprint is removed from the locker"); | ||
<% | ||
} | ||
} | ||
%> | ||
window.location.replace("../approveAdmin.jsp"); | ||
</script> | ||
</body> | ||
</html> |
240 changes: 240 additions & 0 deletions
240
WebContent/html/webpages/administration/approveAdmin.jsp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
<%@ page import="database.*,entities.*"%> | ||
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" | ||
pageEncoding="ISO-8859-1"%> | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
|
||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
<!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags --> | ||
<meta name="description" content=""> | ||
<meta name="author" content=""> | ||
|
||
<title>Synchrony Financial</title> | ||
|
||
<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"> | ||
<style> | ||
div.deviceContainer { | ||
border: solid; | ||
border-width: thin; | ||
padding: 15px; | ||
background-color: #E9EAEB; | ||
display: inline-block; | ||
} | ||
.table { | ||
width: auto; | ||
background-color: #E9EAEB; | ||
} | ||
div.imgContainer { | ||
display: inline-block; | ||
text-align: center; | ||
} | ||
img.device { | ||
display: block; | ||
} | ||
div.deviceDescp { | ||
display: inline-block; | ||
width: 200px; | ||
text-align: center; | ||
} | ||
button.approvebutton { | ||
display: block; | ||
margin: auto; | ||
} | ||
tr.entry { | ||
cursor: pointer; | ||
} | ||
div.approveConfirm { | ||
display: none; | ||
top: 50%; | ||
left: 50%; | ||
position: fixed; | ||
width: 155px; | ||
height: 85px; | ||
line-height: 85px; | ||
text-align: center; | ||
background-color: #FBC600; | ||
border: solid; | ||
border-color: #3B3C43; | ||
border-radius: 5px; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<nav class="navbar navbar-inverse navbar-fixed-top" | ||
id="navbaruniversal"><%@ 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.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> | ||
|
||
<div class="displayDevice"> | ||
<table class="table table-bordered table-hover" id="tabledisplay"> | ||
<tr> | ||
<th>Name</th> | ||
<th>SSO</th> | ||
<th>Finger Print</th> | ||
</tr> | ||
<tbody id="tablemainbody"> | ||
</tbody> | ||
</table> | ||
<button type="button" id='addshit'>Add Admin</button> | ||
<button type="button" id='deleteshit'>Remove Admin</button> | ||
</div> | ||
|
||
|
||
|
||
<div id="addAdminModal" class="modal"> | ||
<div class="modal-content" | ||
style="overflow-y: auto; overflow-x: hidden"> | ||
<div class="modal-head"> | ||
<span id="closeOrderForm" class="close">×</span> | ||
<h4>Input new admin information</h4> | ||
</div> | ||
<div class="modal-body"> | ||
<form name="addAdminModal" onsubmit="return addingAdmin()" | ||
action="adminThings.jsp" method="post"> | ||
<input type="text" name="AdminID" style="display: none;" /> | ||
<div class="form-group row"> | ||
<input type = "text", name="thing" style=""display:none;"> | ||
<label for="SSO">SSO</label><br /> <input type="adminID" | ||
class="form-control" name="adminID" placeholder="xxxxxxxxx" | ||
style="margin: 0 auto; width: 60%" required> | ||
</div> | ||
<button type="submit" class="btn btn-primary" name="Submit">Submit</button> | ||
</form> | ||
</div> | ||
</div> | ||
<div id="removeAdminModal" class="modal"> | ||
<div class="modal-content" | ||
style="overflow-y: auto; overflow-x: hidden"> | ||
<div class="modal-head"> | ||
<span id="closeOrderForm" class="close">×</span> | ||
<h4>Enter the SSO of the admin to be deleted</h4> | ||
</div> | ||
<div class="modal-body"> | ||
<form name="removeAdminModal" onsubmit="return removingAdmin()" | ||
action="adminThings.jsp" method="post"> | ||
<input type="text" name="AdminID" style="display: none;" /> | ||
<div class="form-group row"> | ||
<input type = "text", name="thing", style="display:none;"> | ||
<label for="SSO">SSO</label><br /> <input type="adminID" | ||
class="form-control" name="adminID" placeholder="xxxxxxxxx" | ||
style="margin: 0 auto; width: 60%" required> | ||
</div> | ||
</div> | ||
<button type="submit" class="btn btn-primary" name="Submit">Submit</button> | ||
</form> | ||
</div> | ||
</div> | ||
<script src="../javascript/navbar.js"></script> | ||
</body> | ||
</html> | ||
<% | ||
Admin[] admins = AdminQuery.getAllAdmin(); | ||
String adminString = Admin.arrayToString(admins); | ||
adminString = adminString.replace("'", "\\'"); | ||
%> | ||
<script type=text/javascript> | ||
var admins = makeAdminArray(); | ||
populateAdmin(); | ||
var editAdmins = new Array; | ||
window.onclick = function(event) { | ||
var modal = document.getElementById('addAdminModal'); | ||
if(event.target == modal) modal.style.display = "none"; | ||
} | ||
$("tr.entry").click(changeColor); | ||
document.getElementById('addshit').addEventListener('click', addAdmin); | ||
document.getElementById('deleteshit').addEventListener('click', removeAdmin); | ||
function populateAdmin() | ||
{ | ||
var html = ""; | ||
for(var i = 0; i < admins.length; i++) | ||
{ | ||
html += "<tr class = 'entry' id = '" + admins[i].id + "'><td>" + admins[i].name + "</td><td>" + admins[i].id + "</td><td>" + admins[i].finger + "</td></tr>"; | ||
} | ||
document.getElementById("tablemainbody").innerHTML = html; | ||
} | ||
|
||
function makeAdminArray() | ||
{ | ||
window.json = '<%=adminString%>'; | ||
return JSON.parse(window.json); | ||
} | ||
|
||
function changeColor() { | ||
var id = this.getAttribute('id'); | ||
var i = 0; | ||
if (editAdmins.includes(id)) { | ||
while (i < editAdmins.length) { | ||
if (editAdmins[i] == id) { | ||
$(this).css("background-color", '#e9eaeb'); | ||
editAdmins.splice(i, 1); | ||
} | ||
i++; | ||
} | ||
} else { | ||
editAdmins.push(id); | ||
$(this).css("background-color", 'pink'); | ||
} | ||
|
||
} | ||
|
||
function addAdmin() { | ||
document.getElementById('addAdminModal').style.display = 'block'; | ||
} | ||
|
||
function removeAdmin() | ||
{ | ||
document.getElementById('removeAdminModal').style.display = 'block'; | ||
} | ||
|
||
|
||
function addingAdmin() | ||
{ | ||
document.addAdminModal.thing='add'; | ||
} | ||
|
||
function removingAdmin() | ||
{ | ||
document.addAdminModal.thing='remove'; | ||
} | ||
</script> |
Oops, something went wrong.