From 5590ded009eb9ac27619434a9e4f931f1b8bb3c0 Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Wed, 5 Apr 2017 23:08:48 -0400 Subject: [PATCH] Enhancements and Bug Fixes --- WebContent/html/css/stylesheet.css | 15 --- WebContent/html/javascript/profileIcon.js | 37 ------ WebContent/html/javascript/profileSettings.js | 86 ------------- WebContent/html/webpages/profileSettings.jsp | 121 +++++++++++++++++- src/database/EmployeeQueries.java | 4 +- src/entities/Admin.java | 4 +- src/entities/User.java | 15 ++- 7 files changed, 137 insertions(+), 145 deletions(-) delete mode 100644 WebContent/html/javascript/profileIcon.js delete mode 100644 WebContent/html/javascript/profileSettings.js diff --git a/WebContent/html/css/stylesheet.css b/WebContent/html/css/stylesheet.css index 514900a..0d323da 100644 --- a/WebContent/html/css/stylesheet.css +++ b/WebContent/html/css/stylesheet.css @@ -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; } diff --git a/WebContent/html/javascript/profileIcon.js b/WebContent/html/javascript/profileIcon.js deleted file mode 100644 index 1b127b2..0000000 --- a/WebContent/html/javascript/profileIcon.js +++ /dev/null @@ -1,37 +0,0 @@ -var iconSelect; - - 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/1.png', 'iconValue':'1'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/2.png', 'iconValue':'2'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/3.png', 'iconValue':'3'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/4.png', 'iconValue':'4'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/5.png', 'iconValue':'5'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/6.png', 'iconValue':'6'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/7.png', 'iconValue':'7'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/8.png', 'iconValue':'8'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/9.png', 'iconValue':'9'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/10.png', 'iconValue':'10'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/11.png', 'iconValue':'11'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/12.png', 'iconValue':'12'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/13.png', 'iconValue':'13'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/14.png', 'iconValue':'14'}); - icons.push({'iconFilePath':'../imgs/my-icons-collection-32px/png/15.png', 'iconValue':'15'}); - - 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/11.png"); - - }; \ No newline at end of file diff --git a/WebContent/html/javascript/profileSettings.js b/WebContent/html/javascript/profileSettings.js deleted file mode 100644 index 907c3b1..0000000 --- a/WebContent/html/javascript/profileSettings.js +++ /dev/null @@ -1,86 +0,0 @@ -//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(name); - //$('#inputSSO').val(SSO); - //$('#inputTelephone').val(telephone); - //$('#inputEmail').val(email); -} - -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"; -} \ No newline at end of file diff --git a/WebContent/html/webpages/profileSettings.jsp b/WebContent/html/webpages/profileSettings.jsp index ade5075..a17f077 100644 --- a/WebContent/html/webpages/profileSettings.jsp +++ b/WebContent/html/webpages/profileSettings.jsp @@ -1,3 +1,5 @@ +<%@ page import = "database.*,entities.User" %> +<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> @@ -91,6 +93,7 @@

Change profile image:

+
@@ -117,10 +120,122 @@ + - - + 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"; + } + \ No newline at end of file diff --git a/src/database/EmployeeQueries.java b/src/database/EmployeeQueries.java index 981329b..ecb5687 100644 --- a/src/database/EmployeeQueries.java +++ b/src/database/EmployeeQueries.java @@ -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(); diff --git a/src/entities/Admin.java b/src/entities/Admin.java index d6fe586..2ebfd89 100644 --- a/src/entities/Admin.java +++ b/src/entities/Admin.java @@ -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); } } diff --git a/src/entities/User.java b/src/entities/User.java index 5545d91..cec664c 100644 --- a/src/entities/User.java +++ b/src/entities/User.java @@ -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;