diff --git a/front/src/components/AttendanceGraph.vue b/front/src/components/AttendanceGraph.vue index a9a3221..2a0c379 100644 --- a/front/src/components/AttendanceGraph.vue +++ b/front/src/components/AttendanceGraph.vue @@ -1,52 +1,118 @@ diff --git a/front/src/models/AttendanceGraph.ts b/front/src/models/AttendanceGraph.ts new file mode 100644 index 0000000..3db1b6a --- /dev/null +++ b/front/src/models/AttendanceGraph.ts @@ -0,0 +1,28 @@ +import type {Event} from "@/models/Event.ts"; +import type {Attendee} from "@/models/Attendee.ts"; + +export class AttendanceGraph { + + private event: Event; + private maxAttendees: number; + + public constructor(event : Event) { + this.event = event; + this.maxAttendees = event.getMaxAttendees(); + console.log(this.maxAttendees); + } + + + public getDates() : number[] { + return Array.from(this.event.getDates()); + } + + public getAttendees(date : number): Attendee[] { + return this.event.getAttendees(date); + } + + public getRatio(date : number) : number{ + return (this.getAttendees(date).length / this.maxAttendees); + } + +} diff --git a/front/src/models/Event.ts b/front/src/models/Event.ts index 0ff1e12..0d3f120 100644 --- a/front/src/models/Event.ts +++ b/front/src/models/Event.ts @@ -21,19 +21,25 @@ export class Event { return this.token; } - public getAttendances() : Map { - return this.attendances; + public getDates() : number[] { + return Array.from(this.attendances.keys()).sort(); } - public getDates() : {dates : string[], attendances : number[]}{ - let dates = []; - let attendances = []; - for (let [date, attendees] of this.attendances.entries()) { - dates.push(DateHelper.formatDate(date)) - attendances.push(attendees.length) + public getAttendees(date : number) : Attendee[] { + if(this.attendances.has(date)){ + return this.attendances.get(date)!; //Fuck TS } - return {dates : dates, attendances : attendances}; + return []; } + + public getMaxAttendees(){ + let max = 0; + this.attendances.forEach(attendee => { + if(attendee.length > max) max = attendee.length; + }) + return max; + } + } export interface EventState { diff --git a/front/src/views/EventView.vue b/front/src/views/EventView.vue index b41e2dc..016dc3b 100644 --- a/front/src/views/EventView.vue +++ b/front/src/views/EventView.vue @@ -6,6 +6,7 @@ import {DateHelper} from "@/helpers/DateHelper.ts"; import {Event} from "@/models/Event.ts"; import ErrorBlock from "@/components/ErrorBlock.vue"; import AttendanceGraph from "@/components/AttendanceGraph.vue"; +import Calendar from "@/components/Calendar.vue"; const route = useRoute(); const store = eventCreationStore(); @@ -30,33 +31,39 @@ function extractToken() : string { diff --git a/front/src/views/JoinView.vue b/front/src/views/JoinView.vue index 6ed6d23..efe8a32 100644 --- a/front/src/views/JoinView.vue +++ b/front/src/views/JoinView.vue @@ -32,7 +32,6 @@ const token = ref(""); min-width: 300px; } - .actions-group { min-height: 250px; }