Spaces:
Building
Building
Update flare-ui/src/app/services/api.service.ts
Browse files
flare-ui/src/app/services/api.service.ts
CHANGED
@@ -178,6 +178,18 @@ export class ApiService {
|
|
178 |
private authService: AuthService
|
179 |
) {}
|
180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
// ===================== Auth =====================
|
182 |
login(username: string, password: string): Observable<any> {
|
183 |
return this.http.post(`${this.adminUrl}/login`, { username, password }).pipe(
|
@@ -256,6 +268,11 @@ export class ApiService {
|
|
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(
|
@@ -322,6 +339,11 @@ export class ApiService {
|
|
322 |
}
|
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,
|
@@ -366,6 +388,11 @@ export class ApiService {
|
|
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(
|
|
|
178 |
private authService: AuthService
|
179 |
) {}
|
180 |
|
181 |
+
// ===================== Utils =====================
|
182 |
+
private normalizeTimestamp(timestamp: string | null | undefined): string {
|
183 |
+
if (!timestamp) return '';
|
184 |
+
|
185 |
+
// Remove milliseconds for comparison
|
186 |
+
if (timestamp.includes('.') && timestamp.endsWith('Z')) {
|
187 |
+
return timestamp.split('.')[0] + 'Z';
|
188 |
+
}
|
189 |
+
|
190 |
+
return timestamp;
|
191 |
+
}
|
192 |
+
|
193 |
// ===================== Auth =====================
|
194 |
login(username: string, password: string): Observable<any> {
|
195 |
return this.http.post(`${this.adminUrl}/login`, { username, password }).pipe(
|
|
|
268 |
}
|
269 |
|
270 |
updateProject(id: number, data: any): Observable<any> {
|
271 |
+
// Normalize the timestamp before sending
|
272 |
+
if (data.last_update_date) {
|
273 |
+
data.last_update_date = this.normalizeTimestamp(data.last_update_date);
|
274 |
+
}
|
275 |
+
|
276 |
return this.http.put(`${this.adminUrl}/projects/${id}`, data, {
|
277 |
headers: this.getAuthHeaders()
|
278 |
}).pipe(
|
|
|
339 |
}
|
340 |
|
341 |
updateVersion(projectId: number, versionNo: number, data: any, force: boolean = false): Observable<any> {
|
342 |
+
// Normalize the timestamp before sending
|
343 |
+
if (data.last_update_date) {
|
344 |
+
data.last_update_date = this.normalizeTimestamp(data.last_update_date);
|
345 |
+
}
|
346 |
+
|
347 |
return this.http.put(
|
348 |
`${this.adminUrl}/projects/${projectId}/versions/${versionNo}${force ? '?force=true' : ''}`,
|
349 |
data,
|
|
|
388 |
}
|
389 |
|
390 |
updateAPI(name: string, data: any): Observable<any> {
|
391 |
+
// Normalize the timestamp before sending
|
392 |
+
if (data.last_update_date) {
|
393 |
+
data.last_update_date = this.normalizeTimestamp(data.last_update_date);
|
394 |
+
}
|
395 |
+
|
396 |
return this.http.put(`${this.adminUrl}/apis/${name}`, data, {
|
397 |
headers: this.getAuthHeaders()
|
398 |
}).pipe(
|