Skip to content

Commit 3de59df

Browse files
authored
Merge pull request #129 from ChannelFinder/caputlog_ui
Update caputlog UI
2 parents eb389b0 + 6ee4b5b commit 3de59df

File tree

5 files changed

+62
-9
lines changed

5 files changed

+62
-9
lines changed

src/app/App.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ function App() {
3838
<Route path="/pv/:id" exact={true} element={<PV handleOpenErrorAlert={setOpenErrorAlert} handleErrorMessage={setErrorMessage} handleSeverity={setSeverity} />} />
3939
<Route path="/ioc" exact={true} element={<IOC />} />
4040
<Route path="/plot" exact={true} element={<Plot />} />
41-
<Route path="/services" exact={true} element={<Services />} />
4241
{
4342
config.USE_CAPUTLOG ? <Route path="/caputlog" exact={true} element={<CaputLogPage />} /> : null
4443
}
44+
<Route path="/services" exact={true} element={<Services />} />
4545
<Route path="/help" exact={true} element={<Help />} />
4646
<Route path="/" exact={true} element={<Home handleOpenErrorAlert={setOpenErrorAlert} handleErrorMessage={setErrorMessage} handleSeverity={setSeverity} />} />
4747
</Routes>

src/components/caputlog/CaputLogSearchLayout.jsx

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React, { useState, useEffect } from "react";
22
import { Layout } from "@elastic/react-search-ui-views";
33
import { ErrorBoundary, Facet, PagingInfo, ResultsPerPage, Paging, useSearch, SearchBox } from "@elastic/react-search-ui";
4-
import { Box, Button, TextField, InputAdornment } from "@mui/material";
4+
import { Box, Button, TextField, InputAdornment, Tooltip } from "@mui/material";
55
import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
6+
import ClearRoundedIcon from '@mui/icons-material/ClearRounded';
67
import DatePicker from "react-datepicker";
78
import "react-datepicker/dist/react-datepicker.css";
89
import './CaputLogSearchLayout.css';
10+
import CustomSearchBoxView from "./CustomSearchBoxView";
911
import moment from "moment";
1012
import PropTypes from "prop-types";
1113

@@ -15,17 +17,19 @@ const propTypes = {
1517
field: PropTypes.string.isRequired,
1618
label: PropTypes.string.isRequired,
1719
})),
20+
initialSearchTerm: PropTypes.string,
1821
children: PropTypes.func.isRequired,
1922
}
2023

2124
function CaputLogSearchLayout({
2225
showSearchBox = false,
2326
facetFields = [],
27+
initialSearchTerm = "",
2428
children
2529
}) {
2630
const [startDate, setStartDate] = useState(null);
2731
const [endDate, setEndDate] = useState(null);
28-
const { wasSearched, setFilter, removeFilter, results, setSort } = useSearch();
32+
const { wasSearched, setFilter, removeFilter, results, setSort, setSearchTerm } = useSearch();
2933

3034
// Set initial sort to @timestamp desc on mount
3135
useEffect(() => {
@@ -49,9 +53,10 @@ function CaputLogSearchLayout({
4953
}
5054
};
5155

52-
const clearDateFilters = () => {
56+
const clearAllFilters = () => {
5357
setStartDate(null);
5458
setEndDate(null);
59+
setSearchTerm(initialSearchTerm);
5560
removeFilter("@timestamp");
5661
};
5762

@@ -67,7 +72,10 @@ function CaputLogSearchLayout({
6772
flexDirection: "column",
6873
}} >
6974
{showSearchBox && (
70-
<SearchBox inputProps={{ placeholder: "Search by PV Name, User, or Client" }} />
75+
<SearchBox
76+
inputProps={{ placeholder: "Search by PV Name, User, or Client" }}
77+
view={CustomSearchBoxView}
78+
/>
7179
)}
7280
<Box sx={{ display: 'flex', flexDirection: 'row', gap: 1, width: '100%' }}>
7381
<Box sx={{ flex: 1 }}>
@@ -98,9 +106,17 @@ function CaputLogSearchLayout({
98106
}
99107
/>
100108
</Box>
101-
<Button variant="contained" onClick={clearDateFilters}>
102-
Clear
103-
</Button>
109+
<Tooltip arrow title="Clear All Filters">
110+
<Button
111+
variant="contained"
112+
disableElevation
113+
color="secondary"
114+
onClick={clearAllFilters}
115+
sx={{ minWidth: 56, height: 40 }}
116+
>
117+
CLEAR <ClearRoundedIcon sx={{ color: 'black' }} fontSize="medium" />
118+
</Button>
119+
</Tooltip>
104120
</Box>
105121
</Box>
106122
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import SearchRoundedIcon from "@mui/icons-material/SearchRounded";
2+
import { Button, Tooltip, TextField } from "@mui/material";
3+
4+
const CustomSearchBoxView = ({ value, onChange, onSubmit }) => (
5+
<form onSubmit={onSubmit}
6+
style={{
7+
display: "flex",
8+
gap: "8px",
9+
alignItems: "center",
10+
width: "100%"
11+
}}
12+
>
13+
<TextField
14+
fullWidth
15+
value={value}
16+
onChange={(e) => onChange(e.target.value)}
17+
placeholder="Search by PV Name, User, or Client"
18+
variant="outlined"
19+
size="small"
20+
/>
21+
<Tooltip title="Search">
22+
<Button
23+
variant="contained"
24+
disableElevation
25+
color="info"
26+
type="submit"
27+
sx={{ minWidth: 56, height: 40 }}
28+
>
29+
SEARCH <SearchRoundedIcon sx={{ color: "black" }} />
30+
</Button>
31+
</Tooltip>
32+
</form>
33+
);
34+
35+
export default CustomSearchBoxView;

src/components/header/Header.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import AppsIcon from '@mui/icons-material/Apps';
99
import SsidChartIcon from '@mui/icons-material/SsidChart';
1010
import HelpIcon from '@mui/icons-material/Help';
1111
import InfoIcon from '@mui/icons-material/Info'
12+
import TroubleshootIcon from '@mui/icons-material/Troubleshoot';
1213
import MenuIcon from '@mui/icons-material/Menu';
1314
import { makeStyles } from 'tss-react/mui';
1415

@@ -73,7 +74,7 @@ function Header() {
7374
{config.USE_CAPUTLOG &&
7475
<ListItemButton key="CaputLog" component={NavLink} to="/caputlog" onClick={handleMenuToggle} divider color="primary">
7576
<ListItemIcon>
76-
<InfoIcon color="primary" />
77+
<TroubleshootIcon color="primary" />
7778
</ListItemIcon>
7879
<ListItemText primary="CaputLog" />
7980
</ListItemButton>

src/components/pv/caputlogtable/CaputLogTable.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ function CaputLogTable(props) {
3333
<SearchProvider config={searchConfig} >
3434
<CaputLogSearchLayout
3535
showSearchBox={false}
36+
initialSearchTerm={ props.pvName ? `${props.pvName}.*` : "" }
3637
facetFields={[
3738
{ field: "user.keyword", label: "User" },
3839
{ field: "client.keyword", label: "Client" },

0 commit comments

Comments
 (0)