From 3e33f10ea55ae8294a6e8bd620f9665619a79799 Mon Sep 17 00:00:00 2001 From: "D. Berge" Date: Sun, 29 Oct 2023 11:53:24 +0100 Subject: [PATCH] Add download control to Calendar view. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Will download the event log for the currently selected calendar period (day, week, month, …) in a choice of formats. --- lib/www/client/source/src/views/Calendar.vue | 87 ++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/lib/www/client/source/src/views/Calendar.vue b/lib/www/client/source/src/views/Calendar.vue index 1694f09..2de8f0f 100644 --- a/lib/www/client/source/src/views/Calendar.vue +++ b/lib/www/client/source/src/views/Calendar.vue @@ -37,7 +37,65 @@ {{ $refs.calendar.title }} + + + ({{downloadableItemCount}} log entries) + + + + + + + Seis+JSON + + JSON + YAML + CSV + + + + i.category ?? "General"))]; }, + calendarDates () { + // The this.items.length reference is only needed to force recalculation + // of this computed property, as this.$refs is not reactive. + // https://github.com/vuejs/vue/issues/3842 + if (this.items.length && this.$refs.calendar) { + return { + start: this.$refs.calendar.renderProps.start.date, + end: this.$refs.calendar.renderProps.end.date + } + } + }, + + downloadableItemCount () { + return this.events.filter(i => i.tstamp.substr(0, 10) >= this.calendarDates?.start && + i.tstamp.substr(0, 10) <= this.calendarDates?.end).length; + }, + ...mapGetters(['sequencesLoading', 'sequences', 'events']) }, @@ -298,6 +373,18 @@ export default { }; }, + downloadUrl (qry) { + if (this.calendarDates) { + const url = new URL(`/api/project/${this.$route.params.project}/event`, document.location.href); + for (const key in qry) { + url.searchParams.set(key, qry[key]); + } + url.searchParams.set("date0", this.calendarDates.start); + url.searchParams.set("date1", this.calendarDates.end); + return url.toString(); + } + }, + ...mapActions(["api"])