Made magic button in code editor
This commit is contained in:
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
version: '3'
|
version: '3'
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
build: ./frontend
|
#build: ./frontend
|
||||||
image: ghcr.io/frikky/shuffle-frontend:nightly
|
image: ghcr.io/frikky/shuffle-frontend:nightly
|
||||||
container_name: shuffle-frontend
|
container_name: shuffle-frontend
|
||||||
hostname: shuffle-frontend
|
hostname: shuffle-frontend
|
||||||
@@ -16,7 +16,7 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- backend
|
- backend
|
||||||
backend:
|
backend:
|
||||||
build: ./backend
|
#build: ./backend
|
||||||
image: ghcr.io/frikky/shuffle-backend:nightly
|
image: ghcr.io/frikky/shuffle-backend:nightly
|
||||||
container_name: shuffle-backend
|
container_name: shuffle-backend
|
||||||
hostname: ${BACKEND_HOSTNAME}
|
hostname: ${BACKEND_HOSTNAME}
|
||||||
|
|||||||
@@ -12,6 +12,10 @@ import {
|
|||||||
FullscreenExit as FullscreenExitIcon,
|
FullscreenExit as FullscreenExitIcon,
|
||||||
} from "@material-ui/icons";
|
} from "@material-ui/icons";
|
||||||
|
|
||||||
|
import {
|
||||||
|
AutoFixHigh as AutoFixHighIcon,
|
||||||
|
} from '@mui/icons-material';
|
||||||
|
|
||||||
import { useTheme } from '@material-ui/core/styles';
|
import { useTheme } from '@material-ui/core/styles';
|
||||||
import { validateJson } from "../views/Workflows.jsx";
|
import { validateJson } from "../views/Workflows.jsx";
|
||||||
import ReactJson from "react-json-view";
|
import ReactJson from "react-json-view";
|
||||||
@@ -28,6 +32,22 @@ const CodeEditor = (props) => {
|
|||||||
const [validation, setValidation] = React.useState(false);
|
const [validation, setValidation] = React.useState(false);
|
||||||
const [expOutput, setExpOutput] = React.useState(" ");
|
const [expOutput, setExpOutput] = React.useState(" ");
|
||||||
|
|
||||||
|
const autoFormat = (input) => {
|
||||||
|
if (validation !== true) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
input = JSON.stringify(JSON.parse(input), null, 4)
|
||||||
|
} catch (e) {
|
||||||
|
console.log("Failed magic JSON stringification: ", e)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input !== localcodedata) {
|
||||||
|
setlocalcodedata(input)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function expectedOutput(input) {
|
function expectedOutput(input) {
|
||||||
|
|
||||||
const found = input.match(/[$]{1}([a-zA-Z0-9_-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,}/g)
|
const found = input.match(/[$]{1}([a-zA-Z0-9_-]+\.?){1}([a-zA-Z0-9#_-]+\.?){0,}/g)
|
||||||
@@ -80,6 +100,7 @@ const CodeEditor = (props) => {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
<div style={{display: "flex"}}>
|
||||||
<DialogTitle
|
<DialogTitle
|
||||||
style={{
|
style={{
|
||||||
paddingBottom:20,
|
paddingBottom:20,
|
||||||
@@ -88,6 +109,25 @@ const CodeEditor = (props) => {
|
|||||||
>
|
>
|
||||||
Code Editor
|
Code Editor
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
|
<IconButton
|
||||||
|
style={{
|
||||||
|
marginLeft: 400,
|
||||||
|
height: 50,
|
||||||
|
width: 50,
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
autoFormat(localcodedata)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Tooltip
|
||||||
|
color="primary"
|
||||||
|
title={"Auto format data"}
|
||||||
|
placement="top"
|
||||||
|
>
|
||||||
|
<AutoFixHighIcon style={{color: "rgba(255,255,255,0.7)"}}/>
|
||||||
|
</Tooltip>
|
||||||
|
</IconButton>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<span style={{
|
<span style={{
|
||||||
border: `2px solid ${theme.palette.inputColor}`,
|
border: `2px solid ${theme.palette.inputColor}`,
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { useInterval } from "react-powerhooks";
|
|||||||
import { makeStyles, useTheme } from "@material-ui/core/styles";
|
import { makeStyles, useTheme } from "@material-ui/core/styles";
|
||||||
|
|
||||||
import { v4 as uuidv4 } from "uuid";
|
import { v4 as uuidv4 } from "uuid";
|
||||||
import { Link, useParams } from "react-router-dom";
|
import { useNavigate, Link, useParams } from "react-router-dom";
|
||||||
// import { Prompt } from "react-router"; // FIXME
|
// import { Prompt } from "react-router"; // FIXME
|
||||||
import { useBeforeunload } from "react-beforeunload";
|
import { useBeforeunload } from "react-beforeunload";
|
||||||
import ReactJson from "react-json-view";
|
import ReactJson from "react-json-view";
|
||||||
@@ -80,6 +80,10 @@ import {
|
|||||||
AddComment as AddCommentIcon,
|
AddComment as AddCommentIcon,
|
||||||
} from "@material-ui/icons";
|
} from "@material-ui/icons";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Preview as PreviewIcon,
|
||||||
|
} from '@mui/icons-material';
|
||||||
|
|
||||||
import Autocomplete from "@material-ui/lab/Autocomplete";
|
import Autocomplete from "@material-ui/lab/Autocomplete";
|
||||||
import * as cytoscape from "cytoscape";
|
import * as cytoscape from "cytoscape";
|
||||||
import * as edgehandles from "cytoscape-edgehandles";
|
import * as edgehandles from "cytoscape-edgehandles";
|
||||||
@@ -214,6 +218,7 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
const { globalUrl, isLoggedIn, isLoaded, userdata } = defaultprops;
|
const { globalUrl, isLoggedIn, isLoaded, userdata } = defaultprops;
|
||||||
const referenceUrl = globalUrl + "/api/v1/hooks/";
|
const referenceUrl = globalUrl + "/api/v1/hooks/";
|
||||||
const alert = useAlert()
|
const alert = useAlert()
|
||||||
|
let navigate = useNavigate();
|
||||||
|
|
||||||
const params = useParams();
|
const params = useParams();
|
||||||
var props = JSON.parse(JSON.stringify(defaultprops))
|
var props = JSON.parse(JSON.stringify(defaultprops))
|
||||||
@@ -3335,6 +3340,17 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
typeof window === "undefined" || window.location === undefined
|
typeof window === "undefined" || window.location === undefined
|
||||||
? ""
|
? ""
|
||||||
: window.location.search;
|
: window.location.search;
|
||||||
|
const tmpExec = new URLSearchParams(cursearch).get("execution_highlight");
|
||||||
|
if (
|
||||||
|
tmpExec !== undefined &&
|
||||||
|
tmpExec !== null &&
|
||||||
|
tmpExec === "executions"
|
||||||
|
) {
|
||||||
|
setExecutionModalOpen(true)
|
||||||
|
const newitem = removeParam("execution_highlight", cursearch);
|
||||||
|
props.history.push(curpath + newitem);
|
||||||
|
}
|
||||||
|
|
||||||
const tmpView = new URLSearchParams(cursearch).get("view");
|
const tmpView = new URLSearchParams(cursearch).get("view");
|
||||||
if (
|
if (
|
||||||
tmpView !== undefined &&
|
tmpView !== undefined &&
|
||||||
@@ -11254,6 +11270,48 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var similarActionsView = null
|
||||||
|
if (data.similar_actions !== undefined && data.similar_actions !== null) {
|
||||||
|
var minimumMatch = 85
|
||||||
|
var matching_executions = []
|
||||||
|
for (var k in data.similar_actions){
|
||||||
|
if (data.similar_actions.hasOwnProperty(k)) {
|
||||||
|
if (data.similar_actions[k].similarity > minimumMatch) {
|
||||||
|
matching_executions.push(data.similar_actions[k].execution_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matching_executions.length !== 0) {
|
||||||
|
var parsed_url = matching_executions.join(",")
|
||||||
|
|
||||||
|
similarActionsView =
|
||||||
|
<Tooltip
|
||||||
|
color="primary"
|
||||||
|
title="See executions with similar results (not identical)"
|
||||||
|
placement="top"
|
||||||
|
style={{ zIndex: 50000, marginLeft: 20,}}
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
style={{
|
||||||
|
marginTop: "auto",
|
||||||
|
marginBottom: "auto",
|
||||||
|
height: 30,
|
||||||
|
paddingLeft: 0,
|
||||||
|
width: 30,
|
||||||
|
}}
|
||||||
|
onClick={() => {
|
||||||
|
navigate(`?execution_highlight=${parsed_url}`)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PreviewIcon style={{ color: "rgba(255,255,255,0.5)" }}/>
|
||||||
|
</IconButton>
|
||||||
|
</Tooltip>
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
key={index}
|
key={index}
|
||||||
@@ -11376,9 +11434,10 @@ const AngularWorkflow = (defaultprops) => {
|
|||||||
<Typography variant="body1">
|
<Typography variant="body1">
|
||||||
<b>Status </b>
|
<b>Status </b>
|
||||||
</Typography>
|
</Typography>
|
||||||
<Typography variant="body1" color="textSecondary">
|
<Typography variant="body1" color="textSecondary" style={{marginRight: 15,}}>
|
||||||
{data.status}
|
{data.status}
|
||||||
</Typography>
|
</Typography>
|
||||||
|
{similarActionsView}
|
||||||
</div>
|
</div>
|
||||||
{validate.valid ? (
|
{validate.valid ? (
|
||||||
<span>
|
<span>
|
||||||
|
|||||||
Reference in New Issue
Block a user