ciyidogan commited on
Commit
e295fed
·
verified ·
1 Parent(s): 729e4c2

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

Browse files
flare-ui/src/app/services/api.service.ts CHANGED
@@ -212,7 +212,14 @@ export class ApiService {
212
  headers: this.getAuthHeaders(),
213
  params: { include_deleted: includeDeleted.toString() }
214
  }).pipe(
215
- catchError(this.handleError)
 
 
 
 
 
 
 
216
  );
217
  }
218
 
@@ -232,7 +239,19 @@ export class ApiService {
232
  return this.http.put(`${this.apiUrl}/projects/${id}`, data, {
233
  headers: this.getAuthHeaders()
234
  }).pipe(
235
- catchError(this.handleError)
 
 
 
 
 
 
 
 
 
 
 
 
236
  );
237
  }
238
 
@@ -273,7 +292,12 @@ export class ApiService {
273
  return this.http.post(`${this.apiUrl}/projects/${projectId}/versions`, data, {
274
  headers: this.getAuthHeaders()
275
  }).pipe(
276
- catchError(this.handleError)
 
 
 
 
 
277
  );
278
  }
279
 
@@ -325,10 +349,20 @@ export class ApiService {
325
  return this.http.put(`${this.apiUrl}/apis/${name}`, data, {
326
  headers: this.getAuthHeaders()
327
  }).pipe(
328
- catchError(this.handleError)
 
 
 
 
 
 
 
 
 
 
 
329
  );
330
  }
331
-
332
  deleteAPI(name: string): Observable<any> {
333
  return this.http.delete(`${this.apiUrl}/apis/${name}`, {
334
  headers: this.getAuthHeaders()
 
212
  headers: this.getAuthHeaders(),
213
  params: { include_deleted: includeDeleted.toString() }
214
  }).pipe(
215
+ catchError(error => {
216
+ // Race condition check
217
+ if (error.status === 409) {
218
+ console.warn('Race condition detected in getProjects:', error.error);
219
+ // Component'ler bu hatayı handle edecek
220
+ }
221
+ return throwError(() => error);
222
+ })
223
  );
224
  }
225
 
 
239
  return this.http.put(`${this.apiUrl}/projects/${id}`, data, {
240
  headers: this.getAuthHeaders()
241
  }).pipe(
242
+ catchError(error => {
243
+ // Race condition özel handling
244
+ if (error.status === 409) {
245
+ const details = error.error?.details || {};
246
+ return throwError(() => ({
247
+ ...error,
248
+ raceCondition: true,
249
+ lastUpdateUser: details.last_update_user,
250
+ lastUpdateDate: details.last_update_date
251
+ }));
252
+ }
253
+ return throwError(() => error);
254
+ })
255
  );
256
  }
257
 
 
292
  return this.http.post(`${this.apiUrl}/projects/${projectId}/versions`, data, {
293
  headers: this.getAuthHeaders()
294
  }).pipe(
295
+ catchError(error => {
296
+ if (error.status === 409) {
297
+ console.warn('Race condition in createVersion:', error.error);
298
+ }
299
+ return throwError(() => error);
300
+ })
301
  );
302
  }
303
 
 
349
  return this.http.put(`${this.apiUrl}/apis/${name}`, data, {
350
  headers: this.getAuthHeaders()
351
  }).pipe(
352
+ catchError(error => {
353
+ if (error.status === 409) {
354
+ const details = error.error?.details || {};
355
+ return throwError(() => ({
356
+ ...error,
357
+ raceCondition: true,
358
+ lastUpdateUser: details.last_update_user,
359
+ lastUpdateDate: details.last_update_date
360
+ }));
361
+ }
362
+ return throwError(() => error);
363
+ })
364
  );
365
  }
 
366
  deleteAPI(name: string): Observable<any> {
367
  return this.http.delete(`${this.apiUrl}/apis/${name}`, {
368
  headers: this.getAuthHeaders()