updated claims api: submit job and get status
This commit is contained in:
parent
4e3df67f7e
commit
21c70d6d62
|
@ -106,6 +106,16 @@ export class ClaimsService {
|
|||
.pipe(catchError(this.handleError));
|
||||
|
||||
}
|
||||
getStatus(jobId, apiUrl:string):any{
|
||||
|
||||
let url = apiUrl +"jobStatus/" + jobId;
|
||||
|
||||
return this.http.get(url,CustomOptions.getAuthOptions())
|
||||
//.map(res => res.json())
|
||||
//.do(request => console.info("Insert Response:"+request) )
|
||||
.pipe(catchError(this.handleError));
|
||||
|
||||
}
|
||||
private handleError (error: Response) {
|
||||
// in a real world app, we may send the error to some remote logging infrastructure
|
||||
// instead of just logging it to the console
|
||||
|
|
|
@ -14,7 +14,8 @@ import {
|
|||
Message
|
||||
} from "../../claim-utils/claimHelper.class";
|
||||
import {UserManagementService} from "../../../services/user-management.service";
|
||||
import {Subscriber} from "rxjs";
|
||||
import {Subscriber, timer} from "rxjs";
|
||||
import {map} from "rxjs/operators";
|
||||
|
||||
@Component({
|
||||
selector: 'claim-insert',
|
||||
|
@ -30,7 +31,18 @@ import {Subscriber} from "rxjs";
|
|||
<div class="uk-width-expand uk-margin-small-left">CONFIRM LINKING</div>
|
||||
</button>
|
||||
</div>
|
||||
<modal-loading [message]="'Please wait...'"></modal-loading>
|
||||
<modal-loading [message]="'Please wait...'">
|
||||
|
||||
<div *ngIf="claimsJob">
|
||||
<div *ngIf="claimsJob && claimsJob.insertedIds.length <1" class="uk-text-meta uk-text-small">
|
||||
Initiating process....</div>
|
||||
<div *ngIf="claimsJob && claimsJob.insertedIds.length >0" class="uk-text-meta uk-text-small">
|
||||
{{claimsJob.insertedIds.length}} out of {{claims2Insert}} links created.</div>
|
||||
<div *ngIf="feedRecordsJob" class="uk-text-meta uk-text-small">{{feedRecordsJob.length}} records added in the index...</div>
|
||||
<div *ngIf="claimsJob.status != 'COMPLETE'" class="uk-text-meta uk-text-small">
|
||||
Please don't close the window, process is ongoing...</div>
|
||||
</div>
|
||||
</modal-loading>
|
||||
<modal-alert (alertOutput)="confirmClose()">
|
||||
<h4 class="modal-title uk-text-bold " id="myModalLabel">Confirmation notice</h4>
|
||||
<p>All the links you provided will be published in the OpenAIRE platform. <br>
|
||||
|
@ -84,7 +96,9 @@ export class ClaimInsertComponent {
|
|||
private errorInClaims: ClaimRecord2Insert[] = [];
|
||||
private insertedRecords = [];
|
||||
private errorInRecords = [];
|
||||
|
||||
public claimsJob;
|
||||
public feedRecordsJob;
|
||||
public claims2Insert;
|
||||
public insert() {
|
||||
this.confirmOpen();
|
||||
}
|
||||
|
@ -180,9 +194,9 @@ export class ClaimInsertComponent {
|
|||
if (directclaims.length > 0 && this.properties.environment != "development"){
|
||||
this.subscriptions.push(this.claimService.insertDirectRecords(directclaims, this.properties.claimsAPIURL).subscribe(
|
||||
data => {
|
||||
this.insertedRecords = data.insertedIds;
|
||||
|
||||
this.errorInRecords = data.errorInClaims;
|
||||
// this.insertedRecords = data.insertedIds;
|
||||
//
|
||||
// this.errorInRecords = data.errorInClaims;
|
||||
this.isertBulkClaims(claims);
|
||||
},
|
||||
err => {
|
||||
|
@ -214,7 +228,7 @@ export class ClaimInsertComponent {
|
|||
this.errors.splice(0, this.errors.length);
|
||||
this.subscriptions.push(this.claimService.insertBulkClaims(claims, this.properties.claimsAPIURL).subscribe(
|
||||
data => {
|
||||
this.insertedClaims = data.insertedIds;
|
||||
/*this.insertedClaims = data.insertedIds;
|
||||
this.errorInClaims = data.errorInClaims;
|
||||
//TODO remove - testing having errors in claims
|
||||
// this.insertedClaims.pop();
|
||||
|
@ -233,6 +247,17 @@ export class ClaimInsertComponent {
|
|||
this.errors.push(error);
|
||||
}
|
||||
this.afterclaimsInsertion();
|
||||
|
||||
*/
|
||||
console.log(data)
|
||||
this.claims2Insert = claims.length;
|
||||
this.claimsJob = data.data;
|
||||
let timerSubscription = timer(0, 10000).pipe(
|
||||
map(() => {
|
||||
this.getStatus(); // load data contains the http request
|
||||
})
|
||||
).subscribe();
|
||||
this.subscriptions.push(timerSubscription);
|
||||
},
|
||||
err => {
|
||||
err = err && err.error?err.error:err;
|
||||
|
@ -517,8 +542,34 @@ export class ClaimInsertComponent {
|
|||
}
|
||||
if(this.defaultColors){
|
||||
buttonClass+=" linksbaskettitles uk-padding-small ";
|
||||
}
|
||||
}
|
||||
return buttonClass + "uk-text-center ";
|
||||
}
|
||||
|
||||
getStatus(){
|
||||
|
||||
console.log("TODO status fetch")
|
||||
this.subscriptions.push(this.claimService.getStatus(this.claimsJob.id, this.properties.claimsAPIURL).subscribe(data => {
|
||||
console.log(data);
|
||||
this.claimsJob = data.data;
|
||||
if(this.claimsJob.status == "COMPLETE" || data.data.status == "ERROR"){
|
||||
this.insertedClaims = this.claimsJob.insertedIds;
|
||||
this.errorInClaims = this.claimsJob.errorInClaims;
|
||||
|
||||
if (this.claims2Insert != this.insertedClaims.length) {
|
||||
let error: ClaimsErrorMessage = new ClaimsErrorMessage();
|
||||
error.type = "claimServiceFail2Insert";
|
||||
error.inserted = this.insertedClaims.length;
|
||||
error.failed = this.errorInClaims.length;
|
||||
this.createErrorMessagesPerEntity((this.insertedClaims.length == 0));
|
||||
this.errors.push(error);
|
||||
}
|
||||
this.afterclaimsInsertion();
|
||||
|
||||
|
||||
}
|
||||
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue