mirror of
https://github.com/kubeshark/kubeshark.git
synced 2025-08-21 01:45:39 +00:00
Adapt the UI to the new filtering system
This commit is contained in:
parent
252563fa44
commit
7766948156
@ -1,7 +1,7 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import styles from './style/Filters.module.sass';
|
import styles from './style/Filters.module.sass';
|
||||||
import {FilterSelect} from "./UI/FilterSelect";
|
import {FilterSelect} from "./UI/FilterSelect";
|
||||||
import {TextField} from "@material-ui/core";
|
import {TextField, Button} from "@material-ui/core";
|
||||||
import {ALL_KEY} from "./UI/Select";
|
import {ALL_KEY} from "./UI/Select";
|
||||||
|
|
||||||
interface FiltersProps {
|
interface FiltersProps {
|
||||||
@ -11,14 +11,14 @@ interface FiltersProps {
|
|||||||
setStatusFilter: (methods: Array<string>) => void;
|
setStatusFilter: (methods: Array<string>) => void;
|
||||||
pathFilter: string
|
pathFilter: string
|
||||||
setPathFilter: (val: string) => void;
|
setPathFilter: (val: string) => void;
|
||||||
|
ws: any
|
||||||
|
openWebSocket: (query: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const Filters: React.FC<FiltersProps> = ({methodsFilter, setMethodsFilter, statusFilter, setStatusFilter, pathFilter, setPathFilter}) => {
|
export const Filters: React.FC<FiltersProps> = ({methodsFilter, setMethodsFilter, statusFilter, setStatusFilter, pathFilter, setPathFilter, ws, openWebSocket}) => {
|
||||||
|
|
||||||
return <div className={styles.container}>
|
return <div className={styles.container}>
|
||||||
<MethodFilter methodsFilter={methodsFilter} setMethodsFilter={setMethodsFilter}/>
|
<QueryForm ws={ws} openWebSocket={openWebSocket}/>
|
||||||
<StatusTypesFilter statusFilter={statusFilter} setStatusFilter={setStatusFilter}/>
|
|
||||||
<PathFilter pathFilter={pathFilter} setPathFilter={setPathFilter}/>
|
|
||||||
</div>;
|
</div>;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -102,18 +102,39 @@ const StatusTypesFilter: React.FC<StatusTypesFilterProps> = ({statusFilter, setS
|
|||||||
</FilterContainer>;
|
</FilterContainer>;
|
||||||
};
|
};
|
||||||
|
|
||||||
interface PathFilterProps {
|
interface QueryFormProps {
|
||||||
pathFilter: string;
|
ws: any
|
||||||
setPathFilter: (val: string) => void;
|
openWebSocket: (query: string) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const PathFilter: React.FC<PathFilterProps> = ({pathFilter, setPathFilter}) => {
|
class QueryForm extends React.Component<QueryFormProps, { value: string }> {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {value: ''};
|
||||||
|
|
||||||
return <FilterContainer>
|
this.handleChange = this.handleChange.bind(this);
|
||||||
<div className={styles.filterLabel}>Path</div>
|
this.handleSubmit = this.handleSubmit.bind(this);
|
||||||
<div>
|
}
|
||||||
<TextField value={pathFilter} variant="outlined" className={styles.filterText} style={{minWidth: '150px'}} onChange={(e: any) => setPathFilter(e.target.value)}/>
|
|
||||||
</div>
|
|
||||||
</FilterContainer>;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
handleChange(event) {
|
||||||
|
this.setState({value: event.target.value});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleSubmit(event) {
|
||||||
|
this.props.ws.close()
|
||||||
|
this.props.openWebSocket(this.state.value)
|
||||||
|
// alert('A name was submitted: ' + this.state.value);
|
||||||
|
event.preventDefault();
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<form onSubmit={this.handleSubmit}>
|
||||||
|
<label>
|
||||||
|
<TextField value={this.state.value} onChange={this.handleChange} variant="outlined" className={styles.filterText} style={{minWidth: '450px'}} placeholder="Mizu Filter Syntax"/>
|
||||||
|
</label>
|
||||||
|
<Button type="submit" variant="contained" style={{marginLeft: "10px"}}>Apply</Button>
|
||||||
|
</form>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -67,8 +67,9 @@ export const TrafficPage: React.FC<TrafficPageProps> = ({setAnalyzeStatus, onTLS
|
|||||||
|
|
||||||
const listEntry = useRef(null);
|
const listEntry = useRef(null);
|
||||||
|
|
||||||
const openWebSocket = () => {
|
const openWebSocket = (query) => {
|
||||||
ws.current = new WebSocket(MizuWebsocketURL);
|
var url = MizuWebsocketURL + "?q=" + query;
|
||||||
|
ws.current = new WebSocket(url);
|
||||||
ws.current.onopen = () => setConnection(ConnectionStatus.Connected);
|
ws.current.onopen = () => setConnection(ConnectionStatus.Connected);
|
||||||
ws.current.onclose = () => setConnection(ConnectionStatus.Closed);
|
ws.current.onclose = () => setConnection(ConnectionStatus.Closed);
|
||||||
}
|
}
|
||||||
@ -110,7 +111,7 @@ export const TrafficPage: React.FC<TrafficPageProps> = ({setAnalyzeStatus, onTLS
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
(async () => {
|
(async () => {
|
||||||
openWebSocket();
|
openWebSocket("");
|
||||||
try{
|
try{
|
||||||
const tapStatusResponse = await api.tapStatus();
|
const tapStatusResponse = await api.tapStatus();
|
||||||
setTappingStatus(tapStatusResponse);
|
setTappingStatus(tapStatusResponse);
|
||||||
@ -184,7 +185,7 @@ export const TrafficPage: React.FC<TrafficPageProps> = ({setAnalyzeStatus, onTLS
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{entries.length > 0 && <div className="TrafficPage-Container">
|
{<div className="TrafficPage-Container">
|
||||||
<div className="TrafficPage-ListContainer">
|
<div className="TrafficPage-ListContainer">
|
||||||
<Filters methodsFilter={methodsFilter}
|
<Filters methodsFilter={methodsFilter}
|
||||||
setMethodsFilter={setMethodsFilter}
|
setMethodsFilter={setMethodsFilter}
|
||||||
@ -192,6 +193,8 @@ export const TrafficPage: React.FC<TrafficPageProps> = ({setAnalyzeStatus, onTLS
|
|||||||
setStatusFilter={setStatusFilter}
|
setStatusFilter={setStatusFilter}
|
||||||
pathFilter={pathFilter}
|
pathFilter={pathFilter}
|
||||||
setPathFilter={setPathFilter}
|
setPathFilter={setPathFilter}
|
||||||
|
ws={ws.current}
|
||||||
|
openWebSocket={openWebSocket}
|
||||||
/>
|
/>
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<EntriesList entries={entries}
|
<EntriesList entries={entries}
|
||||||
|
@ -29,8 +29,8 @@
|
|||||||
input
|
input
|
||||||
padding: 4px 12px
|
padding: 4px 12px
|
||||||
background: $main-background-color
|
background: $main-background-color
|
||||||
border-radius: 12px
|
border-radius: 4px
|
||||||
font-size: 12px
|
font-size: 14px
|
||||||
border: 1px solid #BCC6DD
|
border: 1px solid #BCC6DD
|
||||||
fieldset
|
fieldset
|
||||||
border: none
|
border: none
|
||||||
|
@ -31,11 +31,13 @@ button
|
|||||||
&:not(.MuiFab-root)
|
&:not(.MuiFab-root)
|
||||||
&.MuiButtonBase-root
|
&.MuiButtonBase-root
|
||||||
box-sizing: border-box
|
box-sizing: border-box
|
||||||
font-weight: 500
|
font-weight: 600
|
||||||
line-height: 1
|
line-height: 1
|
||||||
border-radius: 20px
|
border-radius: 4px
|
||||||
letter-spacing: 0.02857em
|
letter-spacing: 0.02857em
|
||||||
text-transform: uppercase
|
background-color: $blue-color
|
||||||
|
color: #fff
|
||||||
|
text-transform: none
|
||||||
img:not(.custom)
|
img:not(.custom)
|
||||||
max-width: 13px
|
max-width: 13px
|
||||||
max-height: 13px
|
max-height: 13px
|
||||||
|
Loading…
Reference in New Issue
Block a user