Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add interface for updating the POST data field (dev)
  • Loading branch information
cccs-rs authored Feb 10, 2025
2 parents 39b1b7d + 2a65241 commit 4d6c95d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/components/models/base/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ export type UpdateSource = {
/** Pattern used to find files of interest from source */
pattern?: string;

/** Data that's sent in POST requests */
post_data?: { [key: string]: any };

/** Private key used to authenticate with source */
private_key?: string;

Expand Down Expand Up @@ -455,6 +458,7 @@ export const DEFAULT_SOURCE: UpdateSource = {
override_classification: false,
password: '',
pattern: '',
post_data: {},
private_key: '',
proxy: '',
ssl_ignore_errors: false,
Expand Down
36 changes: 35 additions & 1 deletion src/components/routes/manage/signature_sources_details.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const WrappedSourceDetail = ({
const [showPrivateKey, setShowPrivateKey] = useState<boolean>(false);

const gitFetch = useMemo<boolean>(() => source.fetch_method === 'GIT', [source.fetch_method]);
const postFetch = useMemo<boolean>(() => source.fetch_method === 'POST', [source.fetch_method]);

const handleFieldChange = useCallback(
event => {
Expand Down Expand Up @@ -119,6 +120,14 @@ const WrappedSourceDetail = ({
[setModified, setSource, source]
);

const handlePostDataChange = useCallback(
event => {
setSource({ ...source, post_data: event.updated_src });
setModified(true);
},
[setModified, setSource, source]
);

const handleUpdateIntervalChange = useCallback(
event => {
if (!event.target.value) {
Expand Down Expand Up @@ -470,7 +479,32 @@ const WrappedSourceDetail = ({
}}
/>
</Grid>

{postFetch && (
<Grid item xs={12}>
<div className={classes.label}>{t('post_data')}</div>
<JSONEditor
name={false}
src={source.post_data}
enableClipboard={false}
groupArraysAfterLength={10}
displayDataTypes={false}
displayObjectSize={false}
onAdd={handlePostDataChange}
onDelete={handlePostDataChange}
onEdit={handlePostDataChange}
collapsed={true}
style={{
border: `1px solid ${theme.palette.divider}`,
borderRadius: '4px',
fontSize: '1rem',
minHeight: theme.spacing(5),
padding: '4px',
overflowX: 'auto',
width: '100%'
}}
/>
</Grid>
)}
<Grid item xs={12}>
<div className={classes.label}>
{t('proxy')}
Expand Down
1 change: 1 addition & 0 deletions src/locales/en/manage/signature_sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"override_classification": "Override signature-defined classification with source classification",
"password": "Password",
"pattern": "Regex pattern",
"post_data": "POST Data",
"private_key": "Private key",
"private_key_used": "A private key will be used to connect to the source",
"proxy": "Proxy server",
Expand Down
1 change: 1 addition & 0 deletions src/locales/fr/manage/signature_sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
"override_classification": "Override signature-defined classification with source classificationRemplacer la classification définie par la signature par la classification de la source",
"password": "Mot de passe",
"pattern": "Modèle Regex",
"post_data": "Données POST",
"private_key": "Clé privée",
"private_key_used": "Une clé privée sera utilisée pour se connecter à la source",
"proxy": "Serveur Proxy",
Expand Down

0 comments on commit 4d6c95d

Please sign in to comment.