diff --git a/pages/Register.vue b/pages/Register.vue
index c95ef06f..2032b1ec 100644
--- a/pages/Register.vue
+++ b/pages/Register.vue
@@ -31,11 +31,8 @@ export default {
user: {}
}
},
- head () {
- return {
- title: this.settings.title + ' - ' + this.$t('common.register')
- }
- },
+ // https://nuxtjs.org/api/pages-validate/
+ // If the validate method does not return true, Nuxt.js will automatically load the 404 error page.
validate ({ store }) {
return store.state.settings.allow_registration
},
@@ -71,6 +68,11 @@ export default {
}
this.loading = false
}
+ },
+ head () {
+ return {
+ title: this.settings.title + ' - ' + this.$t('common.register')
+ }
}
}
diff --git a/pages/settings.vue b/pages/settings.vue
index 3ef01f0a..c8457fa6 100644
--- a/pages/settings.vue
+++ b/pages/settings.vue
@@ -1,41 +1,38 @@
el-main
- h4 {{$t('common.settings')}}
- el-divider {{$auth.user.email}}
- el-form(action='/api/user' method='PUT' @submit.native.prevent='update_settings' inline label-width='200px')
-
- el-form-item(:label="$t('settings.change_password')")
- el-input(v-model='password' type='password')
-
- el-button(type='success' native-type='submit') {{$t('common.save')}}
+ p {{$auth.user.email}}
+ //- el-form(action='/api/user' method='PUT' @submit.native.prevent='update_settings' inline label-width='200px')
+ //- el-form-item(:label="$t('settings.change_password')")
+ //- el-input(v-model='password' type='password')
+ //- el-button(type='success' native-type='submit') {{$t('common.save')}}
el-divider {{$t('settings.danger_section')}}
p {{$t('settings.remove_account')}}
el-button(type='danger' @click='remove_account') {{$t('common.remove')}}
diff --git a/plugins/element-ui.js b/plugins/element-ui.js
index 182e6815..6352f85a 100644
--- a/plugins/element-ui.js
+++ b/plugins/element-ui.js
@@ -2,9 +2,10 @@ import Vue from 'vue'
import { Button, Select, Tag, Option, Table, FormItem, Card, Row, Col, Upload, Checkbox, RadioButton, RadioGroup,
Form, Tabs, TabPane, Switch, Input, Loading, TimeSelect, Badge, ButtonGroup, Divider, Step, Steps, Radio, Main,
TableColumn, ColorPicker, Pagination, Popover, Tooltip, Dialog, Image, Backtop, Collapse, CollapseItem, Link,
- Dropdown, DropdownMenu, DropdownItem, Submenu, PageHeader, Header, Icon, Alert,
+ Dropdown, DropdownMenu, DropdownItem, Submenu, PageHeader, Header, Icon, Alert, Autocomplete,
Container, Footer, Timeline, TimelineItem, Menu, MenuItem } from 'element-ui'
import locale from 'element-ui/lib/locale'
+// import '../assets/style.scss'
const locales = {
it: require('element-ui/lib/locale/lang/it'),
@@ -16,6 +17,7 @@ const locales = {
export default ({ app, store }) => {
locale.use(locales[store.state.locale])
Vue.use(Button)
+ Vue.use(Autocomplete)
Vue.use(Alert)
Vue.use(Icon)
Vue.use(Dropdown)
diff --git a/plugins/vue-awesome.js b/plugins/vue-awesome.js
index 897fced8..4c19bab9 100644
--- a/plugins/vue-awesome.js
+++ b/plugins/vue-awesome.js
@@ -33,6 +33,19 @@ import 'vue-awesome/icons/calendar-week'
import 'vue-awesome/icons/calendar-alt'
import 'vue-awesome/icons/network-wired'
import 'vue-awesome/icons/rss'
+import 'vue-awesome/icons/bold'
+import 'vue-awesome/icons/italic'
+import 'vue-awesome/icons/strikethrough'
+import 'vue-awesome/icons/quote-right'
+import 'vue-awesome/icons/underline'
+import 'vue-awesome/icons/code'
+import 'vue-awesome/icons/paragraph'
+import 'vue-awesome/icons/list-ul'
+import 'vue-awesome/icons/list-ol'
+import 'vue-awesome/icons/heading'
+import 'vue-awesome/icons/link'
+import 'vue-awesome/icons/hands-helping'
+import 'vue-awesome/icons/question'
import Icon from 'vue-awesome/components/Icon'
diff --git a/server/api/controller/settings.js b/server/api/controller/settings.js
index 31a24d9a..1bfe546a 100644
--- a/server/api/controller/settings.js
+++ b/server/api/controller/settings.js
@@ -100,10 +100,10 @@ const settingsController = {
}
},
- getUserLocale (req, res) {
- // load user locale specified in configuration
- res.json(settingsController.user_locale)
- },
+ // getUserLocale (req, res) {
+ // // load user locale specified in configuration
+ // res.json(settingsController.user_locale)
+ // },
async setRequest (req, res) {
const { key, value, is_secret } = req.body
@@ -111,6 +111,12 @@ const settingsController = {
if (ret) { res.sendStatus(200) } else { res.sendStatus(400) }
},
+ async setFavicon (req, res) {
+ if (!req.file) return res.status(400).send('Mmmmm sould not be here!')
+ await settingsController.set('favicon', path.join(req.file.destination, req.file.filename))
+ res.sendStatus(200)
+ },
+
getAllRequest (req, res) {
// get public settings and public configuration
const settings = {
diff --git a/server/api/index.js b/server/api/index.js
index 55e66ca7..4536b87b 100644
--- a/server/api/index.js
+++ b/server/api/index.js
@@ -68,10 +68,10 @@ api.delete('/event/notification/:code', eventController.delNotification)
api.get('/settings', settingsController.getAllRequest)
api.post('/settings', isAdmin, settingsController.setRequest)
+api.post('/settings/favicon', isAdmin, multer({ dest: 'thumb/' }).single('favicon'), settingsController.setFavicon)
+// api.get('/settings/user_locale', settingsController.getUserLocale)
-api.get('/settings/user_locale', settingsController.getUserLocale)
-
-// confirm event
+// confirm eventtags
api.get('/event/confirm/:event_id', isAuth, eventController.confirm)
api.get('/event/unconfirm/:event_id', isAuth, eventController.unconfirm)
@@ -83,6 +83,7 @@ api.get('/export/:type', cors, exportController.export)
// get events in this range
api.get('/event/:month/:year', cors, eventController.getAll)
+api.get('/event', cors, eventController.select)
api.get('/instances', isAdmin, instanceController.getAll)
api.get('/instances/:instance_domain', isAdmin, instanceController.get)
diff --git a/server/firstrun.js b/server/firstrun.js
index e3a6284c..cbdcee27 100644
--- a/server/firstrun.js
+++ b/server/firstrun.js
@@ -30,7 +30,7 @@ module.exports = {
const db = require('./api/models')
const users = await db.user.findAll()
if (users.length) {
- consola.warn(` ⚠ Non empty db! Please move your current db elsewhere than retry.`)
+ consola.warn(' ⚠ Non empty db! Please move your current db elsewhere than retry.')
return false
}
@@ -51,7 +51,7 @@ module.exports = {
await db.notification.create({ action: 'Update', type: 'ap', filters: { is_visible: true } })
await db.notification.create({ action: 'Delete', type: 'ap', filters: { is_visible: true } })
- // send anon email to administrator
+ // send anon event to administrator
await db.notification.create({ action: 'Create', type: 'admin_email', filters: { is_visible: false } })
// TODO
diff --git a/server/helpers.js b/server/helpers.js
index 96c5160b..235326c8 100644
--- a/server/helpers.js
+++ b/server/helpers.js
@@ -13,7 +13,7 @@ const jwt = expressJwt({
if (req.headers.authorization && req.headers.authorization.split(' ')[0] === 'Bearer') {
return req.headers.authorization.split(' ')[1]
} else if (req.cookies && req.cookies['auth._token.local']) {
- const [ prefix, token ] = req.cookies['auth._token.local'].split(' ')
+ const [prefix, token] = req.cookies['auth._token.local'].split(' ')
if (prefix === 'Bearer') { return token }
}
return null
@@ -28,8 +28,8 @@ module.exports = {
req.secretSettings = settingsController.secretSettings
req.settings.baseurl = config.baseurl
- req.settings.title = config.title
- req.settings.description = config.description
+ req.settings.title = req.settings.title || config.title
+ req.settings.description = req.settings.description || config.description
req.settings.version = pkg.version
// set locale and user locale
@@ -39,6 +39,7 @@ module.exports = {
req.settings.locale = acceptLanguage.get(acceptedLanguages)
req.settings.user_locale = settingsController.user_locale[req.settings.locale]
moment.locale(req.settings.locale)
+ moment.tz.setDefault(req.settings.instance_timezone)
// TODO: oauth
// auth
diff --git a/server/routes.js b/server/routes.js
index 8403f16b..d3d7b60c 100644
--- a/server/routes.js
+++ b/server/routes.js
@@ -22,13 +22,16 @@ app.use((req, res, next) => {
app.use(spamFilter)
// serve favicon and static content
-app.use('/favicon.ico', express.static(path.resolve(config.favicon || './assets/favicon.ico')))
app.use('/logo.png', express.static('./static/gancio.png'))
app.use('/media/', express.static(config.upload_path))
// initialize instance settings / authentication / locale
app.use(cookieParser())
app.use(helpers.initMiddleware)
+app.use('/favicon.ico', (req, res, next) => {
+ const favicon_path = req.settings.favicon || config.favicon || './assets/favicon.ico'
+ return express.static(path.resolve(favicon_path))(req, res, next)
+})
// rss/ics/atom feed
app.get('/feed/:type', cors(), exportController.export)
diff --git a/store/index.js b/store/index.js
index a8a50d2b..b83c542e 100644
--- a/store/index.js
+++ b/store/index.js
@@ -1,4 +1,4 @@
-import moment from 'dayjs'
+import moment from 'moment-timezone'
import intersection from 'lodash/intersection'
import find from 'lodash/find'
@@ -44,7 +44,9 @@ export const getters = {
if (!state.filters.show_recurrent_events && e.recurrent) { return false }
if (search_for_places) {
- if (find(state.filters.places, p => p === e.place.id)) { return true }
+ if (find(state.filters.places, p => p.id === e.place.id)) {
+ return true
+ }
}
if (search_for_tags) {
@@ -70,11 +72,11 @@ export const getters = {
if (!state.filters.show_recurrent_events && e.recurrent) { return false }
if (!match && search_for_places) {
- if (find(state.filters.places, p => p === e.place.id)) { return true }
+ if (find(state.filters.places, p => p.id === e.place.id)) { return true }
}
if (search_for_tags) {
- const common_tags = intersection(e.tags, state.filters.tags)
+ const common_tags = intersection(e.tags, state.filters.tags.map(t => t.tag))
if (common_tags.length > 0) { return true }
}
@@ -147,22 +149,33 @@ export const mutations = {
}
export const actions = {
- // this method is called server side only for each request
- // we use it to get configuration from db, setting locale, etc...
- nuxtServerInit ({ commit }, { app, store, req }) {
- if (req.user) {
- this.$auth.setUser(req.user)
- }
+ // this method is called server side only for each request for nuxt
+ // we use it to get configuration from db, set locale, etc...
+ async nuxtServerInit ({ commit }, { app, store, req }) {
+ if (req.user) { this.$auth.setUser(req.user) }
+
const settings = req.settings
commit('setSettings', settings)
+
+ const start_datetime = moment().startOf('month').startOf('week').unix()
+ const events = await this.$axios.$get(`/event?start=${start_datetime}`)
+ commit('setEvents', events)
+
+ const { tags, places } = await this.$axios.$get('/event/meta')
+ store.commit('update', { tags, places })
+
// apply settings
commit('showRecurrentEvents', settings.allow_recurrent_event && settings.recurrent_event_visible)
},
- async updateEvents ({ commit }, page) {
+ async updateEvents ({ commit, state }, page) {
const month = moment().month()
const year = moment().year()
commit('setPast', page.year < year || (page.year === year && page.month <= month))
- const events = await this.$axios.$get(`/event/${page.month - 1}/${page.year}`)
+ // const events = await this.$axios.$get(`/event/${page.month - 1}/${page.year}`)
+ const start_datetime = moment().year(page.year).month(page.month - 1).unix()
+ const query = `start=${start_datetime}`
+
+ const events = await this.$axios.$get(`/event?${query}`)
commit('setEvents', events)
},
async updateMeta ({ commit }) {