Spaces:
Building
Building
Update flare-ui/src/app/dialogs/api-edit-dialog/api-edit-dialog.component.html
Browse files
flare-ui/src/app/dialogs/api-edit-dialog/api-edit-dialog.component.html
CHANGED
@@ -1,469 +1,502 @@
|
|
1 |
-
<h2 mat-dialog-title>
|
2 |
-
@if (data.mode === 'create') {
|
3 |
-
Create New API
|
4 |
-
} @else if (data.mode === 'duplicate') {
|
5 |
-
Duplicate API
|
6 |
-
} @else if (data.mode === 'test') {
|
7 |
-
Test API: {{ data.api.name }}
|
8 |
-
} @else {
|
9 |
-
Edit API: {{ data.api.name }}
|
10 |
-
}
|
11 |
-
</h2>
|
12 |
-
|
13 |
-
<mat-dialog-content>
|
14 |
-
<mat-tab-group [(selectedIndex)]="activeTabIndex">
|
15 |
-
<!-- General Tab -->
|
16 |
-
<mat-tab label="General">
|
17 |
-
<div class="tab-content">
|
18 |
-
<mat-form-field appearance="outline">
|
19 |
-
<mat-label>Name</mat-label>
|
20 |
-
<input matInput [formControl]="$any(form.get('name'))" placeholder="e.g., get_flights">
|
21 |
-
<mat-hint>Unique identifier for this API</mat-hint>
|
22 |
-
@if (form.get('name')?.hasError('required') && form.get('name')?.touched) {
|
23 |
-
<mat-error>Name is required</mat-error>
|
24 |
-
}
|
25 |
-
@if (form.get('name')?.hasError('pattern') && form.get('name')?.touched) {
|
26 |
-
<mat-error>Only alphanumeric and underscore allowed</mat-error>
|
27 |
-
}
|
28 |
-
</mat-form-field>
|
29 |
-
|
30 |
-
<mat-form-field appearance="outline">
|
31 |
-
<mat-label>URL</mat-label>
|
32 |
-
<input matInput [formControl]="$any(form.get('url'))" placeholder="https://api.example.com/endpoint">
|
33 |
-
<mat-hint>Full URL including protocol</mat-hint>
|
34 |
-
@if (form.get('url')?.hasError('required') && form.get('url')?.touched) {
|
35 |
-
<mat-error>URL is required</mat-error>
|
36 |
-
}
|
37 |
-
@if (form.get('url')?.hasError('pattern') && form.get('url')?.touched) {
|
38 |
-
<mat-error>Invalid URL format</mat-error>
|
39 |
-
}
|
40 |
-
</mat-form-field>
|
41 |
-
|
42 |
-
<div class="row">
|
43 |
-
<mat-form-field appearance="outline" class="method-field">
|
44 |
-
<mat-label>Method</mat-label>
|
45 |
-
<mat-select [formControl]="$any(form.get('method'))">
|
46 |
-
@for (method of httpMethods; track method) {
|
47 |
-
<mat-option [value]="method">{{ method }}</mat-option>
|
48 |
-
}
|
49 |
-
</mat-select>
|
50 |
-
</mat-form-field>
|
51 |
-
|
52 |
-
<mat-form-field appearance="outline" class="timeout-field">
|
53 |
-
<mat-label>Timeout (seconds)</mat-label>
|
54 |
-
<input matInput type="number" [formControl]="$any(form.get('timeout_seconds'))">
|
55 |
-
<mat-hint>Request timeout in seconds</mat-hint>
|
56 |
-
@if (form.get('timeout_seconds')?.hasError('min')) {
|
57 |
-
<mat-error>Minimum 1 second</mat-error>
|
58 |
-
}
|
59 |
-
@if (form.get('timeout_seconds')?.hasError('max')) {
|
60 |
-
<mat-error>Maximum 300 seconds</mat-error>
|
61 |
-
}
|
62 |
-
</mat-form-field>
|
63 |
-
</div>
|
64 |
-
|
65 |
-
<mat-form-field appearance="outline" class="full-width">
|
66 |
-
<mat-label>Body Template</mat-label>
|
67 |
-
<textarea matInput
|
68 |
-
[formControl]="$any(form.get('body_template'))"
|
69 |
-
rows="8"
|
70 |
-
placeholder='{"key": "value"}'
|
71 |
-
(click)="saveCursorPosition('body_template', $event)"
|
72 |
-
(keyup)="saveCursorPosition('body_template', $event)"></textarea>
|
73 |
-
<mat-hint>JSON template with template variable support</mat-hint>
|
74 |
-
@if (!validateJSON('body_template')) {
|
75 |
-
<mat-error>Invalid JSON format</mat-error>
|
76 |
-
}
|
77 |
-
</mat-form-field>
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
</div>
|
89 |
-
|
90 |
-
<
|
91 |
-
<
|
92 |
-
<
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
<
|
102 |
-
<
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
<
|
116 |
-
<mat-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
</mat-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
<
|
160 |
-
<
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
<
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
}
|
195 |
-
</mat-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
<mat-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
</mat-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
<mat-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
<
|
250 |
-
<mat-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
</mat-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
<
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
@
|
322 |
-
<
|
323 |
-
<mat-
|
324 |
-
<
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
<
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
<
|
369 |
-
|
370 |
-
|
371 |
-
<mat-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
</
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
<
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
<
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
469 |
</mat-dialog-actions>
|
|
|
1 |
+
<h2 mat-dialog-title>
|
2 |
+
@if (data.mode === 'create') {
|
3 |
+
Create New API
|
4 |
+
} @else if (data.mode === 'duplicate') {
|
5 |
+
Duplicate API
|
6 |
+
} @else if (data.mode === 'test') {
|
7 |
+
Test API: {{ data.api.name }}
|
8 |
+
} @else {
|
9 |
+
Edit API: {{ data.api.name }}
|
10 |
+
}
|
11 |
+
</h2>
|
12 |
+
|
13 |
+
<mat-dialog-content>
|
14 |
+
<mat-tab-group [(selectedIndex)]="activeTabIndex">
|
15 |
+
<!-- General Tab -->
|
16 |
+
<mat-tab label="General">
|
17 |
+
<div class="tab-content">
|
18 |
+
<mat-form-field appearance="outline">
|
19 |
+
<mat-label>Name</mat-label>
|
20 |
+
<input matInput [formControl]="$any(form.get('name'))" placeholder="e.g., get_flights">
|
21 |
+
<mat-hint>Unique identifier for this API</mat-hint>
|
22 |
+
@if (form.get('name')?.hasError('required') && form.get('name')?.touched) {
|
23 |
+
<mat-error>Name is required</mat-error>
|
24 |
+
}
|
25 |
+
@if (form.get('name')?.hasError('pattern') && form.get('name')?.touched) {
|
26 |
+
<mat-error>Only alphanumeric and underscore allowed</mat-error>
|
27 |
+
}
|
28 |
+
</mat-form-field>
|
29 |
+
|
30 |
+
<mat-form-field appearance="outline">
|
31 |
+
<mat-label>URL</mat-label>
|
32 |
+
<input matInput [formControl]="$any(form.get('url'))" placeholder="https://api.example.com/endpoint">
|
33 |
+
<mat-hint>Full URL including protocol</mat-hint>
|
34 |
+
@if (form.get('url')?.hasError('required') && form.get('url')?.touched) {
|
35 |
+
<mat-error>URL is required</mat-error>
|
36 |
+
}
|
37 |
+
@if (form.get('url')?.hasError('pattern') && form.get('url')?.touched) {
|
38 |
+
<mat-error>Invalid URL format</mat-error>
|
39 |
+
}
|
40 |
+
</mat-form-field>
|
41 |
+
|
42 |
+
<div class="row">
|
43 |
+
<mat-form-field appearance="outline" class="method-field">
|
44 |
+
<mat-label>Method</mat-label>
|
45 |
+
<mat-select [formControl]="$any(form.get('method'))">
|
46 |
+
@for (method of httpMethods; track method) {
|
47 |
+
<mat-option [value]="method">{{ method }}</mat-option>
|
48 |
+
}
|
49 |
+
</mat-select>
|
50 |
+
</mat-form-field>
|
51 |
+
|
52 |
+
<mat-form-field appearance="outline" class="timeout-field">
|
53 |
+
<mat-label>Timeout (seconds)</mat-label>
|
54 |
+
<input matInput type="number" [formControl]="$any(form.get('timeout_seconds'))">
|
55 |
+
<mat-hint>Request timeout in seconds</mat-hint>
|
56 |
+
@if (form.get('timeout_seconds')?.hasError('min')) {
|
57 |
+
<mat-error>Minimum 1 second</mat-error>
|
58 |
+
}
|
59 |
+
@if (form.get('timeout_seconds')?.hasError('max')) {
|
60 |
+
<mat-error>Maximum 300 seconds</mat-error>
|
61 |
+
}
|
62 |
+
</mat-form-field>
|
63 |
+
</div>
|
64 |
+
|
65 |
+
<mat-form-field appearance="outline" class="full-width">
|
66 |
+
<mat-label>Body Template</mat-label>
|
67 |
+
<textarea matInput
|
68 |
+
[formControl]="$any(form.get('body_template'))"
|
69 |
+
rows="8"
|
70 |
+
placeholder='{"key": "value"}'
|
71 |
+
(click)="saveCursorPosition('body_template', $event)"
|
72 |
+
(keyup)="saveCursorPosition('body_template', $event)"></textarea>
|
73 |
+
<mat-hint>JSON template with template variable support</mat-hint>
|
74 |
+
@if (!validateJSON('body_template')) {
|
75 |
+
<mat-error>Invalid JSON format</mat-error>
|
76 |
+
}
|
77 |
+
</mat-form-field>
|
78 |
+
|
79 |
+
<!-- JSON Validation Indicator -->
|
80 |
+
<div class="json-validation-status">
|
81 |
+
@if (validateJSON('body_template')) {
|
82 |
+
<mat-icon class="valid">check_circle</mat-icon>
|
83 |
+
<span class="valid">Valid JSON</span>
|
84 |
+
} @else {
|
85 |
+
<mat-icon class="invalid">error</mat-icon>
|
86 |
+
<span class="invalid">Invalid JSON</span>
|
87 |
+
}
|
88 |
+
</div>
|
89 |
+
|
90 |
+
<div class="template-variables">
|
91 |
+
<strong>Available Variables:</strong>
|
92 |
+
<mat-chip-set>
|
93 |
+
@for (variable of getTemplateVariables(false); track variable) {
|
94 |
+
<mat-chip (click)="insertTemplateVariable('body_template', variable)">
|
95 |
+
{{ variable }}
|
96 |
+
</mat-chip>
|
97 |
+
}
|
98 |
+
</mat-chip-set>
|
99 |
+
</div>
|
100 |
+
|
101 |
+
<mat-form-field appearance="outline">
|
102 |
+
<mat-label>Proxy URL (Optional)</mat-label>
|
103 |
+
<input matInput [formControl]="$any(form.get('proxy'))" placeholder="http://proxy.example.com:8080">
|
104 |
+
<mat-hint>HTTP proxy for this API call</mat-hint>
|
105 |
+
</mat-form-field>
|
106 |
+
</div>
|
107 |
+
</mat-tab>
|
108 |
+
|
109 |
+
<!-- Headers Tab -->
|
110 |
+
<mat-tab label="Headers">
|
111 |
+
<div class="tab-content">
|
112 |
+
<div class="array-section">
|
113 |
+
<div class="section-header">
|
114 |
+
<h3>Request Headers</h3>
|
115 |
+
<button mat-button color="primary" (click)="addHeader()">
|
116 |
+
<mat-icon>add</mat-icon>
|
117 |
+
Add Header
|
118 |
+
</button>
|
119 |
+
</div>
|
120 |
+
|
121 |
+
@if (headers.length === 0) {
|
122 |
+
<p class="empty-message">No headers configured. Click "Add Header" to add one.</p>
|
123 |
+
}
|
124 |
+
|
125 |
+
@for (header of headers.controls; track header; let i = $index) {
|
126 |
+
<div class="array-item" [formGroup]="$any(header)">
|
127 |
+
<mat-form-field appearance="outline" class="key-field">
|
128 |
+
<mat-label>Header Name</mat-label>
|
129 |
+
<input matInput formControlName="key" placeholder="Content-Type">
|
130 |
+
</mat-form-field>
|
131 |
+
|
132 |
+
<mat-form-field appearance="outline" class="value-field">
|
133 |
+
<mat-label>Header Value</mat-label>
|
134 |
+
<input matInput formControlName="value" placeholder="application/json">
|
135 |
+
<button mat-icon-button matSuffix [matMenuTriggerFor]="headerMenu">
|
136 |
+
<mat-icon>code</mat-icon>
|
137 |
+
</button>
|
138 |
+
<mat-menu #headerMenu="matMenu">
|
139 |
+
@for (variable of getTemplateVariables(); track variable) {
|
140 |
+
<button mat-menu-item (click)="insertHeaderValue(i, variable)">
|
141 |
+
{{ variable }}
|
142 |
+
</button>
|
143 |
+
}
|
144 |
+
</mat-menu>
|
145 |
+
</mat-form-field>
|
146 |
+
|
147 |
+
<button mat-icon-button color="warn" (click)="removeHeader(i)">
|
148 |
+
<mat-icon>delete</mat-icon>
|
149 |
+
</button>
|
150 |
+
</div>
|
151 |
+
}
|
152 |
+
</div>
|
153 |
+
</div>
|
154 |
+
</mat-tab>
|
155 |
+
|
156 |
+
<!-- Response Tab -->
|
157 |
+
<mat-tab label="Response">
|
158 |
+
<div class="tab-content">
|
159 |
+
<mat-form-field appearance="outline" class="full-width">
|
160 |
+
<mat-label>Response Prompt</mat-label>
|
161 |
+
<textarea matInput
|
162 |
+
[formControl]="$any(form.get('response_prompt'))"
|
163 |
+
rows="4"
|
164 |
+
placeholder="Optional instructions for processing the response"></textarea>
|
165 |
+
<mat-hint>Instructions for AI to process the response (optional)</mat-hint>
|
166 |
+
</mat-form-field>
|
167 |
+
|
168 |
+
<mat-divider></mat-divider>
|
169 |
+
|
170 |
+
<div class="array-section">
|
171 |
+
<div class="section-header">
|
172 |
+
<h3>Response Mappings</h3>
|
173 |
+
<button mat-button color="primary" (click)="addResponseMapping()">
|
174 |
+
<mat-icon>add</mat-icon>
|
175 |
+
Add Mapping
|
176 |
+
</button>
|
177 |
+
</div>
|
178 |
+
|
179 |
+
<p class="info-text">
|
180 |
+
Extract values from API response and save them as variables for use in subsequent intents.
|
181 |
+
</p>
|
182 |
+
|
183 |
+
@if (responseMappings.length === 0) {
|
184 |
+
<p class="empty-message">No response mappings configured.</p>
|
185 |
+
}
|
186 |
+
|
187 |
+
@for (mapping of responseMappings.controls; track mapping; let i = $index) {
|
188 |
+
<mat-expansion-panel [formGroup]="$any(mapping)">
|
189 |
+
<mat-expansion-panel-header>
|
190 |
+
<mat-panel-title>
|
191 |
+
{{ mapping.get('variable_name')?.value || 'New Mapping' }}
|
192 |
+
</mat-panel-title>
|
193 |
+
<mat-panel-description>
|
194 |
+
{{ mapping.get('json_path')?.value || 'Configure mapping' }}
|
195 |
+
</mat-panel-description>
|
196 |
+
</mat-expansion-panel-header>
|
197 |
+
|
198 |
+
<div class="mapping-content">
|
199 |
+
<mat-form-field appearance="outline">
|
200 |
+
<mat-label>Variable Name</mat-label>
|
201 |
+
<input matInput formControlName="variable_name" placeholder="booking_ref">
|
202 |
+
<mat-hint>Name to store the extracted value</mat-hint>
|
203 |
+
@if (mapping.get('variable_name')?.hasError('pattern')) {
|
204 |
+
<mat-error>Lowercase letters, numbers and underscore only</mat-error>
|
205 |
+
}
|
206 |
+
</mat-form-field>
|
207 |
+
|
208 |
+
<mat-form-field appearance="outline">
|
209 |
+
<mat-label>Caption</mat-label>
|
210 |
+
<input matInput formControlName="caption" placeholder="Booking Reference">
|
211 |
+
<mat-hint>Human-readable description</mat-hint>
|
212 |
+
</mat-form-field>
|
213 |
+
|
214 |
+
<div class="row">
|
215 |
+
<mat-form-field appearance="outline" class="type-field">
|
216 |
+
<mat-label>Type</mat-label>
|
217 |
+
<mat-select formControlName="type">
|
218 |
+
@for (type of variableTypes; track type) {
|
219 |
+
<mat-option [value]="type">{{ type }}</mat-option>
|
220 |
+
}
|
221 |
+
</mat-select>
|
222 |
+
</mat-form-field>
|
223 |
+
|
224 |
+
<mat-form-field appearance="outline" class="path-field">
|
225 |
+
<mat-label>JSON Path</mat-label>
|
226 |
+
<input matInput formControlName="json_path" placeholder="$.data.bookingReference">
|
227 |
+
<mat-hint>JSONPath expression to extract value</mat-hint>
|
228 |
+
</mat-form-field>
|
229 |
+
</div>
|
230 |
+
|
231 |
+
<button mat-button color="warn" (click)="removeResponseMapping(i)">
|
232 |
+
<mat-icon>delete</mat-icon>
|
233 |
+
Remove Mapping
|
234 |
+
</button>
|
235 |
+
</div>
|
236 |
+
</mat-expansion-panel>
|
237 |
+
}
|
238 |
+
</div>
|
239 |
+
|
240 |
+
<!-- Retry Settings -->
|
241 |
+
<mat-divider></mat-divider>
|
242 |
+
|
243 |
+
<div class="retry-section" [formGroup]="$any(form.get('retry'))">
|
244 |
+
<h3>Retry Settings</h3>
|
245 |
+
|
246 |
+
<div class="row">
|
247 |
+
<mat-form-field appearance="outline">
|
248 |
+
<mat-label>Retry Count</mat-label>
|
249 |
+
<input matInput type="number" formControlName="retry_count">
|
250 |
+
<mat-hint>Number of retry attempts</mat-hint>
|
251 |
+
</mat-form-field>
|
252 |
+
|
253 |
+
<mat-form-field appearance="outline">
|
254 |
+
<mat-label>Backoff (seconds)</mat-label>
|
255 |
+
<input matInput type="number" formControlName="backoff_seconds">
|
256 |
+
<mat-hint>Delay between retries</mat-hint>
|
257 |
+
</mat-form-field>
|
258 |
+
|
259 |
+
<mat-form-field appearance="outline">
|
260 |
+
<mat-label>Strategy</mat-label>
|
261 |
+
<mat-select formControlName="strategy">
|
262 |
+
@for (strategy of retryStrategies; track strategy) {
|
263 |
+
<mat-option [value]="strategy">{{ strategy }}</mat-option>
|
264 |
+
}
|
265 |
+
</mat-select>
|
266 |
+
</mat-form-field>
|
267 |
+
</div>
|
268 |
+
</div>
|
269 |
+
</div>
|
270 |
+
</mat-tab>
|
271 |
+
|
272 |
+
<!-- Test Tab -->
|
273 |
+
<mat-tab label="Test">
|
274 |
+
<div class="tab-content">
|
275 |
+
<div class="test-section">
|
276 |
+
<h3>Test API Call</h3>
|
277 |
+
|
278 |
+
<div class="test-controls">
|
279 |
+
<button mat-raised-button color="primary"
|
280 |
+
(click)="testAPI()"
|
281 |
+
[disabled]="testing || !form.get('url')?.valid || !form.get('method')?.valid">
|
282 |
+
@if (testing) {
|
283 |
+
<ng-container>
|
284 |
+
<mat-icon class="spin">sync</mat-icon>
|
285 |
+
Testing...
|
286 |
+
</ng-container>
|
287 |
+
} @else {
|
288 |
+
<ng-container>
|
289 |
+
<mat-icon>play_arrow</mat-icon>
|
290 |
+
Test API
|
291 |
+
</ng-container>
|
292 |
+
}
|
293 |
+
</button>
|
294 |
+
|
295 |
+
<button mat-button (click)="updateTestRequestJson()">
|
296 |
+
<mat-icon>refresh</mat-icon>
|
297 |
+
Generate Test Data
|
298 |
+
</button>
|
299 |
+
</div>
|
300 |
+
|
301 |
+
<mat-form-field appearance="outline" class="full-width">
|
302 |
+
<mat-label>Test Request Body</mat-label>
|
303 |
+
<textarea matInput
|
304 |
+
[(ngModel)]="testRequestJson"
|
305 |
+
rows="10"
|
306 |
+
placeholder="Enter test request JSON here"></textarea>
|
307 |
+
<mat-hint>Variables will be replaced with test values</mat-hint>
|
308 |
+
</mat-form-field>
|
309 |
+
|
310 |
+
@if (testResult) {
|
311 |
+
<mat-divider></mat-divider>
|
312 |
+
|
313 |
+
<div class="test-result" [class.success]="testResult.success" [class.error]="!testResult.success">
|
314 |
+
<h4>Test Result</h4>
|
315 |
+
|
316 |
+
@if (testResult.success) {
|
317 |
+
<div class="result-status">
|
318 |
+
<mat-icon>check_circle</mat-icon>
|
319 |
+
<span>Success ({{ testResult.status_code }})</span>
|
320 |
+
</div>
|
321 |
+
} @else {
|
322 |
+
<div class="result-status">
|
323 |
+
<mat-icon>error</mat-icon>
|
324 |
+
<span>Failed: {{ testResult.error }}</span>
|
325 |
+
</div>
|
326 |
+
}
|
327 |
+
|
328 |
+
@if (testResult.response_time) {
|
329 |
+
<p><strong>Response Time:</strong> {{ testResult.response_time }}ms</p>
|
330 |
+
}
|
331 |
+
|
332 |
+
@if (testResult.response_body) {
|
333 |
+
<mat-form-field appearance="outline" class="full-width">
|
334 |
+
<mat-label>Response Body</mat-label>
|
335 |
+
<textarea matInput
|
336 |
+
[value]="testResult.response_body | json"
|
337 |
+
rows="10"
|
338 |
+
readonly></textarea>
|
339 |
+
</mat-form-field>
|
340 |
+
}
|
341 |
+
|
342 |
+
@if (testResult.request_body) {
|
343 |
+
<mat-form-field appearance="outline" class="full-width">
|
344 |
+
<mat-label>Actual Request Sent</mat-label>
|
345 |
+
<textarea matInput
|
346 |
+
[value]="testResult.request_body | json"
|
347 |
+
rows="8"
|
348 |
+
readonly></textarea>
|
349 |
+
</mat-form-field>
|
350 |
+
}
|
351 |
+
</div>
|
352 |
+
}
|
353 |
+
</div>
|
354 |
+
</div>
|
355 |
+
</mat-tab>
|
356 |
+
|
357 |
+
<!-- Auth Tab -->
|
358 |
+
<mat-tab label="Authentication">
|
359 |
+
<div class="tab-content" [formGroup]="$any(form.get('auth'))">
|
360 |
+
<mat-checkbox formControlName="enabled">
|
361 |
+
Enable Authentication
|
362 |
+
</mat-checkbox>
|
363 |
+
|
364 |
+
@if (form.get('auth.enabled')?.value) {
|
365 |
+
<mat-divider></mat-divider>
|
366 |
+
|
367 |
+
<div class="auth-section">
|
368 |
+
<h3>Token Configuration</h3>
|
369 |
+
|
370 |
+
<mat-form-field appearance="outline">
|
371 |
+
<mat-label>Token Endpoint</mat-label>
|
372 |
+
<input matInput formControlName="token_endpoint" placeholder="https://api.example.com/auth/token">
|
373 |
+
<mat-hint>URL to obtain authentication token</mat-hint>
|
374 |
+
@if (form.get('auth.token_endpoint')?.hasError('required') && form.get('auth.token_endpoint')?.touched) {
|
375 |
+
<mat-error>Token endpoint is required when auth is enabled</mat-error>
|
376 |
+
}
|
377 |
+
</mat-form-field>
|
378 |
+
|
379 |
+
<mat-form-field appearance="outline">
|
380 |
+
<mat-label>Token Response Path</mat-label>
|
381 |
+
<input matInput formControlName="response_token_path" placeholder="token">
|
382 |
+
<mat-hint>JSON path to extract token from response</mat-hint>
|
383 |
+
@if (form.get('auth.response_token_path')?.hasError('required') && form.get('auth.response_token_path')?.touched) {
|
384 |
+
<mat-error>Token path is required when auth is enabled</mat-error>
|
385 |
+
}
|
386 |
+
</mat-form-field>
|
387 |
+
|
388 |
+
<mat-form-field appearance="outline" class="full-width">
|
389 |
+
<mat-label>Token Request Body</mat-label>
|
390 |
+
<textarea matInput
|
391 |
+
formControlName="token_request_body"
|
392 |
+
rows="6"
|
393 |
+
(click)="saveCursorPosition('auth.token_request_body', $event)"
|
394 |
+
(keyup)="saveCursorPosition('auth.token_request_body', $event)"
|
395 |
+
placeholder='{"username": "api_user", "password": "api_pass"}'></textarea>
|
396 |
+
<mat-hint>JSON body for token request</mat-hint>
|
397 |
+
@if (!validateJSON('auth.token_request_body')) {
|
398 |
+
<mat-error>Invalid JSON format</mat-error>
|
399 |
+
}
|
400 |
+
</mat-form-field>
|
401 |
+
|
402 |
+
<!-- JSON Validation Indicator -->
|
403 |
+
<div class="json-validation-status">
|
404 |
+
@if (validateJSON('auth.token_request_body')) {
|
405 |
+
<mat-icon class="valid">check_circle</mat-icon>
|
406 |
+
<span class="valid">Valid JSON</span>
|
407 |
+
} @else {
|
408 |
+
<mat-icon class="invalid">error</mat-icon>
|
409 |
+
<span class="invalid">Invalid JSON</span>
|
410 |
+
}
|
411 |
+
</div>
|
412 |
+
|
413 |
+
<div class="template-variables">
|
414 |
+
<strong>Available Variables:</strong>
|
415 |
+
<mat-chip-set>
|
416 |
+
@for (variable of getTemplateVariables(); track variable) {
|
417 |
+
<mat-chip (click)="insertTemplateVariable('auth.token_request_body', variable)">
|
418 |
+
{{ variable }}
|
419 |
+
</mat-chip>
|
420 |
+
}
|
421 |
+
</mat-chip-set>
|
422 |
+
</div>
|
423 |
+
|
424 |
+
<mat-divider></mat-divider>
|
425 |
+
|
426 |
+
<h3>Token Refresh (Optional)</h3>
|
427 |
+
|
428 |
+
<mat-form-field appearance="outline">
|
429 |
+
<mat-label>Refresh Endpoint</mat-label>
|
430 |
+
<input matInput formControlName="token_refresh_endpoint" placeholder="https://api.example.com/auth/refresh">
|
431 |
+
<mat-hint>URL to refresh expired token</mat-hint>
|
432 |
+
</mat-form-field>
|
433 |
+
|
434 |
+
<mat-form-field appearance="outline" class="full-width">
|
435 |
+
<mat-label>Refresh Request Body</mat-label>
|
436 |
+
<textarea matInput
|
437 |
+
formControlName="token_refresh_body"
|
438 |
+
rows="4"
|
439 |
+
(click)="saveCursorPosition('auth.token_refresh_body', $event)"
|
440 |
+
(keyup)="saveCursorPosition('auth.token_refresh_body', $event)"
|
441 |
+
placeholder='{"refresh_token": "your_refresh_token"}'></textarea>
|
442 |
+
<mat-hint>JSON body for refresh request</mat-hint>
|
443 |
+
@if (!validateJSON('auth.token_refresh_body')) {
|
444 |
+
<mat-error>Invalid JSON format</mat-error>
|
445 |
+
}
|
446 |
+
</mat-form-field>
|
447 |
+
|
448 |
+
<!-- JSON Validation Indicator -->
|
449 |
+
<div class="json-validation-status">
|
450 |
+
@if (validateJSON('auth.token_refresh_body')) {
|
451 |
+
<mat-icon class="valid">check_circle</mat-icon>
|
452 |
+
<span class="valid">Valid JSON</span>
|
453 |
+
} @else {
|
454 |
+
<mat-icon class="invalid">error</mat-icon>
|
455 |
+
<span class="invalid">Invalid JSON</span>
|
456 |
+
}
|
457 |
+
</div>
|
458 |
+
|
459 |
+
<div class="template-variables">
|
460 |
+
<strong>Available Variables:</strong>
|
461 |
+
<mat-chip-set>
|
462 |
+
@for (variable of getTemplateVariables(); track variable) {
|
463 |
+
<mat-chip (click)="insertTemplateVariable('auth.token_refresh_body', variable)">
|
464 |
+
{{ variable }}
|
465 |
+
</mat-chip>
|
466 |
+
}
|
467 |
+
</mat-chip-set>
|
468 |
+
</div>
|
469 |
+
</div>
|
470 |
+
}
|
471 |
+
</div>
|
472 |
+
</mat-tab>
|
473 |
+
</mat-tab-group>
|
474 |
+
</mat-dialog-content>
|
475 |
+
|
476 |
+
<mat-dialog-actions align="end">
|
477 |
+
<button mat-button (click)="cancel()">
|
478 |
+
@if (data.mode === 'test') {
|
479 |
+
Close
|
480 |
+
} @else {
|
481 |
+
Cancel
|
482 |
+
}
|
483 |
+
</button>
|
484 |
+
@if (data.mode !== 'test') {
|
485 |
+
<button mat-raised-button color="primary"
|
486 |
+
(click)="save()"
|
487 |
+
[disabled]="saving || form.invalid">
|
488 |
+
@if (saving) {
|
489 |
+
<ng-container>
|
490 |
+
<mat-icon class="spin">sync</mat-icon>
|
491 |
+
Saving...
|
492 |
+
</ng-container>
|
493 |
+
} @else {
|
494 |
+
@if (data.mode === 'create' || data.mode === 'duplicate') {
|
495 |
+
Create
|
496 |
+
} @else {
|
497 |
+
Update
|
498 |
+
}
|
499 |
+
}
|
500 |
+
</button>
|
501 |
+
}
|
502 |
</mat-dialog-actions>
|