Skip to content

Commit

Permalink
use GET query instead of post with only type as path param
Browse files Browse the repository at this point in the history
  • Loading branch information
bilalesi committed Oct 28, 2024
1 parent 7ac2d3e commit 4fb8f51
Show file tree
Hide file tree
Showing 11 changed files with 370 additions and 172 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{
"editor.formatOnSave": true,
"files.eol": "\n"
"files.eol": "\n",
"files.watcherExclude": {
"**/target": true
}
}
Binary file added cypress/downloads/downloads.html
Binary file not shown.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"dependencies": {
"@ant-design/charts": "^1.3.4",
"@ant-design/icons": "^4.4.0",
"@aws-crypto/sha1-browser": "^5.2.0",
"@bbp/nexus-sdk": "1.3.15",
"@bbp/react-nexus": "1.3.15",
"@reduxjs/toolkit": "^1.8.5",
Expand Down Expand Up @@ -148,6 +149,7 @@
"redux-thunk": "^2.3.0",
"resize-observer-polyfill": "^1.5.1",
"showdown": "^1.9.1",
"sparqljs": "^3.7.1",
"string-similarity": "^4.0.4",
"ts-debounce": "^1.0.0",
"ts-invariant": "^0.4.4",
Expand Down
1 change: 1 addition & 0 deletions r1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "detail": "Not Found" }
179 changes: 90 additions & 89 deletions src/shared/components/SparqlResultsTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const SparqlResultsTable: React.FunctionComponent<ResultTableProps> = ({
handleClick,
tableLabel,
}) => {
console.log('@@SparqlResultsTable',)
const [selectedColumns, setSelectedColumns] = React.useState<
HeaderProperties | undefined
>(headerProperties);
Expand All @@ -64,102 +65,102 @@ const SparqlResultsTable: React.FunctionComponent<ResultTableProps> = ({
const columnList = [
...(columnsToSelect
? columnsToSelect.map(({ title, dataIndex }) => {
// We can create special renderers for the cells here
let render;
switch (title) {
case 'Created At':
render = (date: string) => (
<span>
<FriendlyTimeAgo date={moment(date)} />
</span>
);
break;
case 'Project':
render = (projectURI: string) => {
if (projectURI) {
const [org, project] = parseProjectUrl(projectURI);
return (
<span>
<b>{org}</b> / {project}
</span>
);
}
return null;
};
break;
default:
render = (value: string) => {
const item = items.find(item => item[dataIndex] === value);
const studioResourceViewLink = item
? `/?_self=${item.self.value}`
: '';
if (isISODate(value)) {
return (
<a href={studioResourceViewLink}>
{getDateString(moment(value))}
</a>
);
}
// We can create special renderers for the cells here
let render;
switch (title) {
case 'Created At':
render = (date: string) => (
<span>
<FriendlyTimeAgo date={moment(date)} />
</span>
);
break;
case 'Project':
render = (projectURI: string) => {
if (projectURI) {
const [org, project] = parseProjectUrl(projectURI);
return (
<span>
<b>{org}</b> / {project}
</span>
);
}
return null;
};
break;
default:
render = (value: string) => {
const item = items.find(item => item[dataIndex] === value);
const studioResourceViewLink = item
? `/?_self=${item.self.value}`
: '';
if (isISODate(value)) {
return (
<a href={studioResourceViewLink}>
{getDateString(moment(value))}
</a>
);
}

return <a href={studioResourceViewLink}>{value}</a>;
};
return <a href={studioResourceViewLink}>{value}</a>;
};

break;
}
break;
}

const distinctValues = filteredItems.reduce((memo, item) => {
const value = item[dataIndex];
if (value && !memo.includes(value)) {
memo.push(value);
}
return memo;
}, [] as any[]);
const distinctValues = filteredItems.reduce((memo, item) => {
const value = item[dataIndex];
if (value && !memo.includes(value)) {
memo.push(value);
}
return memo;
}, [] as any[]);

const filterOptions =
distinctValues.length > MIN_FILTER_LIMIT &&
const filterOptions =
distinctValues.length > MIN_FILTER_LIMIT &&
distinctValues.length < MAX_FILTER_LIMIT
? {
filters: distinctValues.map(value => ({
value,
text: isISODate(value)
? getDateString(moment(value))
: value,
})),
filterMultiple: false,
filteredValue: filteredValues
? filteredValues[dataIndex]
: null,
onFilter: (filterValue: any, item: any) => {
return item[dataIndex] === filterValue;
},
}
: {};
return {
title,
dataIndex,
render,
className: `result-column ${dataIndex}`,
sorter: (
a: {
[key: string]: any;
? {
filters: distinctValues.map(value => ({
value,
text: isISODate(value)
? getDateString(moment(value))
: value,
})),
filterMultiple: false,
filteredValue: filteredValues
? filteredValues[dataIndex]
: null,
onFilter: (filterValue: any, item: any) => {
return item[dataIndex] === filterValue;
},
b: {
[key: string]: any;
}
) => {
const sortA = a[dataIndex];
const sortB = b[dataIndex];
if (sortA < sortB) {
return -1;
}
if (sortA > sortB) {
return 1;
}
return 0;
}
: {};
return {
title,
dataIndex,
render,
className: `result-column ${dataIndex}`,
sorter: (
a: {
[key: string]: any;
},
...filterOptions,
};
})
b: {
[key: string]: any;
}
) => {
const sortA = a[dataIndex];
const sortB = b[dataIndex];
if (sortA < sortB) {
return -1;
}
if (sortA > sortB) {
return 1;
}
return 0;
},
...filterOptions,
};
})
: []),
];

Expand Down
24 changes: 14 additions & 10 deletions src/shared/containers/DataTableContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ type DataTableProps = {
};
showEdit?: boolean;
toggledEdit?: (show: boolean) => void;
selectedWorkspace?: any
selectedDashboard?: any
};

export interface TableError {
Expand Down Expand Up @@ -137,6 +139,8 @@ const DataTableContainer: React.FC<DataTableProps> = ({
options,
showEdit,
toggledEdit,
selectedWorkspace,
selectedDashboard,
}) => {
const basePath =
useSelector((state: RootState) => state.config.basePath) || '';
Expand Down Expand Up @@ -334,7 +338,9 @@ const DataTableContainer: React.FC<DataTableProps> = ({
tableResourceId,
basePath,
err => setTableDataError(err),
changeTableResource.data
changeTableResource.data,
selectedWorkspace,
selectedDashboard
);

const renderTitle = ({
Expand Down Expand Up @@ -454,12 +460,12 @@ const DataTableContainer: React.FC<DataTableProps> = ({
<span className="table-row-count">
{/* If the user filters a column (i.e. updates) or enters a serch term (i.e. update dataResult), show the total rows in format <rows shown to user>/<total rows>, otherwise only show total rows. */}
{displayedRows &&
displayedRows !== tableData.dataResult.data?.items?.length
displayedRows !== tableData.dataResult.data?.items?.length
? `${displayedRows} / `
: tableData.dataResult?.data?.items.length !==
tableData.dataResult.data?.total
? `${tableData.dataResult.data?.items?.length} /`
: ''}
? `${tableData.dataResult.data?.items?.length} /`
: ''}
{`${tableData.dataResult?.data?.total ?? 0} `}
Results
</span>
Expand Down Expand Up @@ -544,9 +550,8 @@ const DataTableContainer: React.FC<DataTableProps> = ({
antnotifcation.info({
duration: 5,
message: `${additionalSelectedRows -
1} other resources with same metadata have also been automatically ${
selected ? 'selected' : 'unselected'
} for download.`,
1} other resources with same metadata have also been automatically ${selected ? 'selected' : 'unselected'
} for download.`,
});
}
},
Expand Down Expand Up @@ -587,9 +592,8 @@ const DataTableContainer: React.FC<DataTableProps> = ({
if (additionalSelectedRows > 0) {
antnotifcation.info({
duration: 5,
message: `${additionalSelectedRows} other resources with same metadata have also been automatically ${
selected ? 'selected' : 'unselected'
} for download.`,
message: `${additionalSelectedRows} other resources with same metadata have also been automatically ${selected ? 'selected' : 'unselected'
} for download.`,
});
}

Expand Down
Loading

0 comments on commit 4fb8f51

Please sign in to comment.