diff --git a/www/src/components/AppBar.tsx b/www/src/components/AppBar.tsx index 4c676626..5a06cbbc 100644 --- a/www/src/components/AppBar.tsx +++ b/www/src/components/AppBar.tsx @@ -44,17 +44,9 @@ const useStyles = makeStyles(theme => }) ); -const locations = ["SYD2", "SG4", "LON2", "NYC2", "STO3", "AMS2"]; +interface IAppBarProps {} -interface IAppBarProps { - cohort?: string; - onChangeCohort?: (event: React.ChangeEvent) => void; -} - -const AppBar: React.FunctionComponent = ({ - cohort, - onChangeCohort, -}) => { +const AppBar: React.FunctionComponent = () => { const classes = useStyles(); const theme = useTheme(); const trigger = useScrollTrigger({ disableHysteresis: true, threshold: 0 }); @@ -89,27 +81,6 @@ const AppBar: React.FunctionComponent = ({ firetable - - {cohort !== undefined && onChangeCohort && ( - - - All - {locations.map(option => ( - - {option} - - ))} - - - )} ); diff --git a/www/src/components/Table/Filters/index.tsx b/www/src/components/Table/Filters/index.tsx index b4b42e9e..f8aee133 100644 --- a/www/src/components/Table/Filters/index.tsx +++ b/www/src/components/Table/Filters/index.tsx @@ -1,8 +1,11 @@ import React, { useState, useEffect } from "react"; -import { FieldType } from "../../Fields"; +import _find from "lodash/find"; + import { + makeStyles, + createStyles, + Popover, Button, - Paper, Typography, IconButton, FormControl, @@ -11,14 +14,14 @@ import { MenuItem, TextField, } from "@material-ui/core"; -import _find from "lodash/find"; import FilterIcon from "@material-ui/icons/FilterList"; -import { makeStyles, Theme, createStyles } from "@material-ui/core/styles"; -import Popper from "@material-ui/core/Popper"; import CloseIcon from "@material-ui/icons/Close"; -import { FireTableFilter } from "../../../hooks/useFiretable"; + import MultiSelect from "../../MultiSelect"; +import { FieldType } from "../../Fields"; +import { FireTableFilter } from "../../../hooks/useFiretable"; + const OPERATORS = [ { value: "==", @@ -65,32 +68,20 @@ const OPERATORS = [ }, ]; -const useStyles = makeStyles((theme: Theme) => +const useStyles = makeStyles(theme => createStyles({ - paper: { - padding: theme.spacing(2), - width: 640, - }, - close: { + paper: { width: 640 }, + + closeButton: { position: "absolute", - right: 0, - }, - content: { - padding: theme.spacing(3), - }, - formControl: {}, - filterType: { - display: "flex", - alignContent: "center", - }, - filterTypeSelect: { - margin: theme.spacing(0, 1), - // height: 50, - }, - footer: { - position: "absolute", - bottom: 0, + top: theme.spacing(0.5), + right: theme.spacing(0.5), }, + + content: { padding: theme.spacing(4) }, + + topRow: { marginBottom: theme.spacing(3.5) }, + bottomButtons: { marginTop: theme.spacing(4.5) }, }) ); @@ -140,7 +131,9 @@ const Filters = ({ columns, tableFilters, setFilters }: any) => { operator.compatibleTypes.includes(selectedColumn.type) ) : []; + const [anchorEl, setAnchorEl] = useState(null); + const handleClose = () => setAnchorEl(null); const handleClick = (event: React.MouseEvent) => { setAnchorEl(anchorEl ? null : event.currentTarget); @@ -167,14 +160,19 @@ const Filters = ({ columns, tableFilters, setFilters }: any) => { const value = e.target.value; if (value) setQuery(query => ({ ...query, value: value })); }} + variant="filled" + hiddenLabel + placeholder="Text value" /> ); + case FieldType.singleSelect: const val = query?.value ? Array.isArray(query.value) ? query.value : [query.value as string] : []; + return ( { @@ -187,128 +185,170 @@ const Filters = ({ columns, tableFilters, setFilters }: any) => { field="" value={val} multiple={operator === "in"} + TextFieldProps={{ hiddenLabel: true }} /> ); + default: + return <>Not available; + // return ; break; } }; return ( <> - - - - { - setAnchorEl(null); - }} + + + + + + +
+ {/* - - -
- {/*
- Results match - - - - of the filter criteria. -
*/} - - - - Column - - - Condition - - - Value - + + Results match - - - - - - - - {query.key && ( - - - - )} - - - {query.operator && - renderInputField(selectedColumn, query.operator)} - - - - {/* */} - + all + any + -
- - + + + of the filter criteria. + +
*/} + + + + Column + + + Condition + + + Value + + + + + + + + Select Column + + {filterColumns.map(c => ( + {c.label} + ))} + + + + + { + setQuery(query => ({ + ...query, + operator: e.target.value as string, + })); + }} + SelectProps={{ displayEmpty: true }} + > + + Select Condition + + {operators.map(operator => ( + {operator.label} + ))} + + + + + {query.operator && + renderInputField(selectedColumn, query.operator)} + + + + + {/* */} + + + +
+
); }; diff --git a/www/src/views/TablesView.tsx b/www/src/views/TablesView.tsx index 011af4d9..1376a3af 100644 --- a/www/src/views/TablesView.tsx +++ b/www/src/views/TablesView.tsx @@ -1,5 +1,4 @@ -import React, { useContext, useState } from "react"; -import { Link } from "react-router-dom"; +import React, { useContext } from "react"; import { createStyles, @@ -15,6 +14,7 @@ import routes from "../constants/routes"; import { AppContext } from "../AppProvider"; import AppBar from "../components/AppBar"; +import Loading from "components/Loading"; import GoIcon from "../components/GoIcon"; import StyledCard from "../components/StyledCard"; import CreateTableDialog from "../components/CreateTableDialog"; @@ -69,13 +69,9 @@ const TablesView = () => { const [settings, createTable] = useSettings(); const tables = settings.tables; - const [cohort, setCohort] = useState("all"); - const handleCohortChange = (e: React.ChangeEvent) => - setCohort(e.target.value); - return (
- + @@ -111,37 +107,24 @@ const TablesView = () => { justify="space-between" className={classes.cardGrid} > - {Array.isArray(tables) - ? tables.map((table: any) => ( - - - - )) - : "TODO: card skeleton"} + {Array.isArray(tables) ? ( + tables.map((table: any) => ( + + + + )) + ) : ( + + )}