mirror of
https://github.com/bec-project/bec_atlas.git
synced 2025-07-13 22:51:49 +02:00
refactor(remote-data-service) : add patch to remote-data service, refactored scandataservice to simplify api
This commit is contained in:
@ -54,6 +54,23 @@ export class RemoteDataService {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Base method for making a PATCH request to the server
|
||||||
|
* @param path path to the endpoint
|
||||||
|
* @param payload payload to send
|
||||||
|
* @param headers additional headers
|
||||||
|
* @returns response from the server
|
||||||
|
*/
|
||||||
|
protected patch<T>(path: string, payload: any, headers: HttpHeaders) {
|
||||||
|
return this.httpClient.patch<T>(
|
||||||
|
this.serverSettings.getServerAddress() + path,
|
||||||
|
payload,
|
||||||
|
{
|
||||||
|
headers,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
@ -189,4 +206,22 @@ export class ScanCountService extends RemoteDataService {
|
|||||||
}
|
}
|
||||||
return this.get<ScanCountResponse>('scans/count', filters, headers);
|
return this.get<ScanCountResponse>('scans/count', filters, headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method for updating the user data for a scan
|
||||||
|
* @param scanId Unique identifier for the scan
|
||||||
|
* @param userData User data to update
|
||||||
|
* @returns response from the server
|
||||||
|
* @throws HttpErrorResponse if the request fails
|
||||||
|
* @throws TimeoutError if the request takes too long
|
||||||
|
*/
|
||||||
|
updateUserData(scanId: string, userData: ScanUserData) {
|
||||||
|
let headers = new HttpHeaders();
|
||||||
|
headers = headers.set('Content-Type', 'application/json; charset=utf-8');
|
||||||
|
return this.post<string>(
|
||||||
|
'scans/user_data',
|
||||||
|
{ scan_id: scanId, ...userData },
|
||||||
|
headers
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import {
|
|||||||
Signal,
|
Signal,
|
||||||
inject,
|
inject,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { ScanCountService, ScanDataService } from '../core/remote-data.service';
|
import { ScanDataService } from '../core/remote-data.service';
|
||||||
import { ScanDataResponse } from '../core/model/scan-data';
|
import { ScanDataResponse } from '../core/model/scan-data';
|
||||||
import { CommonModule } from '@angular/common';
|
import { CommonModule } from '@angular/common';
|
||||||
import { MatTableModule } from '@angular/material/table';
|
import { MatTableModule } from '@angular/material/table';
|
||||||
@ -152,7 +152,7 @@ export class ScanTableComponent {
|
|||||||
loadScanCountResource = resource({
|
loadScanCountResource = resource({
|
||||||
request: () => this.reloadCriteria(),
|
request: () => this.reloadCriteria(),
|
||||||
loader: ({ request, abortSignal }): Promise<ScanCountResponse> => {
|
loader: ({ request, abortSignal }): Promise<ScanCountResponse> => {
|
||||||
return firstValueFrom(this.scanCount.getScanCount(request.sessionId));
|
return firstValueFrom(this.scanData.getScanCount(request.sessionId));
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -182,10 +182,7 @@ export class ScanTableComponent {
|
|||||||
return data.count;
|
return data.count;
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(
|
constructor(private scanData: ScanDataService) {
|
||||||
private scanData: ScanDataService,
|
|
||||||
private scanCount: ScanCountService
|
|
||||||
) {
|
|
||||||
this.tableData = computed(() =>
|
this.tableData = computed(() =>
|
||||||
this.handleScanData(this.loadScanDataResource.value() || [])
|
this.handleScanData(this.loadScanDataResource.value() || [])
|
||||||
);
|
);
|
||||||
|
Reference in New Issue
Block a user