diff --git a/frontend/src/components/ServerForm.tsx b/frontend/src/components/ServerForm.tsx index 2556cd1..43aef04 100644 --- a/frontend/src/components/ServerForm.tsx +++ b/frontend/src/components/ServerForm.tsx @@ -41,7 +41,12 @@ const ServerForm = ({ onSubmit, onCancel, initialData = null, modalTitle, formEr args: (initialData && initialData.config && initialData.config.args) || [], type: getInitialServerType(), // Initialize the type field env: [], - headers: [] + headers: [], + options: { + timeout: (initialData && initialData.config && initialData.config.options && initialData.config.options.timeout) || 60000, + resetTimeoutOnProgress: (initialData && initialData.config && initialData.config.options && initialData.config.options.resetTimeoutOnProgress) || false, + maxTotalTimeout: (initialData && initialData.config && initialData.config.options && initialData.config.options.maxTotalTimeout) || undefined, + } }) const [envVars, setEnvVars] = useState( @@ -56,6 +61,7 @@ const ServerForm = ({ onSubmit, onCancel, initialData = null, modalTitle, formEr : [], ) + const [isRequestOptionsExpanded, setIsRequestOptionsExpanded] = useState(false) const [error, setError] = useState(null) const isEdit = !!initialData @@ -66,7 +72,7 @@ const ServerForm = ({ onSubmit, onCancel, initialData = null, modalTitle, formEr // Transform space-separated arguments string into array const handleArgsChange = (value: string) => { - let args = value.split(' ').filter((arg) => arg.trim() !== '') + const args = value.split(' ').filter((arg) => arg.trim() !== '') setFormData({ ...formData, arguments: value, args }) } @@ -107,6 +113,17 @@ const ServerForm = ({ onSubmit, onCancel, initialData = null, modalTitle, formEr setHeaderVars(newHeaderVars) } + // Handle options changes + const handleOptionsChange = (field: 'timeout' | 'resetTimeoutOnProgress' | 'maxTotalTimeout', value: number | boolean | undefined) => { + setFormData(prev => ({ + ...prev, + options: { + ...prev.options, + [field]: value + } + })) + } + // Submit handler for server configuration const handleSubmit = async (e: React.FormEvent) => { e.preventDefault() @@ -127,6 +144,18 @@ const ServerForm = ({ onSubmit, onCancel, initialData = null, modalTitle, formEr } }) + // Prepare options object, only include defined values + const options: any = {} + if (formData.options?.timeout && formData.options.timeout !== 60000) { + options.timeout = formData.options.timeout + } + if (formData.options?.resetTimeoutOnProgress) { + options.resetTimeoutOnProgress = formData.options.resetTimeoutOnProgress + } + if (formData.options?.maxTotalTimeout) { + options.maxTotalTimeout = formData.options.maxTotalTimeout + } + const payload = { name: formData.name, config: { @@ -141,7 +170,8 @@ const ServerForm = ({ onSubmit, onCancel, initialData = null, modalTitle, formEr args: formData.args, env: Object.keys(env).length > 0 ? env : undefined, } - ) + ), + ...(Object.keys(options).length > 0 ? { options } : {}) } } @@ -365,6 +395,75 @@ const ServerForm = ({ onSubmit, onCancel, initialData = null, modalTitle, formEr )} + {/* Request Options Configuration */} +
+
setIsRequestOptionsExpanded(!isRequestOptionsExpanded)} + > + + + {isRequestOptionsExpanded ? '▼' : '▶'} + +
+ + {isRequestOptionsExpanded && ( +
+
+
+ + handleOptionsChange('timeout', parseInt(e.target.value) || 60000)} + className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" + placeholder="30000" + min="1000" + max="300000" + /> +

{t('server.timeoutDescription')}

+
+ +
+ + handleOptionsChange('maxTotalTimeout', e.target.value ? parseInt(e.target.value) : undefined)} + className="shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline" + placeholder="Optional" + min="1000" + /> +

{t('server.maxTotalTimeoutDescription')}

+
+
+ +
+ +

+ {t('server.resetTimeoutOnProgressDescription')} +

+
+
+ )} +
+