Skip to content

Commit

Permalink
reduced debouncing on some fields and notification fix
Browse files Browse the repository at this point in the history
  • Loading branch information
its-a-feature committed Feb 21, 2025
1 parent 2fb43a3 commit 71ca8d9
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 58 deletions.
8 changes: 8 additions & 0 deletions MythicReactUI/CHANGELOG.MD
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.13] - 2025-02-21

### Changed

- Updated the debounce delay on logon to be 0 to prevent failed logons
- Updated graph edges to not be connectable
- Fixed an issue with event notifications not showing up

## [0.3.12] - 2025-02-21

### Changed
Expand Down
61 changes: 28 additions & 33 deletions MythicReactUI/src/components/EventFeedNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,49 +22,44 @@ const subscribe_payloads = gql`
`;

export function EventFeedNotifications(props) {
const me = props.me;
const [fromNow, setFromNow] = React.useState(getSkewedNow().toISOString());
//const fromNow = React.useRef( );
const { loading, error, data } = useSubscription(subscribe_payloads, {
useSubscription(subscribe_payloads, {
variables: {fromNow: fromNow },
fetchPolicy: "no-cache",
shouldResubscribe: true,
onError: (errorData) => {
console.log(errorData);
}
});

useEffect( () => {
//console.log(data, loading, error, fromNow.current);
if(!loading && !error && data && data.operationeventlog_stream.length > 0){
if(data.operationeventlog_stream[0].level === "api" || data.operationeventlog_stream[0].level === "debug" ){
return;
}
if(data.operationeventlog_stream[0].resolved){
return;
}
if(data.operationeventlog_stream[0].operator){
const message = data.operationeventlog_stream[0].operator.username + ":\n" + data.operationeventlog_stream[0].message;
if (data.operationeventlog_stream[0].level === "warning") {
snackActions.warning(message, { autoClose: 2000});
} else {
snackActions.info(message, { autoClose: 2000});
},
onData: ({data}) => {
if (data.data.operationeventlog_stream.length > 0){
if(data.data.operationeventlog_stream[0].level === "api" || data.data.operationeventlog_stream[0].level === "debug" ){
return;
}

}else {
if (data.operationeventlog_stream[0].level === "warning") {
snackActions.warning(data.operationeventlog_stream[0].message, {autoClose: 3000});
} else {
snackActions.info(
<div style={{width: "100%"}}>{data.operationeventlog_stream[0].message}</div>,
{autoClose: 3000});
if(data.data.operationeventlog_stream[0].resolved){
return;
}
if(data.data.operationeventlog_stream[0].operator){
const message = data.data.operationeventlog_stream[0].operator.username + ":\n" + data.data.operationeventlog_stream[0].message;
if (data.data.operationeventlog_stream[0].level === "warning") {
snackActions.warning(message, { autoClose: 2000});
} else {
snackActions.info(message, { autoClose: 2000});
}

}
}else if(error){
console.error(error);
}else {
if (data.data.operationeventlog_stream[0].level === "warning") {
snackActions.warning(data.data.operationeventlog_stream[0].message, {autoClose: 3000});
} else {
snackActions.info(
<div style={{width: "100%"}}>{data.data.operationeventlog_stream[0].message}</div>,
{autoClose: 3000});
}

}
}
}
}, [loading, data, error, me.user?.id]);
return null;
});
return null
}

Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const MythicTextField = ({
maxRows = 10,
errorText = "",
helperText = "",
debounceDelay = 200,
debounceDelay = 100,
}) => {
const [localValue, setLocalValue] = React.useState({value: value, event: null});
const debouncedLocalInput = useDebounce(localValue, debounceDelay);
Expand Down
16 changes: 8 additions & 8 deletions MythicReactUI/src/components/pages/Callbacks/C2PathDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -391,12 +391,12 @@ function AgentNode({data}) {
<div style={{padding: 0, margin: 0, ...additionalStyles}}>
{
[...Array(data.sourceCount)].map((e, i) => (
<Handle type={"source"} id={`${i+1}`} key={`${i+1}`} style={data.sourceCount > 1 ? getOffset(i) : {}} position={sourcePosition} />
<Handle type={"source"} id={`${i+1}`} key={`${i+1}`} style={data.sourceCount > 1 ? getOffset(i) : {}} isConnectable={false} position={sourcePosition} />
))

}
<img alt={data.img} style={{margin: "auto"}} src={data.img} className={"circleImageNode"} />
<Handle type={"target"} position={targetPosition} />
<Handle type={"target"} position={targetPosition} isConnectable={false}/>
<Typography style={{textAlign: "center", margin: 0, padding: 0}} >{data.label}</Typography>
</div>
)
Expand All @@ -406,13 +406,13 @@ function TaskNode({data}) {
const targetPosition = getTargetPosition(data["elk.direction"]);
return (
<div >
<Handle type={"source"} position={sourcePosition} />
<Handle type={"source"} position={sourcePosition} isConnectable={false} />
{data.id > 0 &&
<TaskLabelFlat task={data} showOnSelectTask={!data.selected} onSelectTask={() => {data.onSelectTask(data)}}
graphView={true}
/>
}
<Handle type={"target"} position={targetPosition} />
<Handle type={"target"} position={targetPosition} isConnectable={false} />
</div>
)
}
Expand All @@ -426,12 +426,12 @@ function BrowserscriptNode({data}) {
} : {};
return (
<div style={{padding: 0, margin: 0, display: "flex", flexDirection: "column", ...additionalStyles}}>
<Handle type={"source"} position={sourcePosition} />
<Handle type={"source"} position={sourcePosition} isConnectable={false} />
{data.img}
<div style={{top: 0, right: 0, height: "50%", width: "50%", position: "absolute"}}>
{data.overlay_img}
</div>
<Handle type={"target"} position={targetPosition} />
<Handle type={"target"} position={targetPosition} isConnectable={false} />
<Typography style={{textAlign: "center", margin: 0, padding: 0}} >{data.data.label}</Typography>
</div>
)
Expand All @@ -441,11 +441,11 @@ export function GroupNode({data}) {
const targetPosition = getTargetPosition(data["elk.direction"]);
return (
<>
<Handle hidden type={"source"} position={sourcePosition} />
<Handle hidden type={"source"} position={sourcePosition} isConnectable={false} />
<div className={"groupNode"} style={{width: data.width, height: data.height, margin: "auto"}}>
<Typography style={{textAlign: "center", margin: 0, padding: 0}} >{data.label}</Typography>
</div>
<Handle type={"target"} hidden position={targetPosition} />
<Handle type={"target"} hidden position={targetPosition} isConnectable={false} />
</>


Expand Down
8 changes: 4 additions & 4 deletions MythicReactUI/src/components/pages/Login/InviteForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ export function InviteForm(props){
<CardContent>
<img src={logo} height="400px" alt="Mythic logo"/>
<form onSubmit={submit}>
<MythicTextField name='code' value={inviteCode}
<MythicTextField name='code' value={inviteCode} debounceDelay={0}
onChange={onChangeText} width={31}/>
<MythicTextField name='username' value={username} onChange={onChangeText}
width={31}/>
width={31} debounceDelay={0}/>
<MythicTextField name='password' type="password" onEnter={submit} value={password}
onChange={onChangeText} width={31}/>
onChange={onChangeText} width={31} debounceDelay={0}/>
<MythicTextField name='email' value={email} onChange={onChangeText}
width={31}/>
width={31} debounceDelay={0}/>
<Button type="submit" color="primary" onClick={submit} variant="contained"
style={{}}>Register</Button>
</form>
Expand Down
6 changes: 3 additions & 3 deletions MythicReactUI/src/components/pages/Login/LoginForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ export function LoginForm(props){
{requestField.length === 0 &&
<>
<MythicTextField name='username' value={username} onChange={onUsernameChange}
width={31}/>
width={31} debounceDelay={0}/>
<MythicTextField name='password' type="password" onEnter={submit} value={password}
onChange={onPasswordChange} width={31}/>
onChange={onPasswordChange} width={31} debounceDelay={0}/>
<Button type="submit" color="primary" onClick={submit} variant="contained"
style={{}}>Login</Button>
</>
Expand All @@ -205,7 +205,7 @@ export function LoginForm(props){
{requestField.map(r => (
<MythicTextField key={r.name} name={r.name} value={r.value} onChange={onUpdateText}
type={r.name === "password" ? "password" : ""}
width={31}/>
width={31} debounceDelay={0}/>
))}
<Button type="submit" color="primary" onClick={submitNonIDP} variant="contained"
style={{}}>Login via {selectedAuthOptionRef.current.idp}</Button>
Expand Down
2 changes: 1 addition & 1 deletion MythicReactUI/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import jwt_decode from 'jwt-decode';
import {meState} from './cache';
import {getSkewedNow} from "./components/utilities/Time";

export const mythicUIVersion = "0.3.12";
export const mythicUIVersion = "0.3.13";

let fetchingNewToken = false;

Expand Down
6 changes: 3 additions & 3 deletions mythic-react-docker/mythic/public/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"files": {
"main.css": "/new/static/css/main.602591e6.css",
"main.js": "/new/static/js/main.9e64a751.js",
"main.js": "/new/static/js/main.d79cea76.js",
"static/media/mythic-red.png": "/new/static/media/mythic-red.203468a4e5240d239aa0.png",
"static/media/graphql.png": "/new/static/media/graphql.8f15978b39b0870a9f0e.png",
"static/media/Mythic_Logo.svg": "/new/static/media/Mythic_Logo.6842c911bebe36d6f83fc7ced4a2cd99.svg",
"static/media/mythic_red_small.svg": "/new/static/media/mythic_red_small.793b41cc7135cdede246661ec232976b.svg",
"index.html": "/new/index.html",
"main.602591e6.css.map": "/new/static/css/main.602591e6.css.map",
"main.9e64a751.js.map": "/new/static/js/main.9e64a751.js.map"
"main.d79cea76.js.map": "/new/static/js/main.d79cea76.js.map"
},
"entrypoints": [
"static/css/main.602591e6.css",
"static/js/main.9e64a751.js"
"static/js/main.d79cea76.js"
]
}
2 changes: 1 addition & 1 deletion mythic-react-docker/mythic/public/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/new/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="apple-touch-icon" href="/new/logo192.png"/><link rel="manifest" href="/new/manifest.json"/><title>Mythic</title><script defer="defer" src="/new/static/js/main.9e64a751.js"></script><link href="/new/static/css/main.602591e6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/new/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><link rel="apple-touch-icon" href="/new/logo192.png"/><link rel="manifest" href="/new/manifest.json"/><title>Mythic</title><script defer="defer" src="/new/static/js/main.d79cea76.js"></script><link href="/new/static/css/main.602591e6.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

0 comments on commit 71ca8d9

Please sign in to comment.