Skip to content

Commit

Permalink
Merge pull request #248 from x-atlas-consortia/maxsibilla/issue-245
Browse files Browse the repository at this point in the history
Maxsibilla/issue 245
  • Loading branch information
yuanzhou authored Jan 8, 2025
2 parents c25a255 + 4e0ce84 commit d8e270c
Show file tree
Hide file tree
Showing 5 changed files with 118 additions and 63 deletions.
2 changes: 1 addition & 1 deletion src/components/DataTable/DatasetTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ const DatasetTable = ({
render: (organType, record) => {
if (!organType) return null
return (
<span className='txt-break-spaces'>{getUBKGName(organType)}</span>
<span>{getUBKGName(organType)}</span>
)
}
},
Expand Down
63 changes: 59 additions & 4 deletions src/components/DataTable/UploadTable.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Button,Modal, Table} from "antd";
import React, {useContext, useEffect, useState} from "react";
import Spinner from "../Spinner";
import {eq} from "../../lib/helpers/general";
import {eq, getUBKGName} from "../../lib/helpers/general";
import ModalOver from "../ModalOver";
import TABLE from "../../lib/helpers/table";
import URLS from "../../lib/helpers/urls";
Expand All @@ -10,6 +10,7 @@ import AppContext from "../../context/AppContext";
import {STATUS} from "../../lib/constants";
import BulkEditForm from "../BulkEditForm";
import UI_BLOCKS from "../../lib/helpers/uiBlocks";
import { getHierarchy } from "@/lib/helpers/hierarchy";

const UploadTable = ({ data, loading, filterUploads, uploadData, datasetData, handleTableChange, page, pageSize, sortField, sortOrder, filters, className}) => {
const [rawData, setRawData] = useState([])
Expand All @@ -33,9 +34,33 @@ const UploadTable = ({ data, loading, filterUploads, uploadData, datasetData, ha

const [modal, setModal] = useState({cancelCSS: 'none'})

const filterField = (f) => {
return [...new Set(data.map(item => item[f]))]
}

const makeHierarchyFilters = (items) => {
const hierarchyNames = new Set()
for (let i of items) {
let groupName = getHierarchy(i)
if (!eq(i, groupName)) {
const normalized = groupName.toLowerCase()
if (hierarchyGroupings[normalized] === undefined) {
hierarchyGroupings[normalized] = []
}
hierarchyGroupings[normalized].push(i)
}
hierarchyNames.add(groupName)
}
return Array.from(hierarchyNames)
}

const unfilteredGroupNames = [...new Set(data.map(item => item.group_name))];
const uniqueGroupNames = unfilteredGroupNames.filter(name => name.trim() !== "" && name !== " ");
const uniqueAssignedToGroupNames = [...new Set(data.map(item => item.assigned_to_group_name))]
const unfilteredOrganTypes = makeHierarchyFilters(filterField('intended_organ'))
const uniqueOrganType = unfilteredOrganTypes.filter(name => name !== "" && name !== " ");
const uniqueDatasetType = filterField('intended_dataset_type')

let urlParamFilters = {};

for (let _field of ["group_name", "status"]) {
Expand Down Expand Up @@ -99,8 +124,38 @@ const UploadTable = ({ data, loading, filterUploads, uploadData, datasetData, ha
};
const uploadColumns = [
TABLE.reusableColumns(urlSortOrder, urlParamFilters).id(renderDropdownContent),
TABLE.reusableColumns(urlSortOrder, urlParamFilters).groupName(uniqueGroupNames, '25%'),
TABLE.reusableColumns(urlSortOrder, urlParamFilters).groupName(uniqueGroupNames),
TABLE.reusableColumns(urlSortOrder, urlParamFilters).statusUpload,
{
title: "Intended Organ",
width: 180,
dataIndex: "intended_organ",
align: "left",
defaultSortOrder: urlSortOrder["intended_organ"] || null,
sorter: (a,b) => a.intended_organ.localeCompare(b.intended_organ),
filteredValue: urlParamFilters["intended_organ"] ? filters['intended_organ'].toLowerCase().split(",") : null,
filters: uniqueOrganType.map(name => ({ text: getUBKGName(name), value: name.toLowerCase() })),
onFilter: (value, record) => eq(record.organ, value) || hierarchyGroupings[value]?.includes(record.organ),
ellipsis: true,
render: (organType, record) => {
if (!organType) return null
return (
<span>{getUBKGName(organType)}</span>
)
}
},
{
title: "Intended Dataset Type",
width: 230,
dataIndex: "intended_dataset_type",
align: "left",
defaultSortOrder: urlSortOrder["intended_dataset_type"] || null,
sorter: (a,b) => a.intended_dataset_type.localeCompare(b.intended_dataset_type),
filteredValue: urlParamFilters["intended_dataset_type"] || null,
filters: uniqueDatasetType.map(name => ({ text: name, value: name.toLowerCase() })),
onFilter: (value, record) => eq(record.intended_dataset_type, value),
ellipsis: true,
},
TABLE.reusableColumns(urlSortOrder, urlParamFilters, {}).assignedToGroupName(uniqueAssignedToGroupNames),
{
title: "Ingest Task",
Expand All @@ -116,7 +171,7 @@ const UploadTable = ({ data, loading, filterUploads, uploadData, datasetData, ha
},
{
title: "Title",
width: '23%',
width: 320,
dataIndex: "title",
align: "left",
defaultSortOrder: urlSortOrder["title"] || null,
Expand All @@ -125,7 +180,7 @@ const UploadTable = ({ data, loading, filterUploads, uploadData, datasetData, ha
},
{
title: "UUID",
width: '25%',
width: 310,
dataIndex: "uuid",
align: "left",
defaultSortOrder: urlSortOrder["uuid"] || null,
Expand Down
2 changes: 1 addition & 1 deletion src/lib/helpers/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ const TABLE = {
},
statusUpload: {
title: "Status",
width: '15%',
width: 150,
dataIndex: "status",
align: "left",
defaultSortOrder: defaultSortOrder["status"] || null,
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "data-ingest-board",
"version": "1.4.2",
"version": "1.4.3",
"private": true,
"scripts": {
"all": "npm-run-all --parallel dev css addons",
Expand Down
Loading

0 comments on commit d8e270c

Please sign in to comment.