feat: create action ui directory
This commit is contained in:
11
src/components/action/action-settings/index.ts
Normal file
11
src/components/action/action-settings/index.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { ScrollSettings } from './scroll';
|
||||
import { ScreenshotSettings } from "./screenshot";
|
||||
import { ScrapeSettings } from "./scrape";
|
||||
import { ScrapeSchemaSettings } from "./scrapeSchema";
|
||||
|
||||
export {
|
||||
ScrollSettings,
|
||||
ScreenshotSettings,
|
||||
ScrapeSettings,
|
||||
ScrapeSchemaSettings,
|
||||
};
|
||||
30
src/components/action/action-settings/scrape.tsx
Normal file
30
src/components/action/action-settings/scrape.tsx
Normal file
@@ -0,0 +1,30 @@
|
||||
import React, { forwardRef, useImperativeHandle } from 'react';
|
||||
import { Stack, TextField } from "@mui/material";
|
||||
import { WarningText } from '../../ui/texts';
|
||||
import InfoIcon from "@mui/icons-material/Info";
|
||||
|
||||
export const ScrapeSettings = forwardRef((props, ref) => {
|
||||
const [settings, setSettings] = React.useState<string>('');
|
||||
useImperativeHandle(ref, () => ({
|
||||
getSettings() {
|
||||
return settings;
|
||||
}
|
||||
}));
|
||||
|
||||
return (
|
||||
<Stack direction="column">
|
||||
<TextField
|
||||
sx={{ marginLeft: '15px', marginRight: '15px' }}
|
||||
type="string"
|
||||
label="Selector"
|
||||
onChange={(e) => setSettings(e.target.value)}
|
||||
/>
|
||||
<WarningText>
|
||||
<InfoIcon color='warning' />
|
||||
The scrape function uses heuristic algorithm to automatically scrape only important data from the page.
|
||||
If a selector is used it will scrape and automatically parse all available
|
||||
data inside of the selected element(s).
|
||||
</WarningText>
|
||||
</Stack>
|
||||
);
|
||||
});
|
||||
25
src/components/action/action-settings/scrapeSchema.tsx
Normal file
25
src/components/action/action-settings/scrapeSchema.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React, { forwardRef, useCallback, useImperativeHandle, useRef } from 'react';
|
||||
import { WarningText } from "../../ui/texts";
|
||||
import InfoIcon from "@mui/icons-material/Info";
|
||||
import { KeyValueForm } from "../../recorder/KeyValueForm";
|
||||
|
||||
export const ScrapeSchemaSettings = forwardRef((props, ref) => {
|
||||
const keyValueFormRef = useRef<{ getObject: () => object }>(null);
|
||||
|
||||
useImperativeHandle(ref, () => ({
|
||||
getSettings() {
|
||||
const settings = keyValueFormRef.current?.getObject() as Record<string, string>
|
||||
return settings;
|
||||
}
|
||||
}));
|
||||
|
||||
return (
|
||||
<div>
|
||||
<WarningText>
|
||||
<InfoIcon color='warning' />
|
||||
The interpreter scrapes the data from a webpage into a "curated" table.
|
||||
</WarningText>
|
||||
<KeyValueForm ref={keyValueFormRef} />
|
||||
</div>
|
||||
);
|
||||
});
|
||||
126
src/components/action/action-settings/screenshot.tsx
Normal file
126
src/components/action/action-settings/screenshot.tsx
Normal file
@@ -0,0 +1,126 @@
|
||||
import React, { forwardRef, useImperativeHandle } from 'react';
|
||||
import { InputLabel, MenuItem, TextField, Select, FormControl } from "@mui/material";
|
||||
import { ScreenshotSettings as Settings } from "../../../shared/types";
|
||||
import styled from "styled-components";
|
||||
import { SelectChangeEvent } from "@mui/material/Select/Select";
|
||||
import { Dropdown } from "../../ui/DropdownMui";
|
||||
|
||||
export const ScreenshotSettings = forwardRef((props, ref) => {
|
||||
const [settings, setSettings] = React.useState<Settings>({});
|
||||
useImperativeHandle(ref, () => ({
|
||||
getSettings() {
|
||||
return settings;
|
||||
}
|
||||
}));
|
||||
|
||||
const handleInput = (event: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const { id, value, type } = event.target;
|
||||
let parsedValue: any = value;
|
||||
if (type === "number") {
|
||||
parsedValue = parseInt(value);
|
||||
};
|
||||
setSettings({
|
||||
...settings,
|
||||
[id]: parsedValue,
|
||||
});
|
||||
};
|
||||
|
||||
const handleSelect = (event: SelectChangeEvent) => {
|
||||
const { name, value } = event.target;
|
||||
let parsedValue: any = value;
|
||||
if (value === "true" || value === "false") {
|
||||
parsedValue = value === "true";
|
||||
};
|
||||
setSettings({
|
||||
...settings,
|
||||
[name]: parsedValue,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<SettingsWrapper>
|
||||
<Dropdown
|
||||
id="type"
|
||||
label="type"
|
||||
value={settings.type || "png"}
|
||||
handleSelect={handleSelect}
|
||||
>
|
||||
<MenuItem value="jpeg">jpeg</MenuItem>
|
||||
<MenuItem value="png">png</MenuItem>
|
||||
</Dropdown>
|
||||
{settings.type === "jpeg" ?
|
||||
<TextField
|
||||
type="number"
|
||||
id="quality"
|
||||
label="quality"
|
||||
size='small'
|
||||
InputProps={{ inputProps: { min: 0, max: 100 } }}
|
||||
onChange={handleInput}
|
||||
/> : null
|
||||
}
|
||||
<TextField
|
||||
type="number"
|
||||
id="timeout"
|
||||
label="timeout"
|
||||
size='small'
|
||||
onChange={handleInput}
|
||||
defaultValue='30000'
|
||||
/>
|
||||
<Dropdown
|
||||
id="animations"
|
||||
label="animations"
|
||||
value={settings.animations || 'allow'}
|
||||
handleSelect={handleSelect}
|
||||
>
|
||||
<MenuItem value="disabled">disabled</MenuItem>
|
||||
<MenuItem value="allow">allow</MenuItem>
|
||||
</Dropdown>
|
||||
{settings.type === "png" ?
|
||||
<Dropdown
|
||||
id="omitBackground"
|
||||
label="omitBackground"
|
||||
value={settings.omitBackground?.toString() || "false"}
|
||||
handleSelect={handleSelect}
|
||||
>
|
||||
<MenuItem value="true">true</MenuItem>
|
||||
<MenuItem value="false">false</MenuItem>
|
||||
</Dropdown>
|
||||
: null
|
||||
}
|
||||
<Dropdown
|
||||
id="caret"
|
||||
label="caret"
|
||||
value={settings.caret || "hide"}
|
||||
handleSelect={handleSelect}
|
||||
>
|
||||
<MenuItem value="hide">hide</MenuItem>
|
||||
<MenuItem value="initial">initial</MenuItem>
|
||||
</Dropdown>
|
||||
<Dropdown
|
||||
id="fullPage"
|
||||
label="fullPage"
|
||||
value={settings.fullPage?.toString() || "false"}
|
||||
handleSelect={handleSelect}
|
||||
>
|
||||
<MenuItem value="true">true</MenuItem>
|
||||
<MenuItem value="false">false</MenuItem>
|
||||
</Dropdown>
|
||||
<Dropdown
|
||||
id="scale"
|
||||
label="scale"
|
||||
value={settings.scale || "device"}
|
||||
handleSelect={handleSelect}
|
||||
>
|
||||
<MenuItem value="css">css</MenuItem>
|
||||
<MenuItem value="device">device</MenuItem>
|
||||
</Dropdown>
|
||||
</SettingsWrapper>
|
||||
);
|
||||
});
|
||||
|
||||
const SettingsWrapper = styled.div`
|
||||
margin-left: 15px;
|
||||
* {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
`;
|
||||
21
src/components/action/action-settings/scroll.tsx
Normal file
21
src/components/action/action-settings/scroll.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import React, { forwardRef, useImperativeHandle } from 'react';
|
||||
import { TextField } from "@mui/material";
|
||||
|
||||
export const ScrollSettings = forwardRef((props, ref) => {
|
||||
const [settings, setSettings] = React.useState<number>(0);
|
||||
useImperativeHandle(ref, () => ({
|
||||
getSettings() {
|
||||
return settings;
|
||||
}
|
||||
}));
|
||||
|
||||
return (
|
||||
<TextField
|
||||
sx={{ marginLeft: '15px' }}
|
||||
type="number"
|
||||
label="Number of pages"
|
||||
required
|
||||
onChange={(e) => setSettings(parseInt(e.target.value))}
|
||||
/>
|
||||
);
|
||||
});
|
||||
Reference in New Issue
Block a user