From da33c855cd4237c55af966e9308a9915231a8c57 Mon Sep 17 00:00:00 2001 From: Connor L Jackson Date: Sun, 4 Dec 2016 21:38:23 -0500 Subject: [PATCH] Simple admin page added --- WebContent/html/javascript/admin.js | 126 ++++++++++++++++++ WebContent/html/javascript/navbar.js | 2 +- WebContent/html/javascript/shoppingCart.js | 26 ++-- WebContent/html/webpages/admin.html | 83 ++++++++++++ bin/database/MySQLAccess.class | Bin 0 -> 543 bytes bin/features/RequestHandler.class | Bin 0 -> 3699 bytes .../ClientManager.class | Bin 0 -> 629 bytes .../SystemManager.class | Bin 0 -> 2394 bytes 8 files changed, 223 insertions(+), 14 deletions(-) create mode 100644 WebContent/html/javascript/admin.js create mode 100644 WebContent/html/webpages/admin.html create mode 100644 bin/database/MySQLAccess.class create mode 100644 bin/features/RequestHandler.class create mode 100644 bin/functionality_managers/ClientManager.class create mode 100644 bin/functionality_managers/SystemManager.class diff --git a/WebContent/html/javascript/admin.js b/WebContent/html/javascript/admin.js new file mode 100644 index 0000000..468600d --- /dev/null +++ b/WebContent/html/javascript/admin.js @@ -0,0 +1,126 @@ +var dev1 = { + id: 1, + name:"George", + description:"George is probably the coolest iPhone to exist. Ever. Point blank, period.", + hardware:"iphone", + software:"apple", +}; + +var dev2 = { + id: 2, + name:"Greyson", + description:"Greyson is pretty cool.. I guess.", + hardware:"iphone", + software:"apple", +}; + +var dev3 = { + id: 3, + name:"Linkin Park", + description:'"The hardest part of ending is starting again."', + hardware:"ipad", + software:"apple", +}; + +var dev4 = { + id: 4, + name:"Abercrombie", + description:"To all the people that hated me in high school, I have the prettiest clothes you all wear now!!", + hardware:"ipad", + software:"apple", +}; + +var dev5 = { + id: 5, + name:"Hulk", + description:"Go ahead and HULK SMASH! this awesome computer stick into your USB.", + hardware:"computerStick", + software:"intel", +}; + +var dev6 = { + id: 6, + name:"Captain America", + description:'"Make America Great Again. Wait, thats someone else.."', + hardware:"computerStick", + software:"intel", +}; + +var devices = [dev1, dev2, dev3, dev4, dev5, dev6]; + +show(); + +/** +This displays all the requested items on the screen. +**/ +function show(){ + //get the option that you selected + var requested = getRequestedItems(); + var html = '

Please review the device requests below.

'; + + //iterate through the hardcoded device DB and select all the ones that match the selected option + for(var i = 0; i < requested.length; i++){ + for(var j = 0; j < devices.length; j++){ + if(requested[i] === devices[j].id){ + html += '
' + devices[j].name + '

' + devices[j].description + '



' + break; + } + } + } + + if(html.localeCompare("")==0) + html = "

There are no requests to approve

"; + + //add to HTML page + document.getElementById('devContainer').innerHTML = html; + + //now we need to add event listeners to all the request buttons + var approvebuttons = document.getElementsByClassName('approvebutton'); + for(var i = 0; i < approvebuttons.length; i++){ + approvebuttons[i].addEventListener('click',approveRequest); + } +} + +/** +This function gets requested items from local storage. +**/ +function getRequestedItems(){ + var requested = new Array; //make new array + var requested_str = localStorage.getItem('requested'); //get the string from local storage + if(requested_str !== '' && requested_str !== null){ //as long as its not null + requested = JSON.parse(requested_str); //make into array + } + return requested; //return value is an array +} + +/** +This function approves a request! +**/ +function approveRequest(){ + var id = this.getAttribute('id'); + id = parseInt(id.replace(/[^0-9\.]/g,''),10); //this gets just the numerical value from the id! + var unavailable = getUnavailableItems(); //this is an array + var requested = getRequestedItems(); + unavailable.push(id); //push to bottom of cart + localStorage.setItem('unavailable', JSON.stringify(unavailable)); + for(var j = 0; j < requested.length; j++){ //iterate cart + if(requested[j] == id){ //match ids + requested.splice(j,1); //remove from the cart + break; + } + } + localStorage.setItem('requested', JSON.stringify(requested)); //update local storage + show(); + $('#approved').fadeIn(1000); + $('#approved').fadeIn(1000); + $('#approved').fadeOut(1000); +} + +function getUnavailableItems(){ + var unavailable = new Array; + var unavailable_str = localStorage.getItem('unavailable'); + if(unavailable_str !== "" && unavailable_str !== null){ + unavailable = JSON.parse(unavailable_str); + } + return unavailable; +} \ No newline at end of file diff --git a/WebContent/html/javascript/navbar.js b/WebContent/html/javascript/navbar.js index 6e62706..0cd657f 100644 --- a/WebContent/html/javascript/navbar.js +++ b/WebContent/html/javascript/navbar.js @@ -1 +1 @@ -document.getElementById('navbaruniversal').innerHTML = '
' \ No newline at end of file +document.getElementById('navbaruniversal').innerHTML = '
' \ No newline at end of file diff --git a/WebContent/html/javascript/shoppingCart.js b/WebContent/html/javascript/shoppingCart.js index 498d818..04cd257 100644 --- a/WebContent/html/javascript/shoppingCart.js +++ b/WebContent/html/javascript/shoppingCart.js @@ -149,14 +149,14 @@ function orderSelected(){ if(response == true){ //if they confirm for(var i = 0; i < checked.length; i++){ //iterate all the checked off devices var id = checked[i]; //get the id of each device - var unavailable = getUnavailableItems(); //get the unavailable items + var requested = getRequestedItems(); //get the unavailable items var cart = getCartItems(); //get the cart - unavailable.push(id); //add to unavailable list + requested.push(id); //add to unavailable list for(var j = 0; j < cart.length; j++){ //iterate cart if(cart[j] == id) //match id's cart.splice(j,1); //remove from the cart } - localStorage.setItem('unavailable', JSON.stringify(unavailable)); //update local storage + localStorage.setItem('requested', JSON.stringify(requested)); //update local storage localStorage.setItem('cart', JSON.stringify(cart)); //update local storage } checked = new Array; //reset the checked off array @@ -194,9 +194,9 @@ function orderAll(){ var cart = getCartItems(); //get the cart for(var i = 0; i < cart.length; i++){ //iterate the cart var id = cart[i]; //get the id of each device - var unavailable = getUnavailableItems(); //get the unavailable items - unavailable.push(id); //add to unavailable list - localStorage.setItem('unavailable', JSON.stringify(unavailable)); //update local storage + var requested = getRequestedItems(); //get the unavailable items + requested.push(id); //add to unavailable list + localStorage.setItem('requested', JSON.stringify(requested)); //update local storage } checked = new Array; //reset the checked off array cart = new Array; //cart should now be empty, so reset also @@ -219,13 +219,13 @@ function deleteAll(){ } /** -This function gets unavailable items from local storage. +This function gets requested items from local storage. **/ -function getUnavailableItems(){ - var unavailable = new Array; //make new array - var unavailable_str = localStorage.getItem('unavailable'); //get the string from local storage - if(unavailable_str !== '' && unavailable_str !== null){ //as long as its not null - unavailable = JSON.parse(unavailable_str); //make into array +function getRequestedItems(){ + var requested = new Array; //make new array + var requested_str = localStorage.getItem('requested'); //get the string from local storage + if(requested_str !== '' && requested_str !== null){ //as long as its not null + requested = JSON.parse(requested_str); //make into array } - return unavailable; //return value is an array + return requested; //return value is an array } \ No newline at end of file diff --git a/WebContent/html/webpages/admin.html b/WebContent/html/webpages/admin.html new file mode 100644 index 0000000..094bfa8 --- /dev/null +++ b/WebContent/html/webpages/admin.html @@ -0,0 +1,83 @@ + + + + + + + + + + Synchrony Financial + + + + + + + + + + + + +
+

Admin View Approvals

+
+
+ +
+

Approved!

+
+ + + + + \ No newline at end of file diff --git a/bin/database/MySQLAccess.class b/bin/database/MySQLAccess.class new file mode 100644 index 0000000000000000000000000000000000000000..f494f5e9f8a59aa97fc2b15c944172f386a46d0b GIT binary patch literal 543 zcmZuuO;5r=5PbuM0#^A(K>WHX2Yd0RF)<{b>Sqm}m$K24(qdao{8=81i3fjxKgu{; zMAVo~X5P%aeKR}z{_*+-U>{pLQiR%2#9|;KX`VjXm)5c4$SBgG5lSQRAWTpAx90g^ zB%PR`JAv;fsBR_I=-xAXvz#0F2ZVeSi&&1O&+OWQW6!fpDNjN<5uqG@CkdSe_2O?; zsfIF|da*5kt6t5sOvxU)z8fDA(mT6-g4PR$vVb(o29~js2cc>pgRDYz13GdFts2Oq zpis-e5)4Aoa(#I=9S>x9Ee4(>RII=eUSEW+iocRteCI}lhV|e2c$|VAOhZSWxJse) zW3_u~Z`kIJY5oNbDK!+Mlo~1VJW%3!9QMSAAHcTA(GBy6eXIL|QkR}lQKqI$Lz(7N ma<$F2oycamMV8;FvqTP6Mon(G#&u&Rgbvm@B5Wi#H$MRnxpOW6 literal 0 HcmV?d00001 diff --git a/bin/features/RequestHandler.class b/bin/features/RequestHandler.class new file mode 100644 index 0000000000000000000000000000000000000000..aa208691741fe0937a3db3d59d116eb03515666d GIT binary patch literal 3699 zcmcguU2_xH8Geqm(#p$192*%7byyREzhoO4Fw_Po{wR)!u?coefqrByE!M(%SCLi* z(=<(8w+(5VHvOW|kA!JwnCaxA^uo|&CNu5yqSNX0raz!}?Q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DN$_`78Jv>%ND?T@E79%0@r}TR7H31O9I1 z8*31c@yW%J15juKvEz4WY-(A<&hFG2o|uwvd)Kh9XAK=|=p9t##HTsYsx%#1!@wV&Bam7@*+uf?r&vQ2){!K2LY@o(v6H3JitE^g zx3C*Gc-eRxZTLO+dXKCBzzfBn$m?IR7yrbQ_!su!-*^iDfgxh(5ZllxTF@0xcqXK& zOd$!w=kWzeD@R|%mq_|H(SVm=QX_k~!#pyK{5sx578ccVgOOb1T%2C#u)sMLxw16E zl{Qyi;!GQ~2N+c`q_QP+;Q>wxIr&7%RLEsP3C@!3l}`iMn}?hXXmc8A+mvgO@J<|9?! zQ_eO*t3lKOIMqWi=rHa5x6@l0A-2j0Yzey~VfWIw>K0rc<|6*3c z!9zEM1AnK}IGs-@14?utb_WN0ld&=$tVUAS7ETb4=A^Rw9cbbEn@n*vCX%sUW*JoM zTTETnM#$uTG;sVZ-$pnZrHaSU&DMPoCz$C7?`LU_P6l}mhapt+nh3NgnVkqSj07X8 z=qUfkgA5g}IT~ab3o_K8JfIpyM?@ybOF0w!A=gFlBiYo1QRaR1eGHwuhaaCR^Z#P1 zry_u#+`@SH!ej>@&EGt`j>Mmn#OkWenC~Gbzgf4a%KXmMZy8tELAnFgpCap198I&7 zPV>J10uegHTApFX)38~aD>z%DfYmBes{!vkQSb_W$vT&9{#sc9Te(B1fJ#k=RyM6< XO>aZ=BQ&z6r7Wf-YHxEkf_MH0JWf@% literal 0 HcmV?d00001 diff --git a/bin/functionality_managers/ClientManager.class b/bin/functionality_managers/ClientManager.class new file mode 100644 index 0000000000000000000000000000000000000000..781f456bd0e8933823632892c6355377d0a6f7cd GIT binary patch literal 629 zcma)3+e*Vg6r63VwP|YVwbr{JQmdF3-xMFLh(c7bQV<_xn{L}J=@!$C;AaV5K*102 zqr{V>AfkdSZ1!x<%$b>e|9E)=u#KfO5)7-&K)G7>6!)aQyY6zuTf*<#6;BGKPvSC- z6hpqlZ@KMp)w0j(9pP$*gx_W;I!(cK;ET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