Loading messages added in Deposit Pages

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-portal/trunk@44614 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2016-11-22 12:55:40 +00:00
parent 206bc1e73b
commit 6a95445031
4 changed files with 57 additions and 12 deletions

View File

@ -1,7 +1,7 @@
import {Component, Input} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import { Router } from '@angular/router';
import {OpenaireProperties} from '../utils/properties/openaireProperties';
import {OpenaireProperties, ErrorCodes} from '../utils/properties/openaireProperties';
import {SearchOrganizationsService} from '../services/searchOrganizations.service';
@ -45,7 +45,22 @@ import {SearchOrganizationsService} from '../services/searchOrganizations.servic
</div>
<div>
<ul class="list-group" >
<li class="list-group-item" *ngFor=" let item of organizations">
<li class="list-group-item" *ngIf="status == errorCodes.LOADING">
<div class="alert alert-info" role="alert">
Loading...
</div>
</li>
<li class="list-group-item" *ngIf="status == errorCodes.NONE">
<div class="alert alert-warning" role="alert">
No organizations found
</div>
</li>
<li class="list-group-item" *ngIf="status == errorCodes.ERROR">
<div class="alert alert-danger" role="alert">
Sorry! Organizations are not currently available
</div>
</li>
<li class="list-group-item" *ngFor=" let item of organizations">
<a style="cursor:pointer;" (click)="organizationSelected(item.id)">{{item.name}}</a>
</li>
</ul>
@ -68,6 +83,9 @@ export class DepositComponent {
@Input() compatibility: string = '';
@Input() requestFor: string = "Publications";
private status: number;
private errorCodes:ErrorCodes = new ErrorCodes();
constructor (private _router: Router,
private _searchOrganizationsService: SearchOrganizationsService) {
console.info("constructor deposit");
@ -82,12 +100,23 @@ export class DepositComponent {
keywordChanged() {
console.info("keywordChanged: "+this.keyword);
this.status = this.errorCodes.LOADING;
this.organizations = [];
this._searchOrganizationsService.searchOrganizationsForDeposit(this.keyword, this.compatibility, 1, 10).subscribe(
data => {
this.organizations = data;
this.status = this.errorCodes.DONE;
if(this.organizations.length == 0) {
this.status = this.errorCodes.NONE;
}
},
err => {
console.error(err);
this.status = this.errorCodes.ERROR;
console.info("error");
}
);
}

View File

@ -17,6 +17,11 @@ import {OrganizationService} from '../services/organization.service';
<h2>Deposit {{requestFor}}</h2>
</div>
<div *ngIf="status == errorCodes.LOADING || (status == errorCodes.LOADING && searchDataprovidersComponent.status == errorCodes.LOADING)"
class="alert alert-info" role="alert">
Loading...
</div>
<div *ngIf="searchDataprovidersComponent.totalResults > 0">
<h2 *ngIf="organization != undefined">
<span>Data providers for institution: </span>
@ -35,7 +40,8 @@ import {OrganizationService} from '../services/organization.service';
<search-result [(results)]="searchDataprovidersComponent.results" [(status)]= "searchDataprovidersComponent.status"></search-result>
</div>
<div *ngIf="searchDataprovidersComponent.totalResults == 0" class = "alert alert-warning">
<div *ngIf="(searchDataprovidersComponent.status == errorCodes.NONE && status == errorCodes.DONE)
|| status == errorCodes.NONE" class = "alert alert-warning">
<div *ngIf="organization != undefined">
No data providers found
<span *ngIf="organization != undefined">
@ -63,6 +69,9 @@ export class DepositResultComponent {
private organization: {"name": string, "url": string};
private organizationId: string;
private status: number;
private errorCodes:ErrorCodes = new ErrorCodes();
sub: any;
subDataproviders: any;
@ -79,6 +88,9 @@ export class DepositResultComponent {
this.zenodo = OpenaireProperties.getZenodoURL();
this.searchDataprovidersComponent = new SearchDataprovidersComponent(this.route, this._searchDataprovidersService);
this.status = this.errorCodes.LOADING;
console.info("loading");
}
ngOnInit() {
@ -115,17 +127,22 @@ export class DepositResultComponent {
this._organizationService.getOrganizationInfo(this.organizationId).subscribe(
data => {
this.organization = data.title;
this.status = this.errorCodes.DONE;
console.info("done");
this.subDataproviders = this.route.queryParams.subscribe(params => {
this.searchDataproviders();
});
//var errorCodes:ErrorCodes = new ErrorCodes();
//this.status = errorCodes.DONE;
},
err => {
console.error(err)
console.info("error");
//var errorCodes:ErrorCodes = new ErrorCodes();
//this.status = errorCodes.ERROR;
//console.error(err)
if(err.status == '404') {
this.status = this.errorCodes.NONE;
console.info("none");
} else {
this.status = this.errorCodes.ERROR;
console.info("error");
}
}
);
}

View File

@ -119,7 +119,8 @@ console.info("PAGE init = "+this.searchUtils.page);
}
public getResultsForDeposit(id:string, type:string, page: number, size: number){
//var errorCodes:ErrorCodes = new ErrorCodes();
//this.status = errorCodes.LOADING;
if(id != "") {
this._searchDataprovidersService.searchDataprovidersForDeposit(id,type, page, size).subscribe(

View File

@ -18,10 +18,8 @@ export class OrganizationService {
return this.http.get(url)
.map(res => <any> res.json())
.do(res => console.info(res['result']['metadata']['oaf:entity']['oaf:organization']))
.map(res => res['result']['metadata']['oaf:entity']['oaf:organization'])
.map(res => [res, res['rels']['rel']])
//.do(res => console.info(res))
.map(res => this.parseOrganizationInfo(res));
}