[#133] added dl event button (#134)

Co-authored-by: Camille Moussu <cmoussu@linagora.com>
This commit is contained in:
Camille Moussu
2025-09-23 12:33:08 +02:00
committed by GitHub
parent cd724a30a0
commit 3dd7e1a985
3 changed files with 32 additions and 2 deletions
+1
View File
@@ -7,3 +7,4 @@ var SSO_CODE_CHALLENGE_METHOD = "S256";
var SSO_POST_LOGOUT_REDIRECT = "http://example.com?logout=1";
var CALENDAR_BASE_URL = "https://calendar.example.com";
var MAIL_SPA_URL = "https://mail.example.com";
var DEBUG = false;
+7
View File
@@ -16,6 +16,13 @@ export async function getEvent(event: CalendarEvent) {
return { ...eventjson, ...event };
}
export async function dlEvent(event: CalendarEvent) {
const response = await api.get(`dav${event.URL}?export=`);
const eventData = await response.text();
return eventData;
}
export async function putEvent(event: CalendarEvent, calOwnerEmail?: string) {
const response = await api(`dav${event.URL}`, {
method: "PUT",
+24 -2
View File
@@ -30,16 +30,17 @@ import VideocamIcon from "@mui/icons-material/Videocam";
import ErrorOutlineIcon from "@mui/icons-material/ErrorOutline";
import CircleIcon from "@mui/icons-material/Circle";
import CancelIcon from "@mui/icons-material/Cancel";
import CheckCircleIcon from "@mui/icons-material/CheckCircle";
import FileDownloadOutlinedIcon from "@mui/icons-material/FileDownloadOutlined";
import { userAttendee } from "../User/userDataTypes";
import EventDisplayModal, {
InfoRow,
renderAttendeeBadge,
stringAvatar,
} from "./EventDisplay";
import { getEvent } from "./EventApi";
import { dlEvent, getEvent } from "./EventApi";
import { CalendarEvent } from "./EventsTypes";
import EventDuplication from "../../components/Event/EventDuplicate";
import { getCalendar } from "../Calendars/CalendarApi";
export default function EventPreviewModal({
eventId,
@@ -123,6 +124,27 @@ export default function EventPreviewModal({
gap: 1,
}}
>
{(window as any).DEBUG && (
<IconButton
onClick={async () => {
const icsContent = await dlEvent(event);
const blob = new Blob([icsContent], {
type: "text/calendar",
});
const url = URL.createObjectURL(blob);
const link = document.createElement("a");
link.href = url;
link.download = `${eventId}.ics`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
URL.revokeObjectURL(url);
}}
>
<FileDownloadOutlinedIcon />
</IconButton>
)}
<EventDuplication event={event} onClose={onClose} />
{mailSpaUrl && attendees.length > 0 && (
<IconButton