Skip to content

Commit

Permalink
few UI tweaks and bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
its-a-feature committed Aug 2, 2024
1 parent a325ec1 commit 7cc9870
Showing 10 changed files with 61 additions and 12 deletions.
7 changes: 7 additions & 0 deletions MythicReactUI/CHANGELOG.MD
Original file line number Diff line number Diff line change
@@ -4,6 +4,13 @@ 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.2.11] - 2024-08-02

### Changed

- Fixed a duplicating issue when trying to up/down arrow through tasking
- Added button to auto-format output as JSON for text views and update mode to JSON

## [0.2.10] - 2024-07-31

### Changed
Original file line number Diff line number Diff line change
@@ -188,7 +188,15 @@ export function CallbacksTabsTaskingInputPreMemo(props){
if(!mountedRef.current || !props.parentMountedRef.current){
return;
}
const newTasks = [...taskOptions, ...data.data.task_stream];
const newTasks = data.data.task_stream.reduce( (prev, cur) => {
let prevIndex = prev.findIndex(t => t.id === cur.id);
if(prevIndex >= 0){
prev[prevIndex] = {...cur};
return [...prev];
} else {
return [...prev, {...cur}];
}
}, [...taskOptions]);
newTasks.sort((a,b) => a.id > b.id ? -1 : 1);
setTaskOptions(newTasks);
const filteredOptions = newTasks.filter( c => applyFilteringToTasks(c));
Original file line number Diff line number Diff line change
@@ -41,6 +41,7 @@ import Tabs from '@mui/material/Tabs';
import Tab from '@mui/material/Tab';
import {previewFileQuery} from "../Search/FileMetaTable";
import { useMutation } from '@apollo/client';
import CodeIcon from '@mui/icons-material/Code';

export const ResponseDisplayMedia = ({media, expand, task}) =>{
const displayType = mimeType(media?.filename);
@@ -242,6 +243,7 @@ const DisplayText = ({agent_file_id, expand, filename, preview}) => {
snackActions.error(data);
}
});
const currentContentRef = React.useRef();
React.useEffect( () => {
if(preview){
// get first 512KB
@@ -297,9 +299,18 @@ const DisplayText = ({agent_file_id, expand, filename, preview}) => {
const toggleWrapText = () => {
setWrapText(!wrapText);
}
const formatJSON = () => {
try{
let tmp = JSON.stringify(JSON.parse(currentContentRef.current?.editor?.getValue()), null, 2);
setContent(tmp);
setMode("json");
}catch(error){
snackActions.warning("Failed to reformat as JSON")
}
}
return (
<div style={{display: "flex", height: "100%", flexDirection: "column"}}>
<div style={{display: "inline-flex", flexDirection: "row"}}>
<div style={{display: "inline-flex", flexDirection: "row", alignItems: "center"}}>
<FormControl sx={{ display: "inline-block" }} size="small" color={"secondary"}>
<TextField
select
@@ -325,9 +336,15 @@ const DisplayText = ({agent_file_id, expand, filename, preview}) => {
/>
</IconButton>
</MythicStyledTooltip>
<MythicStyledTooltip title={"Auto format JSON"} >
<IconButton onClick={formatJSON} style={{}}>
<CodeIcon color={"info"} style={{cursor: "pointer"}} />
</IconButton>
</MythicStyledTooltip>
</div>
<div style={{display: "flex", flexGrow: 1, height: "100%"}}>
<AceEditor
ref={currentContentRef}
mode={mode}
theme={theme.palette.mode === "dark" ? "monokai" : "xcode"}
fontSize={14}
Original file line number Diff line number Diff line change
@@ -25,11 +25,13 @@ import UnfoldMoreIcon from '@mui/icons-material/UnfoldMore';
import UnfoldLessIcon from '@mui/icons-material/UnfoldLess';
import { useReactiveVar } from '@apollo/client';
import { meState } from '../../../cache';
import CodeIcon from '@mui/icons-material/Code';

const MaxRenderSize = 2000000;
export const ResponseDisplayPlaintext = (props) =>{
const theme = useTheme();
const me = useReactiveVar(meState);
const currentContentRef = React.useRef();
const [plaintextView, setPlaintextView] = React.useState("");
const [mode, setMode] = React.useState("html");
const [wrapText, setWrapText] = React.useState(true);
@@ -54,6 +56,15 @@ export const ResponseDisplayPlaintext = (props) =>{
const toggleWrapText = () => {
setWrapText(!wrapText);
}
const formatJSON = () => {
try{
let tmp = JSON.stringify(JSON.parse(currentContentRef.current?.editor?.getValue()), null, 2);
setPlaintextView(tmp);
setMode("json");
}catch(error){
snackActions.warning("Failed to reformat as JSON")
}
}
const onChangeShowOptions = (e) => {
setShowOptions(!showOptions);
}
@@ -80,7 +91,7 @@ export const ResponseDisplayPlaintext = (props) =>{
return (
<div style={{display: "flex", height: "100%", flexDirection: "column"}}>
{showOptions &&
<div style={{display: "inline-flex", flexDirection: "row"}}>
<div style={{display: "inline-flex", flexDirection: "row", alignItems: "center"}}>
<FormControl sx={{ display: "inline-block" }} size="small">
<TextField
label={"Syntax"}
@@ -105,6 +116,11 @@ export const ResponseDisplayPlaintext = (props) =>{
/>
</IconButton>
</MythicStyledTooltip>
<MythicStyledTooltip title={"Auto format JSON"} >
<IconButton onClick={formatJSON} style={{}}>
<CodeIcon color={"info"} style={{cursor: "pointer"}} />
</IconButton>
</MythicStyledTooltip>
</div>
}
<div style={{height: "1px", width: "100%", display: "flex", zIndex: 1, backgroundColor: theme.palette.secondary.main}}>
@@ -118,6 +134,7 @@ export const ResponseDisplayPlaintext = (props) =>{

<div style={{display: "flex", flexGrow: 1, height: "100%"}}>
<AceEditor
ref={currentContentRef}
mode={mode}
theme={theme.palette.mode === "dark" ? "monokai" : "xcode"}
fontSize={14}
2 changes: 1 addition & 1 deletion MythicReactUI/src/index.js
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ import {snackActions} from './components/utilities/Snackbar';
import jwt_decode from 'jwt-decode';
import {meState} from './cache';

export const mythicUIVersion = "0.2.10";
export const mythicUIVersion = "0.2.11";

let fetchingNewToken = false;

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,15 +1,15 @@
{
"files": {
"main.css": "/new/static/css/main.7e143bf2.css",
"main.js": "/new/static/js/main.751a3b5e.js",
"main.js": "/new/static/js/main.220682dd.js",
"static/media/mythic-red.png": "/new/static/media/mythic-red.203468a4e5240d239aa0.png",
"static/media/mythic_red_small.svg": "/new/static/media/mythic_red_small.793b41cc7135cdede246661ec232976b.svg",
"index.html": "/new/index.html",
"main.7e143bf2.css.map": "/new/static/css/main.7e143bf2.css.map",
"main.751a3b5e.js.map": "/new/static/js/main.751a3b5e.js.map"
"main.220682dd.js.map": "/new/static/js/main.220682dd.js.map"
},
"entrypoints": [
"static/css/main.7e143bf2.css",
"static/js/main.751a3b5e.js"
"static/js/main.220682dd.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.751a3b5e.js"></script><link href="/new/static/css/main.7e143bf2.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.220682dd.js"></script><link href="/new/static/css/main.7e143bf2.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 7cc9870

Please sign in to comment.