-
Notifications
You must be signed in to change notification settings - Fork 23
feat: up-879: Datasets improvements fixed #411
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
base: main
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,7 +95,9 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| this.pageSize, | ||
| this.currentPage - 1 | ||
| ); | ||
| this.objects = result.objects; | ||
| this.objects = ECCClientGa4ghDrsObjects.sortObjectsByLastUpdated( | ||
| result.objects | ||
| ); | ||
|
|
||
| // Update total objects and pages from API response | ||
| if (result.pagination?.total !== undefined) { | ||
|
|
@@ -166,6 +168,17 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| this.loadData(); | ||
| } | ||
|
|
||
| private static sortObjectsByLastUpdated(objects: DrsObject[]): DrsObject[] { | ||
| return [...objects].sort((a, b) => { | ||
| // Use updated_time if available, otherwise fall back to created_time | ||
| const aTime = a.updated_time || a.created_time; | ||
| const bTime = b.updated_time || b.created_time; | ||
|
|
||
| // Sort in reverse chronological order (most recent first) | ||
| return new Date(bTime).getTime() - new Date(aTime).getTime(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue: Consider handling missing/invalid timestamps more defensively in the sort comparator. If |
||
| }); | ||
| } | ||
|
|
||
| private renderPagination() { | ||
| return html` | ||
| <ecc-utils-design-pagination> | ||
|
|
@@ -299,7 +312,7 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| .map( | ||
| () => html` | ||
| <ecc-utils-design-table-row> | ||
| <ecc-utils-design-table-cell class="w-6/12"> | ||
| <ecc-utils-design-table-cell class="w-5/12"> | ||
| <div class="flex flex-col w-full gap-2"> | ||
| <ecc-utils-design-skeleton | ||
| class="part:h-5 part:w-40" | ||
|
|
@@ -317,14 +330,14 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| class="part:h-4 part:w-20" | ||
| ></ecc-utils-design-skeleton> | ||
| </ecc-utils-design-table-cell> | ||
| <ecc-utils-design-table-cell class="w-2/12"> | ||
| <ecc-utils-design-table-cell class="w-2.5/12"> | ||
| <ecc-utils-design-skeleton | ||
| class="part:h-4 part:w-24" | ||
| ></ecc-utils-design-skeleton> | ||
| </ecc-utils-design-table-cell> | ||
| <ecc-utils-design-table-cell class="w-2/12"> | ||
| <ecc-utils-design-table-cell class="w-2.5/12"> | ||
| <ecc-utils-design-skeleton | ||
| class="part:h-8 part:w-8 part:rounded" | ||
| class="part:h-4 part:w-24" | ||
| ></ecc-utils-design-skeleton> | ||
| </ecc-utils-design-table-cell> | ||
| </ecc-utils-design-table-row> | ||
|
|
@@ -341,9 +354,17 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| return `${parseFloat((bytes / k ** i).toFixed(2))} ${sizes[i]}`; | ||
| } | ||
|
|
||
| private static formatDate(dateString: string): string { | ||
| private static formatDateTime(dateString: string): string { | ||
| try { | ||
| return new Date(dateString).toLocaleDateString(); | ||
| return new Date(dateString).toLocaleString("en-US", { | ||
| year: "numeric", | ||
| month: "2-digit", | ||
| day: "2-digit", | ||
| hour: "2-digit", | ||
| minute: "2-digit", | ||
| second: "2-digit", | ||
| hour12: false, | ||
| }); | ||
| } catch { | ||
| return dateString; | ||
| } | ||
|
|
@@ -403,18 +424,18 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| <ecc-utils-design-table> | ||
| <ecc-utils-design-table-header> | ||
| <ecc-utils-design-table-row> | ||
| <ecc-utils-design-table-head class="w-6/12" | ||
| <ecc-utils-design-table-head class="w-5/12" | ||
| >Object Info</ecc-utils-design-table-head | ||
| > | ||
| <ecc-utils-design-table-head class="w-2/12" | ||
| >Size</ecc-utils-design-table-head | ||
| > | ||
| <ecc-utils-design-table-head class="w-2/12" | ||
| <ecc-utils-design-table-head class="w-2.5/12" | ||
| >Created</ecc-utils-design-table-head | ||
| > | ||
| <ecc-utils-design-table-head | ||
| class="w-2/12" | ||
| ></ecc-utils-design-table-head> | ||
| <ecc-utils-design-table-head class="w-2.5/12" | ||
| >Last Updated</ecc-utils-design-table-head | ||
| > | ||
| </ecc-utils-design-table-row> | ||
| </ecc-utils-design-table-header> | ||
| <ecc-utils-design-table-body> | ||
|
|
@@ -426,7 +447,7 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| return html` | ||
| <ecc-utils-design-table-row> | ||
| <ecc-utils-design-table-cell | ||
| colspan="5" | ||
| colspan="4" | ||
| class="part:text-center part:py-8 part:text-muted-foreground" | ||
| > | ||
| No objects found | ||
|
|
@@ -437,7 +458,7 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| return this.objects.map( | ||
| (object) => html` | ||
| <ecc-utils-design-table-row> | ||
| <ecc-utils-design-table-cell class="w-6/12"> | ||
| <ecc-utils-design-table-cell class="w-5/12"> | ||
| <div class="flex flex-col w-full"> | ||
| <ecc-utils-design-button | ||
| class="part:font-medium part:text-primary part:w-fit part:cursor-pointer part:p-0" | ||
|
|
@@ -467,22 +488,19 @@ export class ECCClientGa4ghDrsObjects extends LitElement { | |
| )}</span | ||
| > | ||
| </ecc-utils-design-table-cell> | ||
| <ecc-utils-design-table-cell class="w-2/12"> | ||
| <ecc-utils-design-table-cell class="w-2.5/12"> | ||
| <span class="text-sm" | ||
| >${ECCClientGa4ghDrsObjects.formatDate( | ||
| >${ECCClientGa4ghDrsObjects.formatDateTime( | ||
| object.created_time | ||
| )}</span | ||
| > | ||
| </ecc-utils-design-table-cell> | ||
| <ecc-utils-design-table-cell class="w-2/12"> | ||
| <slot name=${`actions-${object.id}`}> | ||
| <ecc-utils-design-button | ||
| size="sm" | ||
| @click=${() => this.handleObjectSelect(object.id)} | ||
| > | ||
| View Details | ||
| </ecc-utils-design-button> | ||
| </slot> | ||
| <ecc-utils-design-table-cell class="w-2.5/12"> | ||
| <span class="text-sm" | ||
| >${ECCClientGa4ghDrsObjects.formatDateTime( | ||
| object.updated_time || object.created_time | ||
| )}</span | ||
| > | ||
| </ecc-utils-design-table-cell> | ||
| </ecc-utils-design-table-row> | ||
| ` | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is incorrect as the sorting should be handled on the backend.