ciyidogan commited on
Commit
669102c
·
verified ·
1 Parent(s): 65c64a7

Update flare-ui/src/app/services/api.service.ts

Browse files
flare-ui/src/app/services/api.service.ts CHANGED
@@ -170,7 +170,7 @@ export interface TTSSettings {
170
  })
171
  export class ApiService {
172
  private apiUrl = '/api';
173
- private baseUrl = `${this.apiUrl}/api`;
174
 
175
  constructor(
176
  private http: HttpClient,
@@ -219,7 +219,7 @@ export class ApiService {
219
  }
220
 
221
  updateEnvironment(data: Environment): Observable<any> {
222
- return this.http.put(`${this.apiUrl}/environment`, data, {
223
  headers: this.getAuthHeaders()
224
  }).pipe(
225
  catchError(this.handleError)
@@ -228,7 +228,7 @@ export class ApiService {
228
 
229
  // ===================== Projects =====================
230
  getProjects(includeDeleted = false): Observable<Project[]> {
231
- return this.http.get<Project[]>(`${this.apiUrl}/projects`, {
232
  headers: this.getAuthHeaders(),
233
  params: { include_deleted: includeDeleted.toString() }
234
  }).pipe(
@@ -248,7 +248,7 @@ export class ApiService {
248
  }
249
 
250
  createProject(data: any): Observable<any> {
251
- return this.http.post(`${this.apiUrl}/projects`, data, {
252
  headers: this.getAuthHeaders()
253
  }).pipe(
254
  catchError(this.handleError)
@@ -256,7 +256,7 @@ export class ApiService {
256
  }
257
 
258
  updateProject(id: number, data: any): Observable<any> {
259
- return this.http.put(`${this.apiUrl}/projects/${id}`, data, {
260
  headers: this.getAuthHeaders()
261
  }).pipe(
262
  catchError(error => {
@@ -276,7 +276,7 @@ export class ApiService {
276
  }
277
 
278
  deleteProject(id: number): Observable<any> {
279
- return this.http.delete(`${this.apiUrl}/projects/${id}`, {
280
  headers: this.getAuthHeaders()
281
  }).pipe(
282
  catchError(this.handleError)
@@ -284,7 +284,7 @@ export class ApiService {
284
  }
285
 
286
  toggleProject(id: number): Observable<any> {
287
- return this.http.patch(`${this.apiUrl}/projects/${id}/toggle`, {}, {
288
  headers: this.getAuthHeaders()
289
  }).pipe(
290
  catchError(this.handleError)
@@ -292,7 +292,7 @@ export class ApiService {
292
  }
293
 
294
  exportProject(id: number): Observable<any> {
295
- return this.http.get(`${this.apiUrl}/projects/${id}/export`, {
296
  headers: this.getAuthHeaders()
297
  }).pipe(
298
  catchError(this.handleError)
@@ -300,7 +300,7 @@ export class ApiService {
300
  }
301
 
302
  importProject(data: any): Observable<any> {
303
- return this.http.post(`${this.apiUrl}/projects/import`, data, {
304
  headers: this.getAuthHeaders()
305
  }).pipe(
306
  catchError(this.handleError)
@@ -309,7 +309,7 @@ export class ApiService {
309
 
310
  // ===================== Versions =====================
311
  createVersion(projectId: number, data: any): Observable<any> {
312
- return this.http.post(`${this.apiUrl}/projects/${projectId}/versions`, data, {
313
  headers: this.getAuthHeaders()
314
  }).pipe(
315
  catchError(error => {
@@ -323,7 +323,7 @@ export class ApiService {
323
 
324
  updateVersion(projectId: number, versionNo: number, data: any, force: boolean = false): Observable<any> {
325
  return this.http.put(
326
- `${this.apiUrl}/projects/${projectId}/versions/${versionNo}${force ? '?force=true' : ''}`,
327
  data,
328
  { headers: this.getAuthHeaders() }
329
  ).pipe(
@@ -332,7 +332,7 @@ export class ApiService {
332
  }
333
 
334
  deleteVersion(projectId: number, versionNo: number): Observable<any> {
335
- return this.http.delete(`${this.apiUrl}/projects/${projectId}/versions/${versionNo}`, {
336
  headers: this.getAuthHeaders()
337
  }).pipe(
338
  catchError(this.handleError)
@@ -340,7 +340,7 @@ export class ApiService {
340
  }
341
 
342
  publishVersion(projectId: number, versionNo: number): Observable<any> {
343
- return this.http.post(`${this.apiUrl}/projects/${projectId}/versions/${versionNo}/publish`, {}, {
344
  headers: this.getAuthHeaders()
345
  }).pipe(
346
  catchError(this.handleError)
@@ -349,7 +349,7 @@ export class ApiService {
349
 
350
  // ===================== APIs =====================
351
  getAPIs(includeDeleted = false): Observable<API[]> {
352
- return this.http.get<API[]>(`${this.apiUrl}/apis`, {
353
  headers: this.getAuthHeaders(),
354
  params: { include_deleted: includeDeleted.toString() }
355
  }).pipe(
@@ -358,7 +358,7 @@ export class ApiService {
358
  }
359
 
360
  createAPI(data: any): Observable<any> {
361
- return this.http.post(`${this.apiUrl}/apis`, data, {
362
  headers: this.getAuthHeaders()
363
  }).pipe(
364
  catchError(this.handleError)
@@ -366,7 +366,7 @@ export class ApiService {
366
  }
367
 
368
  updateAPI(name: string, data: any): Observable<any> {
369
- return this.http.put(`${this.apiUrl}/apis/${name}`, data, {
370
  headers: this.getAuthHeaders()
371
  }).pipe(
372
  catchError(error => {
@@ -384,7 +384,7 @@ export class ApiService {
384
  );
385
  }
386
  deleteAPI(name: string): Observable<any> {
387
- return this.http.delete(`${this.apiUrl}/apis/${name}`, {
388
  headers: this.getAuthHeaders()
389
  }).pipe(
390
  catchError(this.handleError)
@@ -392,7 +392,7 @@ export class ApiService {
392
  }
393
 
394
  testAPI(data: any): Observable<any> {
395
- return this.http.post(`${this.apiUrl}/apis/test`, data, {
396
  headers: this.getAuthHeaders()
397
  }).pipe(
398
  catchError(this.handleError)
@@ -401,7 +401,7 @@ export class ApiService {
401
 
402
  // ===================== Spark Integration =====================
403
  sparkStartup(projectName: string): Observable<any> {
404
- return this.http.post(`${this.apiUrl}/spark/startup`,
405
  { project_name: projectName },
406
  { headers: this.getAuthHeaders() }
407
  ).pipe(
@@ -410,7 +410,7 @@ export class ApiService {
410
  }
411
 
412
  sparkGetProjects(): Observable<any> {
413
- return this.http.get(`${this.apiUrl}/spark/projects`, {
414
  headers: this.getAuthHeaders()
415
  }).pipe(
416
  catchError(this.handleError)
@@ -418,7 +418,7 @@ export class ApiService {
418
  }
419
 
420
  sparkEnableProject(projectName: string): Observable<any> {
421
- return this.http.post(`${this.apiUrl}/spark/project/enable`,
422
  { project_name: projectName },
423
  { headers: this.getAuthHeaders() }
424
  ).pipe(
@@ -427,7 +427,7 @@ export class ApiService {
427
  }
428
 
429
  sparkDisableProject(projectName: string): Observable<any> {
430
- return this.http.post(`${this.apiUrl}/spark/project/disable`,
431
  { project_name: projectName },
432
  { headers: this.getAuthHeaders() }
433
  ).pipe(
@@ -436,7 +436,7 @@ export class ApiService {
436
  }
437
 
438
  sparkDeleteProject(projectName: string): Observable<any> {
439
- return this.http.delete(`${this.apiUrl}/spark/project/${projectName}`, {
440
  headers: this.getAuthHeaders()
441
  }).pipe(
442
  catchError(this.handleError)
@@ -445,7 +445,7 @@ export class ApiService {
445
 
446
  // ===================== Tests =====================
447
  runTests(testType: string): Observable<any> {
448
- return this.http.post(`${this.apiUrl}/test/run-all`, { test_type: testType }, {
449
  headers: this.getAuthHeaders()
450
  }).pipe(
451
  catchError(this.handleError)
@@ -454,7 +454,7 @@ export class ApiService {
454
 
455
  // ===================== Activity Log =====================
456
  getActivityLog(limit = 50): Observable<any[]> {
457
- return this.http.get<any[]>(`${this.apiUrl}/activity-log`, {
458
  headers: this.getAuthHeaders(),
459
  params: { limit: limit.toString() }
460
  }).pipe(
@@ -464,7 +464,7 @@ export class ApiService {
464
 
465
  // ===================== Validation =====================
466
  validateRegex(pattern: string, testValue: string): Observable<any> {
467
- return this.http.post(`${this.apiUrl}/validate/regex`,
468
  { pattern, test_value: testValue },
469
  { headers: this.getAuthHeaders() }
470
  ).pipe(
@@ -475,7 +475,7 @@ export class ApiService {
475
  // ===================== Chat =====================
476
  /* 1️⃣ Proje isimleri (combo’yu doldurmak için) */
477
  getChatProjects() {
478
- return this.http.get<string[]>(`${this.apiUrl}/projects/names`);
479
  }
480
 
481
  /* 2️⃣ Oturum başlat */
@@ -525,11 +525,11 @@ export class ApiService {
525
 
526
  // ===================== Locale =====================
527
  getAvailableLocales(): Observable<any> {
528
- return this.http.get(`${this.apiUrl}/locales`, { headers: this.getAuthHeaders() });
529
  }
530
 
531
  getLocaleDetails(code: string): Observable<any> {
532
- return this.http.get(`${this.apiUrl}/locales/${code}`, { headers: this.getAuthHeaders() });
533
  }
534
 
535
  // ===================== Error Handler =====================
 
170
  })
171
  export class ApiService {
172
  private apiUrl = '/api';
173
+ private adminUrl = `${this.apiUrl}/admin`;
174
 
175
  constructor(
176
  private http: HttpClient,
 
219
  }
220
 
221
  updateEnvironment(data: Environment): Observable<any> {
222
+ return this.http.put(`${this.adminUrl}/environment`, data, {
223
  headers: this.getAuthHeaders()
224
  }).pipe(
225
  catchError(this.handleError)
 
228
 
229
  // ===================== Projects =====================
230
  getProjects(includeDeleted = false): Observable<Project[]> {
231
+ return this.http.get<Project[]>(`${this.adminUrl}/projects`, {
232
  headers: this.getAuthHeaders(),
233
  params: { include_deleted: includeDeleted.toString() }
234
  }).pipe(
 
248
  }
249
 
250
  createProject(data: any): Observable<any> {
251
+ return this.http.post(`${this.adminUrl}/projects`, data, {
252
  headers: this.getAuthHeaders()
253
  }).pipe(
254
  catchError(this.handleError)
 
256
  }
257
 
258
  updateProject(id: number, data: any): Observable<any> {
259
+ return this.http.put(`${this.adminUrl}/projects/${id}`, data, {
260
  headers: this.getAuthHeaders()
261
  }).pipe(
262
  catchError(error => {
 
276
  }
277
 
278
  deleteProject(id: number): Observable<any> {
279
+ return this.http.delete(`${this.adminUrl}/projects/${id}`, {
280
  headers: this.getAuthHeaders()
281
  }).pipe(
282
  catchError(this.handleError)
 
284
  }
285
 
286
  toggleProject(id: number): Observable<any> {
287
+ return this.http.patch(`${this.adminUrl}/projects/${id}/toggle`, {}, {
288
  headers: this.getAuthHeaders()
289
  }).pipe(
290
  catchError(this.handleError)
 
292
  }
293
 
294
  exportProject(id: number): Observable<any> {
295
+ return this.http.get(`${this.adminUrl}/projects/${id}/export`, {
296
  headers: this.getAuthHeaders()
297
  }).pipe(
298
  catchError(this.handleError)
 
300
  }
301
 
302
  importProject(data: any): Observable<any> {
303
+ return this.http.post(`${this.adminUrl}/projects/import`, data, {
304
  headers: this.getAuthHeaders()
305
  }).pipe(
306
  catchError(this.handleError)
 
309
 
310
  // ===================== Versions =====================
311
  createVersion(projectId: number, data: any): Observable<any> {
312
+ return this.http.post(`${this.adminUrl}/projects/${projectId}/versions`, data, {
313
  headers: this.getAuthHeaders()
314
  }).pipe(
315
  catchError(error => {
 
323
 
324
  updateVersion(projectId: number, versionNo: number, data: any, force: boolean = false): Observable<any> {
325
  return this.http.put(
326
+ `${this.adminUrl}/projects/${projectId}/versions/${versionNo}${force ? '?force=true' : ''}`,
327
  data,
328
  { headers: this.getAuthHeaders() }
329
  ).pipe(
 
332
  }
333
 
334
  deleteVersion(projectId: number, versionNo: number): Observable<any> {
335
+ return this.http.delete(`${this.adminUrl}/projects/${projectId}/versions/${versionNo}`, {
336
  headers: this.getAuthHeaders()
337
  }).pipe(
338
  catchError(this.handleError)
 
340
  }
341
 
342
  publishVersion(projectId: number, versionNo: number): Observable<any> {
343
+ return this.http.post(`${this.adminUrl}/projects/${projectId}/versions/${versionNo}/publish`, {}, {
344
  headers: this.getAuthHeaders()
345
  }).pipe(
346
  catchError(this.handleError)
 
349
 
350
  // ===================== APIs =====================
351
  getAPIs(includeDeleted = false): Observable<API[]> {
352
+ return this.http.get<API[]>(`${this.adminUrl}/apis`, {
353
  headers: this.getAuthHeaders(),
354
  params: { include_deleted: includeDeleted.toString() }
355
  }).pipe(
 
358
  }
359
 
360
  createAPI(data: any): Observable<any> {
361
+ return this.http.post(`${this.adminUrl}/apis`, data, {
362
  headers: this.getAuthHeaders()
363
  }).pipe(
364
  catchError(this.handleError)
 
366
  }
367
 
368
  updateAPI(name: string, data: any): Observable<any> {
369
+ return this.http.put(`${this.adminUrl}/apis/${name}`, data, {
370
  headers: this.getAuthHeaders()
371
  }).pipe(
372
  catchError(error => {
 
384
  );
385
  }
386
  deleteAPI(name: string): Observable<any> {
387
+ return this.http.delete(`${this.adminUrl}/apis/${name}`, {
388
  headers: this.getAuthHeaders()
389
  }).pipe(
390
  catchError(this.handleError)
 
392
  }
393
 
394
  testAPI(data: any): Observable<any> {
395
+ return this.http.post(`${this.adminUrl}/apis/test`, data, {
396
  headers: this.getAuthHeaders()
397
  }).pipe(
398
  catchError(this.handleError)
 
401
 
402
  // ===================== Spark Integration =====================
403
  sparkStartup(projectName: string): Observable<any> {
404
+ return this.http.post(`${this.adminUrl}/spark/startup`,
405
  { project_name: projectName },
406
  { headers: this.getAuthHeaders() }
407
  ).pipe(
 
410
  }
411
 
412
  sparkGetProjects(): Observable<any> {
413
+ return this.http.get(`${this.adminUrl}/spark/projects`, {
414
  headers: this.getAuthHeaders()
415
  }).pipe(
416
  catchError(this.handleError)
 
418
  }
419
 
420
  sparkEnableProject(projectName: string): Observable<any> {
421
+ return this.http.post(`${this.adminUrl}/spark/project/enable`,
422
  { project_name: projectName },
423
  { headers: this.getAuthHeaders() }
424
  ).pipe(
 
427
  }
428
 
429
  sparkDisableProject(projectName: string): Observable<any> {
430
+ return this.http.post(`${this.adminUrl}/spark/project/disable`,
431
  { project_name: projectName },
432
  { headers: this.getAuthHeaders() }
433
  ).pipe(
 
436
  }
437
 
438
  sparkDeleteProject(projectName: string): Observable<any> {
439
+ return this.http.delete(`${this.adminUrl}/spark/project/${projectName}`, {
440
  headers: this.getAuthHeaders()
441
  }).pipe(
442
  catchError(this.handleError)
 
445
 
446
  // ===================== Tests =====================
447
  runTests(testType: string): Observable<any> {
448
+ return this.http.post(`${this.adminUrl}/test/run-all`, { test_type: testType }, {
449
  headers: this.getAuthHeaders()
450
  }).pipe(
451
  catchError(this.handleError)
 
454
 
455
  // ===================== Activity Log =====================
456
  getActivityLog(limit = 50): Observable<any[]> {
457
+ return this.http.get<any[]>(`${this.adminUrl}/activity-log`, {
458
  headers: this.getAuthHeaders(),
459
  params: { limit: limit.toString() }
460
  }).pipe(
 
464
 
465
  // ===================== Validation =====================
466
  validateRegex(pattern: string, testValue: string): Observable<any> {
467
+ return this.http.post(`${this.adminUrl}/validate/regex`,
468
  { pattern, test_value: testValue },
469
  { headers: this.getAuthHeaders() }
470
  ).pipe(
 
475
  // ===================== Chat =====================
476
  /* 1️⃣ Proje isimleri (combo’yu doldurmak için) */
477
  getChatProjects() {
478
+ return this.http.get<string[]>(`${this.adminUrl}/projects/names`);
479
  }
480
 
481
  /* 2️⃣ Oturum başlat */
 
525
 
526
  // ===================== Locale =====================
527
  getAvailableLocales(): Observable<any> {
528
+ return this.http.get(`${this.adminUrl}/locales`, { headers: this.getAuthHeaders() });
529
  }
530
 
531
  getLocaleDetails(code: string): Observable<any> {
532
+ return this.http.get(`${this.adminUrl}/locales/${code}`, { headers: this.getAuthHeaders() });
533
  }
534
 
535
  // ===================== Error Handler =====================