mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 18:28:47 +00:00
Admin User Stories
This commit is contained in:
parent
17c7e989ef
commit
96423cee8a
@ -60,6 +60,23 @@ exports.getallPostsforUser = (req, res) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
exports.hidePost = (req, res) => {
|
||||||
|
/* db
|
||||||
|
.collection("posts")
|
||||||
|
.doc(${req.params.postId}) */
|
||||||
|
const postId = req.body.postId;
|
||||||
|
db.doc(`/posts/${postId}`)
|
||||||
|
.update({
|
||||||
|
hidden: true
|
||||||
|
})
|
||||||
|
.then(() => {
|
||||||
|
return res.status(200).json({message: "ok"});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
return res.status(500).json(error);
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
exports.getallPosts = (req, res) => {
|
exports.getallPosts = (req, res) => {
|
||||||
let posts = [];
|
let posts = [];
|
||||||
let users = {};
|
let users = {};
|
||||||
@ -113,6 +130,11 @@ exports.getOtherUsersPosts = (req, res) => {
|
|||||||
.firestore()
|
.firestore()
|
||||||
.collection("posts")
|
.collection("posts")
|
||||||
.where("userHandle", "==", req.body.handle);
|
.where("userHandle", "==", req.body.handle);
|
||||||
|
|
||||||
|
post_query += admin
|
||||||
|
.firestore()
|
||||||
|
.collection("posts")
|
||||||
|
.where("microBlogTitle", "==", "Alert").where("userHandle", "==", "Admin");
|
||||||
|
|
||||||
post_query
|
post_query
|
||||||
.get()
|
.get()
|
||||||
|
|||||||
@ -39,6 +39,7 @@ app.post("/login", login);
|
|||||||
//Deletes user account
|
//Deletes user account
|
||||||
app.delete("/delete", fbAuth, deleteUser);
|
app.delete("/delete", fbAuth, deleteUser);
|
||||||
|
|
||||||
|
|
||||||
app.post("/getUserDetails", fbAuth, getUserDetails);
|
app.post("/getUserDetails", fbAuth, getUserDetails);
|
||||||
|
|
||||||
// Returns a list of all usernames
|
// Returns a list of all usernames
|
||||||
@ -82,13 +83,16 @@ app.post("/removeSub", fbAuth, removeSub);
|
|||||||
* handlers/post.js *
|
* handlers/post.js *
|
||||||
*------------------------------------------------------------------*/
|
*------------------------------------------------------------------*/
|
||||||
|
|
||||||
const { getallPostsforUser, getallPosts, putPost, likePost, unlikePost, getLikes, quoteWithPost, quoteWithoutPost, checkforLikePost, getOtherUsersPosts} = require("./handlers/post");
|
const { getallPostsforUser, getallPosts, putPost, hidePost, likePost, unlikePost, getLikes, quoteWithPost, quoteWithoutPost, checkforLikePost, getOtherUsersPosts} = require("./handlers/post");
|
||||||
|
|
||||||
|
|
||||||
app.get("/getallPostsforUser", fbAuth, getallPostsforUser);
|
app.get("/getallPostsforUser", fbAuth, getallPostsforUser);
|
||||||
|
|
||||||
app.get("/getallPosts", getallPosts);
|
app.get("/getallPosts", getallPosts);
|
||||||
|
|
||||||
|
//Hides Post
|
||||||
|
app.post("/hidePost", fbAuth, hidePost);
|
||||||
|
|
||||||
// Adds one post to the database
|
// Adds one post to the database
|
||||||
app.post("/putPost", fbAuth, putPost);
|
app.post("/putPost", fbAuth, putPost);
|
||||||
|
|
||||||
|
|||||||
1177
twistter-frontend/package-lock.json
generated
1177
twistter-frontend/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -10,6 +10,7 @@
|
|||||||
"axios": "^0.19.0",
|
"axios": "^0.19.0",
|
||||||
"clsx": "^1.0.4",
|
"clsx": "^1.0.4",
|
||||||
"create-react-app": "^3.1.2",
|
"create-react-app": "^3.1.2",
|
||||||
|
"firebase-admin": "^8.8.0",
|
||||||
"fuse.js": "^3.4.6",
|
"fuse.js": "^3.4.6",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"jwt-decode": "^2.2.0",
|
"jwt-decode": "^2.2.0",
|
||||||
|
|||||||
@ -59,6 +59,19 @@ class Home extends Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
flagPost = (event) => {
|
||||||
|
// Flags a post
|
||||||
|
let postId = event.target.dataset.key ? event.target.dataset.key : event.target.parentNode.dataset.key;
|
||||||
|
axios.post(`/hidePost`, {postId})
|
||||||
|
.then((res) => {
|
||||||
|
console.log(res.data);
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
console.error(err);
|
||||||
|
});
|
||||||
|
// event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
handleClickLikeButton = (event) => {
|
handleClickLikeButton = (event) => {
|
||||||
// Need the ternary if statement because the user can click on the text or body of the
|
// Need the ternary if statement because the user can click on the text or body of the
|
||||||
// Button and they are two different html elements
|
// Button and they are two different html elements
|
||||||
@ -90,9 +103,15 @@ class Home extends Component {
|
|||||||
let authenticated = this.props.user.authenticated;
|
let authenticated = this.props.user.authenticated;
|
||||||
let {classes} = this.props;
|
let {classes} = this.props;
|
||||||
let username = this.props.user.credentials.handle;
|
let username = this.props.user.credentials.handle;
|
||||||
|
console.log(username);
|
||||||
|
var hiddenBool = true;
|
||||||
|
if (username === "Admin") {
|
||||||
|
hiddenBool = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(hiddenBool);
|
||||||
let postMarkup = this.state.posts ? (
|
let postMarkup = this.state.posts ? (
|
||||||
this.state.posts.map(post =>
|
this.state.posts.map(post => post.hidden ? null :
|
||||||
<Card className={classes.card} key={post.postId}>
|
<Card className={classes.card} key={post.postId}>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
<Typography>
|
<Typography>
|
||||||
@ -115,6 +134,17 @@ class Home extends Component {
|
|||||||
<br />
|
<br />
|
||||||
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics}</Typography>
|
<Typography variant="body2"><b>Topics:</b> {post.microBlogTopics}</Typography>
|
||||||
<br />
|
<br />
|
||||||
|
{!hiddenBool &&
|
||||||
|
<Button
|
||||||
|
onClick={this.flagPost}
|
||||||
|
data-key={post.postId}
|
||||||
|
variant = "contained"
|
||||||
|
color = "primary"
|
||||||
|
>
|
||||||
|
Hide Post
|
||||||
|
</Button>
|
||||||
|
}
|
||||||
|
|
||||||
<Typography id={post.postId} data-likes={post.likeCount} variant="body2" color={"textSecondary"}>Likes {post.likeCount}</Typography>
|
<Typography id={post.postId} data-likes={post.likeCount} variant="body2" color={"textSecondary"}>Likes {post.likeCount}</Typography>
|
||||||
{/* <Like microBlog = {post.postId} count = {post.likeCount} name = {username}></Like> */}
|
{/* <Like microBlog = {post.postId} count = {post.likeCount} name = {username}></Like> */}
|
||||||
<Button
|
<Button
|
||||||
@ -332,8 +362,6 @@ class Like extends Component {
|
|||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
handleClick(){
|
handleClick(){
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user