Skip to content

Commit

Permalink
add comment functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
mayeaux committed Apr 5, 2022
1 parent 0efaaa2 commit 8c537b5
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 18 deletions.
18 changes: 16 additions & 2 deletions controllers/frontend/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,21 @@ exports.getComments = async(req, res) => {

const { startingNumber, previousNumber, nextNumber, numbersArray } = pagination.buildPaginationObject(page);

let { visibility } = req.query;

if(!visibility) visibility = 'all'

let searchQuery = {};

if(visibility !== 'all'){
searchQuery.visibility = visibility;
}

console.log('visibility')
console.log(visibility);

try {
const comments = await Comment.find({}).sort({ _id : -1 }).populate('commenter upload')
const comments = await Comment.find(searchQuery).sort({ _id : -1 }).populate('commenter upload')
.skip(skipAmount).limit(limit);

res.render('admin/comments', {
Expand All @@ -230,7 +243,8 @@ exports.getComments = async(req, res) => {
previousNumber,
nextNumber,
numbersArray,
highlightedNumber: page
highlightedNumber: page,
visibility: visibility
});
} catch(err){
console.log('err');
Expand Down
40 changes: 24 additions & 16 deletions views/admin/comments.pug
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,30 @@ block content
div
div
h2
h2.view-header Users (Admin)
h2.view-header Comments (Admin)
h1 Visibility = #{visibility}
h4
a(href=`/admin/comments/${highlightedNumber}?visibility=public`) Public
br
a(href=`/admin/comments/${highlightedNumber}?visibility=removed`) Removed
hr
if comments.length == 0
.center-block.text-center
ul.pagination
li.page-item
a.page-link(href=`/admin/comments/${previousNumber}`) <

each number in numbersArray
li.page-item(class=(number == highlightedNumber) ? 'active' : undefined)
a.page-link(href=`/admin/comments/${number}`) #{number}

li.page-item
a.page-link(href=`/admin/comments/${nextNumber}`) >

p There are no more comments
else
.center-block.text-center
ul.pagination
li.page-item
a.page-link(href=`/admin/comments/${previousNumber}`) <
a.page-link(href=`/admin/comments/${previousNumber}?visibility=${visibility}`) <

each number in numbersArray
li.page-item(class=(number == highlightedNumber) ? 'active' : undefined)
a.page-link(href=`/admin/comments/${number}`) #{number}
a.page-link(href=`/admin/comments/${number}?visibility=${visibility}`) #{number}

li.page-item
a.page-link(href=`/admin/comments/${nextNumber}`) >
a.page-link(href=`/admin/comments/${nextNumber}?visibility=${visibility}`) >



each comment in comments
div.col-sm-4(style="text-align:center;height:420px;border:1px solid black;")
// NEW CHANNEL UPLOAD FORMAT
Expand Down Expand Up @@ -61,3 +57,15 @@ block content
br
button.btn.btn-danger(name="commentChangeValue" value="deleteCommentBanUser" type="submit" ) Delete Comment/Ban User

div.col-sm-12(style="text-align:center;margin-top:200px;")
.center-block.text-center
ul.pagination
li.page-item
a.page-link(href=`/admin/comments/${previousNumber}?visibility=${visibility}`) <

each number in numbersArray
li.page-item(class=(number == highlightedNumber) ? 'active' : undefined)
a.page-link(href=`/admin/comments/${number}?visibility=${visibility}`) #{number}

li.page-item
a.page-link(href=`/admin/comments/${nextNumber}?visibility=${visibility}`) >

0 comments on commit 8c537b5

Please sign in to comment.