From 3a03688e6a638676e8ed13b3aac04a787578d0d0 Mon Sep 17 00:00:00 2001 From: jslightham <31053827+jslightham@users.noreply.github.com> Date: Wed, 15 Apr 2020 09:54:30 -0400 Subject: [PATCH] fix all present bug and remove console.log --- attendancetracker/API/attendance.route.js | 4 +- attendancetracker/API/login.route.js | 23 +-- .../src/components/Attendance.vue | 134 +++++++++++------- .../src/components/Attendees.vue | 6 +- attendancetracker/src/components/Calendar.vue | 106 ++++++++++++-- attendancetracker/src/components/Insights.vue | 12 +- attendancetracker/src/components/Login.vue | 2 +- attendancetracker/src/components/Register.vue | 4 +- 8 files changed, 209 insertions(+), 82 deletions(-) diff --git a/attendancetracker/API/attendance.route.js b/attendancetracker/API/attendance.route.js index 93af6e2..b1093fc 100644 --- a/attendancetracker/API/attendance.route.js +++ b/attendancetracker/API/attendance.route.js @@ -17,7 +17,7 @@ let Att = require('./attendee.model'); attendanceRoute.route('/attendees').post(function (req, res) { let username = req.body.user; - console.log(username) + //console.log(username) Att.find({user: username}, function (err, posts){ if(err) { res.json(err); @@ -29,7 +29,7 @@ let Att = require('./attendee.model'); attendanceRoute.route('/getById').post(function (req, res) { let username = req.body.user; - console.log(username) + //console.log(username) Att.find({user: username}, function (err, posts){ if(err) { res.json(err); diff --git a/attendancetracker/API/login.route.js b/attendancetracker/API/login.route.js index 238b2fb..f775b23 100644 --- a/attendancetracker/API/login.route.js +++ b/attendancetracker/API/login.route.js @@ -4,15 +4,15 @@ const loginRoute = express.Router(); let LInfo = require('./user.model'); loginRoute.route('/add').post(function (req, res) { - console.log(req.body); + //console.log(req.body); var username = req.body.user; LInfo.findOne({user: username}, function(err, user){ - console.log(user); + //console.log(user); if(user == null){ let post = new LInfo(req.body); post.dates = []; - console.log(post); + //console.log(post); post.save() .then(() => { res.status(200).send("Account added successfully"); @@ -23,7 +23,7 @@ loginRoute.route('/add').post(function (req, res) { } else { res.json(user); - console.log("user"); + //console.log("user"); } }); }); @@ -33,18 +33,18 @@ loginRoute.route('/post').post(function (req, res) { //console.log(res); var username = req.body.user; var password = req.body.pass; - console.log(username); - console.log(password); + //console.log(username); + //console.log(password); LInfo.findOne({user: username, pass: password}, function(err, user){ - console.log(user); + //console.log(user); if(!user){ res.json(null); - console.log("err"); + //console.log("err"); } else { res.json(user); - console.log("user"); + //console.log("user"); } }); }); @@ -65,7 +65,7 @@ loginRoute.route('/post').post(function (req, res) { var username = req.body.user; var dates = req.body.dates; - Att.findOne({user: username}, function(err, post) { + LInfo.findOne({user: username}, function(err, post) { if (!post) res.status(404).send("data is not found"); else { @@ -80,4 +80,7 @@ loginRoute.route('/post').post(function (req, res) { } }); }); + + + module.exports = loginRoute; \ No newline at end of file diff --git a/attendancetracker/src/components/Attendance.vue b/attendancetracker/src/components/Attendance.vue index 0faf560..7c5eb70 100644 --- a/attendancetracker/src/components/Attendance.vue +++ b/attendancetracker/src/components/Attendance.vue @@ -224,24 +224,16 @@ this.$router.push({name: 'login'}); }else{ this.post.user = this.user; - //alert(this.post.user); - let uri = 'http://65.92.152.100:4000/attendance/attendees'; + let uri = 'http://localhost:4000/attendance/attendees'; this.axios.post(uri, this.post).then(res => { this.attendees = res.data; - //console.log(this.attendees); for(var element of this.attendees){ - //console.log(element); if(element.presences.indexOf(this.$route.params.id) > -1){ this.presentNames.push(element._id); - //document.getElementById(element + ":pcheckbox").style.backgroundColor = "green"; }else{ this.absentNames.push(element._id); - //document.getElementById(element + ":acheckbox").style.backgroundColor = "red"; } - } - - //console.log(this.presentNames); }); } }, @@ -258,10 +250,7 @@ presentNames: [], checked: true, post: {}, - user: null, - dismissSecs: 10, - dismissCountDown: 0, - showDismissibleAlert: false + user: null } }, methods: { @@ -273,86 +262,131 @@ //iterate through all present, then all absent, and get array of that id user, then check for the current day, if it contains delete, and append the date to the correct array for(var element of this.presentNames){ var test = {number: element}; - let uri = 'http://65.92.152.100:4000/attendance/getarr'; + let uri = 'http://localhost:4000/attendance/getarr'; this.axios.post(uri, test).then(res => { var arr = res.data.presences; arr = arr.filter(e => e !== this.$route.params.id); - //console.log(arr); var arr2 = res.data.absenses; arr2 = arr2.filter(e => e !== this.$route.params.id); - //console.log(arr2); arr.push(this.$route.params.id); this.post.presences = arr; this.post.absenses = arr2; - //console.log(res.data._id); - var test2 = {id: res.data._id, presences: arr, absenses: arr2}; - //console.log(test2); - let url = 'http://65.92.152.100:4000/attendance/post'; - this.axios.post(url, test2).then(res => { - console.log(res); - - /* - var ldata = {user: this.user}; - let url2 = 'http://65.92.152.100:4000/login/getdates'; - this.axios.post(url2, ldata).then(res => { - console.log(res.data); - var arrd = res.data.dates; - arrd = arrd.filter(e => e !== this.$route.params.id, this.date); - var ddata = {dates: arrd, user: this.user}; - arrd.push(ddata); - console.log(arrd); - let url3 = 'http://65.92.152.100:4000/login/update'; - this.axios.post(url3, ddata).then(res => { + var test2 = {id: res.data._id, presences: arr, absenses: arr2}; + + let url = 'http://localhost:4000/attendance/post'; + this.axios.post(url, test2).then(res => { + console.log("Arr: " + res); + + // start of user updating + + var ldata = {user: this.user}; + let url2 = 'http://localhost:4000/login/getdates'; + this.axios.post(url2, ldata).then(res => { + //console.log(res.data); + var arrd = res.data.dates; + //arrd = arrd.filter(e => e !== this.$route.params.id, this.date); + for(var i = 0; i { + //console.log("URL 3"); console.log(res); + this.$router.push({name: 'calendar'}); }) }) - */ }) }) } - //alert("hello"); - - for(var element1 of this.absentNames){ + + if(this.absentNames.length != 0){ + //alert("absences") + for(var element1 of this.absentNames){ var test1 = {number: element1}; - let uri1 = 'http://65.92.152.100:4000/attendance/getarr'; + let uri1 = 'http://localhost:4000/attendance/getarr'; this.axios.post(uri1, test1).then(res => { var arrr = res.data.absenses; arrr = arrr.filter(e => e !== this.$route.params.id); - //console.log(arrr); var arrr2 = res.data.presences; arrr2 = arrr2.filter(e => e !== this.$route.params.id); - arrr.push(this.$route.params.id); this.post.absenses = arrr; - //console.log(res.data._id); + var testt2 = {id: res.data._id, presences: arrr2, absenses: arrr}; - //console.log(test2); - let url1 = 'http://65.92.152.100:4000/attendance/post'; + + let url1 = 'http://localhost:4000/attendance/post'; this.axios.post(url1, testt2).then(res => { - console.log(res); - this.$router.push({name: 'calendar'}); + console.log("Arr2: " + res); + }) }) + } + // start of user updating + + var ldata = {user: this.user}; + let url2 = 'http://localhost:4000/login/getdates'; + this.axios.post(url2, ldata).then(res => { + //console.log(res.data); + var arrd = res.data.dates; + //arrd = arrd.filter(e => e !== this.$route.params.id, this.date); + for(var i = 0; i { + console.log("URL 3"); + console.log(res); + this.$router.push({name: 'calendar'}); + }) + }) + + + } }, test(input, type){ var letter; if(type == "a"){ - //alert(input); - //console.log(this.presentNames); + this.presentNames = this.presentNames.filter(e => e !== input); - //console.log(this.presentNames); + letter = "p"; document.getElementById(input + ":acheckbox").style.backgroundColor = "red"; document.getElementById(input + ":pcheckbox").style.backgroundColor = "#6CD182"; diff --git a/attendancetracker/src/components/Attendees.vue b/attendancetracker/src/components/Attendees.vue index 106b9ac..cc2dcc1 100644 --- a/attendancetracker/src/components/Attendees.vue +++ b/attendancetracker/src/components/Attendees.vue @@ -123,7 +123,7 @@ export default { this.checkAccount(); this.post.user = this.user; //alert(this.post.user); - let uri = 'http://65.92.152.100:4000/attendance/attendees'; + let uri = 'http://localhost:4000/attendance/attendees'; this.axios.post(uri, this.post).then(res => { this.attendees = res.data; console.log(this.attendees); @@ -152,7 +152,7 @@ export default { del(id){ this.post.id = id; //alert(id); - let uri = 'http://65.92.152.100:4000/attendance/delete'; + let uri = 'http://localhost:4000/attendance/delete'; this.axios.post(uri, this.post).then(() => { location.reload(); }); @@ -161,7 +161,7 @@ export default { //alert(this.attendee.name); this.attendee.user = this.user; - let uri = 'http://65.92.152.100:4000/attendance/add'; + let uri = 'http://localhost:4000/attendance/add'; this.axios.post(uri, this.attendee).then(() => { location.reload(); }); diff --git a/attendancetracker/src/components/Calendar.vue b/attendancetracker/src/components/Calendar.vue index 92b3c35..c788d37 100644 --- a/attendancetracker/src/components/Calendar.vue +++ b/attendancetracker/src/components/Calendar.vue @@ -34,12 +34,27 @@ - -

Attendance Calendar for {{user}}:

+
+
+
+

Attendance Calendar for {{user}}

+
    +
  • - Get started by creating some club members on the "Manage Club Members" page.
  • +
    +
  • - Use the calendar below to select a date to take attendance.
  • +
    +
  • - A day with attendance taken will be highlighted in blue.
  • +
+ +
+ +
-


- +
Calendar loading please wait...
+
+ +
-
+
+
+

Please select a date in the calendar


+
+
+
+ + +
+

Club Attendance

+
You haven't taken any attendance yet! Take some to view club performance.
+
+ +
+
+ +
+ @@ -90,7 +122,8 @@ } #whole-page{ - height: 100vh; + height: 100%; + text-align: center; } #incorrect { @@ -98,14 +131,43 @@ display: none; } + #calcontainer{ + background-color: white; + width: 75%; + text-align: center; + padding: 20px; + border-radius: 10px; + display: inline-block; + } + .box{ + border: 0.25px solid grey; + } + +