-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Used useReducer React Hook to modify the payload as this component will be changed differently each time
- Loading branch information
1 parent
430f122
commit 17d6e3c
Showing
5 changed files
with
196 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import * as React from 'react'; | ||
import Box from '@mui/material/Box'; | ||
import InputLabel from '@mui/material/InputLabel'; | ||
import MenuItem from '@mui/material/MenuItem'; | ||
import FormControl from '@mui/material/FormControl'; | ||
import Select, { SelectChangeEvent } from '@mui/material/Select'; | ||
import { log_levels } from '../schema/Log_Levels'; | ||
|
||
interface Props { | ||
logFilterValue: number; | ||
onLogFilterChange: (newLogFilterValue: number) => void; | ||
} | ||
|
||
const BasicSelect: React.FC<Props> = ({ logFilterValue, onLogFilterChange }) => { | ||
const handleChange = (event: SelectChangeEvent) => { | ||
const newLogFilterValue = event.target.value as unknown as number; | ||
onLogFilterChange(newLogFilterValue); | ||
}; | ||
|
||
return ( | ||
<Box sx={{ minWidth: 120 }}> | ||
<FormControl fullWidth> | ||
<InputLabel id="log-filter-id">Minimum Log Filter</InputLabel> | ||
<Select | ||
labelId="log-filter-id" | ||
id="log-filter-label" | ||
value={logFilterValue.toString()} | ||
label="Minimum Log Filter" | ||
onChange={handleChange} | ||
> | ||
{Object.entries(log_levels).map(([level_value, level_name]) => ( | ||
<MenuItem key={level_value} value={parseInt(level_value)}> | ||
{level_name} | ||
</MenuItem> | ||
))} | ||
|
||
</Select> | ||
</FormControl> | ||
</Box> | ||
); | ||
} | ||
|
||
export default BasicSelect; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export const log_levels: {[key: number]: string} = { | ||
0:"EMERG", | ||
1:"ALERT", | ||
2:"CRIT", | ||
3:"ERROR", | ||
4:"WARN", | ||
5:"NOTICE", | ||
6:"INFO", | ||
7:"DEBUG",}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Payload Type Interfaces | ||
export interface PayloadInterface { | ||
parameters: string[]; | ||
queries: Query[]; | ||
} | ||
|
||
export interface Query { | ||
query: QueryDetails; | ||
timerange: Timerange; | ||
filters: string[]; | ||
search_types: SearchType[]; | ||
} | ||
|
||
export interface QueryDetails { | ||
type: string; | ||
query_string: string; | ||
} | ||
|
||
export interface Timerange { | ||
from: number; | ||
type: string; | ||
} | ||
|
||
export interface SearchType { | ||
limit: number; | ||
offset: number; | ||
sort: Sort[]; | ||
fields: string[]; | ||
decorators: string[]; | ||
type: string; | ||
filter: string | null; | ||
filters: string[]; | ||
} | ||
|
||
export interface Sort { | ||
field: string; | ||
order: string; | ||
} | ||
|
||
export interface ActionType { | ||
type: string; | ||
log_level?: number | 7; | ||
query_condition?: string | ""; | ||
} | ||
|
||
export interface QueryString { | ||
app_name?: string | "*"; | ||
beamline?: string | "*"; | ||
filter?: string | "*"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { PayloadInterface } from "./interfaces"; | ||
export const payload: PayloadInterface = { | ||
parameters: [], | ||
queries: [ | ||
{ | ||
query: { | ||
type: "elasticsearch", | ||
query_string: "", | ||
}, | ||
timerange: { | ||
from: 300, | ||
type: "relative", | ||
}, | ||
filters: [], | ||
search_types: [ | ||
{ | ||
limit: 100, | ||
offset: 0, | ||
sort: [ | ||
{ | ||
field: "timestamp", | ||
order: "DESC", | ||
}, | ||
], | ||
fields: [], | ||
decorators: [], | ||
type: "messages", | ||
filter: null, | ||
filters: [], | ||
}, | ||
], | ||
}, | ||
], | ||
}; |