Skip to content
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

Update TOC page #3580

Merged
merged 7 commits into from
Jan 15, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions dashboard/src/actions/tocActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const fetchTOC =
if (!isSubDir) {
const inventoryLink = uriTemplate(endpoints, "datasets_inventory", {
dataset: datasetId,
target: "",
target: path,
});
dispatch({
type: TYPES.SET_INVENTORY_LINK,
Expand All @@ -45,7 +45,7 @@ export const fetchTOC =
dispatch({ type: TYPES.COMPLETED });
};

const setOptions = (data, isParent, keyPath, isDirectory) => {
const makeOptions = (data, isParent, keyPath, isDirectory) => {
const options = data.map((item) => ({
name: item.name,
id: isParent ? `${keyPath}*${item.name}` : item.name,
Expand All @@ -56,6 +56,14 @@ const setOptions = (data, isParent, keyPath, isDirectory) => {
options.forEach((opt) => {
opt["children"] = [];
});
} else {
data.forEach((item) => {
options.forEach((opt) => {
if (item.name === opt.name) {
opt["size"] = item.size;
}
});
});
webbnh marked this conversation as resolved.
Show resolved Hide resolved
}
return options;
};
Expand All @@ -72,13 +80,13 @@ export const parseToTreeView =
(contentData, activeItem, isSubDir, parent) => (dispatch, getState) => {
const keyPath = parent.replaceAll("/", "*");
const drillMenuData = [...getState().toc.drillMenuData];
const directories = setOptions(
const directories = makeOptions(
contentData.directories,
parent,
keyPath,
true
);
const files = setOptions(contentData.files, parent, keyPath, false);
const files = makeOptions(contentData.files, parent, keyPath, false);
const treeOptions = [...directories, ...files];
if (isSubDir) {
if (activeItem.includes("*")) {
Expand Down
59 changes: 32 additions & 27 deletions dashboard/src/modules/components/TableComponent/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import DatePickerWidget from "../DatePickerComponent";
import { RenderPagination } from "../OverviewComponent/common-component";
import TablePagination from "../PaginationComponent";
import { ViewOptions } from "../ComparisonComponent/common-components";
import { uid } from "utils/helper";
import { useKeycloak } from "@react-keycloak/web";
import { useNavigate } from "react-router";

Expand Down Expand Up @@ -204,33 +205,37 @@ const TableWithFavorite = () => {
</Thead>
<Tbody>
{selectedArray.length > 0 ? (
selectedArray.map((repo, rowIndex) => (
<Tr key={repo?.resource_id}>
<Td
className="dataset_name"
dataLabel={columnNames.name}
onClick={() =>
navigate(
`/${HOME}${TOC}/${repo?.resource_id}/${repo?.name}`
)
}
>
{repo?.name}
</Td>
<Td dataLabel={columnNames.uploadedDate}>
{repo?.metadata.dataset.uploaded}
</Td>
<Td
favorites={{
isFavorited: isRepoFavorited(repo),
onFavorite: (_event, isFavoriting) => {
markRepoFavorited(repo, isFavoriting);
},
rowIndex,
}}
/>
</Tr>
))
selectedArray.map((repo, rowIndex) =>
repo ? (
<Tr key={repo.resource_id}>
<Td
className="dataset_name"
dataLabel={columnNames.name}
onClick={() =>
navigate(
`/${HOME}${TOC}/${repo.resource_id}/${repo.name}`
)
}
>
{repo.name}
</Td>
<Td dataLabel={columnNames.uploadedDate}>
{repo.metadata.dataset.uploaded}
</Td>
<Td
favorites={{
isFavorited: isRepoFavorited(repo),
onFavorite: (_event, isFavoriting) => {
markRepoFavorited(repo, isFavoriting);
},
rowIndex,
}}
/>
</Tr>
) : (
<Tr key={uid()}></Tr>
)
)
) : (
<Tr key={"empty-row"}>
<Td colSpan={8}>
Expand Down