1313//
1414// You should have received a copy of the GNU Affero General Public License
1515// along with this program. If not, see <http://www.gnu.org/licenses/>.
16- import React , { useEffect , useState } from "react" ;
16+
17+ import React , { useEffect , useState , Fragment } from "react" ;
18+ import { IMessageEvent , w3cwebsocket as W3CWebSocket } from "websocket" ;
19+ import { useSelector } from "react-redux" ;
1720import {
18- FormControl ,
21+ Box ,
22+ Button ,
23+ DataTable ,
1924 Grid ,
20- InputBase ,
21- MenuItem ,
25+ InputBox ,
26+ InputLabel ,
27+ PageLayout ,
2228 Select ,
23- TextField ,
24- } from "@mui/material" ;
25- import { IMessageEvent , w3cwebsocket as W3CWebSocket } from "websocket" ;
26- import { useSelector } from "react-redux" ;
27- import { Theme } from "@mui/material/styles" ;
28- import { Button , PageLayout } from "mds" ;
29- import createStyles from "@mui/styles/createStyles" ;
30- import withStyles from "@mui/styles/withStyles" ;
29+ } from "mds" ;
3130import { AppState , useAppDispatch } from "../../../store" ;
3231import { Bucket , BucketList , EventInfo } from "./types" ;
3332import { niceBytes , timeFromDate } from "../../../common/utils" ;
3433import { wsProtocol } from "../../../utils/wsUtils" ;
35- import {
36- actionsTray ,
37- containerForHeader ,
38- searchField ,
39- tableStyles ,
40- } from "../Common/FormComponents/common/styleLibrary" ;
4134import { ErrorResponseHandler } from "../../../common/types" ;
42- import TableWrapper from "../Common/TableWrapper/TableWrapper" ;
43- import api from "../../../common/api" ;
44- import makeStyles from "@mui/styles/makeStyles" ;
4535import { watchMessageReceived , watchResetMessages } from "./watchSlice" ;
36+ import { setHelpName } from "../../../systemSlice" ;
37+ import api from "../../../common/api" ;
4638import PageHeaderWrapper from "../Common/PageHeaderWrapper/PageHeaderWrapper" ;
4739import HelpMenu from "../HelpMenu" ;
48- import { setHelpName } from "../../../systemSlice" ;
49-
50- const useStyles = makeStyles ( ( theme : Theme ) =>
51- createStyles ( {
52- searchPrefix : {
53- flexGrow : 1 ,
54- marginLeft : 15 ,
55- } ,
56- watchTableHeight : {
57- height : "calc(100vh - 270px)" ,
58- } ,
59- bucketField : {
60- flexGrow : 2 ,
61- minWidth : 200 ,
62- } ,
63- ...tableStyles ,
64- ...actionsTray ,
65- ...searchField ,
66- ...containerForHeader ,
67- } ) ,
68- ) ;
69-
70- const SelectStyled = withStyles ( ( theme : Theme ) =>
71- createStyles ( {
72- root : {
73- lineHeight : "50px" ,
74- "label + &" : {
75- marginTop : theme . spacing ( 3 ) ,
76- } ,
77- "& .MuiSelect-select:focus" : {
78- backgroundColor : "transparent" ,
79- } ,
80- } ,
81- input : {
82- height : 50 ,
83- fontSize : 13 ,
84- lineHeight : "50px" ,
85- } ,
86- } ) ,
87- ) ( InputBase ) ;
8840
8941const Watch = ( ) => {
9042 const dispatch = useAppDispatch ( ) ;
91- const classes = useStyles ( ) ;
92-
9343 const messages = useSelector ( ( state : AppState ) => state . watch . messages ) ;
9444
9545 const [ start , setStart ] = useState ( false ) ;
@@ -177,89 +127,83 @@ const Watch = () => {
177127 // eslint-disable-next-line react-hooks/exhaustive-deps
178128 } , [ ] ) ;
179129
130+ const optionsArray = bucketNames . map ( ( option ) => ( {
131+ label : option . label ,
132+ value : option . value ,
133+ } ) ) ;
134+
180135 return (
181- < React . Fragment >
136+ < Fragment >
182137 < PageHeaderWrapper label = "Watch" actions = { < HelpMenu /> } />
183-
184138 < PageLayout >
185- < Grid container spacing = { 1 } item xs = { 12 } >
186- < Grid item xs = { 12 } className = { classes . actionsTray } >
187- < FormControl variant = "outlined" className = { classes . bucketField } >
139+ < Grid container >
140+ < Grid
141+ item
142+ xs = { 12 }
143+ sx = { {
144+ display : "flex" ,
145+ gap : 10 ,
146+ marginBottom : 15 ,
147+ alignItems : "center" ,
148+ } }
149+ >
150+ < Box sx = { { flexGrow : 1 } } >
151+ < InputLabel > Bucket</ InputLabel >
188152 < Select
189153 id = "bucket-name"
190154 name = "bucket-name"
191155 value = { bucketName }
192- onChange = { ( e ) => {
193- setBucketName ( e . target . value as string ) ;
156+ onChange = { ( value ) => {
157+ setBucketName ( value as string ) ;
194158 } }
195- className = { classes . searchField }
196159 disabled = { start }
197- input = { < SelectStyled /> }
198- >
199- < MenuItem
200- value = { bucketName }
201- key = { `select-bucket-name-default` }
202- disabled = { true }
203- >
204- Select Bucket
205- </ MenuItem >
206- { bucketNames . map ( ( option ) => (
207- < MenuItem
208- value = { option . value }
209- key = { `select-bucket-name-${ option . label } ` }
210- >
211- { option . label }
212- </ MenuItem >
213- ) ) }
214- </ Select >
215- </ FormControl >
216- < TextField
217- className = { `${ classes . searchField } ${ classes . searchPrefix } ` }
218- id = "prefix-resource"
219- label = "Prefix"
220- disabled = { start }
221- InputProps = { {
222- disableUnderline : true ,
223- } }
224- onChange = { ( e ) => {
225- setPrefix ( e . target . value ) ;
226- } }
227- variant = "standard"
228- />
229- < TextField
230- className = { `${ classes . searchField } ${ classes . searchPrefix } ` }
231- id = "suffix-resource"
232- label = "Suffix"
233- disabled = { start }
234- InputProps = { {
235- disableUnderline : true ,
236- } }
237- onChange = { ( e ) => {
238- setSuffix ( e . target . value ) ;
239- } }
240- variant = "standard"
241- />
242- { start ? (
243- < Button
244- id = { "stop-watch" }
245- type = "submit"
246- variant = "callAction"
247- onClick = { ( ) => setStart ( false ) }
248- label = { "Stop" }
160+ options = { optionsArray }
161+ placeholder = { "Select Bucket" }
249162 />
250- ) : (
251- < Button
252- id = { "start-watch" }
253- type = "submit"
254- variant = "callAction"
255- onClick = { ( ) => setStart ( true ) }
256- label = { "Start" }
163+ </ Box >
164+ < Box sx = { { flexGrow : 1 } } >
165+ < InputLabel > Prefix</ InputLabel >
166+ < InputBox
167+ id = "prefix-resource"
168+ disabled = { start }
169+ onChange = { ( e ) => {
170+ setPrefix ( e . target . value ) ;
171+ } }
172+ />
173+ </ Box >
174+ < Box sx = { { flexGrow : 1 } } >
175+ < InputLabel > Suffix</ InputLabel >
176+ < InputBox
177+ id = "suffix-resource"
178+ disabled = { start }
179+ onChange = { ( e ) => {
180+ setSuffix ( e . target . value ) ;
181+ } }
257182 />
258- ) }
183+ </ Box >
184+ < Box sx = { { alignSelf : "flex-end" , paddingBottom : 4 } } >
185+ { start ? (
186+ < Button
187+ id = { "stop-watch" }
188+ type = "submit"
189+ variant = "callAction"
190+ onClick = { ( ) => setStart ( false ) }
191+ label = { "Stop" }
192+ />
193+ ) : (
194+ < Button
195+ id = { "start-watch" }
196+ type = "submit"
197+ variant = "callAction"
198+ onClick = { ( ) => setStart ( true ) }
199+ label = { "Start" }
200+ />
201+ ) }
202+ </ Box >
259203 </ Grid >
260204
261- < Grid item xs = { 12 } className = { classes . tableBlock } >
262- < TableWrapper
205+ < Grid item xs = { 12 } >
206+ < DataTable
263207 columns = { [
264208 {
265209 label : "Time" ,
@@ -279,12 +223,12 @@ const Watch = () => {
279223 customEmptyMessage = { "No Changes at this time" }
280224 idField = { "watch_table" }
281225 isLoading = { false }
282- customPaperHeight = { classes . watchTableHeight }
226+ customPaperHeight = { "calc(100vh - 270px)" }
283227 />
284228 </ Grid >
285229 </ Grid >
286230 </ PageLayout >
287- </ React . Fragment >
231+ </ Fragment >
288232 ) ;
289233} ;
290234
0 commit comments