mirror of
https://framagit.org/les/gancio.git
synced 2025-01-31 16:42:22 +01:00
cleaning recurrent
This commit is contained in:
parent
f43a77d8a7
commit
ca1c2f3079
5 changed files with 67 additions and 118 deletions
|
@ -17,18 +17,28 @@ apt-get install -y nodejs
|
||||||
```bash
|
```bash
|
||||||
npm install --global gancio
|
npm install --global gancio
|
||||||
```
|
```
|
||||||
|
3. Create database (optional)
|
||||||
3. Setup
|
```sql
|
||||||
```bash
|
apt install postgresql
|
||||||
gancio setup
|
sudo -u postgres psql
|
||||||
|
postgres=# create database gancio;
|
||||||
|
postgres=# create user gancio with encrypted password 'gancio';
|
||||||
|
postgres=# grant all privileges on database gancio to gancio;
|
||||||
```
|
```
|
||||||
|
|
||||||
4. Start
|
4. Create a new user
|
||||||
```bash
|
```bash
|
||||||
|
adduser gancio
|
||||||
|
su gancio
|
||||||
|
```
|
||||||
|
|
||||||
|
5. Setup & test
|
||||||
|
```bash
|
||||||
|
gancio --help
|
||||||
|
gancio setup
|
||||||
gancio start
|
gancio start
|
||||||
```
|
```
|
||||||
5. Enjoy :tada:
|
|
||||||
|
6. Enjoy :tada:
|
||||||
Point your web browser to [http://localhost:3000](http://localhost:3000)
|
Point your web browser to [http://localhost:3000](http://localhost:3000)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,8 @@ const it = {
|
||||||
allow_registration_description : 'Vuoi abilitare la registrazione?',
|
allow_registration_description : 'Vuoi abilitare la registrazione?',
|
||||||
allow_anon_event: 'Si possono inserire eventi anonimi (previa conferma)?',
|
allow_anon_event: 'Si possono inserire eventi anonimi (previa conferma)?',
|
||||||
allow_comments: 'Abilita commenti',
|
allow_comments: 'Abilita commenti',
|
||||||
allow_recurrent_event: 'Abilita eventi ricorrenti'
|
allow_recurrent_event: 'Abilita eventi fissi',
|
||||||
|
recurrent_event_visible: 'Appuntamenti fissi visibili di default'
|
||||||
},
|
},
|
||||||
|
|
||||||
auth: {
|
auth: {
|
||||||
|
|
|
@ -59,11 +59,7 @@
|
||||||
el-radio-button(label="recurrent") <v-icon name='calendar-alt'/> {{$t('event.recurrent')}}
|
el-radio-button(label="recurrent") <v-icon name='calendar-alt'/> {{$t('event.recurrent')}}
|
||||||
br
|
br
|
||||||
span {{$t(`event.${event.type}_description`)}}
|
span {{$t(`event.${event.type}_description`)}}
|
||||||
<<<<<<< HEAD
|
|
||||||
el-select.ml-2(v-if='event.type==="recurrent"' v-model='event.recurrent.frequency' placeholder='Frequenza')
|
el-select.ml-2(v-if='event.type==="recurrent"' v-model='event.recurrent.frequency' placeholder='Frequenza')
|
||||||
=======
|
|
||||||
el-select.ml-2(v-if='event.type==="recurrent"' v-model='event.rec_frequency' placeholder='Frequenza')
|
|
||||||
>>>>>>> doc
|
|
||||||
el-option(label='Tutti i giorni' value='1d' key='1d')
|
el-option(label='Tutti i giorni' value='1d' key='1d')
|
||||||
el-option(label='Ogni settimana' value='1w' key='1w')
|
el-option(label='Ogni settimana' value='1w' key='1w')
|
||||||
el-option(label='Ogni due settimane' value='2w' key='2w')
|
el-option(label='Ogni due settimane' value='2w' key='2w')
|
||||||
|
@ -82,16 +78,9 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
div.text-center.mb-2(v-if='event.type === "recurrent"')
|
div.text-center.mb-2(v-if='event.type === "recurrent"')
|
||||||
<<<<<<< HEAD
|
|
||||||
span {{event.recurrent.type}}
|
|
||||||
span(v-if='event.recurrent.frequency !== "1m" && event.recurrent.frequency !== "2m"') {{whenPatterns}}
|
span(v-if='event.recurrent.frequency !== "1m" && event.recurrent.frequency !== "2m"') {{whenPatterns}}
|
||||||
el-radio-group(v-else v-model='event.recurrent.type')
|
el-radio-group(v-else v-model='event.recurrent.type')
|
||||||
el-radio-button(v-for='whenPattern in whenPatterns' :label='whenPattern.key' :key='whenPatterns.key')
|
el-radio-button(v-for='whenPattern in whenPatterns' :label='whenPattern.key' :key='whenPatterns.key')
|
||||||
=======
|
|
||||||
span(v-if='event.rec_frequency !== "1m" && event.rec_frequency !== "2m"') {{whenPatterns}}
|
|
||||||
el-radio-group(v-else v-model='event.rec_detail')
|
|
||||||
el-radio-button(v-for='whenPattern in whenPatterns' :label='whenPattern.label' :key='whenPatterns.key')
|
|
||||||
>>>>>>> doc
|
|
||||||
span {{whenPattern.label}}
|
span {{whenPattern.label}}
|
||||||
|
|
||||||
el-form.text-center(inline)
|
el-form.text-center(inline)
|
||||||
|
@ -144,17 +133,8 @@ export default {
|
||||||
type: 'normal',
|
type: 'normal',
|
||||||
place: { name: '', address: '' },
|
place: { name: '', address: '' },
|
||||||
title: '', description: '', tags: [],
|
title: '', description: '', tags: [],
|
||||||
<<<<<<< HEAD
|
|
||||||
image: false,
|
image: false,
|
||||||
recurrent: { frequency: '1w', days: [], type: 'weekday' },
|
recurrent: { frequency: '1w', days: [], type: 'weekday' },
|
||||||
=======
|
|
||||||
multidate: false,
|
|
||||||
image: false,
|
|
||||||
recurrent: false,
|
|
||||||
rec_frequency: '1w',
|
|
||||||
rec_when: null,
|
|
||||||
rec_ordinal: false,
|
|
||||||
>>>>>>> doc
|
|
||||||
},
|
},
|
||||||
page: { month, year},
|
page: { month, year},
|
||||||
fileList: [],
|
fileList: [],
|
||||||
|
@ -239,7 +219,6 @@ export default {
|
||||||
const dates = this.date
|
const dates = this.date
|
||||||
if (!dates || !dates.length) return
|
if (!dates || !dates.length) return
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
const freq = this.event.recurrent.frequency
|
const freq = this.event.recurrent.frequency
|
||||||
const weekDays = uniq(map(dates, date => moment(date).format('dddd')))
|
const weekDays = uniq(map(dates, date => moment(date).format('dddd')))
|
||||||
if (freq === '1w' || freq === '2w') {
|
if (freq === '1w' || freq === '2w') {
|
||||||
|
@ -254,22 +233,6 @@ export default {
|
||||||
} else if (freq === '1d') {
|
} else if (freq === '1d') {
|
||||||
return this.$t('event.recurrent_each_day')
|
return this.$t('event.recurrent_each_day')
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
const freq = this.event.rec_frequency
|
|
||||||
const weekDays = uniq(map(dates, date => moment(date).format('dddd')))
|
|
||||||
if (freq === '1w' || freq === '2w') {
|
|
||||||
return this.$t(`event.recurrent_${freq}_days`, {days: weekDays.join(', ')})
|
|
||||||
}
|
|
||||||
if (freq === '1m' || freq === '2m') {
|
|
||||||
const days = uniq(map(dates, date => moment(date).date()))
|
|
||||||
const n = Math.floor((days[0]-1)/7)+1
|
|
||||||
return [
|
|
||||||
{ label: this.$tc(`event.recurrent_${freq}_days`, days.length, {days}) },
|
|
||||||
{ label: this.$tc(`event.recurrent_${freq}_ordinal`, days.length, {n: this.$t(`ordinal.${n}`), days: weekDays.join(', ')}) }
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> doc
|
|
||||||
},
|
},
|
||||||
todayEvents () {
|
todayEvents () {
|
||||||
if (this.event.type === 'multidate') {
|
if (this.event.type === 'multidate') {
|
||||||
|
@ -304,18 +267,16 @@ export default {
|
||||||
attributes = attributes.concat(this.filteredEvents
|
attributes = attributes.concat(this.filteredEvents
|
||||||
.filter(e => e.multidate)
|
.filter(e => e.multidate)
|
||||||
.map( e => ({ key: e.id, highlight: {}, dates: {
|
.map( e => ({ key: e.id, highlight: {}, dates: {
|
||||||
<<<<<<< HEAD
|
|
||||||
start: new Date(e.start_datetime), end: new Date(e.end_datetime) }})))
|
start: new Date(e.start_datetime), end: new Date(e.end_datetime) }})))
|
||||||
|
|
||||||
if (this.event.type === 'recurrent' && this.event.recurrent.frequency && Array.isArray(this.date)) {
|
if (this.event.type === 'recurrent' && this.event.recurrent.frequency) {
|
||||||
const recurrent = {}
|
const recurrent = {}
|
||||||
const frequency = this.event.recurrent.frequency
|
const frequency = this.event.recurrent.frequency
|
||||||
if (frequency === '1w' || frequency === '2w') {
|
if (Array.isArray(this.date) && (frequency === '1w' || frequency === '2w')) {
|
||||||
recurrent.weekdays = uniq(map(this.date, d => moment(d).day()+1 ))
|
recurrent.weekdays = uniq(map(this.date, d => moment(d).day()+1 ))
|
||||||
recurrent.weeklyInterval = frequency[0]*1
|
recurrent.weeklyInterval = frequency[0]*1
|
||||||
recurrent.start = new Date(this.date[0])
|
recurrent.start = new Date(this.date[0])
|
||||||
}
|
} else if (Array.isArray(this.date) && (frequency === '1m' || frequency === '2m')) {
|
||||||
if (frequency === '1m' || frequency === '2m') {
|
|
||||||
if (!this.date || !this.date.length) return attributes
|
if (!this.date || !this.date.length) return attributes
|
||||||
if (this.event.recurrent.type === 'weekday') {
|
if (this.event.recurrent.type === 'weekday') {
|
||||||
const days = uniq(map(this.date, d => moment(d).date()))
|
const days = uniq(map(this.date, d => moment(d).date()))
|
||||||
|
@ -326,32 +287,10 @@ export default {
|
||||||
}
|
}
|
||||||
recurrent.monthlyInterval = frequency[0]*1
|
recurrent.monthlyInterval = frequency[0]*1
|
||||||
recurrent.start = new Date(this.date[0])
|
recurrent.start = new Date(this.date[0])
|
||||||
}
|
} else if (this.event.recurrent.frequency === '1d') {
|
||||||
if (this.event.recurrent.frequency === '1d') {
|
|
||||||
recurrent.dailyInterval = 1
|
recurrent.dailyInterval = 1
|
||||||
=======
|
} else {
|
||||||
start: new Date(e.start_datetime*1000), end: new Date(e.end_datetime*1000) }})))
|
return attributes
|
||||||
|
|
||||||
if (this.event.type==='recurrent' && this.event.rec_frequency && Array.isArray(this.date)) {
|
|
||||||
const recurrent = {}
|
|
||||||
if (this.event.rec_frequency === '1w') {
|
|
||||||
recurrent.weekdays = this.date.map(d => moment(d).day()+1)
|
|
||||||
recurrent.weeklyInterval = 1
|
|
||||||
}
|
|
||||||
if (this.event.rec_frequency === '2w') {
|
|
||||||
recurrent.weekdays = this.date.map(d => moment(d).day()+1)
|
|
||||||
recurrent.weeklyInterval = 2
|
|
||||||
recurrent.start = new Date(this.date[0])
|
|
||||||
}
|
|
||||||
if (this.event.rec_frequency === '1m') {
|
|
||||||
// recurrent.weeks = 1
|
|
||||||
// recurrent.ordinalWeekdays = { 1: this.date.map(d => moment(d).day()+1) }
|
|
||||||
recurrent.days = this.date.map(d => moment(d).date())
|
|
||||||
recurrent.monthlyInterval = 1
|
|
||||||
recurrent.start = new Date(this.date[0])
|
|
||||||
}
|
|
||||||
if (this.event.rec_frequency === '2m') {
|
|
||||||
>>>>>>> doc
|
|
||||||
}
|
}
|
||||||
attributes.push({name: 'recurrent', dates: recurrent, dot: { color: 'red'}})
|
attributes.push({name: 'recurrent', dates: recurrent, dot: { color: 'red'}})
|
||||||
}
|
}
|
||||||
|
@ -419,6 +358,9 @@ export default {
|
||||||
this.time.end = (Number(start_hour)+2) + ':' + start_minute
|
this.time.end = (Number(start_hour)+2) + ':' + start_minute
|
||||||
}
|
}
|
||||||
const [ end_hour, end_minute ] = this.time.end.split(':')
|
const [ end_hour, end_minute ] = this.time.end.split(':')
|
||||||
|
|
||||||
|
const formData = new FormData()
|
||||||
|
|
||||||
if (this.event.type === 'multidate') {
|
if (this.event.type === 'multidate') {
|
||||||
start_datetime = moment(this.date.start)
|
start_datetime = moment(this.date.start)
|
||||||
.set('hour', start_hour).set('minute', start_minute)
|
.set('hour', start_hour).set('minute', start_minute)
|
||||||
|
@ -438,10 +380,12 @@ export default {
|
||||||
days: this.event.recurrent.type === 'ordinal' ? map(this.date, d => moment(d).date() ) : map(this.date, d => moment(d).day()+1 ),
|
days: this.event.recurrent.type === 'ordinal' ? map(this.date, d => moment(d).date() ) : map(this.date, d => moment(d).day()+1 ),
|
||||||
type: this.event.recurrent.type,
|
type: this.event.recurrent.type,
|
||||||
}
|
}
|
||||||
|
if (end_hour<start_hour) {
|
||||||
|
end_datetime = end_datetime.add(1, 'day')
|
||||||
|
}
|
||||||
formData.append('recurrent', JSON.stringify(recurrent))
|
formData.append('recurrent', JSON.stringify(recurrent))
|
||||||
|
|
||||||
}
|
}
|
||||||
const formData = new FormData()
|
|
||||||
|
|
||||||
if (this.event.image) {
|
if (this.event.image) {
|
||||||
formData.append('image', this.event.image.raw, this.event.image.name)
|
formData.append('image', this.event.image.raw, this.event.image.name)
|
||||||
|
@ -454,18 +398,6 @@ export default {
|
||||||
formData.append('start_datetime', start_datetime.unix())
|
formData.append('start_datetime', start_datetime.unix())
|
||||||
formData.append('end_datetime', end_datetime.unix())
|
formData.append('end_datetime', end_datetime.unix())
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
=======
|
|
||||||
if (this.event.type === 'recurrent') {
|
|
||||||
const recurrent = {
|
|
||||||
frequency: this.rec_frequency,
|
|
||||||
days: this.rec_when,
|
|
||||||
ordinal: this.rec_ordinal,
|
|
||||||
}
|
|
||||||
formData.append('recurrent', JSON.stringify(recurrent))
|
|
||||||
}
|
|
||||||
|
|
||||||
>>>>>>> doc
|
|
||||||
if (this.edit) {
|
if (this.edit) {
|
||||||
formData.append('id', this.event.id)
|
formData.append('id', this.event.id)
|
||||||
}
|
}
|
||||||
|
|
|
@ -220,48 +220,54 @@ const eventController = {
|
||||||
})
|
})
|
||||||
|
|
||||||
// build singular events from a recurrent pattern
|
// build singular events from a recurrent pattern
|
||||||
function createEventsFromRecurrent(e, dueTo=null, maxEvents=8) {
|
function createEventsFromRecurrent(e, dueTo=null) {
|
||||||
const events = []
|
const events = []
|
||||||
const recurrent = JSON.parse(e.recurrent)
|
const recurrent = JSON.parse(e.recurrent)
|
||||||
if (!recurrent.frequency) return false
|
if (!recurrent.frequency) return false
|
||||||
const cursor = moment(start)
|
const cursor = moment(start)
|
||||||
const start_date = moment(e.start_datetime)
|
const start_date = moment(e.start_datetime)
|
||||||
|
const duration = moment(e.end_datetime).diff(start_date, 's')
|
||||||
const frequency = recurrent.frequency
|
const frequency = recurrent.frequency
|
||||||
const days = [start_date.day()]
|
const days = recurrent.days
|
||||||
const type = recurrent.type
|
const type = recurrent.type
|
||||||
|
|
||||||
// EACH WEEK
|
// default frequency is '1d' => each day
|
||||||
if (frequency === '1w') {
|
const toAdd = { n: 1, unit: 'day'}
|
||||||
|
|
||||||
|
// each week or 2 (search for the first specified day)
|
||||||
|
if (frequency === '1w' || frequency === '2w') {
|
||||||
while(true) {
|
while(true) {
|
||||||
const found = days.indexOf(cursor.day())
|
const found = days.indexOf(cursor.day())
|
||||||
if (found!==-1) break
|
if (found!==-1) break
|
||||||
cursor.add(1, 'day')
|
cursor.add(1, 'day')
|
||||||
}
|
}
|
||||||
cursor.set('hour', start_date.hour()).set('minute', start_date.minutes())
|
if (frequency === '2w') {
|
||||||
while (true) {
|
const nWeeks = cursor.diff(start_datetime, 'w')%2
|
||||||
if ((dueTo && cursor.isAfter(dueTo)) || events.length>maxEvents) break
|
if (nWeeks) cursor.add(1, 'week')
|
||||||
e.start_datetime = cursor.unix()*1000
|
|
||||||
events.push( Object.assign({}, e) )
|
|
||||||
cursor.add(1, 'week')
|
|
||||||
}
|
}
|
||||||
|
toAdd.n = Number(frequency[0])
|
||||||
|
toAdd.unit = 'week';
|
||||||
|
cursor.set('hour', start_date.hour()).set('minute', start_date.minutes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// EACH TWO WEEKS
|
// each month or 2
|
||||||
if (frequency === '2w') {
|
// if (frequency === '1m' || frequency === '2m') {
|
||||||
while(true) {
|
// // find first match
|
||||||
const found = days.indexOf(cursor.day())
|
// if (type) {
|
||||||
if (found!==-1) break
|
|
||||||
cursor.add(1, 'day')
|
// }
|
||||||
}
|
// }
|
||||||
cursor.set('hour', start_date.hour()).set('minute', start_date.minutes())
|
|
||||||
while (true) {
|
// add event at specified frequency
|
||||||
if ((dueTo && cursor.isAfter(dueTo)) || events.length>maxEvents) break
|
while (true) {
|
||||||
e.start_datetime = cursor.unix()*1000
|
if (dueTo && cursor.isAfter(dueTo)) break
|
||||||
events.push( Object.assign({}, e) )
|
e.start_datetime = cursor.unix()*1000
|
||||||
cursor.add(1, 'week')
|
e.end_datetime = e.start_datetime+(duration*1000)// cursor.clone().hour(end_datetime.hour()).minute(end_datetime.minute()).unix()*1000
|
||||||
}
|
events.push( Object.assign({}, e) )
|
||||||
|
cursor.add(toAdd.n, toAdd.unit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return events
|
return events
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,7 +46,7 @@ export const getters = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (search_for_tags) {
|
if (search_for_tags) {
|
||||||
const common_tags = intersection(map(e.tags, t => t.tag), state.filters.tags);
|
const common_tags = intersection(e.tags, state.filters.tags);
|
||||||
if (common_tags.length > 0) return true
|
if (common_tags.length > 0) return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ export const getters = {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (search_for_tags) {
|
if (search_for_tags) {
|
||||||
const common_tags = intersection(map(e.tags, t => t.tag), state.filters.tags);
|
const common_tags = intersection(e.tags, state.filters.tags);
|
||||||
if (common_tags.length > 0) return true
|
if (common_tags.length > 0) return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,9 +91,9 @@ export const mutations = {
|
||||||
state.events = events.map((e) => {
|
state.events = events.map((e) => {
|
||||||
const currentDay = moment(e.start_datetime).date()
|
const currentDay = moment(e.start_datetime).date()
|
||||||
e.newDay = (!lastDay || lastDay !== currentDay) && currentDay
|
e.newDay = (!lastDay || lastDay !== currentDay) && currentDay
|
||||||
lastDay = currentDay
|
lastDay = currentDay
|
||||||
const end_datetime = e.end_datetime || e.start_datetime+3600*2
|
const end_datetime = e.end_datetime || e.start_datetime+3600000*2
|
||||||
const past = (moment().unix() - end_datetime) > 0
|
const past = ((moment().unix()*1000) - end_datetime) > 0
|
||||||
e.past = !!past
|
e.past = !!past
|
||||||
return e
|
return e
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue