From a065dab274a8d89794d18915c5856376ec24349c Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Wed, 20 Oct 2021 23:17:19 -0400 Subject: [PATCH 01/10] added number of annotations column --- package.json | 2 +- routes/annotations.js | 1 + routes/files.js | 2 +- src/components/course/CourseContents.vue | 16 ++++++++++++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index a3b8ff0..0fbac13 100644 --- a/package.json +++ b/package.json @@ -101,4 +101,4 @@ "last 2 versions", "not ie <= 8" ] -} \ No newline at end of file +} diff --git a/routes/annotations.js b/routes/annotations.js index 74701f3..a519785 100644 --- a/routes/annotations.js +++ b/routes/annotations.js @@ -111,6 +111,7 @@ router.get('/allTagTypes', (req, res) => { * }] */ router.get('/annotation', (req, res) => { + console.log(req) Source.findOne({ where: { [Op.and]: [{ filepath: req.query.url }, { class_id: req.query.class }] }, include: [{ diff --git a/routes/files.js b/routes/files.js index d6f0f58..10c864e 100644 --- a/routes/files.js +++ b/routes/files.js @@ -24,7 +24,7 @@ router.get('/class/:id', (req, res) => { */ router.get('/folder/:id', (req, res) => { FileSystemObject.findByPk(req.params.id) - .then((file) => file.getChildren({include:[{association:'Source', include:[{association:'Assignment', required: false}]}]})) + .then((file) => file.getChildren({include:[{association:'Source', include:[{association:'Assignment', required: false}, {association: 'Locations', required: false}]}]})) .then((files) => { res.status(200).json(files); }); diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index b1716c6..ea96e84 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -90,6 +90,9 @@   {{props.row.filename}} + + {{props.row.Source.Locations.length}} + {{ props.row.Source.Assignment ? @@ -229,6 +232,11 @@ // enabled: true, // }, }, + { + label: 'Annotations', + field: 'annotations', + sortable: true + }, { label: 'Assignment Due', field: 'Source.Assignment.deadlineString', @@ -373,6 +381,14 @@ }) }, + getNumberAnnotations: function(filepath, class_id){ + const token = localStorage.getItem("nb.user"); + const headers = { headers: { Authorization: 'Bearer ' + token }} + axios.get(`/api/annotations/annotation`, {url: filepath, class: class_id}, headers) + .then(res => { + return res.length + }) + }, switchDirectory: function(directory) { this.showDeleted = false this.$emit('switch-directory', directory) From 37c4ba4febf849e036ab8b14172db0b42c4bafad Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Mon, 25 Oct 2021 16:31:03 -0400 Subject: [PATCH 02/10] added reply requests --- routes/files.js | 12 +++++++++++- src/components/course/CourseContents.vue | 15 ++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/routes/files.js b/routes/files.js index 10c864e..58564db 100644 --- a/routes/files.js +++ b/routes/files.js @@ -24,7 +24,17 @@ router.get('/class/:id', (req, res) => { */ router.get('/folder/:id', (req, res) => { FileSystemObject.findByPk(req.params.id) - .then((file) => file.getChildren({include:[{association:'Source', include:[{association:'Assignment', required: false}, {association: 'Locations', required: false}]}]})) + .then((file) => file.getChildren({include:[{association:'Source', + include:[{association:'Assignment', required: false}, + {association: 'Locations', required: false, + include:[{association: 'Thread', required: false, + include: [{association: 'AllAnnotations', required: false, + include: [{association: 'ReplyRequesters', required: false}] + }] + }] + }] + }] + })) .then((files) => { res.status(200).json(files); }); diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index ea96e84..a0fab28 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -91,7 +91,9 @@ {{props.row.filename}} - {{props.row.Source.Locations.length}} + {{props.row.Source.Locations.length}} total annotations + {{getRequestReply(props.row.Source.Locations)}} total reply requests + @@ -389,6 +391,17 @@ return res.length }) }, + getRequestReply: function(locations){ + let numReqs = 0 + for (let i = 0; i < locations.length; i++){ + if(locations[i].Thread){ + for(let j = 0; j < locations[i].Thread.AllAnnotations.length; j++){ + numReqs += locations[i].Thread.AllAnnotations[j].ReplyRequesters.length + } + } + } + return numReqs + }, switchDirectory: function(directory) { this.showDeleted = false this.$emit('switch-directory', directory) From 85521d005dcf2cd46f59addb6e54e96381099a68 Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Thu, 28 Oct 2021 16:04:16 -0400 Subject: [PATCH 03/10] added annotations request api --- routes/annotations.js | 5 ++- routes/files.js | 1 + src/components/course/CourseContents.vue | 47 +++++++++++++++++++----- 3 files changed, 42 insertions(+), 11 deletions(-) diff --git a/routes/annotations.js b/routes/annotations.js index a519785..918cb8b 100644 --- a/routes/annotations.js +++ b/routes/annotations.js @@ -111,7 +111,7 @@ router.get('/allTagTypes', (req, res) => { * }] */ router.get('/annotation', (req, res) => { - console.log(req) + console.log(req.query.url) Source.findOne({ where: { [Op.and]: [{ filepath: req.query.url }, { class_id: req.query.class }] }, include: [{ @@ -132,6 +132,9 @@ router.get('/annotation', (req, res) => { }] }) .then(source => { + if (source == null){ + console.log("here") + } let instructors = source.Class.Instructors.map(user => user.id); let isUserInstructor = instructors.indexOf(req.user.id) >= 0; let isUserStudent = source.Class.GlobalSection.MemberStudents.find(user => user.id === req.user.id); diff --git a/routes/files.js b/routes/files.js index 58564db..3bc6229 100644 --- a/routes/files.js +++ b/routes/files.js @@ -26,6 +26,7 @@ router.get('/folder/:id', (req, res) => { FileSystemObject.findByPk(req.params.id) .then((file) => file.getChildren({include:[{association:'Source', include:[{association:'Assignment', required: false}, + {association:'Class'}, {association: 'Locations', required: false, include:[{association: 'Thread', required: false, include: [{association: 'AllAnnotations', required: false, diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index a0fab28..151eed6 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -91,8 +91,12 @@ {{props.row.filename}} - {{props.row.Source.Locations.length}} total annotations - {{getRequestReply(props.row.Source.Locations)}} total reply requests + + + {{annotations}} + + @@ -279,7 +283,8 @@ newFoldername: "" }, deleteText: "Delete", - showDeleted: false + showDeleted: false, + annotations: {} } }, computed:{ @@ -318,7 +323,7 @@ }, trashExists: function() { return this.contents.filter((a)=>{return a.deleted}).length > 0 - } + }, }, watch:{ currentDir: function() { @@ -327,7 +332,7 @@ showDeleted: function() { if(this.showDeleted) this.fileColumns[0].label = "Restore" else this.fileColumns[0].label = "Edit" - } + }, }, methods:{ addFolder: function() { @@ -376,21 +381,43 @@ if (file.Source && file.Source.Assignment) { file.Source.Assignment.deadlineString = moment(String(file.Source.Assignment.deadline)).format('MM/DD/YYYY HH:mm') } + if (file.Source && file.Source.Class){ + this.annotations[file.id] = this.numberAnnotations(file.Source.filepath, file.Source.Class.id) + } else{ + this.annotations[file.id] = [0,0,0,0] + } + } this.contents = res.data + console.log(this.annotations) }) }, - getNumberAnnotations: function(filepath, class_id){ + numberAnnotations: function(filepath, class_id){ const token = localStorage.getItem("nb.user"); - const headers = { headers: { Authorization: 'Bearer ' + token }} - axios.get(`/api/annotations/annotation`, {url: filepath, class: class_id}, headers) - .then(res => { - return res.length + const request = axios.get(`/api/annotations/annotation?url=${filepath}&class=${class_id}`, {headers: { Authorization: 'Bearer ' + token }}) + request.then(res => { + let out = [0,0,0,0] //me, unread, replyrequest, total + for (let a in res.data){ + if (token === res.data[a].author){ + out[0] += 1 + } + if (!res.data[a].seenByMe){ + out[1] += 1 + } + out[2] += res.data[a].replyRequestCount + out[3] += 1 + } + console.log(out) + return out }) }, + myannotations: function(filepath){ + console.log(filepath) + return this.annotations[filepath][0] + }, getRequestReply: function(locations){ let numReqs = 0 for (let i = 0; i < locations.length; i++){ From be823fbe91d7fbb9abbd383f0dade8d8bdb8c85b Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Tue, 9 Nov 2021 17:32:28 -0500 Subject: [PATCH 04/10] added stats --- routes/annotations.js | 118 ++++++++++++++++++++++- src/components/course/CourseContents.vue | 57 +++++------ 2 files changed, 142 insertions(+), 33 deletions(-) diff --git a/routes/annotations.js b/routes/annotations.js index 918cb8b..2765092 100644 --- a/routes/annotations.js +++ b/routes/annotations.js @@ -381,6 +381,121 @@ router.get('/new_annotation', (req, res) => { }); }); +/** + * + */ +router.get('/stats', (req, res) => { + Source.findOne({ + where: { [Op.and]: [{ filepath: req.query.url }, { class_id: req.query.class }] }, + include: [{ + association: 'Class', + include: [ + { association: 'Instructors', attributes: ['id'] }, + { + association: 'GlobalSection', include: [{ + association: 'MemberStudents', attributes: ['id'] + }] + }, + { + association: 'Sections', separate: true, include: [{ // with the hasMany Sections association, add a "separate: true" to make this join happen separately so that there are no duplicate joins + association: 'MemberStudents', attributes: ['id'] + }] + } + ] + }] + }).then(source => { + let instructors = new Set(source.Class.Instructors.map(user => user.id)) // convert to set so faster to check if a user is in this set + let globalSectionStudents = new Set(source.Class.GlobalSection.MemberStudents.map(user => user.id)) // convert to set so faster to check if a user is in this set + let isUserInstructor = instructors.has(req.user.id); + let isUserStudent = globalSectionStudents.has(req.user.id); + + if (!isUserInstructor && !isUserStudent) { + res.status(200).json([]); + return; + } + + let usersICanSee = new Set([]) // convert to set so faster to check if a user is in this set + let isSingleSectionClass = source.Class.Sections.length === 1 + + for (const section of source.Class.Sections) { + let memberIds = section.MemberStudents.map(user => user.id) + if ((isUserInstructor && section.is_global) || (isSingleSectionClass)) { + usersICanSee = new Set(memberIds) + break; + } else { + if (memberIds.indexOf(req.user.id) >= 0 && !section.is_global) { + usersICanSee = new Set(memberIds) + break + } + } + } + source.getLocations({ + include: + [ + { association: 'HtmlLocation' }, + { + association: 'Thread', + required: true, + include: [ + { + association: 'HeadAnnotation', attributes: ['id', 'content', 'visibility', 'anonymity', 'created_at'], + include: [ + { association: 'Author', attributes: ['id', 'first_name', 'last_name', 'username'] }, + { association: 'ReplyRequesters', attributes: ['id', 'first_name', 'last_name', 'username'] }, + ] + }, + { association: 'SeenUsers', attributes: ['id', 'first_name', 'last_name', 'username'] }, + ] + } + ] + }).then(locations => { + let me = 0 + let unread = 0 + let replyRequests = 0 + let total = 0 + + // TODO: is this the correct way to filter replies? + let goodLocations = locations.filter((location) => { + try { + let head = location.Thread.HeadAnnotation; + + if (head.visibility === 'MYSELF' && head.Author.id !== req.user.id) { + return false; + } + if (head.visibility === 'INSTRUCTORS' && !isUserInstructor) { + return false; + } if (req.query.sectioned === 'true' && isUserStudent && head.Author.id !== req.user.id && !usersICanSee.has(head.Author.id) && !instructors.has(head.Author.id)) { + return false; + } + return true; + } catch(e) { + console.log(e) + return false; + } + }) + + goodLocations.forEach((location) => { + let annot = location.Thread.HeadAnnotation + console.log(req.user.id) + if (annot.Author.id === req.user.id ){ + me += 1 + } + console.log(req.query.url) + console.log(location.Thread.SeenUsers) + if (!(location.Thread.SeenUsers + .reduce((bool, user) => bool || user.id == req.user.id, false))){ + unread += 1 + } + replyRequests += annot.ReplyRequesters.length + total += 1 + }); + + res.status(200).json({ 'me': me, 'unread': unread, 'replyRequests': replyRequests, 'total': total }); + + }) + }); +}); + /** * Make new thread for a given annotation * @name POST/api/annotations/annotation @@ -982,7 +1097,6 @@ router.post('/bookmark/:id', (req, res) => { ); }); - function simplifyUser(user, role) { const id = user.id; user = user.get({ plain: true }); @@ -993,4 +1107,4 @@ function simplifyUser(user, role) { } -module.exports = router; +module.exports = router diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index 151eed6..2da0157 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -90,14 +90,11 @@   {{props.row.filename}} - - - - {{annotations}} - - - + +
Mine: {{myannotations(props.row.Source.filepath)[0]["me"]}}
+
Unread: {{myannotations(props.row.Source.filepath)[0]["unread"]}}
+
Reply Requests: {{myannotations(props.row.Source.filepath)[0]["replyRequests"]}}
+
Total: {{myannotations(props.row.Source.filepath)[0]["total"]}}
@@ -284,7 +281,7 @@ }, deleteText: "Delete", showDeleted: false, - annotations: {} + annotations: [] } }, computed:{ @@ -323,7 +320,7 @@ }, trashExists: function() { return this.contents.filter((a)=>{return a.deleted}).length > 0 - }, + } }, watch:{ currentDir: function() { @@ -381,42 +378,33 @@ if (file.Source && file.Source.Assignment) { file.Source.Assignment.deadlineString = moment(String(file.Source.Assignment.deadline)).format('MM/DD/YYYY HH:mm') } + if (file.Source && file.Source.Class){ - this.annotations[file.id] = this.numberAnnotations(file.Source.filepath, file.Source.Class.id) - } else{ - this.annotations[file.id] = [0,0,0,0] + // this.annotations[file.Source.filepath] = {} + this.numberAnnotations(file.Source.filepath, file.Source.Class.id) + } + else{ + // this.annotations[file.id] = [0,0,0,0] } } this.contents = res.data - console.log(this.annotations) }) }, numberAnnotations: function(filepath, class_id){ const token = localStorage.getItem("nb.user"); - const request = axios.get(`/api/annotations/annotation?url=${filepath}&class=${class_id}`, {headers: { Authorization: 'Bearer ' + token }}) - request.then(res => { - let out = [0,0,0,0] //me, unread, replyrequest, total - for (let a in res.data){ - if (token === res.data[a].author){ - out[0] += 1 - } - if (!res.data[a].seenByMe){ - out[1] += 1 - } - out[2] += res.data[a].replyRequestCount - out[3] += 1 - } - console.log(out) - return out + const config = {headers: { Authorization: 'Bearer ' + token }} + axios.get(`/api/annotations/stats?url=${escape(filepath)}&class=${class_id}`, config) + .then((res) => { + res.data.filepath = filepath + this.annotations.push(res.data) }) }, myannotations: function(filepath){ - console.log(filepath) - return this.annotations[filepath][0] + return this.annotations.filter(a => a.filepath === filepath) }, getRequestReply: function(locations){ let numReqs = 0 @@ -819,4 +807,11 @@ background-color: #0069d9; } + .annotations { + color: black; + /* border: 2px solid #8649af; */ + background-color: #8c58af46; + border-radius: 5px; + padding: 3px; + } \ No newline at end of file From 1148c239d95023c3d5b8dc106535a12c4d312927 Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Tue, 9 Nov 2021 17:33:27 -0500 Subject: [PATCH 05/10] deleted some debugging prints --- routes/annotations.js | 7 ------- 1 file changed, 7 deletions(-) diff --git a/routes/annotations.js b/routes/annotations.js index 2765092..70ab9a5 100644 --- a/routes/annotations.js +++ b/routes/annotations.js @@ -111,7 +111,6 @@ router.get('/allTagTypes', (req, res) => { * }] */ router.get('/annotation', (req, res) => { - console.log(req.query.url) Source.findOne({ where: { [Op.and]: [{ filepath: req.query.url }, { class_id: req.query.class }] }, include: [{ @@ -132,9 +131,6 @@ router.get('/annotation', (req, res) => { }] }) .then(source => { - if (source == null){ - console.log("here") - } let instructors = source.Class.Instructors.map(user => user.id); let isUserInstructor = instructors.indexOf(req.user.id) >= 0; let isUserStudent = source.Class.GlobalSection.MemberStudents.find(user => user.id === req.user.id); @@ -476,12 +472,9 @@ router.get('/stats', (req, res) => { goodLocations.forEach((location) => { let annot = location.Thread.HeadAnnotation - console.log(req.user.id) if (annot.Author.id === req.user.id ){ me += 1 } - console.log(req.query.url) - console.log(location.Thread.SeenUsers) if (!(location.Thread.SeenUsers .reduce((bool, user) => bool || user.id == req.user.id, false))){ unread += 1 From 7b8c13baff9e1eb443121a1eab2d5a894a0a67c9 Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Tue, 9 Nov 2021 17:47:13 -0500 Subject: [PATCH 06/10] addec omments --- routes/annotations.js | 12 +++++++++++- src/components/course/CourseContents.vue | 5 ----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/routes/annotations.js b/routes/annotations.js index 70ab9a5..78a313e 100644 --- a/routes/annotations.js +++ b/routes/annotations.js @@ -378,7 +378,17 @@ router.get('/new_annotation', (req, res) => { }); /** - * + * Get the stats for thetop-level annotation for a given source + * The stats are: my annotations, reply requests, unread, and total + * @name GET/api/annotations/stats + * @param url: source url + * @param class: source class id + * @return [{ + * me: number of annotations written by user + * unread: number of unread annotations, + * replyRequests: number of replyRequests annotation, + * total: total number of annotations + * }] */ router.get('/stats', (req, res) => { Source.findOne({ diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index 2da0157..dc24b80 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -380,12 +380,8 @@ } if (file.Source && file.Source.Class){ - // this.annotations[file.Source.filepath] = {} this.numberAnnotations(file.Source.filepath, file.Source.Class.id) } - else{ - // this.annotations[file.id] = [0,0,0,0] - } } @@ -809,7 +805,6 @@ .annotations { color: black; - /* border: 2px solid #8649af; */ background-color: #8c58af46; border-radius: 5px; padding: 3px; From 167738a7d56246d95fbf40ef34b48d4086324452 Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Wed, 17 Nov 2021 14:47:15 -0500 Subject: [PATCH 07/10] stats update every minute --- src/components/course/CourseContents.vue | 26 +++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index dc24b80..f286eb4 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -91,10 +91,10 @@ {{props.row.filename}} -
Mine: {{myannotations(props.row.Source.filepath)[0]["me"]}}
-
Unread: {{myannotations(props.row.Source.filepath)[0]["unread"]}}
-
Reply Requests: {{myannotations(props.row.Source.filepath)[0]["replyRequests"]}}
-
Total: {{myannotations(props.row.Source.filepath)[0]["total"]}}
+
Mine: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["me"]}}
+
Unread: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["unread"]}}
+
Reply Requests: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["replyRequests"]}}
+
Total: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["total"]}}
@@ -399,9 +399,6 @@ this.annotations.push(res.data) }) }, - myannotations: function(filepath){ - return this.annotations.filter(a => a.filepath === filepath) - }, getRequestReply: function(locations){ let numReqs = 0 for (let i = 0; i < locations.length; i++){ @@ -562,6 +559,21 @@ }, mounted: function() { this.loadFiles() + window.setInterval(()=> { + let new_annotations = [] + for (let file of this.contents){ + if (file.Source && file.Source.Class){ + const token = localStorage.getItem("nb.user"); + const config = {headers: { Authorization: 'Bearer ' + token }} + axios.get(`/api/annotations/stats?url=${escape(file.Source.filepath)}&class=${file.Source.Class.id}`, config) + .then((res) => { + res.data.filepath = file.Source.filepath + new_annotations.push(res.data) + }) + } + } + this.annotations = new_annotations + }, 60000) }, components: { FontAwesomeIcon, From bff388a276536f88f3c85be38dcb32d93773919d Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Sun, 9 Jan 2022 16:10:33 -0500 Subject: [PATCH 08/10] removed sorting --- src/components/course/CourseContents.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index f286eb4..8c17728 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -238,7 +238,7 @@ { label: 'Annotations', field: 'annotations', - sortable: true + sortable: false }, { label: 'Assignment Due', From 8551fde83e757e49f70e0077d7de23b1eb3dba43 Mon Sep 17 00:00:00 2001 From: Alizee Schoen Date: Sun, 9 Jan 2022 16:30:58 -0500 Subject: [PATCH 09/10] changed stats to count all comments --- routes/annotations.js | 37 ++++++++++++++++-------- src/components/course/CourseContents.vue | 3 +- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/routes/annotations.js b/routes/annotations.js index 78a313e..2d4cd47 100644 --- a/routes/annotations.js +++ b/routes/annotations.js @@ -450,6 +450,13 @@ router.get('/stats', (req, res) => { { association: 'ReplyRequesters', attributes: ['id', 'first_name', 'last_name', 'username'] }, ] }, + { + association: 'AllAnnotations', separate: true, attributes: ['id', 'content', 'visibility', 'anonymity', 'created_at'], + include: [ + { association: 'Author', attributes: ['id', 'first_name', 'last_name', 'username'] }, + { association: 'ReplyRequesters', attributes: ['id', 'first_name', 'last_name', 'username'] }, + ] + }, { association: 'SeenUsers', attributes: ['id', 'first_name', 'last_name', 'username'] }, ] } @@ -459,18 +466,18 @@ router.get('/stats', (req, res) => { let unread = 0 let replyRequests = 0 let total = 0 + let thread = 0 // TODO: is this the correct way to filter replies? let goodLocations = locations.filter((location) => { try { - let head = location.Thread.HeadAnnotation; - - if (head.visibility === 'MYSELF' && head.Author.id !== req.user.id) { + let comment = location.Thread.AllAnnotations; + if (comment.visibility === 'MYSELF' && comment.Author.id !== req.user.id) { return false; } - if (head.visibility === 'INSTRUCTORS' && !isUserInstructor) { + if (comment.visibility === 'INSTRUCTORS' && !isUserInstructor) { return false; - } if (req.query.sectioned === 'true' && isUserStudent && head.Author.id !== req.user.id && !usersICanSee.has(head.Author.id) && !instructors.has(head.Author.id)) { + } if (req.query.sectioned === 'true' && isUserStudent && comment.Author.id !== req.user.id && !usersICanSee.has(comment.Author.id) && !instructors.has(comment.Author.id)) { return false; } return true; @@ -481,19 +488,25 @@ router.get('/stats', (req, res) => { }) goodLocations.forEach((location) => { - let annot = location.Thread.HeadAnnotation - if (annot.Author.id === req.user.id ){ - me += 1 - } + + location.Thread.AllAnnotations.forEach((annot) => { + console.log(annot) + if (annot.Author.id === req.user.id ){ + me += 1 + } + + replyRequests += annot.ReplyRequesters.length + total += 1 + }) if (!(location.Thread.SeenUsers .reduce((bool, user) => bool || user.id == req.user.id, false))){ unread += 1 } - replyRequests += annot.ReplyRequesters.length - total += 1 + thread += 1 + }); - res.status(200).json({ 'me': me, 'unread': unread, 'replyRequests': replyRequests, 'total': total }); + res.status(200).json({ 'me': me, 'unread': unread, 'replyRequests': replyRequests, 'thread': thread, 'total': total }); }) }); diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index 8c17728..890b9eb 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -94,6 +94,7 @@
Mine: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["me"]}}
Unread: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["unread"]}}
Reply Requests: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["replyRequests"]}}
+
Threads: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["thread"]}}
Total: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["total"]}}
@@ -236,7 +237,7 @@ // }, }, { - label: 'Annotations', + label: 'Comments', field: 'annotations', sortable: false }, From ab2284d1bc754f708a9fb63e6a8f215caac8cd4e Mon Sep 17 00:00:00 2001 From: Jumana Date: Mon, 14 Feb 2022 16:57:45 -0500 Subject: [PATCH 10/10] removed threads and fixed css --- src/components/course/CourseContents.vue | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/course/CourseContents.vue b/src/components/course/CourseContents.vue index 890b9eb..a3b042b 100644 --- a/src/components/course/CourseContents.vue +++ b/src/components/course/CourseContents.vue @@ -87,14 +87,13 @@ v-if="props.column.field === 'filename'" class="clickable filename"> -   +   {{props.row.filename}}
Mine: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["me"]}}
Unread: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["unread"]}}
Reply Requests: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["replyRequests"]}}
-
Threads: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["thread"]}}
Total: {{annotations.filter(a => a.filepath === props.row.Source.filepath)[0]["total"]}}
@@ -817,9 +816,12 @@ } .annotations { - color: black; - background-color: #8c58af46; - border-radius: 5px; + color: #5f6266; + background-color: #f1f4f7; + border-radius: 5px; padding: 3px; + margin: 1px; + font-size: 80%; + text-align: center; } \ No newline at end of file