P-29i calendar
This commit is contained in:
1 parent
cd6fdeb90d
commit
35b8bb56bb
3 files changed
+162
-55
No files matched your search
@@ -0,0 +1,70 @@
|
|||||||
|
<template>
|
||||||
|
<div>
|
||||||
|
<!-- <my-helper :pretext="kl" /> -->
|
||||||
|
<v-btn @click="useICalReader"> ical</v-btn>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// import {useICalReader} from '@/utils/universal_functions'
|
||||||
|
import { baseURL, axiosApiInstance } from "@/utils/axios-api";
|
||||||
|
import { ref } from "vue";
|
||||||
|
import ical from "ical.js";
|
||||||
|
|
||||||
|
const burl = baseURL.slice(0, -1);
|
||||||
|
|
||||||
|
export default {
|
||||||
|
setup() {
|
||||||
|
const participant = ref("");
|
||||||
|
const calendar = ref("");
|
||||||
|
const useICalReader = async () => {
|
||||||
|
const response = await fetch(`${burl}/media/ical/calendar.ics`);
|
||||||
|
const data = await response.text();
|
||||||
|
const jcalData = ical.parse(data);
|
||||||
|
const icalComponent = new ical.Component(jcalData);
|
||||||
|
const name = icalComponent.getFirstPropertyValue("x-wr-calname");
|
||||||
|
|
||||||
|
const events = icalComponent
|
||||||
|
.getAllSubcomponents("vevent")
|
||||||
|
.map((vevent) => new ical.Event(vevent));
|
||||||
|
|
||||||
|
const calendarEvents = events.map((event) => {
|
||||||
|
let attendees = [];
|
||||||
|
event.attendees.map((att) => {
|
||||||
|
attendees.push(att.jCal[1].cn);
|
||||||
|
});
|
||||||
|
|
||||||
|
return {
|
||||||
|
summary: event.summary,
|
||||||
|
description: event.description,
|
||||||
|
organizer: event.organizer,
|
||||||
|
start: event.startDate.toJSDate(),
|
||||||
|
end: event.endDate.toJSDate(),
|
||||||
|
location: event.location,
|
||||||
|
attendees: attendees,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
participant.value = name;
|
||||||
|
calendar.value = calendarEvents;
|
||||||
|
f_feedbackdata();
|
||||||
|
};
|
||||||
|
|
||||||
|
function f_feedbackdata() {
|
||||||
|
axiosApiInstance
|
||||||
|
.post(`api/calendar_of_events/calendarEvents/`, {
|
||||||
|
participants: participant.value,
|
||||||
|
calendar: calendar.value,
|
||||||
|
})
|
||||||
|
.then((data) => {
|
||||||
|
console.log(data, "datas");
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
useICalReader,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style></style>
|
||||||
@@ -1,70 +1,104 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<!-- <my-helper :pretext="kl" /> -->
|
<my-helper :pretext="events" />
|
||||||
<v-btn @click="useICalReader"> ical</v-btn>
|
<v-sheet
|
||||||
|
class="d-flex"
|
||||||
|
height="54"
|
||||||
|
tile
|
||||||
|
>
|
||||||
|
<v-select
|
||||||
|
v-model="type"
|
||||||
|
:items="types"
|
||||||
|
class="ma-2"
|
||||||
|
label="View Mode"
|
||||||
|
variant="outlined"
|
||||||
|
dense
|
||||||
|
hide-details
|
||||||
|
></v-select>
|
||||||
|
<v-select
|
||||||
|
v-model="weekday"
|
||||||
|
:items="weekdays"
|
||||||
|
class="ma-2"
|
||||||
|
label="weekdays"
|
||||||
|
variant="outlined"
|
||||||
|
dense
|
||||||
|
hide-details
|
||||||
|
></v-select>
|
||||||
|
</v-sheet>
|
||||||
|
<v-sheet>
|
||||||
|
<v-calendar
|
||||||
|
ref="calendar"
|
||||||
|
v-model="value"
|
||||||
|
:events="events"
|
||||||
|
:view-mode="type"
|
||||||
|
:weekdays="weekday"
|
||||||
|
></v-calendar>
|
||||||
|
</v-sheet>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// import {useICalReader} from '@/utils/universal_functions'
|
import { useDate } from 'vuetify'
|
||||||
import { baseURL, axiosApiInstance } from "@/utils/axios-api";
|
import myHelper from '../UI/my-helper.vue'
|
||||||
import { ref } from "vue";
|
|
||||||
import ical from "ical.js";
|
|
||||||
|
|
||||||
const burl = baseURL.slice(0, -1);
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
setup() {
|
components: { myHelper },
|
||||||
const participant = ref("");
|
data: () => ({
|
||||||
const calendar = ref("");
|
type: 'month',
|
||||||
const useICalReader = async () => {
|
types: ['month', 'week', 'day'],
|
||||||
const response = await fetch(`${burl}/media/ical/calendar.ics`);
|
weekday: [0, 1, 2, 3, 4, 5, 6],
|
||||||
const data = await response.text();
|
weekdays: [
|
||||||
const jcalData = ical.parse(data);
|
{ title: 'Sun - Sat', value: [0, 1, 2, 3, 4, 5, 6] },
|
||||||
const icalComponent = new ical.Component(jcalData);
|
{ title: 'Mon - Sun', value: [1, 2, 3, 4, 5, 6, 0] },
|
||||||
const name = icalComponent.getFirstPropertyValue("x-wr-calname");
|
{ title: 'Mon - Fri', value: [1, 2, 3, 4, 5] },
|
||||||
|
{ title: 'Mon, Wed, Fri', value: [1, 3, 5] },
|
||||||
|
],
|
||||||
|
value: [new Date()],
|
||||||
|
events: [],
|
||||||
|
colors: ['blue', 'indigo', 'deep-purple', 'cyan', 'green', 'orange', 'grey darken-1'],
|
||||||
|
titles: ['Meeting', 'Holiday', 'PTO', 'Travel', 'Event', 'Birthday', 'Conference', 'Party'],
|
||||||
|
}),
|
||||||
|
mounted () {
|
||||||
|
const adapter = useDate()
|
||||||
|
this.getEvents({ start: adapter.startOfDay(adapter.startOfMonth(new Date())), end: adapter.endOfDay(adapter.endOfMonth(new Date())) })
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
getEvents ({ start, end }) {
|
||||||
|
const events = []
|
||||||
|
|
||||||
const events = icalComponent
|
const min = start
|
||||||
.getAllSubcomponents("vevent")
|
const max = end
|
||||||
.map((vevent) => new ical.Event(vevent));
|
const days = (max.getTime() - min.getTime()) / 86400000
|
||||||
|
const eventCount = this.rnd(days, days + 20)
|
||||||
|
|
||||||
const calendarEvents = events.map((event) => {
|
for (let i = 0; i < eventCount; i++) {
|
||||||
let attendees = [];
|
const allDay = this.rnd(0, 3) === 0
|
||||||
event.attendees.map((att) => {
|
const firstTimestamp = this.rnd(min.getTime(), max.getTime())
|
||||||
attendees.push(att.jCal[1].cn);
|
const first = new Date(firstTimestamp - (firstTimestamp % 900000))
|
||||||
});
|
const secondTimestamp = this.rnd(2, allDay ? 288 : 8) * 900000
|
||||||
|
const second = new Date(first.getTime() + secondTimestamp)
|
||||||
|
|
||||||
return {
|
events.push({
|
||||||
summary: event.summary,
|
title: this.titles[this.rnd(0, this.titles.length - 1)],
|
||||||
description: event.description,
|
start: first,
|
||||||
organizer: event.organizer,
|
end: second,
|
||||||
start: event.startDate.toJSDate(),
|
color: this.colors[this.rnd(0, this.colors.length - 1)],
|
||||||
end: event.endDate.toJSDate(),
|
allDay: !allDay,
|
||||||
location: event.location,
|
|
||||||
attendees: attendees,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
participant.value = name;
|
|
||||||
calendar.value = calendarEvents;
|
|
||||||
f_feedbackdata();
|
|
||||||
};
|
|
||||||
|
|
||||||
function f_feedbackdata() {
|
|
||||||
axiosApiInstance
|
|
||||||
.post(`api/calendar_of_events/calendarEvents/`, {
|
|
||||||
participants: participant.value,
|
|
||||||
calendar: calendar.value,
|
|
||||||
})
|
})
|
||||||
.then((data) => {
|
|
||||||
console.log(data, "datas");
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
this.events = events
|
||||||
useICalReader,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
};
|
getEventColor (event) {
|
||||||
|
return event.color
|
||||||
|
},
|
||||||
|
rnd (a, b) {
|
||||||
|
return Math.floor((b - a + 1) * Math.random()) + a
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style>
|
||||||
|
|
||||||
|
</style>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
import '@mdi/font/css/materialdesignicons.css'
|
import '@mdi/font/css/materialdesignicons.css'
|
||||||
import 'vuetify/styles'
|
import 'vuetify/styles'
|
||||||
|
import { VCalendar } from 'vuetify/labs/VCalendar'
|
||||||
|
|
||||||
import { createVuetify } from 'vuetify'
|
import { createVuetify } from 'vuetify'
|
||||||
import { ru } from 'vuetify/locale'
|
import { ru } from 'vuetify/locale'
|
||||||
@@ -10,6 +10,9 @@ export default createVuetify({
|
|||||||
locale: {
|
locale: {
|
||||||
messages: { ru },
|
messages: { ru },
|
||||||
},
|
},
|
||||||
|
components: {
|
||||||
|
VCalendar,
|
||||||
|
},
|
||||||
theme: {
|
theme: {
|
||||||
defaultTheme: 'light'
|
defaultTheme: 'light'
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user