Передача на бек
This commit is contained in:
1 parent
1347f2ee6e
commit
42ca24ed5a
7 files changed
+220
-134
No files matched your search
@@ -3,7 +3,7 @@
|
||||
<v-menu
|
||||
v-model="menu"
|
||||
:close-on-content-click="false"
|
||||
:nudge-width="500"
|
||||
:max-width="800"
|
||||
offset-x
|
||||
>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
|
||||
@@ -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>
|
||||
|
||||
@@ -1,147 +1,161 @@
|
||||
const str = 'hello';
|
||||
import {useAccountStore} from '@/store/AccountStore'
|
||||
import {useAppStore} from '@/store/app'
|
||||
import { baseURL } from '@/utils/axios-api'
|
||||
import { axiosApiInstance, clearAxios } from '@/utils/axios-api'
|
||||
import { useRouter } from 'vue-router'
|
||||
import moment from 'moment'
|
||||
import { ref, onMounted } from 'vue'
|
||||
const str = "hello";
|
||||
import { useAccountStore } from "@/store/AccountStore";
|
||||
import { useAppStore } from "@/store/app";
|
||||
import { baseURL } from "@/utils/axios-api";
|
||||
import { axiosApiInstance, clearAxios } from "@/utils/axios-api";
|
||||
import { useRouter } from "vue-router";
|
||||
import moment from "moment";
|
||||
import { ref, onMounted } from "vue";
|
||||
|
||||
import ical from 'ical.js'
|
||||
|
||||
|
||||
export function formatComa(date) {
|
||||
return moment(date).format('DD.MM.YYYY')
|
||||
}
|
||||
|
||||
export function formatDash(date) {
|
||||
return moment(date).format('YYYY-MM-DD')
|
||||
}
|
||||
|
||||
export function formaComaTime(date) {
|
||||
return moment(date).format('DD.MM.YYYY H:mm')
|
||||
}
|
||||
|
||||
export function checking_for_entry (where, what) {
|
||||
if (!where.includes(what))
|
||||
{
|
||||
where.push(what)
|
||||
}
|
||||
return moment(date).format("DD.MM.YYYY");
|
||||
}
|
||||
|
||||
export function getfromserver(path, reactive){
|
||||
try{
|
||||
|
||||
axiosApiInstance.get(path).then(result => {
|
||||
reactive.value = result.data})}
|
||||
catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
export function formatDash(date) {
|
||||
return moment(date).format("YYYY-MM-DD");
|
||||
}
|
||||
|
||||
export function formaComaTime(date) {
|
||||
return moment(date).format("DD.MM.YYYY H:mm");
|
||||
}
|
||||
|
||||
export function checking_for_entry(where, what) {
|
||||
if (!where.includes(what)) {
|
||||
where.push(what);
|
||||
}
|
||||
}
|
||||
|
||||
export function getfromserverfree(path, reactive){
|
||||
try{
|
||||
clearAxios.get(path).then(result => {
|
||||
reactive.value = result.data})}
|
||||
catch(e){
|
||||
console.log(e);
|
||||
}
|
||||
export function getfromserver(path, reactive) {
|
||||
try {
|
||||
axiosApiInstance.get(path).then((result) => {
|
||||
reactive.value = result.data;
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
export function checkremote(filecheck){
|
||||
|
||||
return process.env.NODE_ENV == 'development'? "https://pixelbox.ru/wp-content/uploads/2021/11/avatar-whatsapp-pixelbox.ru-36.jpg":filecheck
|
||||
|
||||
export function getfromserverfree(path, reactive) {
|
||||
try {
|
||||
clearAxios.get(path).then((result) => {
|
||||
reactive.value = result.data;
|
||||
});
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
export function checkremote(filecheck) {
|
||||
return process.env.NODE_ENV == "development"
|
||||
? "https://pixelbox.ru/wp-content/uploads/2021/11/avatar-whatsapp-pixelbox.ru-36.jpg"
|
||||
: filecheck;
|
||||
}
|
||||
|
||||
export default str;
|
||||
|
||||
export function splitname (name) {
|
||||
return name.familyname + ' ' + name.name[0] + '.' + name.parentname[0]+ '.'
|
||||
}
|
||||
|
||||
export function pagecounter(){
|
||||
|
||||
const router = useRouter()
|
||||
const accountStore = useAccountStore()
|
||||
const appStore = useAppStore()
|
||||
export function splitname(name) {
|
||||
return name.familyname + " " + name.name[0] + "." + name.parentname[0] + ".";
|
||||
}
|
||||
|
||||
export function pagecounter() {
|
||||
const router = useRouter();
|
||||
const accountStore = useAccountStore();
|
||||
const appStore = useAppStore();
|
||||
|
||||
let postdata = {
|
||||
user__id: "user" in accountStore &&"id" in accountStore.user? accountStore.user.id: null,
|
||||
user__id:
|
||||
"user" in accountStore && "id" in accountStore.user
|
||||
? accountStore.user.id
|
||||
: null,
|
||||
page: router.currentRoute.value.meta.title,
|
||||
fullPath: router.currentRoute.value.fullPath,
|
||||
ico: router.currentRoute.value.meta.ico
|
||||
}
|
||||
ico: router.currentRoute.value.meta.ico,
|
||||
};
|
||||
|
||||
clearAxios.post(`${baseURL}api/watcher/counter/`, postdata).then((result) => {
|
||||
appStore.countvisitor = result.data;
|
||||
});
|
||||
}
|
||||
|
||||
clearAxios.post(`${baseURL}api/watcher/counter/`, postdata)
|
||||
.then(result => {
|
||||
appStore.countvisitor = result.data
|
||||
})
|
||||
export function getDevelopment() {
|
||||
return process.env.NODE_ENV == "development" ? true : false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
export function useICalReader(url) {
|
||||
///
|
||||
const events = ref([]);
|
||||
|
||||
export function getDevelopment() {
|
||||
return process.env.NODE_ENV == 'development'?true:false
|
||||
}
|
||||
const loadICalFile = async () => {
|
||||
try {
|
||||
const response = await fetch(url);
|
||||
const data = await response.text();
|
||||
const jcalData = ical.parse(data);
|
||||
const icalComponent = new ical.Component(jcalData);
|
||||
const name = icalComponent.getFirstPropertyValue("x-wr-calname");
|
||||
|
||||
export function useICalReader(url) {
|
||||
///
|
||||
const events = ref([])
|
||||
|
||||
const loadICalFile = async () => {
|
||||
try {
|
||||
const response = await fetch(url)
|
||||
const data = await response.text()
|
||||
const jcalData = ical.parse(data)
|
||||
const comp = new ical.Component(jcalData)
|
||||
const vevents = comp.getAllSubcomponents('vevent')
|
||||
const eventsData = vevents.map(vevent => ({
|
||||
vevent: vevent
|
||||
// summary: vevent.getFirstPropertyValue('summary'),
|
||||
// start: vevent.getFirstPropertyValue('dtstart'),
|
||||
// end: vevent.getFirstPropertyValue('dtend')
|
||||
}))
|
||||
events.value = eventsData
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
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,
|
||||
attendee_count: event.attendees.length,
|
||||
duration_seconds: event.duration.toSeconds(),
|
||||
start: event.startDate.toJSDate().getTime() / 1000,
|
||||
end: event.endDate.toJSDate().getTime() / 1000,
|
||||
location: event.location,
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
type: "calendar",
|
||||
title: name,
|
||||
calendar: calendarEvents,
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadICalFile()
|
||||
})
|
||||
|
||||
return {
|
||||
events
|
||||
}
|
||||
}
|
||||
|
||||
// const vevents = comp.getAllSubcomponents('vevent')
|
||||
// const eventsData = vevents.map(vevent => ({
|
||||
// vevent: vevent,
|
||||
|
||||
// summary: vevent.getFirstPropertyValue('summary'),
|
||||
// start: vevent.getFirstPropertyValue('dtstart'),
|
||||
// end: vevent.getFirstPropertyValue('dtend')
|
||||
// }))
|
||||
// events.value = eventsData
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
};
|
||||
|
||||
// export function useICalReader(filePath) {
|
||||
// const icsContent = ref('')
|
||||
|
||||
// const fetchICalFile = async () => {
|
||||
// try {
|
||||
// const response = await fetch(filePath)
|
||||
// if (!response.ok) {
|
||||
// throw new Error('Ошибка при загрузке файла')
|
||||
// }
|
||||
// const data = await response.text()
|
||||
// icsContent.value = data
|
||||
// } catch (error) {
|
||||
// console.error('Ошибка при чтении файла:', error)
|
||||
// }
|
||||
// }
|
||||
|
||||
// return { icsContent, fetchICalFile }
|
||||
// }
|
||||
onMounted(() => {
|
||||
loadICalFile();
|
||||
});
|
||||
|
||||
return {
|
||||
events,
|
||||
};
|
||||
}
|
||||
|
||||
// export function useICalReader(filePath) {
|
||||
// const icsContent = ref('')
|
||||
|
||||
// const fetchICalFile = async () => {
|
||||
// try {
|
||||
// const response = await fetch(filePath)
|
||||
// if (!response.ok) {
|
||||
// throw new Error('Ошибка при загрузке файла')
|
||||
// }
|
||||
// const data = await response.text()
|
||||
// icsContent.value = data
|
||||
// } catch (error) {
|
||||
// console.error('Ошибка при чтении файла:', error)
|
||||
// }
|
||||
// }
|
||||
|
||||
// return { icsContent, fetchICalFile }
|
||||
// }
|
||||
Reference in new issue
Block a user