Spaces:
Running
Running
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
@@ -11,430 +11,429 @@
|
|
11 |
</h2>
|
12 |
|
13 |
<mat-dialog-content>
|
14 |
-
<
|
15 |
-
|
16 |
-
|
17 |
-
<
|
18 |
-
<
|
19 |
-
<mat-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
<mat-error
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
</mat-form-field>
|
28 |
|
29 |
-
<mat-form-field appearance="outline" class="
|
30 |
-
<mat-label>
|
31 |
-
<input matInput
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
35 |
</mat-form-field>
|
|
|
36 |
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
</
|
62 |
-
|
63 |
-
|
64 |
-
<div class="template-helpers">
|
65 |
-
<mat-expansion-panel>
|
66 |
-
<mat-expansion-panel-header>
|
67 |
-
<mat-panel-title>
|
68 |
-
<mat-icon>help_outline</mat-icon>
|
69 |
-
Template Variables
|
70 |
-
</mat-panel-title>
|
71 |
-
</mat-expansion-panel-header>
|
72 |
-
<div class="hint-text" style="margin-bottom: 16px; padding: 16px; background-color: #e3f2fd; border-radius: 4px;">
|
73 |
-
<mat-icon style="vertical-align: middle; color: #1976d2;">info</mat-icon>
|
74 |
-
<strong style="color: #1976d2;">Important:</strong><br>
|
75 |
-
Write all variables <strong>without quotes</strong>: <code>{{ '{' }}{{ '{' }}variables.pnr{{ '}' }}{{ '}' }}</code><br>
|
76 |
-
The system will automatically add quotes for string values during execution.<br><br>
|
77 |
-
<strong>Examples:</strong><br>
|
78 |
-
• <code>{{ '{' }} "pnr": {{ '{' }}{{ '{' }}variables.pnr{{ '}' }}{{ '}' }} {{ '}' }}</code> → <code>{{ '{' }} "pnr": "ABC123" {{ '}' }}</code><br>
|
79 |
-
• <code>{{ '{' }} "count": {{ '{' }}{{ '{' }}variables.passenger_count{{ '}' }}{{ '}' }} {{ '}' }}</code> → <code>{{ '{' }} "count": 2 {{ '}' }}</code><br>
|
80 |
-
• <code>{{ '{' }} "active": {{ '{' }}{{ '{' }}variables.enabled{{ '}' }}{{ '}' }} {{ '}' }}</code> → <code>{{ '{' }} "active": true {{ '}' }}</code>
|
81 |
-
</div>
|
82 |
-
<div class="template-list">
|
83 |
-
<mat-chip *ngFor="let templateVar of getTemplateVariables()"
|
84 |
-
(click)="insertTemplateVariable('body_template', templateVar)"
|
85 |
-
class="template-chip">
|
86 |
-
{{ templateVar }}
|
87 |
-
</mat-chip>
|
88 |
-
</div>
|
89 |
-
</mat-expansion-panel>
|
90 |
-
</div>
|
91 |
</div>
|
92 |
|
93 |
-
|
94 |
-
<
|
95 |
-
|
96 |
-
<mat-error *ngIf="form.get('timeout_seconds')?.hasError('required')">Timeout is required</mat-error>
|
97 |
-
<mat-error *ngIf="form.get('timeout_seconds')?.hasError('min')">Minimum 1 second</mat-error>
|
98 |
-
<mat-error *ngIf="form.get('timeout_seconds')?.hasError('max')">Maximum 300 seconds</mat-error>
|
99 |
-
</mat-form-field>
|
100 |
|
101 |
-
|
102 |
-
<
|
103 |
-
|
104 |
-
|
105 |
-
<
|
106 |
-
<input matInput type="number" formControlName="retry_count">
|
107 |
</mat-form-field>
|
108 |
|
109 |
-
<mat-form-field appearance="outline">
|
110 |
-
<mat-label>
|
111 |
-
<input matInput
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
112 |
</mat-form-field>
|
113 |
|
114 |
-
<mat-
|
115 |
-
<mat-
|
116 |
-
<mat-select formControlName="strategy">
|
117 |
-
<mat-option value="static">Static</mat-option>
|
118 |
-
<mat-option value="exponential">Exponential</mat-option>
|
119 |
-
</mat-select>
|
120 |
-
</mat-form-field>
|
121 |
-
</div>
|
122 |
-
</div>
|
123 |
-
|
124 |
-
<mat-form-field appearance="outline" class="full-width">
|
125 |
-
<mat-label>Response Prompt</mat-label>
|
126 |
-
<textarea matInput formControlName="response_prompt"
|
127 |
-
rows="4"
|
128 |
-
placeholder="Convert the API response to human-friendly text..."></textarea>
|
129 |
-
<mat-hint>Use {{ '{' }}{{ '{' }}api_response{{ '}' }}{{ '}' }} to reference the API response</mat-hint>
|
130 |
-
</mat-form-field>
|
131 |
-
|
132 |
-
<div class="form-section">
|
133 |
-
<div class="section-header">
|
134 |
-
<h4>Response Mappings</h4>
|
135 |
-
<button mat-raised-button color="primary" type="button" (click)="addResponseMapping()">
|
136 |
-
<mat-icon>add</mat-icon>
|
137 |
-
Add Mapping
|
138 |
</button>
|
139 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
145 |
<mat-form-field appearance="outline">
|
146 |
<mat-label>Variable Name</mat-label>
|
147 |
-
<input matInput formControlName="variable_name" placeholder="
|
148 |
-
<mat-hint>
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
<mat-label>Type</mat-label>
|
153 |
-
<mat-select formControlName="type">
|
154 |
-
<mat-option *ngFor="let type of variableTypes" [value]="type">
|
155 |
-
{{ type }}
|
156 |
-
</mat-option>
|
157 |
-
</mat-select>
|
158 |
-
</mat-form-field>
|
159 |
-
|
160 |
-
<mat-form-field appearance="outline" class="json-path-field">
|
161 |
-
<mat-label>JSON Path</mat-label>
|
162 |
-
<input matInput formControlName="json_path" placeholder="FlightInfo.Details.DepartureTime">
|
163 |
-
<mat-hint>Use dot notation for nested values</mat-hint>
|
164 |
</mat-form-field>
|
165 |
-
|
166 |
-
<mat-form-field appearance="outline">
|
167 |
-
<mat-label>Caption</mat-label>
|
168 |
-
<input matInput formControlName="caption" placeholder="Kalkış Saati">
|
169 |
-
<mat-hint>Human-readable label</mat-hint>
|
170 |
-
</mat-form-field>
|
171 |
-
|
172 |
-
<button mat-icon-button color="warn" type="button" (click)="removeResponseMapping(i)">
|
173 |
-
<mat-icon>delete</mat-icon>
|
174 |
-
</button>
|
175 |
-
</div>
|
176 |
-
</div>
|
177 |
|
178 |
-
<div *ngIf="responseMappings.length === 0" class="empty-state-small">
|
179 |
-
<mat-icon>info</mat-icon>
|
180 |
-
<p>No response mappings defined. Use this to extract values from API responses into session variables.</p>
|
181 |
-
</div>
|
182 |
-
</div>
|
183 |
-
|
184 |
-
<mat-form-field appearance="outline" class="full-width">
|
185 |
-
<mat-label>Proxy URL (Optional)</mat-label>
|
186 |
-
<input matInput formControlName="proxy"
|
187 |
-
placeholder="http://proxy.example.com:8080">
|
188 |
-
</mat-form-field>
|
189 |
-
</div>
|
190 |
-
</mat-tab>
|
191 |
-
|
192 |
-
<!-- Headers Tab -->
|
193 |
-
<mat-tab label="Headers">
|
194 |
-
<div class="tab-content">
|
195 |
-
<div class="headers-section">
|
196 |
-
<div class="section-header">
|
197 |
-
<h4>Request Headers</h4>
|
198 |
-
<button mat-raised-button color="primary" type="button" (click)="addHeader()">
|
199 |
-
<mat-icon>add</mat-icon>
|
200 |
-
Add Header
|
201 |
-
</button>
|
202 |
-
</div>
|
203 |
-
|
204 |
-
<div formArrayName="headers" class="headers-list">
|
205 |
-
<div *ngFor="let header of headers.controls; let i = index"
|
206 |
-
[formGroupName]="i"
|
207 |
-
class="header-row">
|
208 |
<mat-form-field appearance="outline">
|
209 |
-
<mat-label>
|
210 |
-
<input matInput formControlName="
|
|
|
211 |
</mat-form-field>
|
212 |
|
213 |
-
<
|
214 |
-
<mat-
|
215 |
-
|
216 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
217 |
|
218 |
-
<button mat-
|
219 |
<mat-icon>delete</mat-icon>
|
|
|
220 |
</button>
|
221 |
</div>
|
222 |
-
</
|
223 |
-
|
224 |
-
|
225 |
-
<mat-icon>info</mat-icon>
|
226 |
-
<p>No headers defined. Click "Add Header" to create one.</p>
|
227 |
-
</div>
|
228 |
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
|
|
|
|
|
|
|
|
252 |
</div>
|
253 |
</div>
|
254 |
-
</
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
<
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
</mat-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
<mat-label>Response Token Path*</mat-label>
|
276 |
-
<input matInput formControlName="response_token_path"
|
277 |
-
placeholder="access_token or data.token">
|
278 |
-
<mat-hint>JSON path to extract token from response (e.g., data.token)</mat-hint>
|
279 |
-
<mat-error *ngIf="form.get('auth.response_token_path')?.hasError('required')">
|
280 |
-
Token path is required when auth is enabled
|
281 |
-
</mat-error>
|
282 |
-
</mat-form-field>
|
283 |
-
|
284 |
-
<div class="form-section">
|
285 |
-
<label class="section-label">Token Request Body:</label>
|
286 |
-
<div class="json-editor">
|
287 |
-
<textarea formControlName="token_request_body"
|
288 |
-
placeholder='{"grant_type": "client_credentials"}'
|
289 |
-
rows="4"
|
290 |
-
class="json-textarea"
|
291 |
-
(click)="saveCursorPosition('auth.token_request_body', $event)"
|
292 |
-
(keyup)="saveCursorPosition('auth.token_request_body', $event)"></textarea>
|
293 |
-
<div class="template-helpers">
|
294 |
-
<mat-expansion-panel>
|
295 |
-
<mat-expansion-panel-header>
|
296 |
-
<mat-panel-title>
|
297 |
-
<mat-icon>help_outline</mat-icon>
|
298 |
-
Template Variables
|
299 |
-
</mat-panel-title>
|
300 |
-
</mat-expansion-panel-header>
|
301 |
-
<div class="hint-text" style="margin-bottom: 16px; padding: 16px; background-color: #e3f2fd; border-radius: 4px;">
|
302 |
-
<mat-icon style="vertical-align: middle; color: #1976d2;">info</mat-icon>
|
303 |
-
<strong style="color: #1976d2;">Important:</strong><br>
|
304 |
-
Write all variables <strong>without quotes</strong>: <code>{{ '{' }}{{ '{' }}variables.pnr{{ '}' }}{{ '}' }}</code><br>
|
305 |
-
The system will automatically add quotes for string values during execution.<br><br>
|
306 |
-
<strong>Examples:</strong><br>
|
307 |
-
• <code>{{ '{' }} "pnr": {{ '{' }}{{ '{' }}variables.pnr{{ '}' }}{{ '}' }} {{ '}' }}</code> → <code>{{ '{' }} "pnr": "ABC123" {{ '}' }}</code><br>
|
308 |
-
• <code>{{ '{' }} "count": {{ '{' }}{{ '{' }}variables.passenger_count{{ '}' }}{{ '}' }} {{ '}' }}</code> → <code>{{ '{' }} "count": 2 {{ '}' }}</code><br>
|
309 |
-
• <code>{{ '{' }} "active": {{ '{' }}{{ '{' }}variables.enabled{{ '}' }}{{ '}' }} {{ '}' }}</code> → <code>{{ '{' }} "active": true {{ '}' }}</code>
|
310 |
-
</div>
|
311 |
-
<div class="template-list">
|
312 |
-
<mat-chip *ngFor="let templateVar of getTemplateVariables(false)"
|
313 |
-
(click)="insertTemplateVariable('auth.token_request_body', templateVar)"
|
314 |
-
class="template-chip">
|
315 |
-
{{ templateVar }}
|
316 |
-
</mat-chip>
|
317 |
-
</div>
|
318 |
-
</mat-expansion-panel>
|
319 |
-
</div>
|
320 |
-
<button mat-button type="button"
|
321 |
-
(click)="validateJSON('auth.token_request_body')"
|
322 |
-
[color]="validateJSON('auth.token_request_body') ? 'primary' : 'warn'">
|
323 |
-
<mat-icon>check_circle</mat-icon>
|
324 |
-
Validate JSON
|
325 |
-
</button>
|
326 |
-
</div>
|
327 |
-
</div>
|
328 |
-
|
329 |
-
<mat-divider></mat-divider>
|
330 |
|
331 |
-
|
|
|
|
|
|
|
|
|
332 |
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
|
|
|
|
|
|
338 |
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
<mat-icon>check_circle</mat-icon>
|
350 |
-
Validate JSON
|
351 |
-
</button>
|
352 |
</div>
|
353 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
354 |
</div>
|
355 |
-
|
356 |
</div>
|
357 |
-
</
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
</
|
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 |
-
<mat-icon>error_outline</mat-icon>
|
415 |
-
{{ testResult.error }}
|
416 |
-
</div>
|
417 |
-
|
418 |
-
<div *ngIf="testResult.headers" class="response-section">
|
419 |
-
<h5>Response Headers:</h5>
|
420 |
-
<pre>{{ testResult.headers | json }}</pre>
|
421 |
-
</div>
|
422 |
-
|
423 |
-
<div *ngIf="testResult.body !== undefined" class="response-section">
|
424 |
-
<h5>Response Body:</h5>
|
425 |
-
<pre>{{ testResult.body }}</pre>
|
426 |
-
</div>
|
427 |
</div>
|
428 |
|
429 |
-
<
|
430 |
-
|
431 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
432 |
</div>
|
433 |
</div>
|
434 |
-
|
435 |
-
</
|
436 |
-
</mat-tab
|
437 |
-
</
|
438 |
</mat-dialog-content>
|
439 |
|
440 |
<mat-dialog-actions align="end">
|
|
|
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]="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]="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]="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]="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]="form.get('body_template')"
|
69 |
+
rows="8"
|
70 |
+
placeholder='{"key": "{{variables.value}}"}'
|
71 |
+
(click)="saveCursorPosition('body_template', $event)"
|
72 |
+
(keyup)="saveCursorPosition('body_template', $event)"></textarea>
|
73 |
+
<mat-hint>JSON template with {{variables}} support</mat-hint>
|
74 |
+
@if (!validateJSON('body_template')) {
|
75 |
+
<mat-error>Invalid JSON format</mat-error>
|
76 |
+
}
|
77 |
+
</mat-form-field>
|
78 |
+
|
79 |
+
<div class="template-variables">
|
80 |
+
<strong>Available Variables:</strong>
|
81 |
+
<mat-chip-set>
|
82 |
+
@for (variable of getTemplateVariables(false); track variable) {
|
83 |
+
<mat-chip (click)="insertTemplateVariable('body_template', variable)">
|
84 |
+
{{ variable }}
|
85 |
+
</mat-chip>
|
86 |
+
}
|
87 |
+
</mat-chip-set>
|
88 |
+
</div>
|
89 |
|
90 |
+
<mat-form-field appearance="outline">
|
91 |
+
<mat-label>Proxy URL (Optional)</mat-label>
|
92 |
+
<input matInput [formControl]="form.get('proxy')" placeholder="http://proxy.example.com:8080">
|
93 |
+
<mat-hint>HTTP proxy for this API call</mat-hint>
|
94 |
+
</mat-form-field>
|
95 |
+
</div>
|
96 |
+
</mat-tab>
|
97 |
+
|
98 |
+
<!-- Headers Tab -->
|
99 |
+
<mat-tab label="Headers">
|
100 |
+
<div class="tab-content">
|
101 |
+
<div class="array-section">
|
102 |
+
<div class="section-header">
|
103 |
+
<h3>Request Headers</h3>
|
104 |
+
<button mat-button color="primary" (click)="addHeader()">
|
105 |
+
<mat-icon>add</mat-icon>
|
106 |
+
Add Header
|
107 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
</div>
|
109 |
|
110 |
+
@if (headers.length === 0) {
|
111 |
+
<p class="empty-message">No headers configured. Click "Add Header" to add one.</p>
|
112 |
+
}
|
|
|
|
|
|
|
|
|
113 |
|
114 |
+
@for (header of headers.controls; track header; let i = $index) {
|
115 |
+
<div class="array-item" [formGroup]="header">
|
116 |
+
<mat-form-field appearance="outline" class="key-field">
|
117 |
+
<mat-label>Header Name</mat-label>
|
118 |
+
<input matInput formControlName="key" placeholder="Content-Type">
|
|
|
119 |
</mat-form-field>
|
120 |
|
121 |
+
<mat-form-field appearance="outline" class="value-field">
|
122 |
+
<mat-label>Header Value</mat-label>
|
123 |
+
<input matInput formControlName="value" placeholder="application/json">
|
124 |
+
<button mat-icon-button matSuffix [matMenuTriggerFor]="headerMenu">
|
125 |
+
<mat-icon>code</mat-icon>
|
126 |
+
</button>
|
127 |
+
<mat-menu #headerMenu="matMenu">
|
128 |
+
@for (variable of getTemplateVariables(); track variable) {
|
129 |
+
<button mat-menu-item (click)="insertHeaderValue(i, variable)">
|
130 |
+
{{ variable }}
|
131 |
+
</button>
|
132 |
+
}
|
133 |
+
</mat-menu>
|
134 |
</mat-form-field>
|
135 |
|
136 |
+
<button mat-icon-button color="warn" (click)="removeHeader(i)">
|
137 |
+
<mat-icon>delete</mat-icon>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
</button>
|
139 |
</div>
|
140 |
+
}
|
141 |
+
</div>
|
142 |
+
</div>
|
143 |
+
</mat-tab>
|
144 |
+
|
145 |
+
<!-- Response Tab -->
|
146 |
+
<mat-tab label="Response">
|
147 |
+
<div class="tab-content">
|
148 |
+
<mat-form-field appearance="outline" class="full-width">
|
149 |
+
<mat-label>Response Prompt</mat-label>
|
150 |
+
<textarea matInput
|
151 |
+
[formControl]="form.get('response_prompt')"
|
152 |
+
rows="4"
|
153 |
+
placeholder="Optional instructions for processing the response"></textarea>
|
154 |
+
<mat-hint>Instructions for AI to process the response (optional)</mat-hint>
|
155 |
+
</mat-form-field>
|
156 |
+
|
157 |
+
<mat-divider></mat-divider>
|
158 |
+
|
159 |
+
<div class="array-section">
|
160 |
+
<div class="section-header">
|
161 |
+
<h3>Response Mappings</h3>
|
162 |
+
<button mat-button color="primary" (click)="addResponseMapping()">
|
163 |
+
<mat-icon>add</mat-icon>
|
164 |
+
Add Mapping
|
165 |
+
</button>
|
166 |
+
</div>
|
167 |
|
168 |
+
<p class="info-text">
|
169 |
+
Extract values from API response and save them as variables for use in subsequent intents.
|
170 |
+
</p>
|
171 |
+
|
172 |
+
@if (responseMappings.length === 0) {
|
173 |
+
<p class="empty-message">No response mappings configured.</p>
|
174 |
+
}
|
175 |
+
|
176 |
+
@for (mapping of responseMappings.controls; track mapping; let i = $index) {
|
177 |
+
<mat-expansion-panel [formGroup]="mapping">
|
178 |
+
<mat-expansion-panel-header>
|
179 |
+
<mat-panel-title>
|
180 |
+
{{ mapping.get('variable_name')?.value || 'New Mapping' }}
|
181 |
+
</mat-panel-title>
|
182 |
+
<mat-panel-description>
|
183 |
+
{{ mapping.get('json_path')?.value || 'Configure mapping' }}
|
184 |
+
</mat-panel-description>
|
185 |
+
</mat-expansion-panel-header>
|
186 |
+
|
187 |
+
<div class="mapping-content">
|
188 |
<mat-form-field appearance="outline">
|
189 |
<mat-label>Variable Name</mat-label>
|
190 |
+
<input matInput formControlName="variable_name" placeholder="booking_ref">
|
191 |
+
<mat-hint>Name to store the extracted value</mat-hint>
|
192 |
+
@if (mapping.get('variable_name')?.hasError('pattern')) {
|
193 |
+
<mat-error>Lowercase letters, numbers and underscore only</mat-error>
|
194 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
195 |
</mat-form-field>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
197 |
<mat-form-field appearance="outline">
|
198 |
+
<mat-label>Caption</mat-label>
|
199 |
+
<input matInput formControlName="caption" placeholder="Booking Reference">
|
200 |
+
<mat-hint>Human-readable description</mat-hint>
|
201 |
</mat-form-field>
|
202 |
|
203 |
+
<div class="row">
|
204 |
+
<mat-form-field appearance="outline" class="type-field">
|
205 |
+
<mat-label>Type</mat-label>
|
206 |
+
<mat-select formControlName="type">
|
207 |
+
@for (type of variableTypes; track type) {
|
208 |
+
<mat-option [value]="type">{{ type }}</mat-option>
|
209 |
+
}
|
210 |
+
</mat-select>
|
211 |
+
</mat-form-field>
|
212 |
+
|
213 |
+
<mat-form-field appearance="outline" class="path-field">
|
214 |
+
<mat-label>JSON Path</mat-label>
|
215 |
+
<input matInput formControlName="json_path" placeholder="$.data.bookingReference">
|
216 |
+
<mat-hint>JSONPath expression to extract value</mat-hint>
|
217 |
+
</mat-form-field>
|
218 |
+
</div>
|
219 |
|
220 |
+
<button mat-button color="warn" (click)="removeResponseMapping(i)">
|
221 |
<mat-icon>delete</mat-icon>
|
222 |
+
Remove Mapping
|
223 |
</button>
|
224 |
</div>
|
225 |
+
</mat-expansion-panel>
|
226 |
+
}
|
227 |
+
</div>
|
|
|
|
|
|
|
228 |
|
229 |
+
<!-- Retry Settings -->
|
230 |
+
<mat-divider></mat-divider>
|
231 |
+
|
232 |
+
<div class="retry-section" [formGroup]="form.get('retry')">
|
233 |
+
<h3>Retry Settings</h3>
|
234 |
+
|
235 |
+
<div class="row">
|
236 |
+
<mat-form-field appearance="outline">
|
237 |
+
<mat-label>Retry Count</mat-label>
|
238 |
+
<input matInput type="number" formControlName="retry_count">
|
239 |
+
<mat-hint>Number of retry attempts</mat-hint>
|
240 |
+
</mat-form-field>
|
241 |
+
|
242 |
+
<mat-form-field appearance="outline">
|
243 |
+
<mat-label>Backoff (seconds)</mat-label>
|
244 |
+
<input matInput type="number" formControlName="backoff_seconds">
|
245 |
+
<mat-hint>Delay between retries</mat-hint>
|
246 |
+
</mat-form-field>
|
247 |
+
|
248 |
+
<mat-form-field appearance="outline">
|
249 |
+
<mat-label>Strategy</mat-label>
|
250 |
+
<mat-select formControlName="strategy">
|
251 |
+
@for (strategy of retryStrategies; track strategy) {
|
252 |
+
<mat-option [value]="strategy">{{ strategy }}</mat-option>
|
253 |
+
}
|
254 |
+
</mat-select>
|
255 |
+
</mat-form-field>
|
256 |
</div>
|
257 |
</div>
|
258 |
+
</div>
|
259 |
+
</mat-tab>
|
260 |
+
|
261 |
+
<!-- Test Tab -->
|
262 |
+
<mat-tab label="Test">
|
263 |
+
<div class="tab-content">
|
264 |
+
<div class="test-section">
|
265 |
+
<h3>Test API Call</h3>
|
266 |
+
|
267 |
+
<div class="test-controls">
|
268 |
+
<button mat-raised-button color="primary"
|
269 |
+
(click)="testAPI()"
|
270 |
+
[disabled]="testing || !form.get('url')?.valid || !form.get('method')?.valid">
|
271 |
+
@if (testing) {
|
272 |
+
<mat-icon class="spin">sync</mat-icon>
|
273 |
+
Testing...
|
274 |
+
} @else {
|
275 |
+
<mat-icon>play_arrow</mat-icon>
|
276 |
+
Test API
|
277 |
+
}
|
278 |
+
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
279 |
|
280 |
+
<button mat-button (click)="updateTestRequestJson()">
|
281 |
+
<mat-icon>refresh</mat-icon>
|
282 |
+
Generate Test Data
|
283 |
+
</button>
|
284 |
+
</div>
|
285 |
|
286 |
+
<mat-form-field appearance="outline" class="full-width">
|
287 |
+
<mat-label>Test Request Body</mat-label>
|
288 |
+
<textarea matInput
|
289 |
+
[(ngModel)]="testRequestJson"
|
290 |
+
rows="10"
|
291 |
+
placeholder="Enter test request JSON here"></textarea>
|
292 |
+
<mat-hint>Variables will be replaced with test values</mat-hint>
|
293 |
+
</mat-form-field>
|
294 |
|
295 |
+
@if (testResult) {
|
296 |
+
<mat-divider></mat-divider>
|
297 |
+
|
298 |
+
<div class="test-result" [class.success]="testResult.success" [class.error]="!testResult.success">
|
299 |
+
<h4>Test Result</h4>
|
300 |
+
|
301 |
+
@if (testResult.success) {
|
302 |
+
<div class="result-status">
|
303 |
+
<mat-icon>check_circle</mat-icon>
|
304 |
+
<span>Success ({{ testResult.status_code }})</span>
|
|
|
|
|
|
|
305 |
</div>
|
306 |
+
} @else {
|
307 |
+
<div class="result-status">
|
308 |
+
<mat-icon>error</mat-icon>
|
309 |
+
<span>Failed: {{ testResult.error }}</span>
|
310 |
+
</div>
|
311 |
+
}
|
312 |
+
|
313 |
+
@if (testResult.response_time) {
|
314 |
+
<p><strong>Response Time:</strong> {{ testResult.response_time }}ms</p>
|
315 |
+
}
|
316 |
+
|
317 |
+
@if (testResult.response_body) {
|
318 |
+
<mat-form-field appearance="outline" class="full-width">
|
319 |
+
<mat-label>Response Body</mat-label>
|
320 |
+
<textarea matInput
|
321 |
+
[value]="testResult.response_body | json"
|
322 |
+
rows="10"
|
323 |
+
readonly></textarea>
|
324 |
+
</mat-form-field>
|
325 |
+
}
|
326 |
+
|
327 |
+
@if (testResult.request_body) {
|
328 |
+
<mat-form-field appearance="outline" class="full-width">
|
329 |
+
<mat-label>Actual Request Sent</mat-label>
|
330 |
+
<textarea matInput
|
331 |
+
[value]="testResult.request_body | json"
|
332 |
+
rows="8"
|
333 |
+
readonly></textarea>
|
334 |
+
</mat-form-field>
|
335 |
+
}
|
336 |
</div>
|
337 |
+
}
|
338 |
</div>
|
339 |
+
</div>
|
340 |
+
</mat-tab>
|
341 |
+
|
342 |
+
<!-- Auth Tab -->
|
343 |
+
<mat-tab label="Authentication">
|
344 |
+
<div class="tab-content" [formGroup]="form.get('auth')">
|
345 |
+
<mat-checkbox formControlName="enabled">
|
346 |
+
Enable Authentication
|
347 |
+
</mat-checkbox>
|
348 |
+
|
349 |
+
@if (form.get('auth.enabled')?.value) {
|
350 |
+
<mat-divider></mat-divider>
|
351 |
+
|
352 |
+
<div class="auth-section">
|
353 |
+
<h3>Token Configuration</h3>
|
354 |
+
|
355 |
+
<mat-form-field appearance="outline">
|
356 |
+
<mat-label>Token Endpoint</mat-label>
|
357 |
+
<input matInput formControlName="token_endpoint" placeholder="https://api.example.com/auth/token">
|
358 |
+
<mat-hint>URL to obtain authentication token</mat-hint>
|
359 |
+
@if (form.get('auth.token_endpoint')?.hasError('required') && form.get('auth.token_endpoint')?.touched) {
|
360 |
+
<mat-error>Token endpoint is required when auth is enabled</mat-error>
|
361 |
+
}
|
362 |
+
</mat-form-field>
|
363 |
+
|
364 |
+
<mat-form-field appearance="outline">
|
365 |
+
<mat-label>Token Response Path</mat-label>
|
366 |
+
<input matInput formControlName="response_token_path" placeholder="token">
|
367 |
+
<mat-hint>JSON path to extract token from response</mat-hint>
|
368 |
+
@if (form.get('auth.response_token_path')?.hasError('required') && form.get('auth.response_token_path')?.touched) {
|
369 |
+
<mat-error>Token path is required when auth is enabled</mat-error>
|
370 |
+
}
|
371 |
+
</mat-form-field>
|
372 |
+
|
373 |
+
<mat-form-field appearance="outline" class="full-width">
|
374 |
+
<mat-label>Token Request Body</mat-label>
|
375 |
+
<textarea matInput
|
376 |
+
formControlName="token_request_body"
|
377 |
+
rows="6"
|
378 |
+
(click)="saveCursorPosition('auth.token_request_body', $event)"
|
379 |
+
(keyup)="saveCursorPosition('auth.token_request_body', $event)"
|
380 |
+
placeholder='{"username": "{{config.api_username}}", "password": "{{config.api_password}}"}'></textarea>
|
381 |
+
<mat-hint>JSON body for token request</mat-hint>
|
382 |
+
@if (!validateJSON('auth.token_request_body')) {
|
383 |
+
<mat-error>Invalid JSON format</mat-error>
|
384 |
+
}
|
385 |
+
</mat-form-field>
|
386 |
+
|
387 |
+
<div class="template-variables">
|
388 |
+
<strong>Available Variables:</strong>
|
389 |
+
<mat-chip-set>
|
390 |
+
@for (variable of getTemplateVariables(); track variable) {
|
391 |
+
<mat-chip (click)="insertTemplateVariable('auth.token_request_body', variable)">
|
392 |
+
{{ variable }}
|
393 |
+
</mat-chip>
|
394 |
+
}
|
395 |
+
</mat-chip-set>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
396 |
</div>
|
397 |
|
398 |
+
<mat-divider></mat-divider>
|
399 |
+
|
400 |
+
<h3>Token Refresh (Optional)</h3>
|
401 |
+
|
402 |
+
<mat-form-field appearance="outline">
|
403 |
+
<mat-label>Refresh Endpoint</mat-label>
|
404 |
+
<input matInput formControlName="token_refresh_endpoint" placeholder="https://api.example.com/auth/refresh">
|
405 |
+
<mat-hint>URL to refresh expired token</mat-hint>
|
406 |
+
</mat-form-field>
|
407 |
+
|
408 |
+
<mat-form-field appearance="outline" class="full-width">
|
409 |
+
<mat-label>Refresh Request Body</mat-label>
|
410 |
+
<textarea matInput
|
411 |
+
formControlName="token_refresh_body"
|
412 |
+
rows="4"
|
413 |
+
(click)="saveCursorPosition('auth.token_refresh_body', $event)"
|
414 |
+
(keyup)="saveCursorPosition('auth.token_refresh_body', $event)"
|
415 |
+
placeholder='{"refresh_token": "{{auth_tokens.api_name.refresh_token}}"}'></textarea>
|
416 |
+
<mat-hint>JSON body for refresh request</mat-hint>
|
417 |
+
@if (!validateJSON('auth.token_refresh_body')) {
|
418 |
+
<mat-error>Invalid JSON format</mat-error>
|
419 |
+
}
|
420 |
+
</mat-form-field>
|
421 |
+
|
422 |
+
<div class="template-variables">
|
423 |
+
<strong>Available Variables:</strong>
|
424 |
+
<mat-chip-set>
|
425 |
+
@for (variable of getTemplateVariables(); track variable) {
|
426 |
+
<mat-chip (click)="insertTemplateVariable('auth.token_refresh_body', variable)">
|
427 |
+
{{ variable }}
|
428 |
+
</mat-chip>
|
429 |
+
}
|
430 |
+
</mat-chip-set>
|
431 |
</div>
|
432 |
</div>
|
433 |
+
}
|
434 |
+
</div>
|
435 |
+
</mat-tab>
|
436 |
+
</mat-tab-group>
|
437 |
</mat-dialog-content>
|
438 |
|
439 |
<mat-dialog-actions align="end">
|