Calendar view: initial call of REPORT method.
authorArt Cancro <ajc@citadel.org>
Tue, 16 Apr 2024 23:25:41 +0000 (16:25 -0700)
committerArt Cancro <ajc@citadel.org>
Tue, 16 Apr 2024 23:29:25 +0000 (16:29 -0700)
Right now it's just a placeholder that outputs the raw XML to the screen.

Use the allprop tag

webcit-ng/static/js/view_calendar.js

index 786090aa6aec57a99cde57ffb4bc5a33d2485711..f5c53fc19b4142b2341712b4e60a1b1c75beb027 100644 (file)
@@ -8,20 +8,35 @@
 
 // RENDERER FOR THIS VIEW
 function view_render_calendar() {
-       fetch(
-               "/ctdl/r/" + escapeHTMLURI(current_room) + "/calendar::"
-       )
+
+       let options = {
+               method: "REPORT",
+               headers: {
+                       "Content-Type" : "application/xml; charset=utf-8"
+               },
+               body: `
+                       <CAL:calendar-query xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav">
+                               <allprop />
+                               <CAL:filter>
+                                       <CAL:comp-filter name="VCALENDAR">
+                                       <CAL:comp-filter name="VEVENT" />
+                                       </CAL:comp-filter>
+                               </CAL:filter>
+                       </CAL:calendar-query>
+               `
+       };
+
+       fetch("/ctdl/r/" + escapeHTMLURI(current_room), options)
        .then(response => {
                if (response.ok) {
-                       return(response.json());
+                       return(response.text());
                }
                else {
                        throw new Error(`${response.status} ${response.statusText}`);
                }
        })
-       .then(j => {
-               document.getElementById("ctdl-main").innerHTML = JSON.stringify(j);
-       })
+       //.then(str => new window.DOMParser().parseFromString(str, "text/xml"))
+       .then(str => document.getElementById("ctdl-main").innerHTML = escapeHTML(str))
        .catch(error => {
                console.log(error);
                document.getElementById("ctdl-main").innerHTML = `<div class="ctdl-fatal-error">${error}</div>`;