Skip to content

Commit

Permalink
Merge pull request #297 from Bandmatch-io/versions/v2.1
Browse files Browse the repository at this point in the history
Versions/v2.1
  • Loading branch information
TCroasdale committed Jul 5, 2022
2 parents 1bb5082 + aca3cef commit 5d8e827
Show file tree
Hide file tree
Showing 26 changed files with 878 additions and 191 deletions.
31 changes: 23 additions & 8 deletions components/Elements/Conversation.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<div ref="container" class="overflow-y-auto">
<div ref="container" class="overflow-y-scroll">
<div v-if="state===states.default">
<div v-for="msg in messages" :key="msg._id" class="w-full flow-root">
<div class="m-3 w-3/4 max-w-350" :class="{ 'float-right': amSender(msg.sender), 'float-left': !amSender(msg.sender) }">
Expand Down Expand Up @@ -31,14 +31,18 @@
</div>
</div>
</div>
<div v-else class="w-1/2 md:w-1/4 mx-auto h-24 my-8">
<div v-else-if="state===states.loading" class="w-1/2 md:w-1/4 mx-auto h-24 my-8">
<LoaderAnim />
</div>
<div v-else class="w-full text-center h-24 my-8">
<alert-octagon-icon size="5x" class="block mx-auto"/>
<p>Could not find conversation</p>
</div>
</div>
</template>

<script>
import { CircleIcon, CheckCircleIcon } from 'vue-feather-icons'
import { CircleIcon, CheckCircleIcon, AlertOctagonIcon } from 'vue-feather-icons'
import MarkdownView from '~/components/Widgets/MarkdownView'
import LoaderAnim from '~/components/Core/LoaderAnim'
Expand All @@ -47,7 +51,8 @@ export default {
MarkdownView,
LoaderAnim,
CircleIcon,
CheckCircleIcon
CheckCircleIcon,
AlertOctagonIcon
},
props: {
convoId: { type: String, default () { return '' } }
Expand All @@ -59,7 +64,7 @@ export default {
default: 1,
error: 2
},
state: 0,
state: 1,
messages: []
}
},
Expand All @@ -73,19 +78,20 @@ export default {
},
methods: {
fetchConversation (id) {
if (id === undefined) {
if (id === undefined || id === '') {
this.messages = []
this.state = this.states.default
this.state = this.states.error
return
}
this.state = this.states.loading
this.$axios.get(`/conversations/${id}`)
this.$axios.get(`/convos/?cid=${id}`)
.then((res) => {
this.state = this.states.default
if (res.data.success) {
this.messages = res.data.messages
this.scrollToBottom()
this.checkRead()
} else {
this.messages = []
}
Expand All @@ -95,6 +101,15 @@ export default {
this.messages = []
})
},
checkRead () {
const lastMSG = this.messages[this.messages.length - 1]
if (lastMSG && !this.amSender(lastMSG.sender)) {
const msgID = lastMSG._id
lastMSG.read = true
this.$axios.patch(`/msgs/read?mid=${msgID}`)
this.$store.commit('unread/removeUnread')
}
},
amSender (sender) {
return sender._id === this.$auth.user._id
},
Expand Down
14 changes: 10 additions & 4 deletions components/Elements/ProfileCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
<div class="block md:inline-block w-300 rounded shadow mx-auto md:mx-5 my-5 bg-gray-100">
<div class="p-3 border-b-2 shadow-sm rounded-t">
<div class="mb-0 grid grid-cols-2">
<h3 class="col-span-1">
<h3 class="col-span-1 overflow-x-hidden">
<award-icon v-if="user.admin" class="inline-block text-secondary-300" />{{ user.displayName }}
</h3>
<small class="col-span-1">
<eye-icon size="1x" class="inline-block mr-1 text-secondary-300" /><timeago :datetime="user.timestamps.last_login" class="mr-1" />
<small class="col-span-1 text-right">
<eye-icon size="1x" class="inline-block mr-1 text-secondary-300" /><timeago :datetime="user.timestamps.last_login" class="ml-auto mr-1" />
</small>
</div>
<p class="mt-0 text-black">
Expand Down Expand Up @@ -35,7 +35,7 @@
<Badge v-for="instrument in user.instruments" :key="instrument" :val="instrument" />
</div>
</div>
<div class="w-full mb-0 grid grid-cols-5">
<div class="w-full mb-0 grid grid-cols-5" v-if="showControls">
<Button :action="navigateToProfile" group-pos="first" class="col-span-2 inline-block mx-0 mb-0 mt-0">
<user-icon class="inline-block" /> Profile
</Button>
Expand Down Expand Up @@ -78,6 +78,12 @@ export default {
admin: false
}
}
},
showControls: {
type: Boolean,
default () {
return true
}
}
},
computed: {
Expand Down
2 changes: 1 addition & 1 deletion components/Elements/RequestPassReset.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default {
e.preventDefault()
this.resetErrors()
this.state = this.states.loading
this.$axios.patch('/users/password/request', this.resetDetails)
this.$axios.patch(`/auth/password/request?email=${this.resetDetails.email}`)
.then((res) => {
if (res.data.success) {
this.state = this.states.success
Expand Down
8 changes: 7 additions & 1 deletion components/Elements/SignupForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@
<TextInput v-model="userInformation.email" type="email" placeholder="you@youremail.com" label="Email" autofill="email">
<mail-icon class="block mx-auto" />
</TextInput>
<TextError v-if="errors.email && errors.email.inUse">
<TextError v-if="errors.user && errors.user.exists">
Email is already in use
</TextError>
<TextError v-if="errors.email && errors.email.invalid">
Email is invalid
</TextError>
<TextError v-if="errors.email && errors.email.missing">
Email is invalid
</TextError>
<p class="mb-5">
<small>We will never share your email with anyone</small>
</p>
Expand Down Expand Up @@ -128,6 +131,9 @@ export default {
password: {
mismatch: false,
invalid: false
},
user: {
exists: false
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions components/Footer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<ul class="col-span-1 w-full grid grid-cols-4">
<li class="inline-block col-span-1 underline p-1">
<nuxt-link to="/about">
About <span class="hidden md:inline">us</span>
About <span class="hidden lg:inline">us</span>
</nuxt-link>
</li>
<li class="inline-block col-span-1 underline p-1">
Expand All @@ -13,17 +13,17 @@
</li>
<li class="inline-block col-span-1 underline p-1">
<nuxt-link to="/privacy">
Privacy <span class="hidden md:inline">Policy</span>
Privacy <span class="hidden lg:inline">Policy</span>
</nuxt-link>
</li>
<li class="inline-block col-span-1 underline p-1">
<nuxt-link to="/terms">
Terms <span class="hidden md:inline">of use</span>
Terms <span class="hidden lg:inline">of use</span>
</nuxt-link>
</li>
</ul>
<p class="col-span-1">
&copy; Bandmatch.io
&copy; Bandmatch.io 2022
</p>
</div>
</template>
Expand Down
87 changes: 87 additions & 0 deletions components/Widgets/Admin/HealthLineChart.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<template>
<div v-if="mobileScreen" class="border rounded p-3 shadow bg-primary-grad">
<h1 class="text-3xl">
Screen too small
</h1>
</div>
<div v-else class="w-3/4 p-1 mx-auto block bg-white rounded shadow border">
<canvas id="chart" class="block mx-auto w-3/4 h-auto" width="1920" height="1080" />
</div>
</template>

<script>
import Chart from 'chart.js'
export default {
props: {
data: { type: Object, default () { return {} } }
},
data () {
return {
chart: undefined,
ctx: undefined,
width: 0
}
},
computed: {
mobileScreen () {
return this.width < 767
}
},
watch: {
data: {
deep: true,
immediate: true,
handler () {
this.createChart()
}
}
},
mounted () {
window.addEventListener('resize', this.onResize)
this.onResize()
},
methods: {
onResize () {
this.width = window.innerWidth
},
createLabel (title, data, color, type) {
return { label: title, data, borderColor: color, fill: false, lineTension: 0.1, type }
},
createChart () {
if (this.chart) {
this.chart.destroy()
}
if (document.getElementById('chart') === null) { return }
if (this.data === undefined) { return }
this.ctx = document.getElementById('chart').getContext('2d')
this.chart = new Chart(this.ctx, {
type: 'line',
data: {
labels: this.data.labels,
datasets: [
this.createLabel('Max', this.data.max, '#28546E', 'line'),
this.createLabel('Min', this.data.min, '#442F76', 'line'),
this.createLabel('Avg', this.data.avg, '#AC9B39', 'line'),
this.createLabel('Count', this.data.count, '#AC7839', 'bar')
]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true
}
}]
}
}
})
}
}
}
</script>

<style lang="scss" scoped>
@import '~/assets/scss/styles.scss';
</style>
10 changes: 5 additions & 5 deletions components/Widgets/Admin/UserControlPanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default {
},
methods: {
clearName () {
this.$axios.delete(`/admin/users/${this.user._id}/displayname`)
this.$axios.delete(`/admin/users/name?uid=${this.user._id}`)
.then((res) => {
if (res.data.success) {
this.$store.commit('toasts/create', { title: 'Admin | User', message: `Cleared ${this.user.displayName}'s name` })
Expand All @@ -48,7 +48,7 @@ export default {
})
},
clearDesc () {
this.$axios.delete(`/admin/users/${this.user._id}/description`)
this.$axios.delete(`/admin/users/description?uid=${this.user._id}`)
.then((res) => {
if (res.data.success) {
this.$store.commit('toasts/create', { title: 'Admin | User', message: `Cleared ${this.user.displayName}'s description` })
Expand All @@ -57,7 +57,7 @@ export default {
})
},
deleteUser () {
this.$axios.delete(`/admin/users/${this.user._id}`)
this.$axios.delete(`/admin/users?uid=${this.user._id}`)
.then((res) => {
if (res.data.success) {
this.$store.commit('toasts/create', { title: 'Admin | User', message: `Deleted ${this.user.displayName}` })
Expand All @@ -66,7 +66,7 @@ export default {
})
},
demoteUser () {
this.$axios.patch(`/admin/users/${this.user._id}/demote`)
this.$axios.patch(`/admin/users/demote?uid=${this.user._id}`)
.then((res) => {
if (res.data.success) {
this.$store.commit('toasts/create', { title: 'Admin | User', message: `Demoted ${this.user.displayName}` })
Expand All @@ -75,7 +75,7 @@ export default {
})
},
promoteUser () {
this.$axios.patch(`/admin/users/${this.user._id}/promote`)
this.$axios.patch(`/admin/users/promote?uid=${this.user._id}`)
.then((res) => {
if (res.data.success) {
this.$store.commit('toasts/create', { title: 'Admin | User', message: `Promoted ${this.user.displayName}` })
Expand Down
14 changes: 7 additions & 7 deletions components/Widgets/MarkdownMiniInput.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@
<small v-if="maxlength" class="block mr-3 float-right">{{ markdownInput.length }} / {{ maxlength }}</small>
<div class="shadow rounded">
<div class="rounded-t shadow-b bg-gray-100 border w-full block flex">
<div v-if="!showHTML" class="rounded-tl clickable flex-grow text-white px-0 py-2 md:px-2 h-full inline-block text-center bg-secondary-300 hover:bg-secondary-400 ring-secondary-200 ring-0 hover:ring ring-opacity-50" @click="() => {showHTML=true}">
<div v-if="!showHTML" class="rounded-tl clickable flex-grow md:flex-none text-white px-0 py-2 md:px-2 h-full inline-block text-center bg-secondary-300 hover:bg-secondary-400 ring-secondary-200 ring-0 hover:ring ring-opacity-50" @click="() => {showHTML=true}">
<eye-icon class="inline-block mx-1 md:mx-2" /><span class="hidden md:inline">Preview</span>
</div>
<div v-else class="w-110p clickable flex-grow text-white px-0 py-2 md:px-2 h-full inline-block text-center bg-secondary-300 hover:bg-secondary-400 ring-secondary-200 ring-0 hover:ring ring-opacity-50" @click="() => {showHTML=false}">
<div v-else class="w-110p clickable flex-grow md:flex-none text-white px-0 py-2 md:px-2 h-full inline-block text-center bg-secondary-300 hover:bg-secondary-400 ring-secondary-200 ring-0 hover:ring ring-opacity-50" @click="() => {showHTML=false}">
<edit-icon class="inline-block mx-1 md:mx-2" />Edit
</div>
<div class="clickable flex-grow text-gray-500 hover:bg-gray-500 hover:text-white px-0 py-2 md:px-2 h-full inline-block text-center" @click="addHeading">
<div class="clickable flex-grow md:flex-none text-gray-500 hover:bg-gray-500 hover:text-white px-0 py-2 md:px-2 h-full inline-block text-center" @click="addHeading">
<type-icon class="inline-block mx-1 md:mx-2" />
</div>
<div class="clickable flex-grow text-gray-500 hover:bg-gray-500 hover:text-white px-0 py-2 md:px-2 h-full inline-block text-center" @click="addList">
<div class="clickable flex-grow md:flex-none text-gray-500 hover:bg-gray-500 hover:text-white px-0 py-2 md:px-2 h-full inline-block text-center" @click="addList">
<list-icon class="inline-block mx-1 md:mx-2" />
</div>
<div class="clickable flex-grow text-gray-500 hover:bg-gray-500 hover:text-white px-0 py-2 md:px-2 h-full inline-block text-center" @click="setBold">
<div class="clickable flex-grow md:flex-none text-gray-500 hover:bg-gray-500 hover:text-white px-0 py-2 md:px-2 h-full inline-block text-center" @click="setBold">
<bold-icon class="inline-block mx-1 md:mx-2" />
</div>
<div class="clickable flex-grow text-gray-500 hover:bg-gray-500 hover:text-white px-0 py-2 md:px-2 h-full inline-block text-center" @click="setItalic">
<div class="clickable flex-grow md:flex-none text-gray-500 hover:bg-gray-500 hover:text-white px-0 py-2 md:px-2 h-full inline-block text-center" @click="setItalic">
<italic-icon class="inline-block mx-1 md:mx-2" />
</div>
<div v-if="useSend" class="rounded-tr clickable flex-grow text-white hover:bg-tertiary-500 px-0 py-2 md:px-2 h-full inline-block text-center bg-tertiary-400" @click="onSend">
<div v-if="useSend" class="rounded-tr clickable flex-grow md:flex-none text-white hover:bg-tertiary-500 px-0 py-2 md:px-2 h-full inline-block text-center bg-tertiary-400 ml-auto" @click="onSend" v-on:keyup.enter="onSend">
<span class="hidden md:inline">Send</span><send-icon class="inline-block mx-1 md:mx-2" />
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions layouts/default.vue
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ export default {
}
this.getUnread()
setInterval(this.getUnread, 60 * 1000)
// setInterval(this.getUnread, 60 * 1000)
},
methods: {
getUnread () {
this.$axios.get('/conversations/unread')
this.$axios.get('/msgs/unread')
.then((res) => {
if (res.data.success) {
this.$store.commit('unread/setUnread', res.data.count)
Expand Down
4 changes: 2 additions & 2 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ export default {
strategies: {
local: {
endpoints: {
login: { url: '/auth', method: 'post', propertyName: 'token.token' },
login: { url: '/auth/', method: 'post', propertyName: 'token.token' },
logout: { url: '/auth/logout', method: 'post' },
user: { url: '/users/profile', method: 'get', propertyName: 'user' }
user: { url: '/users/profile/self', method: 'get', propertyName: 'user' }
}
// tokenRequired: true,
// tokenType: 'bearer',
Expand Down
2 changes: 1 addition & 1 deletion pages/account/changepassword.vue
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export default {
e.preventDefault()
this.resetErrors()
this.state = this.states.loading
this.$axios.patch('/auth/password/', this.passwordDetails)
this.$axios.patch('/auth/password', this.passwordDetails)
.then((res) => {
this.state = this.states.default
if (res.data.success) {
Expand Down

0 comments on commit 5d8e827

Please sign in to comment.