Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordering events by previous and upcoming #243

Merged
merged 9 commits into from
Apr 28, 2023
9 changes: 9 additions & 0 deletions frontend/src/app/events/events.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@
box-shadow: 0px 0px 5px #8c8c8c;
}


.centered-lists {
z-index: 0;
position:relative;
display: flex;
flex-direction: column;
align-items: center;
}

.logo {
width: 50px;
height: 50px;
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/app/events/events.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<tr *ngFor="let user_event of user_events$ | async">
<div style="position: relative">
<mat-card style="width:1750px; height: 200px;">
<mat-card style="width:1750px;">
<mat-card-header>
<div class="'event-name-join-button">
<mat-card-title>{{ user_event.event.name }}</mat-card-title>
Expand All @@ -34,11 +34,6 @@
</div>
<div>
<div class="side-buttons">
<mat-card-actions>
<a mat-list-item class="logo-item">
<img class="logo" [src]="'assets/' + user_event.event.club_name + '.png'" onerror="this.style.display='none';" />
</a>
</mat-card-actions>
<mat-card-actions>
<button mat-raised-button *ngIf="user_event.is_joined; else elseBlock" (click)='changeStatus(user_event)'>Cancel Registration</button>
<ng-template #elseBlock>
Expand Down
20 changes: 19 additions & 1 deletion frontend/src/app/events/events.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@ import { HttpClient } from '@angular/common/http';
import { Component } from '@angular/core';
import { Observable, map } from 'rxjs';
import { Event, User_Event, EventService } from '../event.service'
import { ActivatedRoute, Route } from '@angular/router';
import { ActivatedRoute, ChildActivationStart, Route } from '@angular/router';
import { isAuthenticated } from '../gate/gate.guard';
import { profileResolver } from '../profile/profile.resolver';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Profile, ProfileService } from '../profile/profile.service';
import * as moment from 'moment' ;

@Component({
selector: 'app-events',
Expand All @@ -28,6 +29,7 @@ export class EventsComponent {
public events$: Observable<Event[]>
public user_events$: Observable<User_Event[]>
public searchText = ''
public currentDate = new Date()

constructor(route: ActivatedRoute, private eventService: EventService, private profileService: ProfileService, private http: HttpClient, protected snackBar: MatSnackBar) {
const data = route.snapshot.data as { profile: Profile }
Expand Down Expand Up @@ -153,4 +155,20 @@ export class EventsComponent {
})
}))
}

compareDateGreaterThanNow(date: Date): boolean {
if (moment(date).isAfter(Date())) {
return true
}
else return false
}

compareDateLessThanNow(date: Date): boolean {
console.log("This is the moment of event date" + moment(date))
console.log("This is true/false of current date grateer than event date:" + moment(date).isAfter(Date()))
if (moment(date).isAfter(Date())) {
return false
}
else return true
}
}
119 changes: 84 additions & 35 deletions frontend/src/app/manage-events/manage-events.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,43 +9,92 @@
</ng-container>
<ng-template #list>
<div class="centered-lists">
<mat-card-title style="margin-top: 25px">Upcoming</mat-card-title>
<tr *ngFor="let event of events">
<div style="position: relative">
<mat-card style="width:1750px;">
<mat-card-header>
<div class="'event-name-join-button">
<mat-card-title>{{ event.name }}</mat-card-title>
</div>
</mat-card-header>
<hr>
<mat-card-content>
<div class='description'>
{{ event.show_short_description ? getShortDescription(event) : event.description }}
</div>
<div class="side-buttons">
<mat-card-actions>
<button mat-raised-button (click)='onDelete(event)' type="submit">
{{ "Delete Event" }}
</button>
</mat-card-actions>
<mat-card-actions>
<button mat-raised-button (click)='alterText(event)' type="submit">
{{ event.show_short_description ? "Read More" : "Read Less" }}
</button>
</mat-card-actions>
</div>
<br>
<div class="time-place">
<span style="font-size: 14px">When: {{ event.start_time | date: 'MMM d, y, h:mm a' }} - {{ event.end_time | date: 'MMM d, y, h:mm a' }}</span>
<span style="font-size: 14px">Where: {{ event.location }}</span>
<ng-container *ngIf="compareDateGreaterThanNow(event.start_time);">
<div style="position: relative">
<mat-card style="width:1750px;">
<mat-card-header>
<div class="'event-name-join-button">
<mat-card-title>{{ event.name }}</mat-card-title>
</div>
</mat-card-header>
<mat-card-content>
<div class='description'>
{{ event.show_short_description ? getShortDescription(event) : event.description }}
</div>
<div class="side-buttons">
<mat-card-actions>
<button mat-raised-button (click)='onDelete(event)' type="submit">
{{ "Delete Event" }}
</button>
</mat-card-actions>
<mat-card-actions>
<button mat-raised-button (click)='alterText(event)' type="submit">
{{ event.show_short_description ? "Read More" : "Read Less" }}
</button>
</mat-card-actions>
</div>
<br>
<span style="font-size: 16px">{{ event.attendees }}</span>
</div>
</mat-card-content>
</mat-card>
</div>
<div class="time-place">
<span style="font-size: 14px">When: {{ event.start_time | date: 'MMM d, y, h:mm a' }} - {{ event.end_time | date: 'MMM d, y, h:mm a' }}</span>
<span style="font-size: 14px">Where: {{ event.location }}</span>
<br>
<span style="font-size: 16px">{{ event.attendees }}</span>
</div>
</mat-card-content>
</mat-card>
</div>
</ng-container>
</tr>
<ng-container *ngIf="upcoming_events.length === 0;">
<div style="display: flex;flex-direction:row; margin-bottom: 20px">
<mat-card-subtitle>Your clubs have no upcoming events. <a style="color: #c7c7c7" routerLink="/registerevents">Register an Event</a> for your club now. </mat-card-subtitle>
</div>
</ng-container>
<mat-card-title>Previous</mat-card-title>
<tr *ngFor="let event of events">
<ng-container *ngIf="compareDateLessThanNow(event.start_time);">
<div style="position: relative">
<mat-card style="width:1750px;">
<mat-card-header>
<div class="'event-name-join-button">
<mat-card-title>{{ event.name }}</mat-card-title>
</div>
</mat-card-header>
<mat-card-content>
<div class='description'>
{{ event.show_short_description ? getShortDescription(event) : event.description }}
</div>
<div class="side-buttons">
<mat-card-actions>
<button mat-raised-button (click)='onDelete(event)' type="submit">
{{ "Delete Event" }}
</button>
</mat-card-actions>
<mat-card-actions>
<button mat-raised-button (click)='alterText(event)' type="submit">
{{ event.show_short_description ? "Read More" : "Read Less" }}
</button>
</mat-card-actions>
</div>
<br>
<div class="time-place">
<span style="font-size: 14px">When: {{ event.start_time | date: 'MMM d, y, h:mm a' }} - {{ event.end_time | date: 'MMM d, y, h:mm a' }}</span>
<span style="font-size: 14px">Where: {{ event.location }}</span>
<br>
<span style="font-size: 16px">{{ event.attendees }}</span>
</div>
</mat-card-content>
</mat-card>
</div>
</ng-container>
</tr>
<ng-container *ngIf="previous_events.length === 0;">
<div style="display: flex;flex-direction:row">
<mat-card-subtitle>Your clubs have no previous events.</mat-card-subtitle>
</div>
</ng-container>
</div>
</ng-template>
</div>

</div>
18 changes: 18 additions & 0 deletions frontend/src/app/manage-events/manage-events.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { profileResolver } from '../profile/profile.resolver';
import { Event, EventService } from '../event.service';
import { MatSnackBar } from '@angular/material/snack-bar';
import { Observable } from 'rxjs';
import * as moment from 'moment' ;

@Component({
selector: 'app-manage-events',
Expand All @@ -21,6 +22,8 @@ export class ManageEventsComponent {
};

public club_events$: Observable<Event[]>
public previous_events: Date[] = []
public upcoming_events: Date[] = []

constructor(private eventService: EventService, protected snackBar: MatSnackBar) {
// TODO: get events by club not just all events
Expand Down Expand Up @@ -59,4 +62,19 @@ export class ManageEventsComponent {
}
}

compareDateGreaterThanNow(date: Date): boolean {
if (moment(date).isAfter(Date())) {
this.upcoming_events.push(date)
return true
}
else return false
}

compareDateLessThanNow(date: Date): boolean {
if (moment(date).isAfter(Date())) {
return false
}
this.previous_events.push(date)
return true
}
}
2 changes: 1 addition & 1 deletion frontend/src/app/my-events/my-events.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<div class="centered-lists">
<tr *ngFor="let event of events">
<div style="position: relative">
<mat-card style="width:1750px; height: 200px; ">
<mat-card style="width:1750px;">
<mat-card-header>
<div class="'event-name-join-button">
<mat-card-title>{{ event.name }}</mat-card-title>
Expand Down
19 changes: 19 additions & 0 deletions frontend/src/app/my-events/my-events.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Profile } from '../profile/profile.service';
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Observable, map } from 'rxjs';
import { MatSnackBar } from '@angular/material/snack-bar';
import * as moment from 'moment' ;

@Component({
selector: 'app-my-events',
Expand All @@ -26,6 +27,8 @@ export class MyEventsComponent {
public my_events$: Observable<Event[]>
public my_events_shown$: Observable<Event[]>
public searchText = ''
public previous_events: Date[] = []
public upcoming_events: Date[] = []

constructor(private eventService: EventService, route: ActivatedRoute, private http: HttpClient, protected snackBar: MatSnackBar) {
this.my_events$ = eventService.getMyEvents()
Expand Down Expand Up @@ -76,4 +79,20 @@ export class MyEventsComponent {
this.searchText = ''
this.my_events_shown$ = this.my_events$.pipe(map((events: Event[]) => {return events.map(event => {return {...event, show_short_description: true}})}))
}

compareDateGreaterThanNow(date: Date): boolean {
if (moment(date).isAfter(Date())) {
this.upcoming_events.push(date)
return true
}
else return false
}

compareDateLessThanNow(date: Date): boolean {
if (moment(date).isAfter(Date())) {
return false
}
this.previous_events.push(date)
return true
}
}