Compare commits

...

46 Commits

Author SHA1 Message Date
dependabot[bot]
75b3030c88 Merge aae2ccd6c4 into d1f42aa5cd 2024-12-15 19:36:44 +00:00
Clayton Wilson
d1f42aa5cd Update README.md 2022-03-06 11:12:16 -05:00
Clayton Wilson
f118ed76d1 Added screenshots 2022-03-06 10:09:02 -06:00
dependabot[bot]
aae2ccd6c4 Bump lodash from 4.17.15 to 4.17.21 in /functions
Bumps [lodash](https://github.com/lodash/lodash) from 4.17.15 to 4.17.21.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.15...4.17.21)

Signed-off-by: dependabot[bot] <support@github.com>
2021-05-11 22:50:43 +00:00
DreamCoder23
b9cbd610a9 Update README.md 2020-10-11 23:17:34 -07:00
daabbf80f6 Actually fix deploy error 2019-12-06 14:58:51 -05:00
f9acefaafb Fixed deploy error 2019-12-06 14:55:01 -05:00
948eff32c2 Fix 2019-12-06 14:26:42 -05:00
6de219505a Fix admin alert posts displaying 2019-12-06 14:25:05 -05:00
7132a2ab45 Fix error in getOtherUsersPosts 2019-12-06 14:10:17 -05:00
5474543af4 add catch in addSubscription 2019-12-06 13:56:48 -05:00
6f77d03e2d Add back verify button for Admin 2019-12-06 13:51:21 -05:00
da6e7436ea Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 2019-12-06 13:35:32 -05:00
e7afac9a19 Fix post topics being added to followed topics list 2019-12-06 13:35:28 -05:00
Aditya Sankaran
9449d3544b Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 2019-12-06 13:06:52 -05:00
4f2e07756d tell the user if they aren't following anybody 2019-12-06 13:04:59 -05:00
Aditya Sankaran
f2cf7542a8 fix 2019-12-06 13:04:43 -05:00
ff7677bfb3 Merge pull request #113 from ClaytonWWilson/admin-delete
Admin delete
2019-12-06 12:56:40 -05:00
978af53a74 Merge pull request #114 from ClaytonWWilson/temp-branch
Display disabled DMs as red and fix errors in login and signup
2019-12-06 12:53:57 -05:00
a0a522f1d2 Display disabled DMs as red and fix errors in login and signup 2019-12-06 12:53:27 -05:00
Aditya Sankaran
988c807af2 Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 2019-12-06 12:27:00 -05:00
Aditya Sankaran
01b449d01d separated list of topics by comma and space 2019-12-06 12:26:29 -05:00
f30a9ae27c Fix merge errors, but posts are not displaying on home.js 2019-12-06 12:07:36 -05:00
a459e6581e Merge branch 'master' into admin-delete 2019-12-06 11:45:50 -05:00
Leon Liang
b769ab930a Merge pull request #112 from ClaytonWWilson/fix_unfollow
Fix unfollow
2019-12-06 02:28:42 -05:00
Leon Liang
116f97bf64 fixed topic.id bug 2019-12-06 02:26:01 -05:00
Leon Liang
a4efc15d58 allow follow topic only when following user 2019-12-06 02:23:28 -05:00
Leon Liang
39613584e7 fixed unfollow user and topics 2019-12-06 02:17:52 -05:00
a1f9a4bef3 Fixing errors on the otherUsers page 2019-12-05 21:39:38 -05:00
c85eeccd4c Display formatted time on otherUser page 2019-12-05 21:16:46 -05:00
Leon Liang
bb50e0fa5d Merge pull request #111 from ClaytonWWilson/filter_timeli
fixed up add subscription method
2019-12-05 19:25:44 -05:00
Leon Liang
f111553827 fixed up add subscription method 2019-12-05 19:24:50 -05:00
Aditya Sankaran
5e935f3508 Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 2019-12-05 19:20:50 -05:00
Aditya Sankaran
80a2e1894c sorted posts chronologically everywhere 2019-12-05 19:20:05 -05:00
8acd29e842 Merge branch 'master' of https://github.com/ClaytonWWilson/CS307-Team24 2019-12-05 19:14:47 -05:00
b402c96864 Fixing DMs with users who have them disabled 2019-12-05 19:13:00 -05:00
asankaran35
76792148cd Merge pull request #110 from ClaytonWWilson/chronological
can sort posts chronologically in userline and formatted topics listi…
2019-12-05 18:56:18 -05:00
Aditya Sankaran
a92681451f syntax error 2019-12-05 18:54:43 -05:00
Leon Liang
c7859e0f0a Merge pull request #109 from ClaytonWWilson/finalfix
fixed user and topic relationship. allow add topic directly
2019-12-05 17:25:53 -05:00
Leon Liang
aad9dc0273 Merge branch 'master' into finalfix 2019-12-05 17:25:19 -05:00
Leon Liang
30df98343e added user post tuple 2019-12-05 17:22:55 -05:00
719294f0ed Fix DM code layout 2019-12-05 16:13:56 -05:00
Leon Liang
de72bd9223 added alert to user's page 2019-12-05 13:45:58 -05:00
Danny Voltz
bae2947003 Merge branch 'admin-delete' of https://github.com/ClaytonWWilson/CS307-Team24 into admin-delete:x 2019-12-05 12:25:19 -05:00
Danny Voltz
96423cee8a Admin User Stories 2019-12-05 12:12:25 -05:00
Danny Voltz
6924af58a7 progress for admin delete 2019-11-01 15:40:26 -05:00
22 changed files with 2330 additions and 763 deletions

View File

@@ -1,2 +1,14 @@
# CS307-Team24 # CS307-Team24
CS307 Team 24 Twistter website. CS307 Team 24 Twistter website
### Images
<p>
<img alt="00.png" src="./screenshots/00.png" width="1000">
<img alt="01.png" src="./screenshots/01.png" width="1000">
<img alt="02.png" src="./screenshots/02.png" width="1000">
<img alt="03.png" src="./screenshots/03.png" width="1000">
<img alt="04.png" src="./screenshots/04.png" width="1000">
<img alt="05.png" src="./screenshots/05.png" width="1000">
<img alt="06.png" src="./screenshots/06.png" width="1000">
<img alt="07.png" src="./screenshots/07.png" width="1000">
</p>

View File

@@ -1,7 +1,7 @@
/* eslint-disable prefer-arrow-callback */ /* eslint-disable prefer-arrow-callback */
/* eslint-disable promise/always-return */ /* eslint-disable promise/always-return */
const admin = require("firebase-admin"); const { admin, db } = require("../util/admin");
const { db } = require("../util/admin");
exports.putPost = (req, res) => { exports.putPost = (req, res) => {
const newPost = { const newPost = {
@@ -33,6 +33,18 @@ exports.putPost = (req, res) => {
}); });
}; };
exports.deletePost = (req, res) => {
let posts = db.collection("posts")
.where("userHandle", "==", req.user.handle)
.get()
.then((query) => {
query.forEach((snap) => {
snap.ref.delete();
});
return;
})
};
exports.getallPostsforUser = (req, res) => { exports.getallPostsforUser = (req, res) => {
var post_query = admin var post_query = admin
.firestore() .firestore()
@@ -62,59 +74,81 @@ 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 = {};
// Get all the posts // Get all the posts
var postsPromise = new Promise((resolve, reject) => { var postsPromise = new Promise((resolve, reject) => {
db.collection("posts").get() db.collection("posts")
.then((allPosts) => { .get()
allPosts.forEach((post) => { .then(allPosts => {
allPosts.forEach(post => {
posts.push(post.data()); posts.push(post.data());
}); });
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
resolve(); resolve();
}) })
.catch((error) => { .catch(error => {
reject(error); reject(error);
}) });
}); });
// Get all users // Get all users
var usersPromise = new Promise((resolve, reject) => { var usersPromise = new Promise((resolve, reject) => {
db.collection("users").get() db.collection("users")
.then((allUsers) => { .get()
allUsers.forEach((user) => { .then(allUsers => {
allUsers.forEach(user => {
users[user.data().handle] = user.data(); users[user.data().handle] = user.data();
}) });
resolve(); resolve();
}) })
.catch((error) => { .catch(error => {
reject(error); reject(error);
}) });
}); });
// Wait for the two promises // Wait for the two promises
Promise.all([postsPromise, usersPromise]) Promise.all([postsPromise, usersPromise])
.then(() => { .then(() => {
let newPosts = [] let newPosts = [];
// Add the image url of the person who made the post to all of the post objects // Add the image url of the person who made the post to all of the post objects
posts.forEach((post) => { posts.forEach(post => {
post.profileImage = users[post.userHandle].imageUrl ? users[post.userHandle].imageUrl : null; post.profileImage = users[post.userHandle].imageUrl
? users[post.userHandle].imageUrl
: null;
newPosts.push(post); newPosts.push(post);
}); });
return res.status(200).json(newPosts); return res.status(200).json(newPosts);
}) })
.catch((error) => { .catch(error => {
return res.status(500).json({error}); return res.status(500).json({ error });
}) });
}; };
exports.getOtherUsersPosts = (req, res) => { exports.getAlert = (req, res) => {
var post_query = admin var post_query = admin
.firestore() .firestore()
.collection("posts") .collection("posts")
.where("userHandle", "==", req.body.handle); .where("microBlogTitle", "==", "Alert");
post_query post_query
.get() .get()
@@ -123,6 +157,40 @@ exports.getOtherUsersPosts = (req, res) => {
myPosts.forEach(function(doc) { myPosts.forEach(function(doc) {
posts.push(doc.data()); posts.push(doc.data());
}); });
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
return res.status(200).json(posts);
})
.then(function() {
return res
.status(200)
.json("Successfully retrieved all user's posts from database.");
})
.catch(function(err) {
return res
.status(500)
.json("Failed to retrieve user's posts from database.", err);
});
};
exports.getOtherUsersPosts = (req, res) => {
var post_query = admin
.firestore()
.collection("posts")
.where("userHandle", "==", req.body.handle);
// post_query += admin
// .firestore()
// .collection("posts")
// .where("microBlogTitle", "==", "Alert").where("userHandle", "==", "Admin");
post_query
.get()
.then(function(myPosts) {
let posts = [];
myPosts.forEach(function(doc) {
posts.push(doc.data());
});
posts.sort((a, b) => -a.createdAt.localeCompare(b.createdAt));
return res.status(200).json(posts); return res.status(200).json(posts);
}) })
.then(function() { .then(function() {
@@ -138,23 +206,25 @@ exports.getOtherUsersPosts = (req, res) => {
}; };
exports.quoteWithPost = (req, res) => { exports.quoteWithPost = (req, res) => {
let quoteData; let quoteData;
const quoteDoc = admin.firestore().collection('quote'). const quoteDoc = admin
where('userHandle', '==', req.user.handle). .firestore()
where('quoteId', '==', req.params.postId).limit(1); .collection("quote")
.where("userHandle", "==", req.user.handle)
.where("quoteId", "==", req.params.postId)
.limit(1);
const postDoc = db.doc(`/posts/${req.params.postId}`); const postDoc = db.doc(`/posts/${req.params.postId}`);
postDoc.get() postDoc
.then((doc) => { .get()
if(doc.exists) { .then(doc => {
quoteData = doc.data(); if (doc.exists) {
return quoteDoc.get(); quoteData = doc.data();
} return quoteDoc.get();
else } else {
{ return res.status(404).json({ error: "Post not found" });
return res.status(404).json({error: 'Post not found'}); }
}
}) })
.then(data => { .then(data => {
if (data.empty) { if (data.empty) {
@@ -202,23 +272,25 @@ exports.quoteWithPost = (req, res) => {
}; };
exports.quoteWithoutPost = (req, res) => { exports.quoteWithoutPost = (req, res) => {
let quoteData; let quoteData;
const quoteDoc = admin.firestore().collection('quote'). const quoteDoc = admin
where('userHandle', '==', req.user.handle). .firestore()
where('quoteId', '==', req.params.postId).limit(1); .collection("quote")
.where("userHandle", "==", req.user.handle)
.where("quoteId", "==", req.params.postId)
.limit(1);
const postDoc = db.doc(`/posts/${req.params.postId}`); const postDoc = db.doc(`/posts/${req.params.postId}`);
postDoc.get() postDoc
.then((doc) => { .get()
if(doc.exists) { .then(doc => {
quoteData = doc.data(); if (doc.exists) {
return quoteDoc.get(); quoteData = doc.data();
} return quoteDoc.get();
else } else {
{ return res.status(404).json({ error: "Post not found" });
return res.status(404).json({error: 'Post not found'}); }
}
}) })
.then(data => { .then(data => {
if (data.empty) { if (data.empty) {
@@ -260,7 +332,7 @@ exports.quoteWithoutPost = (req, res) => {
} }
}) })
.catch(err => { .catch(err => {
// return res.status(500).json({ error: "Something is wrong" }); // return res.status(500).json({ error: "Something is wrong" });
return res.status(500).json({ error: err }); return res.status(500).json({ error: err });
}); });
}; };
@@ -274,202 +346,198 @@ exports.checkforLikePost = (req, res) => {
.limit(1); .limit(1);
let result; let result;
likedPostDoc.get().then(data => { likedPostDoc
if (data.empty) { .get()
result = false; .then(data => {
return res.status(200).json(result); if (data.empty) {
} else { result = false;
result = true; return res.status(200).json(result);
return res.status(200).json(result); } else {
} result = true;
}) return res.status(200).json(result);
.catch((err) => { }
})
.catch(err => {
console.log(err); console.log(err);
return res.status(500).json({error: err}); return res.status(500).json({ error: err });
}) });
}; };
exports.likePost = (req, res) => { exports.likePost = (req, res) => {
const postId = req.params.postId;
let likedPostDoc;
db.doc(`/users/${req.userData.handle}`)
.get()
.then(userDoc => {
let likes = userDoc.data().likes;
if (likes === undefined || likes === null) {
likes = [];
}
const postId = req.params.postId; if (likes.includes(postId)) {
let likedPostDoc; return res
db.doc(`/users/${req.userData.handle}`) .status(400)
.get() .json({ error: "This user has already liked this post" });
.then((userDoc) => { }
let likes = userDoc.data().likes;
if (likes === undefined || likes === null) {
likes = [];
}
if (likes.includes(postId)) { likes.push(postId);
return res.status(400).json({error: "This user has already liked this post"});
}
likes.push(postId); return userDoc.ref.update({ likes });
})
.then(() => {
return db.doc(`/posts/${postId}`).get();
})
.then(postDoc => {
let postData = postDoc.data();
postData.likeCount++;
likedPostDoc = postData;
return postDoc.ref.update({ likeCount: postData.likeCount });
})
.then(() => {
return res.status(201).json(likedPostDoc);
})
.catch(err => {
console.log(err);
return res.status(500).json({ error: err });
});
return userDoc.ref.update({likes}) // let postData;
}) // const likeDoc = admin.firestore().collection('likes').where('userHandle', '==', req.user.handle)
.then(() => { // .where('postId', '==', req.params.postId).limit(1);
return db.doc(`/posts/${postId}`).get()
})
.then((postDoc) => {
let postData = postDoc.data();
postData.likeCount++;
likedPostDoc = postData;
return postDoc.ref.update({likeCount : postData.likeCount})
})
.then(() => {
return res.status(201).json(likedPostDoc);
})
.catch((err) => {
console.log(err);
return res.status(500).json({error: err});
})
// let postData; // const postDoc = db.doc(`/posts/${req.params.postId}`);
// const likeDoc = admin.firestore().collection('likes').where('userHandle', '==', req.user.handle)
// .where('postId', '==', req.params.postId).limit(1);
// const postDoc = db.doc(`/posts/${req.params.postId}`); // postDoc.get()
// .then((doc) => {
// postDoc.get() // if(doc.exists) {
// .then((doc) => { // postData = doc.data();
// if(doc.exists) { // return likeDoc.get();
// postData = doc.data(); // }
// return likeDoc.get(); // else
// } // {
// else // return res.status(404).json({error: 'Post not found'});
// { // }
// return res.status(404).json({error: 'Post not found'}); // })
// } // .then((data) => {
// }) // if (data.empty) {
// .then((data) => { // return admin.firestore().collection('likes').add({
// if (data.empty) { // postId : req.params.postId,
// return admin.firestore().collection('likes').add({ // userHandle: req.user.handle
// postId : req.params.postId,
// userHandle: req.user.handle
// })
// .then(() => {
// postData.likeCount++;
// return postDoc.update({likeCount : postData.likeCount})
// })
// .then(() => {
// return res.status(200).json(postData);
// })
// }
// })
// .catch((err) => {
// return res.status(500).json({error: 'Something is wrong'});
// })
}
// })
// .then(() => {
// postData.likeCount++;
// return postDoc.update({likeCount : postData.likeCount})
// })
// .then(() => {
// return res.status(200).json(postData);
// })
// }
// })
// .catch((err) => {
// return res.status(500).json({error: 'Something is wrong'});
// })
};
exports.unlikePost = (req, res) => { exports.unlikePost = (req, res) => {
const postId = req.params.postId;
let likedPostDoc;
db.doc(`/users/${req.userData.handle}`)
.get()
.then(userDoc => {
let likes = userDoc.data().likes;
if (likes === undefined || likes === null) {
likes = [];
}
const postId = req.params.postId; if (!likes.includes(postId)) {
let likedPostDoc; return res
db.doc(`/users/${req.userData.handle}`) .status(400)
.get() .json({ error: "This user hasn't liked this post yet" });
.then((userDoc) => { }
let likes = userDoc.data().likes;
if (likes === undefined || likes === null) {
likes = [];
}
if (!likes.includes(postId)) { let i;
return res.status(400).json({error: "This user hasn't liked this post yet"}); for (i = 0; i < likes.length; i++) {
} if (likes[i] === postId) {
likes.splice(i, 1);
}
}
let i; return userDoc.ref.update({ likes });
for (i = 0; i < likes.length; i++) { })
if (likes[i] === postId) { .then(() => {
likes.splice(i, 1); return db.doc(`/posts/${postId}`).get();
} })
} .then(postDoc => {
let postData = postDoc.data();
postData.likeCount--;
likedPostDoc = postData;
return postDoc.ref.update({ likeCount: postData.likeCount });
})
.then(() => {
return res.status(201).json(likedPostDoc);
})
.catch(err => {
console.log(err);
return res.status(500).json({ error: err });
});
return userDoc.ref.update({likes}) // let postData;
}) // const likeDoc = admin.firestore().collection('likes').where('userHandle', '==', req.user.handle)
.then(() => { // .where('postId', '==', req.params.postId).limit(1);
return db.doc(`/posts/${postId}`).get()
})
.then((postDoc) => {
let postData = postDoc.data();
postData.likeCount--;
likedPostDoc = postData;
return postDoc.ref.update({likeCount : postData.likeCount})
})
.then(() => {
return res.status(201).json(likedPostDoc);
})
.catch((err) => {
console.log(err);
return res.status(500).json({error: err});
})
// let postData; // const postDoc = db.doc(`/posts/${req.params.postId}`);
// const likeDoc = admin.firestore().collection('likes').where('userHandle', '==', req.user.handle)
// .where('postId', '==', req.params.postId).limit(1);
// const postDoc = db.doc(`/posts/${req.params.postId}`); // postDoc.get()
// .then((doc) => {
// postDoc.get() // if(doc.exists) {
// .then((doc) => { // postData = doc.data();
// if(doc.exists) { // return likeDoc.get();
// postData = doc.data(); // }
// return likeDoc.get(); // else
// } // {
// else // return res.status(404).json({error: 'Post not found'});
// { // }
// return res.status(404).json({error: 'Post not found'}); // })
// } // .then((data) => {
// }) // return db
// .then((data) => { // .doc(`/likes/${data.docs[0].id}`)
// return db // .delete()
// .doc(`/likes/${data.docs[0].id}`) // .then(() => {
// .delete() // postData.likeCount--;
// .then(() => { // return postDoc.update({ likeCount: postData.likeCount });
// postData.likeCount--; // })
// return postDoc.update({ likeCount: postData.likeCount }); // .then(() => {
// }) // res.status(200).json(postData);
// .then(() => { // });
// res.status(200).json(postData);
// });
// })
// .catch((err) => {
// console.error(err);
// return res.status(500).json({error: 'Something is wrong'});
// })
}
// })
// .catch((err) => {
// console.error(err);
// return res.status(500).json({error: 'Something is wrong'});
// })
};
exports.getLikes = (req, res) => { exports.getLikes = (req, res) => {
db.doc(`/users/${req.userData.handle}`) db.doc(`/users/${req.userData.handle}`)
.get() .get()
.then((doc) => { .then(doc => {
let likes = doc.data().likes; let likes = doc.data().likes;
if (likes === undefined || likes === null) { if (likes === undefined || likes === null) {
likes = []; likes = [];
} }
return res.status(200).json({likes}); return res.status(200).json({ likes });
}) })
.catch((err) => { .catch(err => {
console.log(err); console.log(err);
return res.status(500).json({error: err}); return res.status(500).json({ error: err });
}) });
} };
exports.getFilteredPosts = (req, res) => { exports.getFilteredPosts = (req, res) => {
admin admin
.firestore() .firestore()
.collection("posts") .collection("posts")
.where("userHandle", "==", "new user") .where("userHandle", "==", "new user")
.where("microBlogTopics", "=="); .where("microBlogTopics", "==");
}; };

View File

@@ -26,6 +26,41 @@ exports.putTopic = (req, res) => {
}); });
}; };
exports.putNewTopic = (req, res) => {
let new_following = [];
let userRef = db.doc(`/users/${req.userData.handle}`);
userRef
.get()
.then(doc => {
let topics = [];
new_following = doc.data().following;
// new_following.push(req.body.following);
new_following.forEach(follow => {
if (follow.handle === req.body.handle) {
// topics = follow.topics;
follow.topics.push(req.body.topic);
}
});
// return res.status(201).json({ new_following });
// add stuff
userRef
.set({ following: new_following }, { merge: true })
.then(doc => {
return res
.status(201)
.json({ message: `Following ${req.body.topic}` });
})
.catch(err => {
return res.status(500).json({ err });
});
return res.status(200).json({ message: "OK" });
})
.catch(err => {
return res.status(500).json({ err });
});
};
exports.getAllTopics = (req, res) => { exports.getAllTopics = (req, res) => {
admin admin
.firestore() .firestore()

File diff suppressed because it is too large Load Diff

View File

@@ -100,18 +100,33 @@ app.post("/addSubscription", fbAuth, addSubscription);
// remove one subscription // remove one subscription
app.post("/removeSub", fbAuth, removeSub); 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,
getAlert
} = 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);
@@ -125,6 +140,8 @@ app.post("/quoteWithoutPost/:postId", fbAuth, quoteWithoutPost);
app.post("/getOtherUsersPosts", fbAuth, getOtherUsersPosts); app.post("/getOtherUsersPosts", fbAuth, getOtherUsersPosts);
app.get("/getAlert", fbAuth, getAlert);
/*------------------------------------------------------------------* /*------------------------------------------------------------------*
* handlers/topic.js * * handlers/topic.js *
*------------------------------------------------------------------*/ *------------------------------------------------------------------*/
@@ -132,7 +149,8 @@ const {
putTopic, putTopic,
getAllTopics, getAllTopics,
deleteTopic, deleteTopic,
getUserTopics getUserTopics,
putNewTopic
} = require("./handlers/topic"); } = require("./handlers/topic");
// add topic to database // add topic to database
@@ -147,4 +165,6 @@ app.post("/deleteTopic", fbAuth, deleteTopic);
// get topic for this user // get topic for this user
app.post("/getUserTopics", fbAuth, getUserTopics); app.post("/getUserTopics", fbAuth, getUserTopics);
app.post("/putNewTopic", fbAuth, putNewTopic);
exports.api = functions.https.onRequest(app); exports.api = functions.https.onRequest(app);

View File

@@ -673,6 +673,14 @@
"readable-stream": "~1.0.32" "readable-stream": "~1.0.32"
} }
}, },
"busboy": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
"integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
"requires": {
"dicer": "0.3.0"
}
},
"bytebuffer": { "bytebuffer": {
"version": "5.0.1", "version": "5.0.1",
"resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz", "resolved": "https://registry.npmjs.org/bytebuffer/-/bytebuffer-5.0.1.tgz",
@@ -2593,9 +2601,9 @@
} }
}, },
"lodash": { "lodash": {
"version": "4.17.15", "version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==" "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}, },
"lodash.at": { "lodash.at": {
"version": "4.6.0", "version": "4.6.0",

BIN
screenshots/00.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
screenshots/01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
screenshots/02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

BIN
screenshots/03.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
screenshots/04.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

BIN
screenshots/05.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 KiB

BIN
screenshots/06.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
screenshots/07.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

File diff suppressed because it is too large Load Diff

View File

@@ -84,23 +84,23 @@ class Writing_Microblogs extends Component {
console.error(err); console.error(err);
}); });
console.log(postData.microBlogTopics); console.log(postData.microBlogTopics);
let topicPromises = []; // let topicPromises = [];
postData.microBlogTopics.forEach(topic => { // postData.microBlogTopics.forEach(topic => {
topicPromises.push(axios // topicPromises.push(axios
.post("/putTopic", { // .post("/putTopic", {
following: topic // following: topic
}) // })
.then(res => { // .then(res => {
console.log(res.data); // console.log(res.data);
}) // })
.catch(err => { // .catch(err => {
console.error(err); // console.error(err);
}) // })
) // )
}); // });
event.preventDefault(); event.preventDefault();
topicPromises.push(postPromise); // topicPromises.push(postPromise);
Promise.all(topicPromises) Promise.all([postPromise])
.then(() => { .then(() => {
this.setState({ this.setState({
value: "", value: "",

View File

@@ -41,36 +41,55 @@ class Home extends Component {
}; };
componentDidMount() { componentDidMount() {
this.setState({loading: true}); this.setState({ loading: true });
let userPromise = axios let userPromise = axios
.get("/user") .get("/user")
.then(res => { .then(res => {
console.log(res.data.credentials.following);
let list = [];
res.data.credentials.following.forEach(element => {
list.push(element.handle);
});
this.setState({ this.setState({
following: res.data.credentials.following, following: list,
topics: res.data.credentials.followedTopics topics: res.data.credentials.followedTopics
}); });
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
let allPosts;
let postPromise = axios let postPromise = axios
.get("/getallPosts") .get("/getallPosts")
.then(res => { .then(res => {
// console.log(res.data); // console.log(res.data);
// this.setState({
// posts: res.data
// });
allPosts = res.data;
// console.log(allPosts)
return axios.get("/getAlert")
})
.then((res) => {
// console.log(res.data)
// res.data.forEach((adminAlert) => {
// allPosts.push(adminAlert);
// })
this.setState({ this.setState({
posts: res.data posts: allPosts
}); });
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
Promise.all([userPromise, postPromise]) Promise.all([userPromise, postPromise])
.then(() => { .then(() => {
this.setState({ this.setState({
loading: false loading: false
}) });
}) })
.catch((error) => { .catch(error => {
console.log(error); console.log(error);
}) });
this.props.getLikes(); this.props.getLikes();
} }
@@ -81,8 +100,22 @@ class Home extends Component {
}); });
} }
handleClickLikeButton = event => { flagPost = (event) => {
// Need the ternary if statement because the user can click on the text or body of the // Flags a post
let postId = event.target.dataset.key ? event.target.dataset.key : event.target.parentNode.dataset.key;
console.log(postId);
axios.post(`/hidePost`, {postId})
.then((res) => {
console.log(res.data);
})
.catch(err => {
console.error(err);
});
// event.preventDefault();
}
handleClickLikeButton = (event) => {
// 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
let postId = event.target.dataset.key let postId = event.target.dataset.key
? event.target.dataset.key ? event.target.dataset.key
@@ -114,51 +147,49 @@ 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(this.state.following); console.log(username);
var hiddenBool = true;
if (username === "Admin") {
hiddenBool = false;
}
let postMarkup = this.state.posts ? ( console.log(hiddenBool);
this.state.posts.map(post => let postMarkup = this.state.posts ? ( this.state.following === undefined || this.state.following === null ? <Typography>You aren't following anybody right now</Typography> :
this.state.following ? ( this.state.posts.map(post => !post.hidden && this.state.following && (this.state.following.includes(post.userHandle) || post.userHandle === "Admin") ? (
this.state.following.includes(post.userHandle) ? (
<Card className={classes.card} key={post.postId}> <Card className={classes.card} key={post.postId}>
<CardContent> <CardContent>
<Typography> <Typography>
{/* { {/* {
this.state.imageUrl ? (<img src={this.state.imageUrl} height="50" width="50" />) : this.state.imageUrl ? (<img src={this.state.imageUrl} height="50" width="50" />) :
(<img src={noImage} height="50" width="50"/>) (<img src={noImage} height="50" width="50"/>)
} */} } */}
{post.profileImage ? ( {
<img src={post.profileImage} height="50" width="50" /> post.profileImage ? (<img src={post.profileImage} height="50" width="50" />) :
) : ( (<img src={noImage} height="50" width="50"/>)
<img src={noImage} height="50" width="50" /> }
)}
</Typography>
<Typography variant="h5">
<b>{post.userHandle}</b>
</Typography>
<Typography variant="body2" color={"textSecondary"}>
{this.formatDate(post.createdAt)}
</Typography> </Typography>
<Typography variant="h5"><b>{post.userHandle}</b></Typography>
<Typography variant="body2" color={"textSecondary"}>{this.formatDate(post.createdAt)}</Typography>
<br /> <br />
<Typography variant="body1"> <Typography variant="body1"><b>{post.microBlogTitle}</b></Typography>
<b>{post.microBlogTitle}</b>
</Typography>
<Typography variant="body2">{post.quoteBody}</Typography> <Typography variant="body2">{post.quoteBody}</Typography>
<br /> <br />
<Typography variant="body2">{post.body}</Typography> <Typography variant="body2">{post.body}</Typography>
<br /> <br />
<Typography variant="body2"> <Typography variant="body2"><b>Topics:</b> {post.microBlogTopics.join(", ")}</Typography>
<b>Topics:</b> {post.microBlogTopics}
</Typography>
<br /> <br />
<Typography {!hiddenBool &&
id={post.postId} <Button
data-likes={post.likeCount} onClick={this.flagPost}
variant="body2" data-key={post.postId}
color={"textSecondary"} variant = "contained"
color = "primary"
> >
Likes {post.likeCount} Hide Post
</Typography> </Button>
}
<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
onClick={this.handleClickLikeButton} onClick={this.handleClickLikeButton}
@@ -166,70 +197,76 @@ class Home extends Component {
disabled={loading} disabled={loading}
variant="outlined" variant="outlined"
color="primary" color="primary"
> >{
{this.state.likes && this.state.likes.includes(post.postId) this.state.likes && this.state.likes.includes(post.postId) ? 'Unlike' : 'Like'
? "Unlike" }</Button>
: "Like"} <Quote microblog = {post.postId}></Quote>
</Button>
<Quote microblog={post.postId}></Quote>
{/* <button>Quote</button> */} {/* <button>Quote</button> */}
{/* <Typography variant="body2" color={"textSecondary"}>Likes {post.likeCount} Comments {post.commentCount}</Typography> */}
</CardContent> </CardContent>
</Card> </Card>
) : (
<p></p>
)
) : ( ) : (
<p>Loading</p> <p></p>
) )
) )
) : ( ) : (
<p>Loading post...</p> <p>Loading post...</p>
); );
return ( return authenticated ? (
authenticated ? ( this.state.loading ? (
this.state.loading ? (<CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress>) : <CircularProgress
<Grid container> size={60}
<Grid item sm={4} xs={8}> style={{ marginTop: "300px" }}
<Writing_Microblogs /> ></CircularProgress>
) : (
<Grid container>
<Grid item sm={4} xs={8}>
<Writing_Microblogs />
</Grid>
<Grid item sm={4} xs={8}>
{postMarkup}
</Grid>
</Grid> </Grid>
<Grid item sm={4} xs={8}> )
{postMarkup} ) : loading ? (
</Grid> <CircularProgress
</Grid> size={60}
) : loading ? style={{ marginTop: "300px" }}
(<CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress>) ></CircularProgress>
: ) : (
( <div>
<div> <div>
<div> <img src={logo} className="app-logo" alt="logo" />
<img src={logo} className="app-logo" alt="logo" /> <br />
<br/><br/> <br />
<b>Welcome to Twistter!</b> <b>Welcome to Twistter!</b>
<br/><br/> <br />
<b>See the most interesting topics people are following right now.</b> <br />
</div> <b>See the most interesting topics people are following right now.</b>
</div>
<br /> <br />
<br /> <br />
<br /> <br />
<br /> <br />
<div> <div>
<b>Join today or sign in if you already have an account.</b> <b>Join today or sign in if you already have an account.</b>
<br /> <br />
<br /> <br />
<form action="./signup"> <form action="./signup">
<button className="authButtons signup">Sign up</button> <button className="authButtons signup">Sign up</button>
</form> </form>
<br /> <br />
<form action="./login"> <form action="./login">
<button className="authButtons login">Sign in</button> <button className="authButtons login">Sign in</button>
</form> </form>
</div> </div>
</div> </div>
)
); );
} }
} }
@@ -412,7 +449,7 @@ class Like extends Component {
}); });
} }
handleClick() { handleClick(){
this.setState({ this.setState({
like: !this.state.like like: !this.state.like
}); });

View File

@@ -83,6 +83,10 @@ const styles = {
wordBreak: "break-all", wordBreak: "break-all",
color: 'black' color: 'black'
}, },
dmRecentMessageDisabled: {
wordBreak: "break-all",
color: 'red'
},
dmListItemContainer: { dmListItemContainer: {
height: 100 height: 100
}, },
@@ -105,7 +109,7 @@ const styles = {
fontSize: 20, fontSize: 20,
backgroundColor: '#1da1f2', backgroundColor: '#1da1f2',
width: 300 width: 300
}, },
messagesGrid: { messagesGrid: {
// // margin: "auto" // // margin: "auto"
// height: "auto", // height: "auto",
@@ -377,7 +381,7 @@ export class directMessages extends Component {
const open = Boolean(this.state.anchorEl); const open = Boolean(this.state.anchorEl);
const id = open ? 'simple-popover' : undefined; const id = open ? 'simple-popover' : undefined;
let dmListMarkup = this.state.dmData ? ( let dmListMarkup = this.state.dmData ? (
this.state.dmData.map((channel) => ( this.state.dmData.map((channel) => (
<Card <Card
onClick={this.handleClickChannel} onClick={this.handleClickChannel}
@@ -426,13 +430,19 @@ export class directMessages extends Component {
<Typography <Typography
className={ className={
this.state.selectedChannel && this.state.selectedChannel.dmId === channel.dmId ? ( this.state.selectedChannel && this.state.selectedChannel.dmId === channel.dmId ? (
classes.dmRecentMessageSelected channel.hasDirectMessagesEnabled ?
classes.dmRecentMessageSelected
:
classes.dmRecentMessageDisabled
) : ( ) : (
classes.dmRecentMessageUnselected channel.hasDirectMessagesEnabled ?
classes.dmRecentMessageUnselected
:
classes.dmRecentMessageDisabled
) )
} }
> >
{ {!channel.hasDirectMessagesEnabled ? "This user has DMs disabled" :
!channel.recentMessage ? !channel.recentMessage ?
'No messages' 'No messages'
: :
@@ -524,35 +534,35 @@ export class directMessages extends Component {
onChange={this.handleChangeAddDMUsername} onChange={this.handleChangeAddDMUsername}
value={this.state.createDMUsername} value={this.state.createDMUsername}
label="Username" label="Username"
variant="outlined" variant="outlined"
helperText={errors.createDirectMessage} helperText={errors.createDirectMessage}
error={errors.createDirectMessage ? true : false} error={errors.createDirectMessage ? true : false}
style={{ style={{
width: 265, width: 265,
marginRight: 10, marginRight: 10,
marginLeft: 10, marginLeft: 10,
textAlign: 'center', textAlign: 'center',
}} }}
/> />
</Grid> </Grid>
<Grid item> <Grid item>
<Button <Button
className={classes.createButton} className={classes.createButton}
variant="outlined" variant="outlined"
color="primary" color="primary"
onClick={this.handleClickCreate} onClick={this.handleClickCreate}
disabled={ disabled={
creatingDirectMessage || creatingDirectMessage ||
this.state.createDMUsername === "" this.state.createDMUsername === ""
} }
> >
Create Create
{creatingDirectMessage && {creatingDirectMessage &&
<CircularProgress size={30} style={{position: "absolute"}}/> // Won't accept classes style for some reason
// Won't accept classes style for some reason <CircularProgress size={30} style={{position: "absolute"}}/>
} }
</Button> </Button>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
<Grid item sm /> <Grid item sm />
@@ -572,13 +582,13 @@ export class directMessages extends Component {
<Grid item className={classes.dmItemsUpper} id="dmItemsUpper"> <Grid item className={classes.dmItemsUpper} id="dmItemsUpper">
{dmListMarkup} {dmListMarkup}
</Grid> </Grid>
<Grid item className={classes.dmItemsLower}> <Grid item className={classes.dmItemsLower}>
<Card key="5555" data-key="5555" className={classes.dmCardUnselected}> <Card key="5555" data-key="5555" className={classes.dmCardUnselected}>
<Box className={classes.dmListItemContainer}> <Box className={classes.dmListItemContainer}>
{addDMMarkup} {addDMMarkup}
</Box> </Box>
</Card> </Card>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
<Grid item className={classes.messagesGrid} sm> <Grid item className={classes.messagesGrid} sm>
@@ -596,30 +606,39 @@ export class directMessages extends Component {
variant="outlined" variant="outlined"
multiline multiline
rows={2} rows={2}
margin="dense" margin="dense"
value={this.state.drafts[this.state.selectedChannel.dmId] ? this.state.drafts[this.state.selectedChannel.dmId] : ""} disabled={!this.state.selectedChannel.hasDirectMessagesEnabled}
onChange={this.handleChangeMessage} value={
!this.state.selectedChannel.hasDirectMessagesEnabled ?
"This user has DMs disabled"
:
this.state.drafts[this.state.selectedChannel.dmId] ?
this.state.drafts[this.state.selectedChannel.dmId]
:
""
}
onChange={this.handleChangeMessage}
/> />
<Fab <Fab
className={classes.messageButton} className={classes.messageButton}
onClick={this.handleClickSend} onClick={this.handleClickSend}
disabled={ disabled={
sendingDirectMessage || sendingDirectMessage ||
!this.state.drafts[this.state.selectedChannel.dmId] || !this.state.drafts[this.state.selectedChannel.dmId] ||
this.state.drafts[this.state.selectedChannel.dmId] === "" this.state.drafts[this.state.selectedChannel.dmId] === ""
} }
> >
<SendIcon style={{ color: '#FFFFFF' }} /> <SendIcon style={{ color: '#FFFFFF' }} />
{ {
sendingDirectMessage && sendingDirectMessage &&
<CircularProgress size={30} style={{position: "absolute"}}/> <CircularProgress size={30} style={{position: "absolute"}}/>
// Won't accept classes style for some reason // Won't accept classes style for some reason
} }
</Fab> </Fab>
</Box> </Box>
</Card> </Card>
)} )}
{!this.state.hasChannelSelected && {!this.state.hasChannelSelected &&
this.state.dmData && <Typography>Select a DM on the left</Typography>} this.state.dmData && <Typography>Select a DM on the left</Typography>}
</Box> </Box>
</Grid> </Grid>

View File

@@ -79,6 +79,7 @@ class user extends Component {
following: null, following: null,
posts: null, posts: null,
myTopics: null, myTopics: null,
followingList: null,
loading: false loading: false
}; };
} }
@@ -92,7 +93,8 @@ class user extends Component {
.then(res => { .then(res => {
console.log("removed sub"); console.log("removed sub");
this.setState({ this.setState({
following: false following: false,
myTopics: []
}); });
}) })
.catch(function(err) { .catch(function(err) {
@@ -115,8 +117,26 @@ class user extends Component {
} }
}; };
handleAdd = newTopic => {
axios
.post("/putNewTopic", {
handle: this.state.profile,
topic: newTopic
})
.then(() => {
let temp = this.state.myTopics;
temp.push(newTopic);
this.setState({
myTopics: temp
});
})
.catch(err => {
console.err(err);
});
};
componentDidMount() { componentDidMount() {
this.setState({loading: true}); this.setState({ loading: true });
let otherUserPromise = axios let otherUserPromise = axios
.post("/getUserDetails", { .post("/getUserDetails", {
handle: this.state.profile handle: this.state.profile
@@ -132,11 +152,18 @@ class user extends Component {
let userPromise = axios let userPromise = axios
.get("/user") .get("/user")
.then(res => { .then(res => {
let list = [];
let fol = false;
res.data.credentials.following.forEach(follow => {
// console.log(follow);
if (this.state.profile === follow.handle) {
fol = true;
list = follow.topics;
}
});
this.setState({ this.setState({
following: res.data.credentials.following.includes( following: fol,
this.state.profile myTopics: list
),
myTopics: res.data.credentials.followedTopics
}); });
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
@@ -153,13 +180,43 @@ class user extends Component {
}) })
.catch(err => console.log(err)); .catch(err => console.log(err));
Promise.all([otherUserPromise, userPromise, posts]) // Only add Admin posts if this is not the Admin account
.then(() => { let alertPromise;
this.setState({loading: false}); if (this.state.profile !== "Admin") {
}) alertPromise = axios
.catch((error) => { .get("/getAlert")
console.log(error); .then(res => {
let temp = this.state.posts;
// console.log(res.data);
res.data.forEach(element => {
element ? temp.push(element) : console.err;
});
// temp.push(res.data[0]);
this.setState({
posts: temp
});
}) })
.catch(function(err) {
console.log(err);
});
} else {
alertPromise = new Promise((resolve, reject) => {
resolve();
});
}
Promise.all([otherUserPromise, userPromise, posts, alertPromise])
.then(() => {
this.setState({ loading: false });
})
.catch(error => {
console.log(error);
});
}
formatDate(dateString) {
let newDate = new Date(Date.parse(dateString));
return newDate.toDateString();
} }
render() { render() {
@@ -188,8 +245,8 @@ class user extends Component {
<p>loading username...</p> <p>loading username...</p>
); );
console.log(this.state.topics); // console.log(this.state.topics);
console.log(this.state.myTopics); // console.log(this.state.myTopics);
let topicsMarkup = this.state.topics ? ( let topicsMarkup = this.state.topics ? (
this.state.topics.map( this.state.topics.map(
topic => topic =>
@@ -197,16 +254,20 @@ class user extends Component {
this.state.myTopics.includes(topic) ? ( this.state.myTopics.includes(topic) ? (
<MyChip <MyChip
label={topic} label={topic}
key={{ topic }.topic.id} key={{ topic }.id}
onDelete onDelete
deleteIcon={<DoneIcon />} deleteIcon={<DoneIcon />}
/> />
) : ( ) : this.state.following ? (
<MyChip <MyChip
label={topic} label={topic}
key={{ topic }.topic.id} key={{ topic }.id}
color="secondary" color="secondary"
clickable
onClick={key => this.handleAdd(topic)}
/> />
) : (
<MyChip label={topic} key={{ topic }.id} color="secondary" />
) )
) : ( ) : (
<p></p> <p></p>
@@ -222,10 +283,10 @@ class user extends Component {
) : ( ) : (
<img src={noImage} height="150" width="150" /> <img src={noImage} height="150" width="150" />
); );
//(this.state.posts);
let postMarkup = this.state.posts ? ( let postMarkup = this.state.posts ? (
this.state.posts.map(post => ( this.state.posts.map(post => (
<Card className={classes.card}> <Card className={classes.card} key={post.postId} data-key={post.postId}>
<CardContent> <CardContent>
<Typography> <Typography>
{this.state.imageUrl ? ( {this.state.imageUrl ? (
@@ -234,11 +295,11 @@ class user extends Component {
<img src={noImage} height="50" width="50" /> <img src={noImage} height="50" width="50" />
)} )}
</Typography> </Typography>
<Typography variant="h7"> <Typography variant="h4">
<b>{post.userHandle}</b> <b>{post.userHandle}</b>
</Typography> </Typography>
<Typography variant="body2" color={"textSecondary"}> <Typography variant="body2" color={"textSecondary"}>
{post.createdAt} {this.formatDate(post.createdAt)}
</Typography> </Typography>
<br /> <br />
@@ -251,7 +312,7 @@ class user extends Component {
<Typography variant="body2">{post.body}</Typography> <Typography variant="body2">{post.body}</Typography>
<br /> <br />
<Typography variant="body2"> <Typography variant="body2">
<b>Topics:</b> {post.microBlogTopics} <b>Topics:</b> {post.microBlogTopics.join(", ")}
</Typography> </Typography>
<br /> <br />
<Typography variant="body2" color={"textSecondary"}> <Typography variant="body2" color={"textSecondary"}>
@@ -264,9 +325,13 @@ class user extends Component {
<p>Posts</p> <p>Posts</p>
); );
return ( return this.state.loading ? (
this.state.loading ? <CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress> : <CircularProgress
<Grid container spacing={24}> size={60}
style={{ marginTop: "300px" }}
></CircularProgress>
) : (
<Grid container spacing={10}>
<Grid item sm={4} xs={8}> <Grid item sm={4} xs={8}>
{imageMarkup} {imageMarkup}
{profileMarkup} {profileMarkup}

View File

@@ -269,6 +269,15 @@ class user extends Component {
</Link> </Link>
) : null; ) : null;
let verifyButtonMarkup = this.state.profile === "Admin" ?
<Link to="/verify">
<Button className={classes.button} variant="outlined" color="primary">
Verify Users
</Button>
</Link>
:
null
return ( return (
this.state.loading ? <CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress> : this.state.loading ? <CircularProgress size={60} style={{marginTop: "300px"}}></CircularProgress> :
<div> <div>
@@ -278,6 +287,7 @@ class user extends Component {
<Grid container> <Grid container>
<Grid item sm> <Grid item sm>
{editButtonMarkup} {editButtonMarkup}
{verifyButtonMarkup}
</Grid> </Grid>
<Grid item sm> <Grid item sm>
{/* <Grid container direction="column"> */} {/* <Grid container direction="column"> */}

View File

@@ -142,5 +142,6 @@ export const sendDirectMessage = (user, message) => (dispatch) => {
sendDirectMessage: err.response.data sendDirectMessage: err.response.data
} }
}) })
dispatch({type: SET_NOT_LOADING_UI_4});
}) })
} }

View File

@@ -36,6 +36,7 @@ export const getUserData = () => (dispatch) => {
// Sends login data to firebase and sets the user data in Redux // Sends login data to firebase and sets the user data in Redux
export const loginUser = (loginData, history) => (dispatch) => { export const loginUser = (loginData, history) => (dispatch) => {
dispatch({type: CLEAR_ERRORS});
dispatch({ type: LOADING_UI }); dispatch({ type: LOADING_UI });
axios axios
.post("/login", loginData) .post("/login", loginData)
@@ -57,6 +58,7 @@ export const loginUser = (loginData, history) => (dispatch) => {
// Sends signup data to firebase and sets the user data in Redux // Sends signup data to firebase and sets the user data in Redux
export const signupUser = (newUserData, history) => (dispatch) => { export const signupUser = (newUserData, history) => (dispatch) => {
dispatch({type: CLEAR_ERRORS});
dispatch({ type: LOADING_UI }); dispatch({ type: LOADING_UI });
axios axios
.post("/signup", newUserData) .post("/signup", newUserData)