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