2022-11-24 17:29:48 +01:00
|
|
|
import dayjs from 'dayjs'
|
|
|
|
|
2019-04-03 00:25:12 +02:00
|
|
|
export const state = () => ({
|
2019-07-13 01:02:11 +02:00
|
|
|
settings: {
|
2019-10-20 14:22:55 +02:00
|
|
|
instance_timezone: 'Europe/Rome',
|
2019-12-04 00:50:15 +01:00
|
|
|
instance_name: '',
|
2019-07-13 01:02:11 +02:00
|
|
|
allow_registration: true,
|
|
|
|
allow_anon_event: true,
|
2022-12-05 23:03:10 +01:00
|
|
|
allow_multidate_event: true,
|
2019-07-13 01:02:11 +02:00
|
|
|
allow_recurrent_event: true,
|
|
|
|
recurrent_event_visible: false,
|
2022-09-08 20:37:20 +02:00
|
|
|
allow_geolocation: false,
|
2022-12-06 00:03:53 +01:00
|
|
|
geocoding_provider_type: '',
|
2022-12-02 11:25:43 +01:00
|
|
|
geocoding_provider: '',
|
|
|
|
geocoding_countrycodes: [],
|
|
|
|
tilelayer_provider: '',
|
|
|
|
tilelayer_provider_attribution: '',
|
2019-10-22 01:01:41 +02:00
|
|
|
enable_federation: false,
|
2019-12-04 00:50:15 +01:00
|
|
|
enable_resources: false,
|
2020-03-18 10:11:24 +01:00
|
|
|
hide_boosts: true,
|
|
|
|
enable_trusted_instances: true,
|
2021-11-09 12:47:26 +01:00
|
|
|
trusted_instances: [],
|
2022-11-21 00:52:02 +01:00
|
|
|
trusted_instances_label: '',
|
2021-11-09 12:47:26 +01:00
|
|
|
footerLinks: []
|
2019-07-13 01:02:11 +02:00
|
|
|
},
|
2023-01-09 17:02:15 +01:00
|
|
|
filter: {
|
|
|
|
query: '',
|
|
|
|
show_recurrent: null,
|
2023-01-12 11:14:34 +01:00
|
|
|
show_multidate: null,
|
2023-01-09 17:02:15 +01:00
|
|
|
},
|
2022-11-24 17:29:48 +01:00
|
|
|
announcements: [],
|
|
|
|
events: []
|
2019-04-03 00:25:12 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
export const mutations = {
|
2019-09-11 19:12:24 +02:00
|
|
|
setSettings (state, settings) {
|
2019-06-06 23:54:32 +02:00
|
|
|
state.settings = settings
|
|
|
|
},
|
2019-09-11 19:12:24 +02:00
|
|
|
setSetting (state, setting) {
|
2019-06-21 23:52:18 +02:00
|
|
|
state.settings[setting.key] = setting.value
|
|
|
|
},
|
2020-02-16 21:03:50 +01:00
|
|
|
setAnnouncements (state, announcements) {
|
|
|
|
state.announcements = announcements
|
2022-11-24 17:29:48 +01:00
|
|
|
},
|
|
|
|
setEvents (state, events) {
|
2023-01-12 11:14:34 +01:00
|
|
|
state.events = Object.freeze(events)
|
2023-01-09 17:02:15 +01:00
|
|
|
},
|
|
|
|
setFilter (state, { type, value }) {
|
|
|
|
state.filter[type] = value
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export const actions = {
|
2020-01-15 23:51:09 +01:00
|
|
|
// this method is called server side only for each request for nuxt
|
|
|
|
// we use it to get configuration from db, set locale, etc...
|
2022-05-31 15:26:31 +02:00
|
|
|
nuxtServerInit ({ commit }, { _req, res }) {
|
2023-01-12 14:40:14 +01:00
|
|
|
if (res.locals && res.locals.settings) {
|
|
|
|
commit('setSettings', res.locals.settings)
|
|
|
|
}
|
2023-01-09 17:02:15 +01:00
|
|
|
commit('setFilter', { type: 'show_recurrent',
|
|
|
|
value: res.locals.settings.allow_recurrent_event && res.locals.settings.recurrent_event_visible })
|
|
|
|
|
2022-02-26 21:27:40 +01:00
|
|
|
if (res.locals.status === 'READY') {
|
|
|
|
commit('setAnnouncements', res.locals.announcements)
|
2021-09-28 12:55:54 +02:00
|
|
|
}
|
2019-04-26 23:14:43 +02:00
|
|
|
},
|
2020-02-16 21:03:50 +01:00
|
|
|
async updateAnnouncements ({ commit }) {
|
|
|
|
const announcements = await this.$axios.$get('/announcements')
|
|
|
|
commit('setAnnouncements', announcements)
|
|
|
|
},
|
|
|
|
setAnnouncements ({ commit }, announcements) {
|
|
|
|
commit('setAnnouncements', announcements)
|
|
|
|
},
|
2019-09-11 19:12:24 +02:00
|
|
|
async setSetting ({ commit }, setting) {
|
|
|
|
await this.$axios.$post('/settings', setting)
|
2019-06-21 23:52:18 +02:00
|
|
|
commit('setSetting', setting)
|
2022-11-24 17:29:48 +01:00
|
|
|
},
|
2023-01-09 17:02:15 +01:00
|
|
|
setFilter ({ commit }, [type, value]) {
|
|
|
|
commit('setFilter', { type, value })
|
|
|
|
},
|
2022-11-25 09:47:57 +01:00
|
|
|
async getEvents ({ commit, state }, params = {}) {
|
2022-11-24 17:29:48 +01:00
|
|
|
const events = await this.$api.getEvents({
|
|
|
|
start: params.start || dayjs().startOf('month').unix(),
|
|
|
|
end: params.end || null,
|
2023-01-09 17:02:15 +01:00
|
|
|
show_recurrent: state.filter.show_recurrent,
|
|
|
|
show_multidate: state.filter.show_multidate
|
2022-11-24 17:29:48 +01:00
|
|
|
})
|
|
|
|
commit('setEvents', events)
|
2019-09-11 19:12:24 +02:00
|
|
|
}
|
2019-04-03 00:25:12 +02:00
|
|
|
}
|