Skip to content

Commit 7b9d086

Browse files
authored
Merge pull request #21635 from itisAliRH/init-g-table-component
Introduce reusable GTable component
2 parents 2f77271 + 5b74186 commit 7b9d086

File tree

12 files changed

+1277
-307
lines changed

12 files changed

+1277
-307
lines changed

client/src/api/datasets.ts

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,54 @@ import {
66
GalaxyApi,
77
type GalaxyApiPaths,
88
type HDADetailed,
9+
type HDASummary,
910
} from "@/api";
1011
import { withPrefix } from "@/utils/redirect";
1112
import { rethrowSimple } from "@/utils/simple-error";
1213

14+
export interface LoadDatasetsOptions {
15+
limit?: number;
16+
offset?: number;
17+
sortBy?: string;
18+
sortDesc?: boolean;
19+
search?: string;
20+
}
21+
22+
export interface LoadDatasetsResult {
23+
data: HDASummary[];
24+
totalMatches: number;
25+
}
26+
27+
export async function loadDatasets(options: LoadDatasetsOptions): Promise<LoadDatasetsResult> {
28+
const { limit = 24, offset = 0, sortBy = "update_time", sortDesc = true, search = "" } = options;
29+
30+
const {
31+
response,
32+
data: datasets,
33+
error,
34+
} = await GalaxyApi().GET("/api/datasets", {
35+
params: {
36+
query: {
37+
q: search ? ["name-contains"] : undefined,
38+
qv: search ? [search] : undefined,
39+
limit,
40+
offset,
41+
order: `${sortBy}${sortDesc ? "-dsc" : "-asc"}`,
42+
view: "summary",
43+
},
44+
},
45+
});
46+
47+
if (error) {
48+
rethrowSimple(error);
49+
}
50+
51+
const totalMatches = parseInt(response.headers.get("total_matches") ?? "0", 10) || 0;
52+
const data = datasets as unknown as HDASummary[];
53+
54+
return { data, totalMatches };
55+
}
56+
1357
export async function fetchDatasetTextContentDetails(params: { id: string }): Promise<DatasetTextContentDetails> {
1458
const { data, error } = await GalaxyApi().GET("/api/datasets/{dataset_id}/get_content_as_text", {
1559
params: {
@@ -56,11 +100,11 @@ export async function undeleteDataset(datasetId: string) {
56100
return data;
57101
}
58102

59-
export async function purgeDataset(datasetId: string) {
103+
export async function deleteDataset(datasetId: string, purge: boolean = false) {
60104
const { data, error } = await GalaxyApi().DELETE("/api/datasets/{dataset_id}", {
61105
params: {
62106
path: { dataset_id: datasetId },
63-
query: { purge: true },
107+
query: { purge },
64108
},
65109
});
66110
if (error) {
@@ -69,6 +113,10 @@ export async function purgeDataset(datasetId: string) {
69113
return data;
70114
}
71115

116+
export async function purgeDataset(datasetId: string) {
117+
return deleteDataset(datasetId, true);
118+
}
119+
72120
type CopyDatasetParamsType = GalaxyApiPaths["/api/histories/{history_id}/contents/{type}s"]["post"]["parameters"];
73121
type CopyDatasetBodyType = components["schemas"]["CreateHistoryContentPayload"];
74122

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
import type { SizeProp } from "@fortawesome/fontawesome-svg-core";
2+
import type { IconDefinition } from "@fortawesome/free-solid-svg-icons";
3+
4+
import type { BootstrapVariant } from "@/components/Common";
5+
6+
/** Bootstrap component sizes */
7+
export type BootstrapSize = "xs" | "sm" | "md" | "lg" | "xl";
8+
9+
/** Table field sorting order */
10+
export type SortOrder = "asc" | "desc";
11+
12+
/** Table field alignment options */
13+
export type FieldAlignment = "left" | "center" | "right";
14+
15+
/** Table field definition */
16+
export interface TableField {
17+
/** Unique key for the field (matches data property name) */
18+
key: string;
19+
/** Display label for the column header */
20+
label?: string;
21+
/** Whether the column is sortable */
22+
sortable?: boolean;
23+
/** Custom CSS classes for the column */
24+
class?: string;
25+
/** Custom CSS classes for the header cell */
26+
headerClass?: string;
27+
/** Custom CSS classes for data cells */
28+
cellClass?: string;
29+
/** Column alignment */
30+
align?: FieldAlignment;
31+
/** Width of the column (CSS value) */
32+
width?: string;
33+
/** Whether to hide the column on small screens */
34+
hideOnSmall?: boolean;
35+
/** Custom formatter function for cell values */
36+
formatter?: (value: any, key: string, item: any) => string;
37+
}
38+
39+
/** Sort change event payload */
40+
export interface SortChangeEvent {
41+
/** The field key being sorted */
42+
sortBy: string;
43+
/** Whether sorting in descending order */
44+
sortDesc: boolean;
45+
}
46+
47+
/** Row click event payload */
48+
export interface RowClickEvent<T = any> {
49+
/** The row item data */
50+
item: T;
51+
/** The row index */
52+
index: number;
53+
/** The original mouse/keyboard event */
54+
event: MouseEvent | KeyboardEvent;
55+
}
56+
57+
/** Row selection event payload */
58+
export interface RowSelectEvent<T = any> {
59+
/** The selected row item */
60+
item: T;
61+
/** The row index */
62+
index: number;
63+
/** Whether the row is now selected */
64+
selected: boolean;
65+
}
66+
67+
/** Table action button configuration */
68+
export interface TableAction {
69+
/** Unique identifier for the action */
70+
id: string;
71+
/** Display label for the action */
72+
label: string;
73+
/** Tooltip text */
74+
title: string;
75+
/** FontAwesome icon */
76+
icon?: IconDefinition;
77+
/** Bootstrap variant */
78+
variant?: BootstrapVariant;
79+
/** Whether the action is disabled */
80+
disabled?: boolean;
81+
/** Whether the action is visible */
82+
visible?: boolean;
83+
/** Bootstrap component size */
84+
size?: BootstrapSize;
85+
/** Vue Router route to navigate to */
86+
to?: string;
87+
/** Hyperlink reference */
88+
href?: string;
89+
/** Link target attribute */
90+
target?: string;
91+
/** Whether link opens in new tab/window */
92+
externalLink?: boolean;
93+
/** Click handler function */
94+
handler?: (item: any, index: number) => void;
95+
}
96+
97+
/** Empty state configuration */
98+
export interface TableEmptyState {
99+
/** Message to display when no data */
100+
message: string;
101+
/** Optional icon to display */
102+
icon?: IconDefinition;
103+
/** Bootstrap variant for styling */
104+
variant?: BootstrapVariant;
105+
}
106+
107+
/** Row status icon configuration */
108+
export interface RowIcon {
109+
/** FontAwesome icon (required) */
110+
icon: IconDefinition;
111+
/** Additional CSS classes */
112+
class?: string;
113+
/** Icon size (FontAwesome SizeProp) */
114+
size?: SizeProp;
115+
/** Tooltip text */
116+
title?: string;
117+
/** Whether icon should spin (loading state) */
118+
spin?: boolean;
119+
}

0 commit comments

Comments
 (0)