Передача на бек
This commit is contained in:
1 parent
f0fd956c2a
commit
f02569a389
7 files changed
+220
-134
No files matched your search
@@ -1,32 +1,84 @@
|
||||
<template>
|
||||
<div>
|
||||
<pre>
|
||||
{{events}}
|
||||
</pre>
|
||||
<!-- <my-helper :pretext="kl" /> -->
|
||||
<v-btn @click="useICalReader"> ical</v-btn>
|
||||
|
||||
</div>
|
||||
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {useICalReader} from '@/utils/universal_functions'
|
||||
// import {useICalReader} from '@/utils/universal_functions'
|
||||
import { baseURL, axiosApiInstance } from '@/utils/axios-api'
|
||||
import { ref } from 'vue';
|
||||
import ical from "ical.js";
|
||||
import { formatDash } from '@/utils/universal_functions'
|
||||
|
||||
const burl = baseURL.slice(0,-1)
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const { events } = useICalReader(`${burl}/media/ical/calendar.ics`)
|
||||
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) => {
|
||||
return {
|
||||
summary: event.summary,
|
||||
description: event.description,
|
||||
organizer: event.organizer,
|
||||
start: formatDash(event.startDate.toJSDate()),
|
||||
end: formatDash(event.endDate.toJSDate()),
|
||||
location: event.location,
|
||||
event: event
|
||||
}
|
||||
})
|
||||
participant.value = name
|
||||
calendar.value = calendarEvents
|
||||
console.log(name, 'name')
|
||||
console.log(calendarEvents, 'calendarEventse')
|
||||
f_feedbackdata()
|
||||
// return {
|
||||
// type: "calendar",
|
||||
// title: name,
|
||||
// calendar: calendarEvents,
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// const s= useICalReader(`${burl}/media/ical/calendar.ics`)
|
||||
// console.log(s.value, 'ddddddddd')
|
||||
function f_feedbackdata() {
|
||||
axiosApiInstance.post(`api/calendar_of_events/calendarEvents/`, {
|
||||
participants: participant.value,
|
||||
calendar: calendar.value
|
||||
})
|
||||
.then(data => {
|
||||
console.log(data,'datas')
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return {
|
||||
events
|
||||
useICalReader
|
||||
}
|
||||
// const { icsContent, fetchICalFile } = useICalReader(`${burl}/media/ical/calendar.ics`)
|
||||
|
||||
// return {
|
||||
// icsContent, fetchICalFile
|
||||
// }
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in new issue
Block a user