Skip to content

Commit

Permalink
Profile Settings Page now Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
clj13001 committed Apr 11, 2017
1 parent 79f8a7f commit 4da198f
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 14 deletions.
8 changes: 4 additions & 4 deletions .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@
<attribute name="org.eclipse.jst.component.dependency" value="/WEB-INF/lib"/>
</attributes>
</classpathentry>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.server.core.container/org.cloudfoundry.appcloudserver.classPathProvider/Cloud Foundry">
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v8.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/jre1.8.0_121">
<attributes>
<attribute name="maven.pomderived" value="true"/>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="lib/servlet-api.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
4 changes: 1 addition & 3 deletions .settings/org.eclipse.wst.common.project.facet.core.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Cloud Foundry"/>
<secondary-runtime name="Apache Tomcat v8.0"/>
<runtime name="Apache Tomcat v8.0"/>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.8"/>
<installed facet="wst.jsdt.web" version="1.0"/>
<installed facet="cloudfoundry.standalone.app" version="1.0"/>
<installed facet="jst.web" version="3.1"/>
</faceted-project>
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ function IconSelect($$elementID, $$parameters) {
_View.selectedIconImgElement.setAttribute('src', icon.iconFilePath);
if(_selectedIndex != -1) _icons[_selectedIndex].element.setAttribute('class','icon selected');
if(_selectedIndex != -1) $('#profimg').attr("src","../imgs/my-icons-collection-128px/png/" + icon.iconValue + ".png");
if(_selectedIndex != -1) $('#hiddenIMG').val(icon.iconValue);
}

_View.iconSelectElement.dispatchEvent(new Event('changed'));
Expand Down
14 changes: 8 additions & 6 deletions WebContent/html/webpages/profileSettings.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -97,27 +97,28 @@
<div id="my-icon-select" style = "display: inline-block;"></div>
</div>
<!-- Where main user information is edited -->
<form class = "infobar">
<form action = "profileSettingsRedirect.jsp" class = "infobar">
<h2>Profile Settings</h2>
<div class = "form-group">
<label for="inputName">Full Name *</label>
<input style = "width: 350px;" type = "name" class="form-control" id="inputName" placeholder="Name" required = "true">
<input name = "name" style = "width: 350px;" type = "name" class="form-control" id="inputName" placeholder="Name" required = "true">
<span class = "help-block"></span>
</div>
<div class = "form-group">
<label for="inputSSO">SSO Number *</label>
<input style = "width: 100px;" type = "id" class="form-control" id="inputSSO" placeholder="SSO #" required = "true">
<input name = "sso" readonly style = "width: 100px;" type = "id" class="form-control" id="inputSSO" placeholder="SSO #" required = "true">
<span class = "help-block"></span>
</div>
<div class = "form-group">
<label for="inputTelephone">Telephone Number</label>
<input style = "width: 120px;" type = "tel" class="form-control" id="inputTelephone" placeholder="Telephone #">
<input name = "phone" style = "width: 120px;" type = "tel" class="form-control" id="inputTelephone" placeholder="Telephone #">
</div>
<div class = "form-group">
<label for="inputEmail">Email</label>
<input style = "width: 350px;" type = "email" class="form-control" id="inputEmail" placeholder="Email">
<input name = "email" style = "width: 350px;" type = "email" class="form-control" id="inputEmail" placeholder="Email">
</div>
<button type="submit" class="btn btn-primary" id = "apply">Apply Changes</button>
<input id = "hiddenIMG" style = "display: none" name = "img">
<button name = "profile" type="submit" class="btn btn-primary" id = "apply">Apply Changes</button>
</form>
</div>
<script>
Expand Down Expand Up @@ -147,6 +148,7 @@
//around here is where you'll have to define the current image, then this will update as the user selects new ones!
$('#profimg').attr("src","../imgs/my-icons-collection-128px/png/" + '<%=self.getIcon()%>' + ".png");
$('#hiddenIMG').val(<%=self.getIcon()%>);
};
//event listener on the apply changes button
Expand Down
51 changes: 51 additions & 0 deletions WebContent/html/webpages/profileSettingsRedirect.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<%@ page import = "database.*,entities.Device" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 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" 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">
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
</nav>
</head>
<body>
<h2>Redirect Page</h2>
<p>You shouldn't be seeing this page :)</p>

<%
//make instance
MySQLAccess myaccess = new MySQLAccess();
String name = request.getParameter("name").replace("\"","\\\"");
int id = Integer.parseInt(request.getParameter("sso"));
String phone = request.getParameter("phone");
String email = request.getParameter("email");
int img = Integer.parseInt(request.getParameter("img"));
//change form was submitted
if(request.getParameter("profile") != null){
EmployeeQueries.updateEmployee(id, name, img, phone, email);
}
%>
<script>
window.location.replace("profileSettings.jsp");
</script>
<nav class="navbar navbar-inverse navbar-fixed-top" id = "navbaruniversal">
<%@ include file="navbar.jsp"%>
</nav>
</body>
</html>
1 change: 0 additions & 1 deletion src/database/DeviceQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ public class DeviceQueries {
private static String password = "74f6e317";

public static Device[] getUserDevices(String userID) throws SQLException, ClassNotFoundException{
//Not sure how to get cookie information (if that is how we choose to accomplish this...) ? But this should be a passed parameter
System.getenv("VCAP_SERVICES");
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Expand Down
24 changes: 24 additions & 0 deletions src/database/EmployeeQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@

public class EmployeeQueries {

private static String database = "jdbc:mysql://us-cdbr-iron-east-04.cleardb.net/ad_15a989204c2ff8a?user=b372dfe7409692&password=74f6e317";
private static String user = "b372dfe7409692";
private static String password = "74f6e317";

public static void initializeEmployee(int id) throws ClassNotFoundException, SQLException
{
MySQLAccess access = new MySQLAccess();
Expand All @@ -29,6 +33,26 @@ public static void updateEmployee(int id, String name, String phone, int locatio
statement.executeUpdate(query);
access.closeConnection();
}

public static void updateEmployee(int id, String name, int icon, String phone, String email) throws ClassNotFoundException, SQLException
{
System.getenv("VCAP_SERVICES");
Class.forName("com.mysql.jdbc.Driver");
Connection connection = DriverManager.getConnection(database, user, password);
Statement stmt = connection.createStatement();
System.out.println("Updating employee "+id+": "+name+".\nPhone: "+phone+", icon: "+icon+", email: "+email);
String query = "";
query+="UPDATE employee SET ";
query+="Name='"+name;
query+="', Phone_Number='"+phone;
query+="', Email ='"+email;
query+="', Img_Index="+icon;
query+=" WHERE Employee_ID="+id;
System.out.println(query);
stmt.executeUpdate(query);
stmt.close();
connection.close();
}

public static User getEmployeeByID(int id) throws ClassNotFoundException, SQLException
{
Expand Down

0 comments on commit 4da198f

Please sign in to comment.