|
|
@ -3,10 +3,12 @@ import React from 'react'; |
|
|
|
import Switch from '@material-ui/core/Switch'; |
|
|
|
import Switch from '@material-ui/core/Switch'; |
|
|
|
import Box from '@material-ui/core/Box'; |
|
|
|
import Box from '@material-ui/core/Box'; |
|
|
|
import FormControlLabel from '@material-ui/core/FormControlLabel'; |
|
|
|
import FormControlLabel from '@material-ui/core/FormControlLabel'; |
|
|
|
import AddCircleOutlineIcon from '@material-ui/icons/AddCircleOutline'; |
|
|
|
|
|
|
|
import Typography from '@material-ui/core/Typography'; |
|
|
|
import Typography from '@material-ui/core/Typography'; |
|
|
|
import Button from '@material-ui/core/Button'; |
|
|
|
import Button from '@material-ui/core/Button'; |
|
|
|
import LabelIcon from '@material-ui/icons/Label'; |
|
|
|
import LabelIcon from '@material-ui/icons/Label'; |
|
|
|
|
|
|
|
import ImportContactsIcon from '@material-ui/icons/ImportContacts'; |
|
|
|
|
|
|
|
import PhotoIcon from '@material-ui/icons/Photo'; |
|
|
|
|
|
|
|
import SearchIcon from '@material-ui/icons/Search'; |
|
|
|
|
|
|
|
|
|
|
|
import { makeStyles } from '@material-ui/core/styles'; |
|
|
|
import { makeStyles } from '@material-ui/core/styles'; |
|
|
|
|
|
|
|
|
|
|
@ -32,49 +34,87 @@ const useStyles = makeStyles(theme => ({ |
|
|
|
export function TagEqualsExpressionControl(props) { |
|
|
|
export function TagEqualsExpressionControl(props) { |
|
|
|
const classes = useStyles(); |
|
|
|
const classes = useStyles(); |
|
|
|
const { name } = props; |
|
|
|
const { name } = props; |
|
|
|
|
|
|
|
|
|
|
|
var pretty_name = name |
|
|
|
|
|
|
|
.replace(/^"/g, '') |
|
|
|
|
|
|
|
.replace(/"$/g, ''); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<> |
|
|
|
<Button |
|
|
|
<Button |
|
|
|
variant="outlined" |
|
|
|
variant="outlined" |
|
|
|
className={classes.filterexpcontrol} |
|
|
|
className={classes.filterexpcontrol} |
|
|
|
startIcon={<LabelIcon />}> |
|
|
|
startIcon={<LabelIcon />}> |
|
|
|
{pretty_name} |
|
|
|
{name} |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
|
</> |
|
|
|
</> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function MatchingFilterExpressionControl(props) { |
|
|
|
export function AlbumEqualsExpressionControl(props) { |
|
|
|
const classes = useStyles(); |
|
|
|
const classes = useStyles(); |
|
|
|
const { expr } = props; |
|
|
|
const { name } = props; |
|
|
|
|
|
|
|
return ( |
|
|
|
if(expr.match_type === MatchTypeEnum.MATCH_EQUALS && |
|
|
|
<> |
|
|
|
expr.match_against === "Tags.name") { |
|
|
|
<Button |
|
|
|
// This is an exact tag match.
|
|
|
|
variant="outlined" |
|
|
|
return <TagEqualsExpressionControl name={expr.match_from} /> |
|
|
|
className={classes.filterexpcontrol} |
|
|
|
|
|
|
|
startIcon={<ImportContactsIcon />}> |
|
|
|
|
|
|
|
{name} |
|
|
|
|
|
|
|
</Button> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var opstr = ""; |
|
|
|
export function ImageNameEqualsExpressionControl(props) { |
|
|
|
if (expr.match_type === MatchTypeEnum.MATCH_EQUALS) { |
|
|
|
const classes = useStyles(); |
|
|
|
opstr = " = "; |
|
|
|
const { name } = props; |
|
|
|
} else if (expr.match_type === MatchTypeEnum.MATCH_REGEXP_CASEINSENSITIVE) { |
|
|
|
return ( |
|
|
|
opstr = " ≈ "; |
|
|
|
<> |
|
|
|
|
|
|
|
<Button |
|
|
|
|
|
|
|
variant="outlined" |
|
|
|
|
|
|
|
className={classes.filterexpcontrol} |
|
|
|
|
|
|
|
startIcon={<PhotoIcon />}> |
|
|
|
|
|
|
|
{name} |
|
|
|
|
|
|
|
</Button> |
|
|
|
|
|
|
|
</> |
|
|
|
|
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var negstr = expr.negate ? "!" : ""; |
|
|
|
export function ImageNameNaturalMatchExpressionControl(props) { |
|
|
|
|
|
|
|
const classes = useStyles(); |
|
|
|
|
|
|
|
const { name } = props; |
|
|
|
return ( |
|
|
|
return ( |
|
|
|
<Button variant="outlined" className={classes.filterexpcontrol}> |
|
|
|
<> |
|
|
|
{negstr + expr.match_against + opstr + expr.match_from} |
|
|
|
<Button |
|
|
|
|
|
|
|
variant="outlined" |
|
|
|
|
|
|
|
className={classes.filterexpcontrol} |
|
|
|
|
|
|
|
startIcon={<><PhotoIcon /><SearchIcon /></>}> |
|
|
|
|
|
|
|
{name} |
|
|
|
</Button> |
|
|
|
</Button> |
|
|
|
|
|
|
|
</> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export function MatchingFilterExpressionControl(props) { |
|
|
|
|
|
|
|
const classes = useStyles(); |
|
|
|
|
|
|
|
const { expr } = props; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var pretty_name = expr.match_from |
|
|
|
|
|
|
|
.replace(/^"/g, '') |
|
|
|
|
|
|
|
.replace(/"$/g, ''); |
|
|
|
|
|
|
|
if (expr.match_type === MatchTypeEnum.MATCH_TAG_EQUALS) { |
|
|
|
|
|
|
|
return <TagEqualsExpressionControl name={pretty_name} /> |
|
|
|
|
|
|
|
} else if (expr.match_type === MatchTypeEnum.MATCH_ALBUM_EQUALS) { |
|
|
|
|
|
|
|
return <AlbumEqualsExpressionControl name={pretty_name} /> |
|
|
|
|
|
|
|
} else if (expr.match_type === MatchTypeEnum.MATCH_ALBUM_EQUALS_OR_CHILD) { |
|
|
|
|
|
|
|
return <AlbumEqualsExpressionControl name={pretty_name + '(/...)'} /> |
|
|
|
|
|
|
|
} else if (expr.match_type === MatchTypeEnum.MATCH_IMAGE_NAME_EQUALS) { |
|
|
|
|
|
|
|
return <ImageNameEqualsExpressionControl name={pretty_name} /> |
|
|
|
|
|
|
|
} else if (expr.match_type === MatchTypeEnum.MATCH_IMAGE_NAME_NATURAL) { |
|
|
|
|
|
|
|
return <ImageNameNaturalMatchExpressionControl name={pretty_name} /> |
|
|
|
|
|
|
|
} else if (expr.match_type === MatchTypeEnum.MATCH_ALBUM_NAME_EQUALS) { |
|
|
|
|
|
|
|
return <AlbumEqualsExpressionControl name={'(.../)' + pretty_name + '(/...)'} /> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
throw new Error('Cannot render matching filter control: unsupported type.'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function LogicalOperatorFilterExpressionControl(props) { |
|
|
|
export function LogicalOperatorFilterExpressionControl(props) { |
|
|
|
const classes = useStyles(); |
|
|
|
const classes = useStyles(); |
|
|
|
const { expr } = props; |
|
|
|
const { expr } = props; |
|
|
@ -160,14 +200,10 @@ export function FilterControl(props) { |
|
|
|
color="primary" |
|
|
|
color="primary" |
|
|
|
/> |
|
|
|
/> |
|
|
|
} |
|
|
|
} |
|
|
|
label={resultTypeString} |
|
|
|
label={resultTypeString + ':'} |
|
|
|
/> |
|
|
|
/> |
|
|
|
<Box> |
|
|
|
|
|
|
|
<Typography>Filters:</Typography> |
|
|
|
|
|
|
|
<AddCircleOutlineIcon /> |
|
|
|
|
|
|
|
<FilterExpressionControl expr={filter} /> |
|
|
|
<FilterExpressionControl expr={filter} /> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
|
|
|
|
</> |
|
|
|
</> |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|