forked from kaverti/website
asdasdasdad
This commit is contained in:
parent
2d3e27197b
commit
bd757e214b
|
@ -1,43 +1,28 @@
|
|||
<template>
|
||||
<div
|
||||
class='post'
|
||||
:class='{
|
||||
"post--highlighted": highlight,
|
||||
"post--selected": selected
|
||||
}'
|
||||
@mouseenter='hover = true'
|
||||
@mouseleave='hover = false'
|
||||
>
|
||||
|
||||
|
||||
<div class='post__meta_data'>
|
||||
<div style='display: inline-flex;'>
|
||||
<avatar-icon :user='post.User' class='post__avatar'></avatar-icon>
|
||||
<div class='post__thread' v-if='showThread' @click.stop='goToThread'>
|
||||
·
|
||||
<avatar-icon :user='$store.state.thread.username' class='post__avatar'></avatar-icon>
|
||||
<div class='post__thread' v-if='showThread'>
|
||||
</div>
|
||||
<div class='post__user' v-else>
|
||||
PLACEHOLDER-USERNAME
|
||||
{{$store.state.thread.username.username}}
|
||||
</div>
|
||||
</div>
|
||||
PLACEHOLDER DATE</div>
|
||||
<div class='post__date post__date--mobile'>PLACEHOLDER DATE</div>
|
||||
</div>
|
||||
<div
|
||||
tabindex='-1'
|
||||
class='post__content'
|
||||
v-html='postContentHTML'
|
||||
@mouseup='setShowQuote'
|
||||
@blur='showQuote = false'
|
||||
v-html='$store.state.thread.content'
|
||||
></div>
|
||||
<div class='post__footer'>
|
||||
<div
|
||||
class='post__footer_group'
|
||||
>
|
||||
<div class='post__footer_sub_group'>
|
||||
<heart-button :post='post' v-if='showReply'></heart-button>
|
||||
</div>
|
||||
<div class='post__footer_sub_group' v-if='post.Replies.length'>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -64,7 +49,8 @@
|
|||
components: {
|
||||
// eslint-disable-next-line vue/no-unused-components
|
||||
ModalWindow,
|
||||
AvatarIcon,
|
||||
// eslint-disable-next-line vue/no-unused-components
|
||||
AvatarIcon,
|
||||
|
||||
},
|
||||
data () {
|
||||
|
|
|
@ -17,11 +17,13 @@
|
|||
@loadPrevious='loadPreviousPosts'
|
||||
>
|
||||
<template v-if='!posts.length'>
|
||||
<thread-post-placeholder
|
||||
v-for='n in 3'
|
||||
:key='"thread-post-placeholder-loading-" + n'
|
||||
:class='{"post--last": n === 2}'
|
||||
></thread-post-placeholder>
|
||||
<thread-cubash-impl
|
||||
:show-reply='!$store.state.thread.locked'
|
||||
:showSelect='$store.state.thread.showRemovePostsButton'
|
||||
:allowQuote='true'
|
||||
|
||||
ref='posts'
|
||||
></thread-cubash-impl>
|
||||
</template>
|
||||
|
||||
<template v-if='$store.state.thread.loadingPosts === "previous"'>
|
||||
|
@ -31,14 +33,6 @@
|
|||
>
|
||||
</thread-post-placeholder>
|
||||
</template>
|
||||
<thread-cubash-impl
|
||||
:show-reply='!$store.state.thread.locked'
|
||||
:showSelect='$store.state.thread.showRemovePostsButton'
|
||||
:highlight='highlightedPostIndex === index'
|
||||
:allowQuote='true'
|
||||
|
||||
ref='posts'
|
||||
></thread-cubash-impl>
|
||||
<thread-post
|
||||
v-for='(post, index) in posts'
|
||||
:key='"thread-post-" + post.id'
|
||||
|
|
|
@ -280,6 +280,8 @@ const mutations = {
|
|||
state.thread = obj.name
|
||||
state.content = obj.content
|
||||
state.title = obj.title
|
||||
state.username = obj.User
|
||||
state.createdAt = obj.createdAt
|
||||
state.threadId = obj.id
|
||||
state.PollQuestionId = obj.PollQuestionId
|
||||
state.category = obj.Category
|
||||
|
|
|
@ -95,10 +95,9 @@ module.exports = (sequelize, DataTypes) => {
|
|||
|
||||
return [
|
||||
{ model: models.User, attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
|
||||
{ model: models.User, as: 'Likes', attributes: ['username', 'createdAt', 'id', 'color', 'picture'] },
|
||||
{ model: models.Thread, include: [models.Category]} ,
|
||||
{
|
||||
model: models.Post, as: 'Replies', include:
|
||||
model: models.Post, as: 'Posts', include:
|
||||
[{ model: models.User, attributes: ['username', 'id', 'color', 'picture'] }]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -194,13 +194,6 @@ router.get('/', async(req, res, next) => {
|
|||
};
|
||||
let offset = Number.isInteger(+req.query.offset) ? +req.query.offset : 0;
|
||||
let havingClause = '';
|
||||
if(req.query.role === 'admin') {
|
||||
havingClause = 'HAVING Users.admin = true';
|
||||
} else if(req.query.role === 'user') {
|
||||
havingClause = 'HAVING Users.admin = false';
|
||||
} else {
|
||||
havingClause = 'Having Users.hidden = false';
|
||||
}
|
||||
if(req.query.search) {
|
||||
//I.e. if there is not already a HAVING clause
|
||||
if(!havingClause.length) {
|
||||
|
@ -211,17 +204,17 @@ router.get('/', async(req, res, next) => {
|
|||
havingClause += 'Users.username LIKE $search';
|
||||
}
|
||||
let sql = `
|
||||
SELECT X.username, X.admin, X.picture, X.level, X.levelProgress, X.bot, X.booster, X.description, X.bodyColor, X.headColor, X.leftLegColor, X.rightLegColor, X.leftArmColor, X.rightArmColor, X.hidden, X.system, X.createdAt, X.contributor, X.postCount, COUNT(Threads.id) as threadCount
|
||||
SELECT X.username, X.postCount, COUNT(Threads.id) as threadCount
|
||||
FROM (
|
||||
SELECT Users.*, COUNT(Posts.id) as postCount
|
||||
FROM Users
|
||||
LEFT OUTER JOIN Posts
|
||||
ON Users.id = Posts.UserId
|
||||
GROUP BY Users.id
|
||||
ON Users.id = Posts.UserUsername
|
||||
GROUP BY Users.username
|
||||
${havingClause}
|
||||
) as X
|
||||
LEFT OUTER JOIN threads
|
||||
ON X.id = Threads.UserId
|
||||
ON X.username = Threads.UserUsername
|
||||
GROUP BY X.id
|
||||
ORDER BY ${sortFields[req.query.sort] || 'X.id'} ${req.query.order === 'asc' ? 'DESC' : 'ASC'}
|
||||
LIMIT 30
|
||||
|
|
Loading…
Reference in New Issue