Skip to content

Commit

Permalink
MWB-952: update filter for states
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverBerserk committed Jan 24, 2025
1 parent a68ba02 commit 47572b3
Show file tree
Hide file tree
Showing 13 changed files with 273 additions and 252 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,44 +8,46 @@ import {TreeItem, treeItemClasses} from '@mui/x-tree-view';
import {SimpleTreeView} from '@mui/x-tree-view/SimpleTreeView';
import FolderOpenIcon from '@mui/icons-material/FolderOpen';
import InsertDriveFileOutlinedIcon from '@mui/icons-material/InsertDriveFileOutlined';
import {Scrollbar} from '../../../../components/scrollbar';

const FileList = ({files, handleFileChange, handleFolderChange, selectedPackageState, selectedTestDataset}) => {
const FileIcon = () => <InsertDriveFileOutlinedIcon sx={{marginLeft: '17px'}}/>
const CollapseIcon = () => <Stack direction='row'><ExpandMoreIcon/><FolderOpenIcon/></Stack>
const ExpandIcon = () => <Stack direction='row'><ChevronRightIcon/><FolderOpenIcon/></Stack>

return (
<Paper>
<Paper sx={{height: '100%'}}>
<Stack sx={{py: 2}}>
<Typography sx={{px: 2, mb: 3, fontWeight: 'bold', cursor: 'pointer'}}
onClick={() => handleFolderChange(undefined)}>
Test Set Summary
</Typography>
<SimpleTreeView slots={{
expandIcon: ExpandIcon,
collapseIcon: CollapseIcon,
endIcon: FileIcon
}}
selectedItems={selectedTestDataset?.oid ?? selectedPackageState?.oid ?? ''}
sx={{
overflowX: 'hidden', minHeight: 270, flexGrow: 1,
[`& .${treeItemClasses.iconContainer}`]: {minWidth: 40, color: 'gray'}
}}>
{files?.map(item => <TreeItem key={item.oid}
itemId={item.oid}
label={item.title}
<Scrollbar>
<SimpleTreeView slots={{
expandIcon: ExpandIcon,
collapseIcon: CollapseIcon,
endIcon: FileIcon
}}
selectedItems={selectedTestDataset?.oid ?? selectedPackageState?.oid ?? ''}
sx={{
[`& .${treeItemClasses.iconContainer}`]: {minWidth: 40, color: 'gray'}
}}>
{files?.map(item => <TreeItem key={item.oid}
itemId={item.oid}
label={item.title}

onClick={() => handleFolderChange(item)}>
{item.test_data_states?.map(child => <TreeItem key={child.oid}
itemId={child.oid}
label={child.title}
onClick={() => {
handleFolderChange(item)
handleFileChange(child)
}}>
onClick={() => handleFolderChange(item)}>
{item.test_data_states?.map(child => <TreeItem key={child.oid}
itemId={child.oid}
label={child.title}
onClick={() => {
handleFolderChange(item)
handleFileChange(child)
}}>
</TreeItem>)}
</TreeItem>)}
</TreeItem>)}
</SimpleTreeView>
</SimpleTreeView>
</Scrollbar>
</Stack>
</Paper>
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ import TableHead from '@mui/material/TableHead';
import DialogTitle from "@mui/material/DialogTitle";
import DialogContent from "@mui/material/DialogContent";
import DialogActions from "@mui/material/DialogActions";
import validationColor from '../mapping-package/state/validation-color';
import {ValueChip} from '../xpath-validation-report/utils';

import {ResultChip} from "./utils";
import {Scrollbar} from 'src/components/scrollbar';
import {ValueChip} from '../xpath-validation-report/utils';
import {useHighlighterTheme} from "src/hooks/use-highlighter-theme";
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter';
import TableSorterHeader from "src/sections/components/table-sorter-header";
Expand Down Expand Up @@ -86,7 +85,7 @@ export const ListTable = (props) => {
<ValueChip value={value.count}
color='primary'
sx={{p: 2}}/>
<ResultChip color={validationColor(key)}
<ResultChip color={key}
clickable
fontColor='#fff'
onClick={() => onClick({title, notices: value.test_datas})}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import {useState} from "react";

import Paper from '@mui/material/Paper';
import Grid from '@mui/material/Unstable_Grid2';
import {ResultFilter} from '../sparql-validation-report/utils';

import {ListTable} from "./list-table";
import {ResultSummaryCoverage} from './result-summary-coverage';
import {TableLoadWrapper} from "./utils";
import useItemsSearch from "src/hooks/use-items-search";
import {mappingPackageStatesApi as sectionApi} from "src/api/mapping-packages/states";

const FILTER_VALUES = ['info', 'valid', 'violation', 'warning'].map(value => ({value: value + 'Count', label: value}))

const ShaclPackageStateReport = ({handleSelectFile, mappingSuiteIdentifier, validationReport, handleExport}) => {
const [dataState, setDataState] = useState({load: false, error: false})

const itemsSearch = useItemsSearch(validationReport, sectionApi);
const [resultFilter, setResultFilter] = useState('')
const filteredItems = validationReport.filter((item) => {
return !resultFilter || item.result[resultFilter]?.count > 0
})

const handleResultFilterChange = e => setResultFilter(e.target.value)

const itemsSearch = useItemsSearch(filteredItems, sectionApi);

return (
<>
Expand All @@ -26,6 +38,15 @@ const ShaclPackageStateReport = ({handleSelectFile, mappingSuiteIdentifier, vali
<Paper>
<TableLoadWrapper dataState={dataState}
data={validationReport}>
<Stack direction='row'
alignItems='center'
justifyContent='space-between'
sx={{mx: 3}}>
<Typography fontWeight='bold'>Assertions</Typography>
<ResultFilter values={FILTER_VALUES}
onStateChange={handleResultFilterChange}
currentState={resultFilter}/>
</Stack>
<ListTable
items={itemsSearch.pagedItems}
count={itemsSearch.count}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,35 @@
import Stack from '@mui/material/Stack';
import Typography from '@mui/material/Typography';
import {useEffect, useState} from "react";

import Paper from '@mui/material/Paper';
import Grid from '@mui/material/Unstable_Grid2';
import {ResultFilter} from '../sparql-validation-report/utils';

import {ListTable} from "./list-table";
import {TableLoadWrapper} from "./utils";
import {ResultSummaryCoverage} from './result-summary-coverage';
import useItemsSearch from "src/hooks/use-items-search";
import {mappingPackageStatesApi as sectionApi} from "src/api/mapping-packages/states";

const FILTER_VALUES = ['info', 'valid', 'violation', 'warning'].map(value => ({value: value + 'Count', label: value}))

const ShaclTestDatasetReport = ({sid, suiteId, handleSelectFile, handleExport}) => {
const [validationReport, setValidationReport] = useState([])
const [dataState, setDataState] = useState({load: true, error: false})


useEffect(() => {
handleValidationReportsGet(sid, suiteId)
}, [suiteId])

const [resultFilter, setResultFilter] = useState('')
const filteredItems = validationReport.filter((item) => {
return !resultFilter || item.result[resultFilter]?.count > 0
})

const handleResultFilterChange = e => setResultFilter(e.target.value)


const handleValidationReportsGet = (sid, suiteId) => {
setDataState({load: true, error: false})
sectionApi.getShaclReportsSuite(sid, suiteId)
Expand Down Expand Up @@ -46,7 +57,7 @@ const ShaclTestDatasetReport = ({sid, suiteId, handleSelectFile, handleExport})
})
}

const itemsSearch = useItemsSearch(validationReport, sectionApi);
const itemsSearch = useItemsSearch(filteredItems, sectionApi);

return (
<>
Expand All @@ -59,6 +70,15 @@ const ShaclTestDatasetReport = ({sid, suiteId, handleSelectFile, handleExport})
<Paper>
<TableLoadWrapper dataState={dataState}
data={validationReport}>
<Stack direction='row'
alignItems='center'
justifyContent='space-between'
sx={{mx: 3}}>
<Typography fontWeight='bold'>Assertions</Typography>
<ResultFilter values={FILTER_VALUES}
onStateChange={handleResultFilterChange}
currentState={resultFilter}/>
</Stack>
<ListTable
items={itemsSearch.pagedItems}
count={itemsSearch.count}
Expand Down
Loading

0 comments on commit 47572b3

Please sign in to comment.