Bulk claim:

add filetype ckecks
	correct messages
	add more checks when the file has no valid format

Login: add a check for empty cookie



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@52501 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2018-06-15 12:58:58 +00:00
parent d5b745fc65
commit 31614c2cb5
4 changed files with 27 additions and 5 deletions

View File

@ -24,7 +24,7 @@ import{EnvProperties} from '../../../utils/properties/env-properties';
<div *ngIf="showReport" uk-alert class="uk-alert uk-alert-primary" role="alert" >
<a class="uk-alert-close" uk-close></a>
<div>Uploaded file contains {{allIds.length}} rows. {{foundIds.length}} results were sucefully fetched from CrossRef and Datacite.</div>
<div>Uploaded file contains {{allIds.length}} rows. <span *ngIf="allIds.length > 0">{{foundIds.length}} results were succefully fetched from CrossRef and Datacite.</span></div>
<div *ngIf ="duplicateIds.length > 0" >{{duplicateIds.length | number}} duplicate DOIs.</div>
<div *ngIf = "notFoundIds.length > 0" >Couldn't be found:
<ul class="">
@ -36,11 +36,11 @@ import{EnvProperties} from '../../../utils/properties/env-properties';
<li *ngFor="let id of noValidIds">"{{id}}"</li>
</ul>
</div>
<div *ngIf = "allIds.length == 0 || foundIds.length == 0" > Please make sure you are using the right format for the csv file... </div>
<div *ngIf = "allIds.length == 0 || foundIds.length == 0" > Please make sure that the uploaded file, is a csv file with the proper format. </div>
</div>
<div *ngIf="errorMessage.length > 0 " class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
<modal-loading [message]= "'Uploading, reading and fetching results from your document. Please give us a moment..'"></modal-loading>
<modal-loading [message]= "'Uploading, reading your documet and fetching results. Please give us a moment..'"></modal-loading>
</div>
<helper div="link-result-bulk" ></helper>
</div>
@ -86,12 +86,19 @@ export class BulkClaimComponent {
if(this.filesToUpload.length == 0){
this.errorMessage = "There is no selected file to upload.";
return ;
}else{
if(this.filesToUpload[0].name.indexOf(".csv") == -1 || this.filesToUpload[0].type != "text/csv"){
this.errorMessage = "No valid file type. The required type is CSV";
return ;
}
}
this.loading.open();
this.makeFileRequest(this.properties.uploadService, [], this.filesToUpload).then((result) => {
var rows = (result as any).split('\n'); // I have used space, you can use any thing.
console.log("Rows:" + rows.length);
var i = 0;
var invalid_rows = 0;
this.duplicateIds = [];
this.allIds = [];
this.foundIds = [];
@ -119,9 +126,14 @@ export class BulkClaimComponent {
}else{
this.noValidIds.push(id);
}
}else{
invalid_rows++;
}
}
if(rows.length == 0 || rows.length == invalid_rows || rows.length == (invalid_rows + this.noValidIds.length)){
this.endOfFetching();
}
}, (error) => {
this.enableUpload = true;

View File

@ -185,6 +185,16 @@ private isertBulkClaims(claims){
if(err.errorInClaims && err.errorInClaims.length >0){
this.errorInClaims = err.errorInClaims;
}
if(this.projects != null){
localStorage.setItem("projects", JSON.stringify(this.projects));
}
localStorage.setItem("contexts", JSON.stringify(this.contexts));
if(this.results != null){
localStorage.setItem("results", JSON.stringify(this.results));
}
if(this.inlineEntity != null){
localStorage.setItem("inlineEntity", JSON.stringify(this.inlineEntity));
}
this.afterclaimsInsertion();
}
);

View File

@ -19,7 +19,7 @@ export class UserComponent {
public user: User;
public loggedIn: boolean = false;
public server: boolean = true;
public errorMessage: string;
public errorMessage: string = "";
public username: string = "";
public password: string = "";
private sub:any;private sublogin:any;

View File

@ -38,7 +38,7 @@ export class Session{
}
public static getUserFromCookie():User{
var cookie= COOKIE.getCookie(COOKIE.cookieName_u);
if(cookie != null){
if(cookie != null && cookie!=""){
var user:User = this.parseUserInfo(cookie);
if(user && user.email){
return user;