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

feature/MWB12-43 #393

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,32 @@ export const TableFilterHeader = ({fieldName, title, sort, desc, onSort, filters
const hoverOpacity = (hover && sort.column !== fieldName) ? .7 : 1

return (

<Tooltip title={tooltipTitle}>
<Stack direction='row'
alignItems='center'>
<Typography variant='h7'
onMouseEnter={() => handleHover(true)}
onMouseLeave={() => handleHover(false)}
sx={{cursor: 'pointer', opacity: hoverOpacity, mt: .4}}
onClick={() => onSort(fieldName, desc)}>
{title ?? fieldName}
</Typography>
<IconButton color="inherit"
sx={{rotate: 90}}
onClick={() => onSort(fieldName, desc)}
size="small">
{(sort.column === fieldName || hover) && <ArrowDownwardIcon
style={{
transform: direction !== 'desc' ? 'rotate(180deg)' : '', transition: 'transform 0.4s',
opacity: hoverOpacity
}}
fontSize='10px'/>}
</IconButton>
<Stack direction='row'
alignItems='center'
onMouseEnter={() => handleHover(true)}
onMouseLeave={() => handleHover(false)}
sx={{cursor: 'pointer', opacity: hoverOpacity}}
onClick={() => onSort(fieldName, desc)}
>
<Typography variant='h7'
sx={{mt: .4}}>
{title ?? fieldName}
</Typography>
<IconButton color="inherit"
sx={{rotate: 90}}
onClick={() => onSort(fieldName, desc)}
size="small">
{(sort.column === fieldName || hover) && <ArrowDownwardIcon
style={{
transform: direction !== 'desc' ? 'rotate(180deg)' : '', transition: 'transform 0.4s',
opacity: hoverOpacity
}}
fontSize='10px'/>}
</IconButton>
</Stack>
<IconButton onClick={handleClick}
size="small">
<FilterAltIcon fontSize='10px'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import FormControl from '@mui/material/FormControl';
import FormControlLabel from '@mui/material/FormControlLabel';
import Radio from '@mui/material/Radio';
import RadioGroup from '@mui/material/RadioGroup';
import {useTheme} from '@mui/material/styles';
import {useState} from 'react';

import {Box} from '@mui/system';
import Stack from '@mui/material/Stack';
import Radio from '@mui/material/Radio';
import {capitalize} from '@mui/material';
import Button from '@mui/material/Button';
import Typography from '@mui/material/Typography';
import {Box} from '@mui/system';
import {useState} from 'react';
import {capitalize, ResultChip} from '../../sparql-validation-report/utils';
import {ValueChip} from '../../xpath-validation-report/utils';
import RadioGroup from '@mui/material/RadioGroup';
import FormControl from '@mui/material/FormControl';
import FormControlLabel from '@mui/material/FormControlLabel';

export const getValidationColor = (color) => {
switch (color) {
Expand Down Expand Up @@ -44,6 +46,23 @@ export const getResultColor = (result) => {
}
}

export const ValueChip = ({children, value, color, style}) => {
const theme = useTheme()
const themeColor = theme.palette?.[color] ?? {}
return (
<Stack sx={{
px: 1.4,
py: 0.3,
alignItems: 'center',
justifyContent: 'center',
backgroundColor: themeColor.alpha12,
color: themeColor.main,
borderRadius: 5,
...style
}}>{value ?? children}</Stack>
)
}

export const getItemsDisplay = (items, total) => Object.entries(items)?.map(item => {
const [itemName, itemCount] = item
const percent = (itemCount / total) * 100 ?? 0
Expand Down Expand Up @@ -197,4 +216,67 @@ export const useFileNavigation = (reportTree) => {
handleSetTestDataset,
handleSetTestAndPackage
}
}


export const handleOpenDetails = (title, notices, handleSelect, setDescription) => {
const description = notices.map((notice, i) =>
<Box key={'notice' + i}>
<Button type='link'
onClick={() => handleSelect(notice.test_data_suite_oid)}
>
{notice.test_data_suite_id}
</Button>
{' / '}
<Button type='link'
onClick={() => handleSelect(notice.test_data_suite_oid, notice.test_data_oid)}
>
{notice.test_data_id}
</Button>
</Box>)

setDescription({open: true, title, description});
}

export const ResultChip = ({label, color, fontColor, onClick, clickable, children}) => {
const hover = onClick ?? clickable ? {'&:hover': {filter: 'brightness(85%)'}, cursor: 'pointer'} : {}
return (
<Box sx={{
textAlign: 'center',
px: 1,
py: .5,
borderRadius: 12,
backgroundColor: color,
color: fontColor, ...hover
}}
onClick={onClick}
>
{label ?? children}
</Box>
)
}

export const ResultCell = ({item, handleSelect, setDescription}) => {
const title = item.title
return <Stack direction="column"
alignItems="center"
justifyContent="center"
gap={2}
height={100}>
{Object.entries(item.result).map(([key, value]) => {
return !!value.count && <Stack direction='row'
key={key}
gap={1}>
<ValueChip value={value.count}
color='primary'
sx={{p: 2}}/>
<ResultChip color={getValidationColor(key)}
clickable
fontColor='#fff'
onClick={() => handleOpenDetails(title, value.test_datas, handleSelect, setDescription)}
label={key}
/>
</Stack>
})}
</Stack>
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import {Prism as SyntaxHighlighter} from 'react-syntax-highlighter';
import PropTypes from 'prop-types';

import Table from '@mui/material/Table';
Expand All @@ -10,18 +9,10 @@ import TableRow from '@mui/material/TableRow';
import {Scrollbar} from 'src/components/scrollbar';
import {useHighlighterTheme} from "src/hooks/use-highlighter-theme";
import TablePagination from 'src/sections/components/table-pagination';
import {LocalHighlighter} from 'src/sections/components/local-highlighter';
import {TableFilterHeader} from "src/layouts/app/table-filter-header/table-filter-header";

export const LocalHighlighter = ({text, language, theme}) => {
return text ? <SyntaxHighlighter
language={language}
wrapLines
customStyle={{borderRadius: 12, border: '1px solid #E4E7EC'}}
style={theme}
lineProps={{style: {overflowWrap: 'break-word', whiteSpace: 'pre-wrap'}}}>
{text}
</SyntaxHighlighter> : null
}

export const ListTableFile = (props) => {

const {
Expand Down Expand Up @@ -92,7 +83,7 @@ export const ListTableFile = (props) => {
onFilter={onFilter}
filters={filters}
fieldName="short_source_constraint_component"
title="Source Constraint Component"/>
title="Constraint Type"/>
</TableCell>
</TableRow>
</TableHead>
Expand All @@ -103,27 +94,27 @@ export const ListTableFile = (props) => {
<TableCell width="25%">
<LocalHighlighter language='turtle'
text={item.short_focus_node}
theme={syntaxHighlighterTheme}/>
style={syntaxHighlighterTheme}/>
</TableCell>
<TableCell>
<LocalHighlighter language='turtle'
text={item.message}
theme={syntaxHighlighterTheme}/>
style={syntaxHighlighterTheme}/>
</TableCell>
<TableCell>
<LocalHighlighter language='sparql'
text={item.short_result_path}
theme={syntaxHighlighterTheme}/>
style={syntaxHighlighterTheme}/>
</TableCell>
<TableCell>
<LocalHighlighter language='turtle'
text={item.short_result_severity}
theme={syntaxHighlighterTheme}/>
style={syntaxHighlighterTheme}/>
</TableCell>
<TableCell>
<LocalHighlighter language='turtle'
text={item.short_source_constraint_component}
theme={syntaxHighlighterTheme}/>
style={syntaxHighlighterTheme}/>
</TableCell>
</TableRow>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {useState} from "react";
import PropTypes from 'prop-types';

import {Box} from "@mui/system";
import Stack from "@mui/material/Stack";
import Table from '@mui/material/Table';
import Button from "@mui/material/Button";
import Dialog from '@mui/material/Dialog';
Expand All @@ -13,17 +11,15 @@ 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 SorterHeader from 'src/sections/components/table-sorter-header';
import {ResultCell} from '../mapping-package/state/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";
import SorterHeader from 'src/sections/components/table-sorter-header';
import TablePagination from "src/sections/components/table-pagination";
import {LocalHighlighter} from 'src/sections/components/local-highlighter';
import TableSorterHeader from "src/sections/components/table-sorter-header";
import {TableFilterHeader} from "src/layouts/app/table-filter-header/table-filter-header";
import {LocalHighlighter} from "./list-table-file";

export const ListTable = (props) => {
const [descriptionDialog, setDescriptionDialog] = useState({open: false, title: "", text: ""})
Expand All @@ -45,62 +41,13 @@ export const ListTable = (props) => {
handleSelectFile
} = props;

const handleOpenDetails = ({title, notices}) => {
console.log('on open details')
const description = notices.map((notice, i) =>
<Box key={'notice' + i}>
<Button type='link'
onClick={() => handleSelectFile(notice.test_data_suite_oid)}
>
{notice.test_data_suite_id}
</Button>
{' / '}
<Button type='link'
onClick={() => handleSelectFile(notice.test_data_suite_oid, notice.test_data_oid)}
>
{notice.test_data_id}
</Button>
</Box>)

setDescriptionDialog({open: true, title, description});
}

const handleClose = () => setDescriptionDialog(e => ({...e, open: false}));

const SorterHeader = (props) => <TableSorterHeader sort={sort}
onSort={onSort}
{...props}
/>


const ResultCell = ({item, onClick}) => {
const title = item.title
return <Stack direction="column"
alignItems="center"
justifyContent="center"
gap={2}
height={100}>
{Object.entries(item.result).map(([key, value]) => {
return value.count > 0
? <Stack direction='row'
key={key}
gap={1}>
<ValueChip value={value.count}
color='primary'
sx={{p: 2}}/>
<ResultChip color={key}
clickable
fontColor='#fff'
onClick={() => onClick({title, notices: value.test_datas})}
label={key}
/>
</Stack>
: null
})
}
</Stack>
}

return (
<>
<TablePagination
Expand All @@ -127,8 +74,12 @@ export const ListTable = (props) => {
title="Test Suite"/>
</TableCell>
<TableCell width="25%">
<SorterHeader fieldName="short_source_constraint_component"
title="Source Constraint Component"/>
<TableFilterHeader sort={sort}
onSort={onSort}
onFilter={onFilter}
filters={filters}
fieldName="short_source_constraint_component"
title="Constraint Type"/>
</TableCell>
<TableCell>
<TableFilterHeader sort={sort}
Expand Down Expand Up @@ -159,26 +110,17 @@ export const ListTable = (props) => {
<TableCell>
<LocalHighlighter language='turtle'
text={item.short_source_constraint_component}
theme={syntaxHighlighterTheme}/>
style={syntaxHighlighterTheme}/>
</TableCell>
<TableCell>
<SyntaxHighlighter
language="turtle"
wrapLines
style={syntaxHighlighterTheme}
customStyle={{borderRadius: 12, border: '1px solid #E4E7EC'}}
lineProps={{
style: {
overflowWrap: 'break-word',
whiteSpace: 'pre-wrap'
}
}}>
{item.short_result_path}
</SyntaxHighlighter>
<LocalHighlighter language='turtle'
text={item.short_result_path}
style={syntaxHighlighterTheme}/>
</TableCell>
<TableCell>
<ResultCell item={item}
onClick={handleOpenDetails}/>
handleSelect={handleSelectFile}
setDescription={setDescriptionDialog}/>
</TableCell>
</TableRow>

Expand Down
Loading
Loading