rowyRun localhost option

This commit is contained in:
shamsmosowi
2021-09-14 12:51:34 +10:00
parent cb2a50c3fb
commit 0821082588
2 changed files with 21 additions and 8 deletions

View File

@@ -73,6 +73,7 @@ interface ProjectContextProps {
route: RunRoute;
body?: any;
params?: string[];
localhost?: boolean;
}) => Promise<any>;
}
@@ -187,15 +188,17 @@ export const ProjectContextProvider: React.FC = ({ children }) => {
route,
body,
params,
localhost = false,
}: {
route: RunRoute;
body?: any;
params?: string[];
localhost?: boolean;
}) => {
const { method, path } = route;
let url =
//'http://localhost:8080'
settings.doc.rowyRunUrl + path;
let url = `${
localhost ? "http://localhost:8080" : settings.doc.rowyRunUrl
}${path}`;
if (params && params.length > 0) url = url + "/" + params.join("/");
const response = await fetch(url, {
method: method, // *GET, POST, PUT, DELETE, etc.

View File

@@ -11,13 +11,10 @@ import {
Tab,
LinearProgress,
MenuItem,
Switch,
FormControlLabel,
} from "@mui/material";
import SparkIcon from "@mui/icons-material/OfflineBoltOutlined";
import { useConfirmation } from "components/ConfirmationDialog";
import SnackbarProgress, {
ISnackbarProgressRef,
} from "components/SnackbarProgress";
import { useProjectContext } from "@src/contexts/ProjectContext";
import { RunRoutes } from "@src/constants/runRoutes";
@@ -26,6 +23,7 @@ export default function TestView() {
const { requestConfirmation } = useConfirmation();
const { enqueueSnackbar, closeSnackbar } = useSnackbar();
const [loading, setLoading] = useState(false);
const [localhost, setLocalhost] = useState(false);
const { rowyRun } = useProjectContext();
const [result, setResult] = useState<any>({});
@@ -50,6 +48,7 @@ export default function TestView() {
method,
path,
},
localhost,
});
setResult(resp);
setLoading(false);
@@ -63,6 +62,17 @@ export default function TestView() {
)}
<Container style={{ margin: "24px 0 200px" }}>
<FormControlLabel
control={
<Switch
size="medium"
onClick={() => {
setLocalhost(!localhost);
}}
/>
}
label="Localhost?"
/>
<TextField
label="Defined Route"
select