Add sorting options
Jenkins Production Deployment

This commit is contained in:
2022-12-28 15:00:56 +01:00
parent 1990c9a42d
commit 8fa2b8cb5f
2 changed files with 33 additions and 4 deletions
+25 -3
View File
@@ -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;
})
}
}