Skip to content

Commit

Permalink
Enhancements and Bug Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
clj13001 committed Apr 6, 2017
1 parent 8a01c2c commit 5590ded
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 145 deletions.
15 changes: 0 additions & 15 deletions WebContent/html/css/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,6 @@ div.modal-body{
overflow: auto;
}

input[type=text]{
margin: 0 auto;
width: 60%;
}

input[type=tel]{
margin: 0 auto;
width: 60%;
}

input[type=number]{
margin: 0 auto;
width: 60%;
}

textarea{
margin: 0 auto;
}
Expand Down
37 changes: 0 additions & 37 deletions WebContent/html/javascript/profileIcon.js

This file was deleted.

86 changes: 0 additions & 86 deletions WebContent/html/javascript/profileSettings.js

This file was deleted.

121 changes: 118 additions & 3 deletions WebContent/html/webpages/profileSettings.jsp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%@ page import = "database.*,entities.User" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html lang="en">
<head>
<meta charset="utf-8">
Expand Down Expand Up @@ -91,6 +93,7 @@
</div>
<br>
<p style = "display: inline-block;">Change profile image:</p>
<!-- Image selector tool -->
<div id="my-icon-select" style = "display: inline-block;"></div>
</div>
<!-- Where main user information is edited -->
Expand All @@ -117,10 +120,122 @@
<button type="submit" class="btn btn-primary" id = "apply">Apply Changes</button>
</form>
</div>
<script>
var iconSelect;
<script src = "../javascript/navbar.js"></script>
<script src = "../javascript/profileIcon.js"></script>
<script src = "../javascript/profileSettings.js"></script>
window.onload = function(){
iconSelect = new IconSelect("my-icon-select",
{'selectedIconWidth':23,
'selectedIconHeight':23,
'selectedBoxPadding':3,
'iconsWidth':48,
'iconsHeight':48,
'boxIconSpace':5,
'vectoralIconNumber':2,
'horizontalIconNumber':8});
var icons = [];
icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/' + <%=self.getIcon()%> + '.png', 'iconValue':' + <%=self.getIcon()%> + '});
for(var i = 1; i <= 15; i++){
if( i != <%=self.getIcon()%>)
icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/' + i + '.png', 'iconValue': i });
}
iconSelect.refresh(icons);
//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");
};
//event listener on the apply changes button
document.getElementById('apply').addEventListener('click',applyChanges);
document.getElementById('inputName').addEventListener('keyup',checkEmpty);
document.getElementById('inputSSO').addEventListener('keyup',checkEmpty);
document.getElementById('closeBttn').addEventListener('click',function(){document.getElementById('missingcontent').style.display = "none";});
var typeTimer;
var doneTypingInterval = 2000 //ms
$('#inputSSO').keyup(function(){clearTimeout(typeTimer); typeTimer = setTimeout(querySSO,doneTypingInterval);});
var flag = 0;
var name;
var SSO;
var telephone;
var email;
//populates the fields
populate();
//sends applied changes to DB
function applyChanges(){
if(flag == 0){
name = $('#inputName').val();
SSO = $('#inputSSO').val();
telephone = $('#inputTelephone').val();
email = $('#inputEmail').val();
//send these values to DB for updates to be made
//EX
//if(name != "")
//send to database
}
else
$('#missingcontent').css('display','block');
}
//populates form fields if info exists in db already
function populate(){
//get values from database
$('#inputName').val('<%=navname%>');
$('#inputSSO').val('<%=self.getID()%>');
$('#inputTelephone').val('<%=self.getPhone()%>');
$('#inputEmail').val('<%=self.getEmail()%>');
}
function checkEmpty(){
var id = this.getAttribute('id');
if($('#' + id).val() == ""){
$('#' + id).parent().attr('class','form-group has-error');
$('#' + id).siblings('span').text(warningtext(id))
}
else{
$('#' + id).parent().attr('class','form-group');
$('#' + id).siblings('span').text('')
}
}
function warningtext(id){
if(id == "inputName")
return "This is a required field.";
else if (id == "inputSSO")
return "This is a required field.";
}
function querySSO(){
//query to see if SSO is in database already
//if so... && val() != ""
//$('#' + id).parent().attr('class','form-group has-error');
//$('#inputSSO').siblings('span').text('SSO is currently in use.');
//flag = 1;
//if not... && val() != ""
//$('#' + id).parent().attr('class','form-group');
//$('#' + id).siblings('span').text('');
}
window.onclick = function(event) {
var modal = document.getElementById('missingcontent');
if(event.target == modal)
modal.style.display = "none";
}
</script>
</body>

</html>
4 changes: 3 additions & 1 deletion src/database/EmployeeQueries.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public static User getEmployeeByID(int id) throws ClassNotFoundException, SQLExc
id,
resultSet.getInt("Location_ID"),
resultSet.getString("Name"),
resultSet.getString("Phone_Number")
resultSet.getString("Phone_Number"),
resultSet.getString("Email"),
resultSet.getInt("Img_Index")
);
resultSet = statement.executeQuery("SELECT Address FROM location WHERE Location_ID = "+employee.getLocation());
resultSet.next();
Expand Down
4 changes: 2 additions & 2 deletions src/entities/Admin.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*/
public class Admin extends User {

public Admin(int id, int location, String name, String phone) {
super(id, location, name, phone);
public Admin(int id, int location, String name, String phone, String email, int icon) {
super(id, location, name, phone, email, icon);
}

}
15 changes: 14 additions & 1 deletion src/entities/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@ public class User {
private String locationName;
private String name;
private String phone;
private String email;
private int icon;

public User(int id, int location, String name, String phone){
public User(int id, int location, String name, String phone, String email, int icon){
this.id = id;
this.location = location;
this.name = name; //later will do table lookup to determine by id
this.phone = phone;
this.email = email;
this.icon = icon;
}

public int getIcon(){
return icon;
}

public String getEmail(){
return email;
}

public int getID()
{
return id;
Expand Down

0 comments on commit 5590ded

Please sign in to comment.