better config / install from cli / allow_registration
This commit is contained in:
@@ -42,6 +42,7 @@
|
||||
:mode='event.multidate ? "range" : "single"'
|
||||
:attributes='attributes'
|
||||
v-model='date'
|
||||
:locale='$i18n.locale'
|
||||
:from-page.sync='page'
|
||||
is-inline
|
||||
is-expanded
|
||||
@@ -161,12 +162,12 @@ export default {
|
||||
data.event.place.address = event.place.address || ''
|
||||
data.event.multidate = event.multidate
|
||||
if (event.multidate) {
|
||||
data.date = { start: new Date(event.start_datetime), end: new Date(event.end_datetime) }
|
||||
data.date = { start: new Date(event.start_datetime*1000), end: new Date(event.end_datetime*1000) }
|
||||
} else {
|
||||
data.date = new Date(event.start_datetime)
|
||||
data.date = new Date(event.start_datetime*1000)
|
||||
}
|
||||
data.time.start = moment(event.start_datetime).format('HH:mm')
|
||||
data.time.end = moment(event.end_datetime).format('HH:mm')
|
||||
data.time.start = moment(event.start_datetime*1000).format('HH:mm')
|
||||
data.time.end = moment(event.end_datetime*1000).format('HH:mm')
|
||||
data.event.title = event.title
|
||||
data.event.description = event.description.replace(/(<([^>]+)>)/ig, '')
|
||||
data.event.id = event.id
|
||||
@@ -193,41 +194,33 @@ export default {
|
||||
const date_end = moment(this.date.end)
|
||||
return this.events.filter(e =>
|
||||
!e.multidate ?
|
||||
date_start.isSame(e.start_datetime, 'day') ||
|
||||
date_start.isBefore(e.start_datime) && date_end.isAfter(e.start_datetime) :
|
||||
date_start.isSame(e.start_datetime, 'day') || date_start.isSame(e.end_datetime) ||
|
||||
date_start.isAfter(e.start_datetime) && date_start.isBefore(e.end_datetime))
|
||||
date_start.isSame(e.start_datetime*1000, 'day') ||
|
||||
date_start.isBefore(e.start_datime*1000) && date_end.isAfter(e.start_datetime*1000) :
|
||||
date_start.isSame(e.start_datetime*1000, 'day') || date_start.isSame(e.end_datetime*1000) ||
|
||||
date_start.isAfter(e.start_datetime*1000) && date_start.isBefore(e.end_datetime*1000))
|
||||
} else {
|
||||
const date = moment(this.date)
|
||||
return this.events.filter(e =>
|
||||
!e.multidate ?
|
||||
date.isSame(moment(e.start_datetime), 'day') :
|
||||
moment(e.start_datetime).isSame(date, 'day') ||
|
||||
moment(e.start_datetime).isBefore(date) && moment(e.end_datetime).isAfter(date)
|
||||
date.isSame(moment(e.start_datetime*1000), 'day') :
|
||||
moment(e.start_datetime*1000).isSame(date, 'day') ||
|
||||
moment(e.start_datetime*1000).isBefore(date) && moment(e.end_datetime*1000).isAfter(date)
|
||||
)
|
||||
}
|
||||
},
|
||||
...mapGetters(['filteredEvents']),
|
||||
attributes () {
|
||||
return [
|
||||
{ key: 'today', dates: new Date(),
|
||||
highlight: { color: 'red' },
|
||||
},
|
||||
{
|
||||
key: 'event',
|
||||
dates: this.filteredEvents
|
||||
.filter(e => !e.multidate)
|
||||
.map(e => e.start_datetime ),
|
||||
dot: { }
|
||||
},
|
||||
{
|
||||
key: 'multidays',
|
||||
dates: this.filteredEvents
|
||||
.filter(e => e.multidate)
|
||||
.map( e => ({ start: e.start_datetime, end: e.end_datetime })),
|
||||
highlight: { color: 'green' }
|
||||
}
|
||||
]
|
||||
let attributes = []
|
||||
attributes.push ({ key: 'today', dates: new Date(), highlight: { color: 'yellow' }})
|
||||
|
||||
attributes = attributes.concat(this.filteredEvents
|
||||
.filter(e => !e.multidate)
|
||||
.map(e => ({ key: e.id, dot: {}, dates: new Date(e.start_datetime*1000)})))
|
||||
|
||||
attributes = attributes.concat(this.filteredEvents
|
||||
.filter(e => e.multidate)
|
||||
.map( e => ({ key: e.id, highlight: {}, dates: {
|
||||
start: new Date(e.start_datetime*1000), end: new Date(e.end_datetime*1000) }})))
|
||||
},
|
||||
disableAddress () {
|
||||
return this.places_name.find(p => p.name === this.event.place.name)
|
||||
@@ -279,7 +272,7 @@ export default {
|
||||
let start_datetime, end_datetime
|
||||
const [ start_hour, start_minute ] = this.time.start.split(':')
|
||||
if (!this.time.end) {
|
||||
this.time.end = this.time.start
|
||||
this.time.end = (Number(start_hour)+2) + ':' + start_minute
|
||||
}
|
||||
const [ end_hour, end_minute ] = this.time.end.split(':')
|
||||
if (this.event.multidate) {
|
||||
@@ -301,8 +294,8 @@ export default {
|
||||
formData.append('place_address', this.event.place.address)
|
||||
formData.append('description', this.event.description)
|
||||
formData.append('multidate', this.event.multidate)
|
||||
formData.append('start_datetime', start_datetime)
|
||||
formData.append('end_datetime', end_datetime)
|
||||
formData.append('start_datetime', start_datetime.unix())
|
||||
formData.append('end_datetime', end_datetime.unix())
|
||||
if (this.edit) {
|
||||
formData.append('id', this.event.id)
|
||||
}
|
||||
|
||||
@@ -80,51 +80,27 @@
|
||||
|
||||
el-pagination(:page-size='perPage' :currentPage.sync='eventPage' :total='events.length')
|
||||
|
||||
//- TAGS
|
||||
//- el-tab-pane.pt-1
|
||||
//- template(slot='label')
|
||||
//- v-icon(name='tags')
|
||||
//- span {{$t('common.tags')}}
|
||||
//- p {{$t('admin.tag_description')}}
|
||||
//- el-tag(v-if='tag.tag' :color='tag.color' size='mini') {{tag.tag}}
|
||||
//- el-form(:inline='true' label-width='120px')
|
||||
//- el-form-item(:label="$t('common.color')")
|
||||
//- el-color-picker(v-model='tag.color' @change='updateColor')
|
||||
//- el-table(:data='paginatedTags' striped small hover
|
||||
//- highlight-current-row @current-change="tagSelected")
|
||||
//- el-table-column(:label="$t('common.tag')")
|
||||
//- template(slot-scope='data')
|
||||
//- el-tag(:color='data.row.color' size='mini') {{data.row.tag}}
|
||||
//- el-pagination(:page-size='perPage' :currentPage.sync='tagPage' :total='tags.length')
|
||||
|
||||
//- SETTINGS
|
||||
el-tab-pane.pt-1
|
||||
template(slot='label')
|
||||
v-icon(name='cog')
|
||||
span {{$t('common.settings')}}
|
||||
|
||||
//- el-form(inline @submit.prevent.stop='save_settings' label-width='140px')
|
||||
//- p {{$t('settings.name_description')}}
|
||||
//- el-form-item(:label="$t('settings.name')")
|
||||
//- el-input(v-model="settings.title")
|
||||
//- el-form-item(:label="$t('settings.description')")
|
||||
//- el-input(v-model="settings.description")
|
||||
//- el-button(slot='append' @click='associate' :disabled='!mastodon_instance.length') {{$t('common.associate')}}
|
||||
|
||||
el-form(inline @submit.native.prevent='associate_mastondon_instance' label-width='140px')
|
||||
p {{$t('admin.mastodon_description')}}
|
||||
el-form-item {{$t('admin.mastodon_instance')}}
|
||||
el-input(v-model="settings.mastodon_instance")
|
||||
el-button(slot='append' native-type='submit' type='success' :disabled='!settings.mastodon_instance') {{$t('common.associate')}}
|
||||
|
||||
el-form-item(:label='$t("admin.mastodon_instance")')
|
||||
el-input(v-model="mastodon_instance")
|
||||
el-form-item
|
||||
el-button(native-type='submit' type='success' :disabled='!mastodon_instance') {{$t('common.associate')}}
|
||||
hr
|
||||
p {{$t('admin.allow_registration_description')}}
|
||||
el-form-item {{$t('admin.allow_registration')}}
|
||||
el-switch(v-model='settings.allow_registration')
|
||||
el-form-item(:label="allow_registration?$t('common.disable'):$t('common.enable')")
|
||||
el-switch(v-model='allow_registration')
|
||||
|
||||
|
||||
</template>
|
||||
<script>
|
||||
import { mapState } from 'vuex'
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import { Message, MessageBox } from 'element-ui'
|
||||
|
||||
export default {
|
||||
@@ -146,10 +122,6 @@ export default {
|
||||
tag: {name: '', color: ''},
|
||||
events: [],
|
||||
loading: false,
|
||||
settings: {
|
||||
allow_registration: true,
|
||||
mastodon_instance: ''
|
||||
},
|
||||
new_user: {
|
||||
email: '',
|
||||
password: '',
|
||||
@@ -169,17 +141,24 @@ export default {
|
||||
},
|
||||
async asyncData ({ $axios, params, store }) {
|
||||
try {
|
||||
console.error(store)
|
||||
const users = await $axios.$get('/users')
|
||||
const events = await $axios.$get('/event/unconfirmed')
|
||||
const settings = await $axios.$get('/settings')
|
||||
|
||||
return { users, events, settings}
|
||||
return { users, events, mastodon_instance: store.state.settings.mastodon_instance }
|
||||
} catch ( e ) {
|
||||
console.error(e)
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['tags', 'places']),
|
||||
...mapState(['tags', 'places', 'settings']),
|
||||
allow_registration: {
|
||||
get () {
|
||||
return this.settings.allow_registration
|
||||
},
|
||||
set (value) {
|
||||
this.setSetting({ key: 'allow_registration', value })
|
||||
}
|
||||
},
|
||||
paginatedEvents () {
|
||||
return this.events.slice((this.eventPage-1) * this.perPage,
|
||||
this.eventPage * this.perPage)
|
||||
@@ -198,6 +177,7 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapActions(['setSetting']),
|
||||
placeSelected (items) {
|
||||
if (items.length === 0 ) {
|
||||
this.place.name = this.place.address = ''
|
||||
@@ -217,24 +197,21 @@ export default {
|
||||
async toggle(user) {
|
||||
user.is_active = !user.is_active
|
||||
this.$axios.$put('/user', user)
|
||||
// const newuser = await api.updateUser(user)
|
||||
},
|
||||
async toggleAdmin(user) {
|
||||
user.is_admin = !user.is_admin
|
||||
this.$axios.$put('/user', user)
|
||||
// const newuser = await api.updateUser(user)
|
||||
},
|
||||
preview (id) {
|
||||
this.$router.push(`/event/${id}`)
|
||||
},
|
||||
async associate_mastondon_instance () {
|
||||
if (!this.settings.mastodon_instance) return false
|
||||
if (!this.mastodon_instance) return false
|
||||
|
||||
const url = await this.$axios.$post('/settings/getauthurl', {instance: this.settings.mastodon_instance})
|
||||
const url = await this.$axios.$post('/settings/getauthurl', { instance: this.mastodon_instance })
|
||||
setTimeout( () => window.location.href=url, 100);
|
||||
},
|
||||
async delete_user (user) {
|
||||
console.error('dentro delete user', user)
|
||||
MessageBox.confirm(this.$t('admin.delete_user_confirm'),
|
||||
this.$t('common.confirm'), {
|
||||
confirmButtonText: this.$t('common.ok'),
|
||||
@@ -257,7 +234,7 @@ export default {
|
||||
this.new_user = { email: '', password: '', is_admin: false }
|
||||
Message({
|
||||
type: 'success',
|
||||
message: this.$t('user.create_ok')
|
||||
message: this.$t('admin.user_create_ok')
|
||||
})
|
||||
} catch (e) {
|
||||
Message({
|
||||
|
||||
@@ -108,7 +108,7 @@ export default {
|
||||
params.push(`tags=${this.filters.tags}`)
|
||||
}
|
||||
|
||||
return `<iframe src="${process.env.baseurl}/embed/list?${params.join('&')}"></iframe>`
|
||||
return `<iframe src="${this.$axios.defaults.baseURL}/embed/list?${params.join('&')}"></iframe>`
|
||||
},
|
||||
link () {
|
||||
const tags = this.filters.tags.join(',')
|
||||
@@ -124,8 +124,8 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
return `${process.env.baseurl}/api/export/${this.type}${query}`
|
||||
},
|
||||
return `${this.$axios.defaults.baseURL}/api/export/${this.type}${query}`
|
||||
},
|
||||
showLink () {
|
||||
return (['feed', 'ics'].indexOf(this.type)>-1)
|
||||
},
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
nuxt-link.float-right(to='/')
|
||||
v-icon(name='times' color='red')
|
||||
h5 {{$t('common.login')}}
|
||||
|
||||
el-form(v-loading='loading' method='POST' action='/api/auth/login')
|
||||
p(v-html="$t('login.description')")
|
||||
|
||||
@@ -20,14 +19,14 @@
|
||||
el-button.mr-1(plain type="success" native-type='submit'
|
||||
:disabled='disabled' @click='submit') {{$t('common.login')}}
|
||||
|
||||
nuxt-link(to='/register')
|
||||
nuxt-link(to='/register' v-if='settings.allow_registration')
|
||||
el-button.mt-1(plain type="primary") {{$t('login.not_registered')}}
|
||||
|
||||
a.float-right(href='#' @click='forgot') {{$t('login.forgot_password')}}
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex'
|
||||
import { mapActions, mapState } from 'vuex'
|
||||
import { Message } from 'element-ui'
|
||||
import get from 'lodash/get'
|
||||
|
||||
@@ -41,6 +40,7 @@ export default {
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
...mapState(['settings']),
|
||||
disabled () {
|
||||
if (process.server) return false
|
||||
return !this.email || !this.password
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { mapActions } from 'vuex'
|
||||
import { mapActions, mapState } from 'vuex'
|
||||
import { Message } from 'element-ui'
|
||||
import get from 'lodash/get'
|
||||
|
||||
@@ -34,7 +34,11 @@ export default {
|
||||
user: { }
|
||||
}
|
||||
},
|
||||
validate ({store}) {
|
||||
return store.state.settings.allow_registration
|
||||
},
|
||||
computed: {
|
||||
...mapState(['settings']),
|
||||
disabled () {
|
||||
if (process.server) return false
|
||||
return !this.user.password || !this.user.email || !this.user.description
|
||||
|
||||
@@ -5,14 +5,18 @@
|
||||
v-icon(name='times' color='red')
|
||||
h5 {{$t('common.settings')}}
|
||||
|
||||
el-form(action='/api/user' method='PUT' @submit.native.prevent='change')
|
||||
el-form(action='/api/user' method='PUT' @submit.native.prevent='change_password')
|
||||
el-form-item {{$t('settings.change_password')}}
|
||||
el-input(v-model='password' type='password')
|
||||
el-button(type='success' native-type='submit') {{$t('common.send')}}
|
||||
|
||||
el-divider {{$t('settings.danger_section')}}
|
||||
p {{$t('settings.remove_account')}}
|
||||
el-button(type='danger' @click='remove_account') {{$t('common.remove')}}
|
||||
</template>
|
||||
<script>
|
||||
import { mapState, mapActions } from 'vuex'
|
||||
import { Message } from 'element-ui'
|
||||
import { Message, MessageBox } from 'element-ui'
|
||||
|
||||
export default {
|
||||
data () {
|
||||
@@ -20,13 +24,13 @@ export default {
|
||||
password: '',
|
||||
}
|
||||
},
|
||||
// async asyncData ({ $axios, params }) {
|
||||
// const user = await $axios.$get('/auth/user')
|
||||
// user.mastodon_auth = ''
|
||||
// return { user }
|
||||
// },
|
||||
async asyncData ({ $axios, params }) {
|
||||
const user = await $axios.$get('/auth/user')
|
||||
user.mastodon_auth = ''
|
||||
return { user }
|
||||
},
|
||||
methods: {
|
||||
async change () {
|
||||
async change_password () {
|
||||
if (!this.password) return
|
||||
const user_data = { id : this.$auth.user.id, password: this.password }
|
||||
try {
|
||||
@@ -37,6 +41,15 @@ export default {
|
||||
console.log(e)
|
||||
}
|
||||
},
|
||||
async remove_account () {
|
||||
MessageBox.confirm(this.$t('settings.remove_account_confirm'), this.$t('common.confirm'), {
|
||||
confirmButtonText: this.$t('common.ok'),
|
||||
cancelButtonText: this.$t('common.cancel'),
|
||||
type: 'error'
|
||||
}).then( () => {
|
||||
this.$axios.$delete('/user')
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user