From 087601ba31a17c6e9e13cfcb12ff7656e5d73b0a Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Fri, 12 Nov 2021 13:36:39 -0500 Subject: [PATCH] Use proxied ics files instead of google-calendar api This means we don't need to expose a google API key to clients --- .gitignore | 1 - package.json | 3 ++- src/App.vue | 10 ++++------ vite.config.ts | 8 ++++++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 7a0c801..fe722d1 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,3 @@ /.cache/ /dist/ /package-lock.json -/src/secrets.json diff --git a/package.json b/package.json index e27809b..3543df0 100644 --- a/package.json +++ b/package.json @@ -16,10 +16,11 @@ }, "dependencies": { "@fullcalendar/core": "^5.10.0", - "@fullcalendar/google-calendar": "^5.6.0", + "@fullcalendar/icalendar": "^5.10.1", "@fullcalendar/timegrid": "^5.6.0", "@fullcalendar/vue3": "^5.10.0", "equicolor": "^1.1.0", + "ical.js": "github:ekreative/ical.js#var-ical", "intl": "^1.2.5", "vue": "^3.2.20" } diff --git a/src/App.vue b/src/App.vue index 60bf107..467a409 100644 --- a/src/App.vue +++ b/src/App.vue @@ -14,9 +14,7 @@ import FullCalendar, { } from '@fullcalendar/vue3'; import timeGridPlugin from '@fullcalendar/timegrid'; import dayGridPlugin from '@fullcalendar/daygrid'; -import googleCalendarPlugin from '@fullcalendar/google-calendar'; - -import { googleCalendarApiKey } from './secrets.json'; +import iCalendarPlugin from '@fullcalendar/icalendar'; const calendars: { [key: string]: string } = { computer_lab: '6mmjp85e4732ru6skf1dda54ls@group.calendar.google.com', @@ -34,12 +32,11 @@ const colors: string[] = equicolor.findNextColors( ); const calendarOptions: CalendarOptions = { - plugins: [timeGridPlugin, dayGridPlugin, googleCalendarPlugin], + plugins: [timeGridPlugin, dayGridPlugin, iCalendarPlugin], allDaySlot: false, nowIndicator: true, initialView: 'timeGridWeek', height: 'auto', - googleCalendarApiKey, slotMinTime: '8:00', slotMaxTime: '22:00', businessHours: { @@ -49,7 +46,8 @@ const calendarOptions: CalendarOptions = { }, eventSources: Object.values(calendars).map((id, idx) => { return { - googleCalendarId: id, + url: "/calendar/ical/" + id + "/public/basic.ics", + format: "ics", color: colors[idx], eventDataTransform: eventDataTransform, }; diff --git a/vite.config.ts b/vite.config.ts index 92491e8..7e7ade5 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -10,4 +10,12 @@ export default defineConfig({ targets: ['defaults', 'not IE 11', "ios 8.4"] }), ], + server: { + proxy: { + '/calendar': { + target: 'https://calendar.google.com', + changeOrigin: true, + }, + }, + }, });