enable loading while upload bulk records | show first draft of error report in case insert fail | add favicon | small bug fixes

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@47042 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2017-05-03 12:39:40 +00:00
parent bf6c47a309
commit e7f4859e84
8 changed files with 52 additions and 99 deletions

View File

@ -21,7 +21,7 @@
<div *ngIf="resultsNum>0" class="">
<span > Show
<select *ngIf="resultsNum>10" [(ngModel)]="size" name="select_size" >
<select *ngIf="resultsNum>10" [(ngModel)]="size" name="select_size" (ngModelChange)="changeSize(size)" >
<option *ngFor="let size of sizes" [value]="size">{{size}}</option>
</select>
</span>
@ -83,8 +83,7 @@
<td>{{claim.date}}</td>
</tr>
</tbody>
</table>
</table>
<modal-alert (alertOutput)="confirmClose($event)">
</modal-alert>
<modal-loading [message]= "'Please wait...'"></modal-loading>

View File

@ -165,9 +165,7 @@ export class DisplayClaimsComponent {
}
}
goToClaim(claimId: number){
this._router.navigate( ['Claim', { id: claimId}] );
}
goTo(page:number = 1){
this.page = page;
@ -205,8 +203,7 @@ export class DisplayClaimsComponent {
return params;
}
changeSize(size: number ){
this.size = size;
this.goTo();
this.goTo();
}
clearFilters(){
@ -219,6 +216,7 @@ export class DisplayClaimsComponent {
this.entityTypes = [];
this.goTo();
}
changeOrderby(sortby:string){
if(sortby==this.sortby){
this.descending = !this.descending;

View File

@ -121,7 +121,7 @@ export class ClaimsService {
let options = new RequestOptions({ headers: headers });
return this.http.post(url, body, options)
.map(res => res.json())
.do(request => console.info("Insert Response:"+request.status) )
.do(request => console.info("Insert Response:"+request) )
.catch(this.handleError);
}

View File

@ -32,7 +32,7 @@ import {Dates, DOI} from '../../../utils/string-utils.class';
</div>
<div *ngIf="errorMessage.length > 0 " class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
<modal-loading [message]= "'Please wait...'"></modal-loading>
<modal-loading [message]= "'Uploading, reading and fetching results from your document. Please give us a moment..'"></modal-loading>
</form>
@ -95,6 +95,8 @@ export class BulkClaimComponent {
this.errorMessage = "There is no selected file to upload.";
return ;
}
this.loading.open();
this.makeFileRequest("http://localhost:8000/upload", [], this.filesToUpload).then((result) => {
var rows = (result as any).split('\n'); // I have used space, you can use any thing.
var i = 0;
@ -131,7 +133,7 @@ export class BulkClaimComponent {
}, (error) => {
this.enableUpload = true;
console.log(error);
// this.loading.close();
this.loading.close();
this.errorMessage = "An error occured while uploading...";
});
}
@ -208,6 +210,8 @@ export class BulkClaimComponent {
if(this.allIds.length == this.foundIds.length+this.notFoundIds.length+ this.duplicateIds.length+this.noValidIds.length ){
this.showReport = true;
this.enableUpload = true;
this.loading.close();
}
}

View File

@ -13,9 +13,8 @@ import {ErrorCodes} from '../../../login/utils/guardHelper.class';
@Component({
selector: 'claim-insert',
template: `
<div *ngIf="errorMessage.length > 0">
<div class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
<div class="uk-alert uk-alert-danger" role="alert" [innerHTML]="errorMessage"></div>
</div>
<div *ngIf="warningMessage.length > 0">
<div class="uk-alert uk-alert-warning" role="alert">{{warningMessage}}</div>
@ -52,7 +51,6 @@ export class ClaimInsertComponent {
public warningMessage = "";
public claimsTODO:number = 0;
public claims:number = 0;
public errorclaims:number = 0;
private servicesRespond:number = 0;
private insertedClaims=[];
@ -122,58 +120,41 @@ private insert(){
}
}
// var created =[];
// var failed =[];
console.info("\n\ndirectclaims: "+directclaims.length+"\n\n");
// for(var i = 0; i<directclaims.length; i++){
// // console.info("\n\ntry to direct insert: "+JSON.stringify(directclaims[i])+"\n\n");
//
// this.directIndexClaimService.directClaim(directclaims[i]).subscribe(
// data => {
// console.log("AAA" + data);
// created.push(directclaims[i].originalId)
// },
// err => {
// console.log(err);
// failed.push(directclaims[i].originalId)
// if(failed.length + created.length == directclaims.length){
// console.log("failed:"+failed);
// console.log("created:"+created);
//
// }
// }
// );
// }
this.claimService.insertDirectRecords(directclaims,token).subscribe(
data => {
this.insertedRecords = data.insertedIds;
this.errorInRecords = data.insertedIds;
this.errorInRecords = data.errorInClaims;
this.afterclaimsInsertion();
},
err => {
console.log(err);
this.insertedRecords = err.insertedIds;
this.errorInRecords = err.insertedIds;
this.errorsInClaimsInsertion();
err=err.json();
if(err.insertedIds && err.insertedIds.length >0){
this.insertedRecords = err.insertedIds;
}
if(err.errorInClaims && err.errorInClaims.length >0){
this.errorInRecords = err.errorInClaims;
}
this.afterclaimsInsertion();
}
);
console.info("try to insert "+claims.length+" claims");
this.claimService.insertBulkClaims(claims,token).subscribe(
data => {
this.insertedClaims = data.insertedIds;
this.errorclaims = data.insertedIds;
this.insertedClaims = data.insertedIds;
this.errorInClaims = data.errorInClaims;
this.afterclaimsInsertion();
},
err => {
console.log(err);
this.insertedClaims = err.insertedIds;
this.errorclaims = err.insertedIds;
this.errorsInClaimsInsertion();
err=err.json();
if(err.insertedIds && err.insertedIds.length >0){
this.insertedClaims = err.insertedIds;
}
if(err.errorInClaims && err.errorInClaims.length >0){
this.errorInClaims = err.errorInClaims;
}
this.afterclaimsInsertion();
}
);
}
@ -231,16 +212,15 @@ private validateDates(){
return true;
}
private afterclaimsInsertion(){
this.servicesRespond++;
if(this.servicesRespond == 2){
this.loading.close();
this.claiming = false;
if(this.errorInClaims.length == 0 && this.insertedClaims.length > 0 && this.errorInRecords.length == 0){
// if(this.inline){
// this.show = "end";
// }else{
this._router.navigate( ['/myclaims'] );
// }
this.showChange.emit({
value: this.show
});
@ -250,30 +230,37 @@ private afterclaimsInsertion(){
}
}
private errorsInClaimsInsertion(){
this.errorMessage = "An Error Occured.";
this.errorMessage = "";
this.loading.close();
this.error = true;
this.claiming = false;
this.showButton = true;
var text =""
console.log("Errors: this.errorInRecords.length: "+this.errorInRecords.length+" - this.errorInClaims.length: "+this.errorInClaims.length);
if(this.errorInRecords.length>0){
text+="The following records couldn't automatically inserted to the Openaire Info space: <br>";
text+="<div>The following records couldn't automatically inserted to the Openaire Info space: <ul>";
for(var i=0; i< this.errorInRecords.length ; i++){
for(var k=0; k< this.results.length ; k++){
if(this.results[k].id == this.errorInRecords[i]){
text+=""+this.results[i].title+" url:"+this.results[i].url+" from "+this.results[i].source;
text+="<li>"+this.results[i].title+" from "+this.results[i].source+"</li>";
}
}
}
text+="</ul></div>";
}
if(this.errorsInClaimsInsertion.length > 0){
text+="The following couldn't be saved: <br>";
for(var i=0; i< this.errorsInClaimsInsertion.length ; i++){
text+="The following couldn't be saved: <br>";
if(this.errorInClaims.length > 0){
text+="<div>The following links couldn't be saved: <ul>";
for(var i=0; i< this.errorInClaims.length ; i++){
// var claim = { claimedBy : user, sourceId : context.concept.id, sourceType : "context", sourceCollectedFrom:"openaire", sourceAccessRights:"OPEN", sourceEmbargoEndDate:"no", targetId : result.id , targetType : result.type, targetCollectedFrom: result.source, targetAccessRights:result.accessRights, targetEmbargoEndDate: (result.embargoEndDate == null?"":result.embargoEndDate)};
text+="<li>"+this.errorInClaims[i].sourceType+": "+this.errorInClaims[i].sourceId +"(from"+this.errorInClaims[i].sourceCollectedFrom+") link to "+this.errorInClaims[i].targetType+": "+this.errorInClaims[i].targetId +"(from"+this.errorInClaims[i].targetCollectedFrom+") </li>";
}
text+="</ul></div>";
}
this.errorMessage+="<div>An error occured:</div>"+text;
console.log(text);
// if(this.inline){
// this.show = "error";
// this.showChange.emit({
@ -359,43 +346,7 @@ createDirectClaim(result, projects, contexts){
console.log("\nJSON:\n"+json);
return entity;
/*
{
"originalId": "ORIG_ID_12345",
"title": "TEST TITLE",
"authors": [
"Michele Artini",
"Claudio Atzori",
"Alessia Bardi"
],
"publisher": "Test publisher",
"description": "DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION DESCRIPTION",
"language": "ita",
"pids": [
{
"type": "doi",
"value": "10.000/xyz-123"
},
{
"type": "oai",
"value": "oai:1234"
}
],
"licenseCode": "OPEN",
"resourceType": "0001",
"url": "http://test.it/xyz",
"collectedFromId": "opendoar____::2659",
"hostedById": "opendoar____::2367",
"linksToProjects": [
"info:eu-repo/grantAgreement/EC/FP7/283595/EU//OpenAIREplus",
"info:eu-repo/grantAgreement/EC/FP7/244909/EU/Making Capabilities Work/WorkAble"
],
"contexts": [
"egi::classification::natsc::math::pure",
"egi::classification::natsc::math::stats"
]
}
*/
}
confirmOpen(){

View File

@ -34,7 +34,7 @@ export class OpenaireProperties {
private static loginAPIURL = "http://mpagasas.di.uoa.gr:8080/uoa-user-management-1.0.0-SNAPSHOT/api/users/authenticates";
// public claimsAPIURL = "http://rudie.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/"
private static claimsAPIURL = "https://scoobydoo.di.uoa.gr:8443/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/";
private static claimsAPIURL = "http://scoobydoo.di.uoa.gr:8080/dnet-openaire-connector-service-1.0.0-SNAPSHOT/rest/claimsService/";
// private static searchAPIURL = " https://beta.services.openaire.eu/search/v2/api/";
// private searchAPIURL = "http://beta.services.openaire.eu/search/v2.0/api/";

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

View File

@ -11,6 +11,7 @@
<meta property="og:description" content="open access, research, scientific publication, European Commission, EC, FP7, ERC, Horizon 2020, H2020, search, projects ">
<meta property="og:title" content="Search OpenAIRE">
<meta name="og:image" content="assets/newlogo.png">
<link href="assets/favicon.ico" rel="shortcut icon" type="image/vnd.microsoft.icon" />
<title>Search OpenAIRE</title>
<script src="assets/jquery/jquery.min.js" type="text/javascript"></script>
<!--uikit-->