diff --git a/src/app/pages/admin/admin.component.html b/src/app/pages/admin/admin.component.html
index b038023..4f0bd67 100644
--- a/src/app/pages/admin/admin.component.html
+++ b/src/app/pages/admin/admin.component.html
@@ -17,10 +17,17 @@
|
Filter:
+ |
+ Sorting:
+
diff --git a/src/app/pages/admin/admin.component.ts b/src/app/pages/admin/admin.component.ts
index 2990e21..372287b 100644
--- a/src/app/pages/admin/admin.component.ts
+++ b/src/app/pages/admin/admin.component.ts
@@ -15,7 +15,8 @@ export class AdminComponent implements OnInit {
selectedCalendar: string = '';
password: string = '';
name: string = '';
- eventFilter: string = '';
+ eventFilter: string = 'all';
+ eventSorting: string = 'start_asc';
constructor(
private api: ApiService
@@ -46,9 +47,10 @@ export class AdminComponent implements OnInit {
startDateTime: new Date(event.startDateTime),
endDateTime: new Date(event.endDateTime),
createdDate: new Date(event.createdDate)
- })
+ });
}
- })
+ this.sortEvents();
+ });
}
login(): void {
@@ -101,4 +103,24 @@ export class AdminComponent implements OnInit {
getUserName(): string {
return UtilsService.getNameFromLocalStorage();
}
+
+ sortEvents(): void {
+ this.events.sort((a,b) => {
+ switch (this.eventSorting) {
+ case '':
+ return 1;
+ case 'start_asc':
+ return a.startDateTime > b.startDateTime ? 1 : -1;
+ case 'start_desc':
+ return a.startDateTime > b.startDateTime ? -1 : 1;
+ case 'created_asc':
+ return a.createdDate > b.createdDate ? 1 : -1;
+ case 'created_desc':
+ return a.createdDate > b.createdDate ? -1 : 1;
+ default:
+ return 1;
+ }
+ return 1;
+ })
+ }
}