diff --git a/corn-frontend/src/app/pages/boards/sidebar-button/sidebar-button.component.html b/corn-frontend/src/app/pages/boards/sidebar-button/sidebar-button.component.html index 51fd2817..7d5ca6e8 100644 --- a/corn-frontend/src/app/pages/boards/sidebar-button/sidebar-button.component.html +++ b/corn-frontend/src/app/pages/boards/sidebar-button/sidebar-button.component.html @@ -1,5 +1,5 @@ \ No newline at end of file diff --git a/corn-frontend/src/app/pages/boards/timeline/timeline.component.html b/corn-frontend/src/app/pages/boards/timeline/timeline.component.html index 97b9ee7d..e096db2a 100644 --- a/corn-frontend/src/app/pages/boards/timeline/timeline.component.html +++ b/corn-frontend/src/app/pages/boards/timeline/timeline.component.html @@ -1 +1,23 @@ -

Timeline

+
Timeline
+ +
+
+ +

{{ currentMonth | date: 'MMMM yyyy' }}

+ +
+
+
{{ day }}
+
+
+ +
+
{{ date.day }}
+
+
+
+
diff --git a/corn-frontend/src/app/pages/boards/timeline/timeline.component.ts b/corn-frontend/src/app/pages/boards/timeline/timeline.component.ts index 9505c29e..7dfc8e8f 100644 --- a/corn-frontend/src/app/pages/boards/timeline/timeline.component.ts +++ b/corn-frontend/src/app/pages/boards/timeline/timeline.component.ts @@ -1,10 +1,80 @@ -import { Component } from '@angular/core'; +import { Component, OnInit } from '@angular/core'; +import { DatePipe, NgForOf } from "@angular/common"; +import { CommonModule } from '@angular/common'; +import { MatIcon} from "@angular/material/icon"; +import { NgIcon, provideIcons } from "@ng-icons/core"; +import { matArrowBack, matArrowForward } from "@ng-icons/material-icons/baseline"; + +interface Week { + days: Day[] +} + +interface Day { + day: number | undefined, + month: number +} @Component({ selector: 'app-timeline', standalone: true, - imports: [], + imports: [ + DatePipe, + NgForOf, + CommonModule, + MatIcon, + NgIcon, + ], templateUrl: './timeline.component.html', + viewProviders: [provideIcons({ + matArrowForward, + matArrowBack, + })] }) export class TimelineComponent { + currentMonth: Date = new Date(); + days: string[] = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']; + weeks: Week[] = []; + + constructor() { } + + ngOnInit(): void { + this.generateCalendar(); } + generateCalendar(): void { + const startDate = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth(), 1); + const endDate = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + 1, 0); + const numDays = endDate.getDate(); + const startDay = startDate.getDay(); + + let dateCounter = 1; + for (let i = 0; i < 6; i++) { + const week : Week = { + days: [] + }; + for (let j = 0; j < 7; j++) { + if ((i === 0 && j < startDay) || dateCounter > numDays) { + week.days.push({ day: undefined, month: -1 }); + } else { + week.days.push({ day: dateCounter, month: this.currentMonth.getMonth() + 1 }); + dateCounter++; + } + } + this.weeks.push(week); + } + } + + prevMonth(): void { + this.currentMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() - 1); + this.resetCalendar(); + } + + nextMonth(): void { + this.currentMonth = new Date(this.currentMonth.getFullYear(), this.currentMonth.getMonth() + 1); + this.resetCalendar(); + } + + resetCalendar(): void { + this.weeks = []; + this.generateCalendar(); + } +} \ No newline at end of file diff --git a/corn-frontend/src/app/pages/home/home.component.html b/corn-frontend/src/app/pages/home/home.component.html index 188802b5..a1c9a10c 100644 --- a/corn-frontend/src/app/pages/home/home.component.html +++ b/corn-frontend/src/app/pages/home/home.component.html @@ -6,13 +6,13 @@ - -