Change mining profiles to be ordered by date descending.

This commit is contained in:
kostis30fyllou 2019-09-10 15:00:48 +03:00
parent 449ee0f782
commit 52645fc89d
1 changed files with 14 additions and 2 deletions

View File

@ -71,7 +71,7 @@ export class ManageprofilesComponent implements OnInit {
this.manageProfilesService.getUsersProfiles()
.subscribe(res => {
if (res) {
this.allUsersProfiles = res;
this.allUsersProfiles = res.sort(this.sortByDate);
}
});
}
@ -80,7 +80,7 @@ export class ManageprofilesComponent implements OnInit {
this.manageProfilesService.getSavedProfiles()
.subscribe(res => {
if (res) {
this.userSavedProfiles = res;
this.userSavedProfiles = res.sort(this.sortByDate);
}
});
}
@ -92,6 +92,18 @@ export class ManageprofilesComponent implements OnInit {
});
}
private sortByDate(a: any, b: any): number {
const aDate = new Date(a.datecreated);
const bDate = new Date(b.datecreated);
if (aDate.getTime() > bDate.getTime()) {
return -1;
} else if (aDate.getTime() < bDate.getTime()) {
return 1;
} else {
return 0;
}
}
private clearLocalStorage(): void {
// clear localstorage values
localStorage.removeItem('grants');