P-38
This commit is contained in:
1 parent
bf3766e6d5
commit
5e462e9e35
7 files changed
+204
-169
No files matched your search
@@ -1,70 +0,0 @@
|
||||
<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,104 +1,105 @@
|
||||
<template>
|
||||
<div>
|
||||
<my-helper :pretext="events" />
|
||||
<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>
|
||||
<v-btn @click="f_feedbackdata"> ical</v-btn>
|
||||
|
||||
<v-file-input
|
||||
:show-size="1000"
|
||||
color="deep-purple-accent-4"
|
||||
label="File input"
|
||||
placeholder="Select your files"
|
||||
prepend-icon="mdi-paperclip"
|
||||
variant="outlined"
|
||||
counter
|
||||
multiple
|
||||
accept=".ics"
|
||||
@input="handleFilesUpload"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useDate } from 'vuetify'
|
||||
import myHelper from '../UI/my-helper.vue'
|
||||
import { axiosApiInstance } from "@/utils/axios-api";
|
||||
import { ref, computed } from "vue";
|
||||
import ical from "ical.js";
|
||||
|
||||
// const burl = baseURL.slice(0, -1);
|
||||
|
||||
export default {
|
||||
components: { myHelper },
|
||||
data: () => ({
|
||||
type: 'month',
|
||||
types: ['month', 'week', 'day'],
|
||||
weekday: [0, 1, 2, 3, 4, 5, 6],
|
||||
weekdays: [
|
||||
{ title: 'Sun - Sat', value: [0, 1, 2, 3, 4, 5, 6] },
|
||||
{ title: 'Mon - Sun', value: [1, 2, 3, 4, 5, 6, 0] },
|
||||
{ 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 = []
|
||||
setup() {
|
||||
|
||||
const min = start
|
||||
const max = end
|
||||
const days = (max.getTime() - min.getTime()) / 86400000
|
||||
const eventCount = this.rnd(days, days + 20)
|
||||
const participant = ref("");
|
||||
const calendar = ref("");
|
||||
const calendarEvents = ref([]);
|
||||
|
||||
for (let i = 0; i < eventCount; i++) {
|
||||
const allDay = this.rnd(0, 3) === 0
|
||||
const firstTimestamp = this.rnd(min.getTime(), max.getTime())
|
||||
const first = new Date(firstTimestamp - (firstTimestamp % 900000))
|
||||
const secondTimestamp = this.rnd(2, allDay ? 288 : 8) * 900000
|
||||
const second = new Date(first.getTime() + secondTimestamp)
|
||||
|
||||
events.push({
|
||||
title: this.titles[this.rnd(0, this.titles.length - 1)],
|
||||
start: first,
|
||||
end: second,
|
||||
color: this.colors[this.rnd(0, this.colors.length - 1)],
|
||||
allDay: !allDay,
|
||||
function f_feedbackdata() {
|
||||
|
||||
axiosApiInstance
|
||||
.post(`api/calendar_of_events/calendarEvents/`, {
|
||||
participants: participant.value,
|
||||
calendar: calendar.value }).then((data) => {
|
||||
console.log(data, "datas");
|
||||
})
|
||||
}
|
||||
|
||||
const handleFilesUpload = (event) => {
|
||||
const file = event.target.files[0];
|
||||
|
||||
if (file) {
|
||||
readFile(file);
|
||||
}
|
||||
};
|
||||
|
||||
const readFile = (file) => {
|
||||
const reader = new FileReader();
|
||||
reader.readAsText(file);
|
||||
reader.onload = (event) => {
|
||||
parseICS(event.target.result);
|
||||
};
|
||||
|
||||
|
||||
};
|
||||
const parseICS = (text) => {
|
||||
const jcalData = ical.parse(text);
|
||||
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 {
|
||||
name: event.summary,
|
||||
description: event.description,
|
||||
// organizer: event.organizer, Может, удалить?
|
||||
startdate: event.startDate.toJSDate(),
|
||||
enddate: event.endDate.toJSDate(),
|
||||
place: event.location,
|
||||
// attendees: attendees, ? Такая же история 0 в базе нет
|
||||
cdate: new Date(event.component.jCal[1][6][3]),
|
||||
content: ''
|
||||
};
|
||||
});
|
||||
|
||||
participant.value = name;
|
||||
calendar.value = calendarEvents;
|
||||
|
||||
};
|
||||
|
||||
return {
|
||||
handleFilesUpload,
|
||||
calendarEvents,
|
||||
f_feedbackdata
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
this.events = events
|
||||
},
|
||||
getEventColor (event) {
|
||||
return event.color
|
||||
},
|
||||
rnd (a, b) {
|
||||
return Math.floor((b - a + 1) * Math.random()) + a
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
<style></style>
|
||||
@@ -0,0 +1,105 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-btn @click="useICalReader"> ical</v-btn>
|
||||
<my-helper :pretext="events" />
|
||||
<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>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { useDate } from 'vuetify'
|
||||
import myHelper from '../UI/my-helper.vue'
|
||||
|
||||
export default {
|
||||
components: { myHelper },
|
||||
data: () => ({
|
||||
type: 'month',
|
||||
types: ['month', 'week', 'day'],
|
||||
weekday: [0, 1, 2, 3, 4, 5, 6],
|
||||
weekdays: [
|
||||
{ title: 'Sun - Sat', value: [0, 1, 2, 3, 4, 5, 6] },
|
||||
{ title: 'Mon - Sun', value: [1, 2, 3, 4, 5, 6, 0] },
|
||||
{ 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 min = start
|
||||
const max = end
|
||||
const days = (max.getTime() - min.getTime()) / 86400000
|
||||
const eventCount = this.rnd(days, days + 20)
|
||||
|
||||
for (let i = 0; i < eventCount; i++) {
|
||||
const allDay = this.rnd(0, 3) === 0
|
||||
const firstTimestamp = this.rnd(min.getTime(), max.getTime())
|
||||
const first = new Date(firstTimestamp - (firstTimestamp % 900000))
|
||||
const secondTimestamp = this.rnd(2, allDay ? 288 : 8) * 900000
|
||||
const second = new Date(first.getTime() + secondTimestamp)
|
||||
|
||||
events.push({
|
||||
title: this.titles[this.rnd(0, this.titles.length - 1)],
|
||||
start: first,
|
||||
end: second,
|
||||
color: this.colors[this.rnd(0, this.colors.length - 1)],
|
||||
allDay: !allDay,
|
||||
})
|
||||
}
|
||||
|
||||
this.events = events
|
||||
},
|
||||
getEventColor (event) {
|
||||
return event.color
|
||||
},
|
||||
rnd (a, b) {
|
||||
return Math.floor((b - a + 1) * Math.random()) + a
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
</style>
|
||||
@@ -8,14 +8,13 @@ import { ru } from 'vuetify/locale'
|
||||
import { VTimePicker } from 'vuetify/labs/VTimePicker'
|
||||
|
||||
export default createVuetify({
|
||||
components: {
|
||||
VTimePicker,
|
||||
},
|
||||
|
||||
locale: {
|
||||
messages: { ru },
|
||||
},
|
||||
components: {
|
||||
VCalendar,
|
||||
VTimePicker,
|
||||
},
|
||||
theme: {
|
||||
defaultTheme: 'light'
|
||||
|
||||
@@ -53,8 +53,8 @@ export default {
|
||||
console.log(safetyData.value, "-------------------------------");
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(() => getSafety())
|
||||
getSafety()
|
||||
// onMounted(() => getSafety())
|
||||
onUpdated(() => getSafety())
|
||||
|
||||
return {
|
||||
|
||||
Reference in new issue
Block a user