From 065ecf9bb4c71ae8c511535a5234b6c4d4f87bcd Mon Sep 17 00:00:00 2001 From: Jack Date: Tue, 15 Jan 2019 18:41:23 -0800 Subject: [PATCH 1/8] Add icon to the all of the pages that are missing --- front/static/login.html | 1 + front/static/signup.html | 1 + 2 files changed, 2 insertions(+) diff --git a/front/static/login.html b/front/static/login.html index 39b3960..f9387dc 100644 --- a/front/static/login.html +++ b/front/static/login.html @@ -6,6 +6,7 @@ + Login diff --git a/front/static/signup.html b/front/static/signup.html index 43a62cd..8cba043 100644 --- a/front/static/signup.html +++ b/front/static/signup.html @@ -6,6 +6,7 @@ + Sign up From e1f06dbb2b743d13750ed87db8363fb2007a3b6c Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Wed, 16 Jan 2019 22:59:51 -0800 Subject: [PATCH 2/8] Add login script to login page --- front/static/login.html | 4 ++-- front/static/login.js | 45 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) create mode 100644 front/static/login.js diff --git a/front/static/login.html b/front/static/login.html index f9387dc..3784525 100644 --- a/front/static/login.html +++ b/front/static/login.html @@ -11,11 +11,11 @@

Login Page

-
+ username:
password:
- + diff --git a/front/static/login.js b/front/static/login.js new file mode 100644 index 0000000..20217d3 --- /dev/null +++ b/front/static/login.js @@ -0,0 +1,45 @@ +function displayErrorMessage(errorMessage) { + const errorReport = document.querySelector("#errorReport"); + errorReport.innerHTML = JSON.parse(errorMessage).error; +} + +function postToLoginEndpoint(event) { + event.preventDefault(); + + const credentials = { + "username" : this.elements.username.value, + "password" : this.elements.password.value + } + const url = "https://reqres.in/api/login" // mock api service + const xhr = new XMLHttpRequest(); + + console.log(`User credentials:\n${JSON.stringify(credentials)}`); + + xhr.open("POST", url, true); + xhr.setRequestHeader("Content-Type", "application/json"); + xhr.onreadystatechange = function() { + if (this.readyState === 4) { + if (this.status === 200) { + console.log("LOGIN SUCCESS!"); + console.log(`Server response:\n${this.response}`); + token = JSON.parse(this.response).token; + localStorage.setItem("token", token); + window.location.replace("dashboard.html"); + } else { + console.log("LOGIN FAILURE!"); + console.log(`Server status: ${this.status}`); + console.log(`Server response:\n${this.response}`); + displayErrorMessage(this.response); + } + } + }; + + xhr.onerror = function() { + alert("Error connecting to the authentication server!"); + }; + + xhr.send(JSON.stringify(credentials)); +} + +const form = document.querySelector("form"); +form.addEventListener("submit", postToLoginEndpoint); From e0540739e7d43bb2c552528fa43f990d7c75e8e5 Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Wed, 16 Jan 2019 23:55:23 -0800 Subject: [PATCH 3/8] Add missing errorReport tag to login.html --- front/static/login.html | 1 + 1 file changed, 1 insertion(+) diff --git a/front/static/login.html b/front/static/login.html index 3784525..40ceccf 100644 --- a/front/static/login.html +++ b/front/static/login.html @@ -16,6 +16,7 @@ password:
+

From 91c0b8eb5e899f2d8987f2f50ac57f3e32eafd47 Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Thu, 17 Jan 2019 13:12:17 -0800 Subject: [PATCH 4/8] Add logout script to dashboard.html and fix formatting --- front/static/dashboard.html | 71 +++++++++++++++++++------------------ front/static/logout.js | 33 +++++++++++++++++ 2 files changed, 70 insertions(+), 34 deletions(-) create mode 100644 front/static/logout.js diff --git a/front/static/dashboard.html b/front/static/dashboard.html index 299c8e0..6b2019c 100644 --- a/front/static/dashboard.html +++ b/front/static/dashboard.html @@ -1,38 +1,41 @@ - - - - - - - Reimbursinator - - - -

-

Reimbursinator Report

- + + + + + + + Reimbursinator + + + +
+
+

Reimbursinator Report

- + +
+ + diff --git a/front/static/logout.js b/front/static/logout.js new file mode 100644 index 0000000..181372e --- /dev/null +++ b/front/static/logout.js @@ -0,0 +1,33 @@ +function postToLogoutEndpoint(event) { + event.preventDefault(); + + const token = localStorage.getItem("token"); + const url = "https://reqres.in/api/logout" // mock api service + const xhr = new XMLHttpRequest(); + + xhr.open("POST", url, true); + xhr.setRequestHeader("Authorization", `Token ${token}`); + xhr.onreadystatechange = function() { + if (this.readyState === 4) { + if (this.status === 200) { + console.log("LOGOUT SUCCESS!"); + console.log(`Server response:\n${this.response}`); + localStorage.removeItem("token"); + window.location.replace("index.html"); + } else { + console.log("LOGOUT FAILURE!"); + console.log(`Server status: ${this.status}`); + console.log(`Server response:\n${this.response}`); + } + } + }; + + xhr.onerror = function() { + alert("Error connecting to authentication server!"); + }; + + xhr.send(); +} + +const logoutLink = document.querySelector("#logoutLink"); +logoutLink.addEventListener("click", postToLogoutEndpoint); From 660c556ca1cec1cfc8410d54b63a84eeaab869a3 Mon Sep 17 00:00:00 2001 From: Daniel Dupriest Date: Thu, 17 Jan 2019 14:12:20 -0800 Subject: [PATCH 5/8] Recreated django project with v2.1.4 and updated docker config to match. --- back/Pipfile | 2 +- back/db.sqlite3 | Bin 131072 -> 131072 bytes back/manage.py | 0 back/reimbursinator/settings.py | 2 +- back/reimbursinator/urls.py | 4 ++-- 5 files changed, 4 insertions(+), 4 deletions(-) mode change 100644 => 100755 back/manage.py diff --git a/back/Pipfile b/back/Pipfile index b7f1045..876b3dc 100644 --- a/back/Pipfile +++ b/back/Pipfile @@ -6,7 +6,7 @@ verify_ssl = true [dev-packages] [packages] -django = "==1.10.7" +django = "==2.1.4" gunicorn = "==19.6.0" [requires] diff --git a/back/db.sqlite3 b/back/db.sqlite3 index b6fecf6420251615360cff2635ba0af13237cc93..1f6f0ed1a08d2e8bcd94c1145e54f8deb305f9f7 100644 GIT binary patch delta 1218 zcmah_Jx^0n8189LY5C|m<>T7K^tQKRDWtTVbM7|_Do!pkIT>rE4crKY@F5FHn>d&l z6Nfu=!^Fi&BQh|ki9f&r7YAd?V4{=1KutX7w!(!raeO}B=Y8L&(TFx0(bsdygk2!C zKuv|QSz^!XYSGXPMyY!%$$Dsn=*)DVC26;&GnLu4`y**|Yno0CRdY3Yx?59C+hB&f zBNuvThDLSOeJkg?HD(z$QQbdsv4=)g+tl1^DYaXpgfeQnPkL!Y)hyL?Kc}?wbF64n z!_tYHNl(|$b;gPo(`{mqP&kmtUM*Kvof;v8mYkZi<&;+#p(z}_XLHk8tHBtQ zB#+zPtZsx5loB3V+F09OcYn^MLM?oBfUdm4bOgeHlsP*-6ylsDI58dza+DCLGk){3 z^c+9MyZAo7jc;HJPvTMZ3w=A7Sa^Zz5(IewA2`*W(&<6*1OzhxR;nx2t*Vd5ZGLgN zTwC(ABB%q#jzO*-<6w%O`*yxuQ}{mRw8Z2P z_oZ{E1qh4yL=m4UgIpcY`|A*T`?0oTpzZLrBOHr$uYJ#Qv7cMy>`7h!jt~n{QLbgC weBGVw_d2;0;d-`krb^!hZBJj@?`TP`Z#zH)RP`#G)ueCrX_9du>tWS z-WJSBJ$h2C6)K4TfQon$6xxCpPon>T;OuPL#3tbJd;GrN$Jc7bTdnxZ`Bbu8q^!tD zmRfU`F~=$;Y7@d7|3-@SYotPmY5Gr7bb!W4nV9~Mlzm()mnxRYDDzEyre7h0viFU>GzogCnJJWC| z@0rWYY#rOITrvz|6N|{vNHTw+R$ulSgb-Tw8s55BTVjOvT`;4<9BWpJMl^o0vA+1f z18P`|5C=pfdH-WZ@9#$}i&X4a*-jA+{7xgv9v43IbNZKhgA&FFSNHaas3(E!VqKtyz9A})u51i0)lY>>+X`f?g|En%$>zrVQt7V@3MEnNI6 Date: Fri, 18 Jan 2019 14:10:09 -0800 Subject: [PATCH 6/8] Changed docker-compose.yml version to 2.0 and tried to fix recursion issue by naming images. --- docker-compose.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index dea2bf8..bd21cbc 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,9 @@ -version: '3.3' +version: '2.0' services: api: build: ./back + image: reimbursinator_back command: gunicorn --bind 0.0.0.0:444 --keyfile /etc/ssl/private/selfsigned.key --certfile /etc/ssl/private/selfsigned.crt reimbursinator.wsgi:application #volumes: # - ./app/:/usr/src/back/ @@ -12,6 +13,7 @@ services: - SECRET_KEY=please_change web: build: ./front + image: reimbursinator_front image: nginx:1.10.3 ports: - "8443:443" From aadc284adeac5e86dd822c4515fd062cdce034b9 Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Fri, 18 Jan 2019 15:37:53 -0800 Subject: [PATCH 7/8] Fix Jquery bug by changing script include order --- front/static/dashboard.html | 12 ++++++------ front/static/index.html | 6 +++--- front/static/login.html | 4 ++-- front/static/signup.html | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/front/static/dashboard.html b/front/static/dashboard.html index 6b2019c..44506e6 100644 --- a/front/static/dashboard.html +++ b/front/static/dashboard.html @@ -1,13 +1,13 @@ - + - - - - + + + + + Reimbursinator -
diff --git a/front/static/index.html b/front/static/index.html index bdab667..c55dda5 100644 --- a/front/static/index.html +++ b/front/static/index.html @@ -2,12 +2,12 @@ - + - + + Reimbursinator -
diff --git a/front/static/login.html b/front/static/login.html index 40ceccf..75f3087 100644 --- a/front/static/login.html +++ b/front/static/login.html @@ -4,9 +4,9 @@ - - + + Login diff --git a/front/static/signup.html b/front/static/signup.html index 8cba043..d8e66fa 100644 --- a/front/static/signup.html +++ b/front/static/signup.html @@ -4,9 +4,9 @@ - - + + Sign up @@ -20,4 +20,4 @@ - \ No newline at end of file + From 108a854ef8a404a181d4432f2a453c872fb869f5 Mon Sep 17 00:00:00 2001 From: Preston Doman Date: Sat, 19 Jan 2019 00:09:27 -0800 Subject: [PATCH 8/8] Add collapsible navbar to all pages --- front/static/dashboard.html | 19 ++++++++++++++++++- front/static/index.html | 25 ++++++++++++++++++++++++- front/static/login.html | 26 +++++++++++++++----------- front/static/logout.js | 5 +++-- front/static/signup.html | 20 ++++++++++++-------- 5 files changed, 72 insertions(+), 23 deletions(-) diff --git a/front/static/dashboard.html b/front/static/dashboard.html index 44506e6..a8b588e 100644 --- a/front/static/dashboard.html +++ b/front/static/dashboard.html @@ -3,6 +3,7 @@ + @@ -10,6 +11,22 @@ Reimbursinator +

Reimbursinator Report

@@ -31,7 +48,7 @@ diff --git a/front/static/index.html b/front/static/index.html index c55dda5..ff26455 100644 --- a/front/static/index.html +++ b/front/static/index.html @@ -3,6 +3,7 @@ + @@ -10,6 +11,28 @@ Reimbursinator +

Reimbursinator

@@ -19,7 +42,7 @@ Sign up
diff --git a/front/static/login.html b/front/static/login.html index 75f3087..5f44283 100644 --- a/front/static/login.html +++ b/front/static/login.html @@ -3,20 +3,24 @@ + - Login + Log in - -

Login Page

-
- username:
- password:
- -
-

- - + +

+

Log in

+
+ username:
+ password:
+ +
+

+ + diff --git a/front/static/logout.js b/front/static/logout.js index 181372e..e7a3a21 100644 --- a/front/static/logout.js +++ b/front/static/logout.js @@ -29,5 +29,6 @@ function postToLogoutEndpoint(event) { xhr.send(); } -const logoutLink = document.querySelector("#logoutLink"); -logoutLink.addEventListener("click", postToLogoutEndpoint); +const logoutLinks = document.querySelectorAll(".log-out-link"); +logoutLinks[0].addEventListener("click", postToLogoutEndpoint); +logoutLinks[1].addEventListener("click", postToLogoutEndpoint); diff --git a/front/static/signup.html b/front/static/signup.html index d8e66fa..7635b4e 100644 --- a/front/static/signup.html +++ b/front/static/signup.html @@ -3,6 +3,7 @@ + @@ -10,14 +11,17 @@ Sign up -

Sign up page

-
- User Name:
- Password:
- Confirm Password:
- - Return to main menu -
+ +

Sign up page

+
+ User Name:
+ Password:
+ Confirm Password:
+ + Return to main menu +