From 1f942d09ddb5ff1427c435c3dc591460c2056aa0 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Tue, 27 Aug 2019 13:19:58 +0000 Subject: [PATCH] [Library|Trunk] Linking: rename attribute title to pageTitle or sectionTitle to avoid showing default html tooltip use default or communty colors for the linking banner Search datacite: fix bug when searching with DOIs enable searching with more than one DOI git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56908 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../claimResultSearchForm.component.ts | 51 +++++++------------ .../service/searchDatacite.service.ts | 7 +-- .../directLinking.component.html | 6 +-- .../linking/bulkClaim/bulkClaim.component.ts | 6 +-- .../insertClaim/insertClaim.component.ts | 28 +++++++++- claims/linking/linkingGeneric.component.html | 6 ++- claims/linking/linkingGeneric.component.ts | 6 +-- .../selected/metadataPreview.component.html | 10 ++-- .../selected/metadataPreview.component.ts | 2 +- .../selected/selectedResults.component.ts | 2 +- 10 files changed, 68 insertions(+), 56 deletions(-) diff --git a/claims/claim-utils/claimResultSearchForm.component.ts b/claims/claim-utils/claimResultSearchForm.component.ts index 90953645..86a2c207 100644 --- a/claims/claim-utils/claimResultSearchForm.component.ts +++ b/claims/claim-utils/claimResultSearchForm.component.ts @@ -12,7 +12,8 @@ import {ClaimEntity, ClaimResult} from './claimHelper.class'; import {DOI, StringUtils} from '../../utils/string-utils.class'; import {EnvProperties} from '../../utils/properties/env-properties'; import {Filter, Value} from "../../searchPages/searchUtils/searchHelperClasses.class"; - +import {Observable, forkJoin} from "rxjs"; +import 'rxjs/add/observable/forkJoin' @Component({ selector: 'claim-result-search-form', templateUrl: 'claimResultSearchForm.component.html', @@ -652,11 +653,22 @@ export class ClaimResultSearchFormComponent { private getDataciteResults(term: string, size: number, page: number) { this.dataciteStatus = this.errorCodes.LOADING; if (this.DOIs.length > 0) { - this._searchDataciteService.getDataciteResultByDOI(term, this.properties, true).subscribe( + let doiObservables: Array> = new Array(); + for(let doi of this.DOIs){ + let ob = this._searchDataciteService.getDataciteResultByDOI(doi, this.properties, true); + doiObservables.push(ob); + + } + Observable.forkJoin(doiObservables).subscribe( data => { - this.dataciteResults = data[1]; + //if DOI not found or an error occured the result will be null -- remove null values + for(let result of data){ + if(result){ + this.dataciteResults.push(result) + } + } this.datacitePage = page; - this.dataciteResultsNum = data[0]; + this.dataciteResultsNum = this.dataciteResults.length; this.dataciteStatus = this.errorCodes.DONE; if (this.dataciteResultsNum == 0) { this._searchDataciteService.searchDataciteResults(term, size, page, this.properties, true).subscribe( @@ -678,36 +690,9 @@ export class ClaimResultSearchFormComponent { ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err); }); } + } - }, - err => { - if (err.status == "404") { - this._searchDataciteService.searchDataciteResults(term, size, page, this.properties, true).subscribe( - data => { - this.dataciteResults = data[1]; - this.datacitePage = page; - this.dataciteResultsNum = data[0]; - this.dataciteStatus = this.errorCodes.DONE; - if (this.dataciteResultsNum == 0) { - this.dataciteStatus = this.errorCodes.NONE; - } - - }, - err => { - - this.dataciteStatus = this.errorCodes.ERROR; - - console.log(err); - ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err); - }); - } else { - this.dataciteStatus = this.errorCodes.ERROR; - //console.log(err); - ClaimResultSearchFormComponent.handleError("Error getting datacite results for term: " + term, err); - } - - - }); + ); } else { diff --git a/claims/claim-utils/service/searchDatacite.service.ts b/claims/claim-utils/service/searchDatacite.service.ts index bb3ff61a..81c7f24a 100644 --- a/claims/claim-utils/service/searchDatacite.service.ts +++ b/claims/claim-utils/service/searchDatacite.service.ts @@ -1,11 +1,12 @@ -import {throwError as observableThrowError} from 'rxjs'; +import {Observable, throwError as observableThrowError} from 'rxjs'; import {Injectable} from '@angular/core'; import {Response} from '@angular/http'; import {HttpClient} from '@angular/common/http'; import {EnvProperties} from '../../../utils/properties/env-properties'; import {ClaimEntity, ClaimResult} from '../claimHelper.class'; import {map} from "rxjs/operators"; - +import 'rxjs/add/operator/catch'; +import 'rxjs/add/observable/of'; @Injectable() export class SearchDataciteService { constructor(private http: HttpClient ) {} @@ -25,7 +26,7 @@ export class SearchDataciteService { let key = url; return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url) - .pipe(map(request => [1, (parse ? SearchDataciteService.parse(request["data"]) : request)])); + .pipe(map(request => (parse ? SearchDataciteService.parse([request["data"]])[0] : request))).catch(e => Observable.of(null)); } diff --git a/claims/directLinking/directLinking.component.html b/claims/directLinking/directLinking.component.html index 8ed083e7..4d2a17d9 100644 --- a/claims/directLinking/directLinking.component.html +++ b/claims/directLinking/directLinking.component.html @@ -1,14 +1,14 @@ + [piwikSiteId]="piwikSiteId" pageTitle="Direct Linking"> -
+
- Link + Link to
diff --git a/claims/linking/bulkClaim/bulkClaim.component.ts b/claims/linking/bulkClaim/bulkClaim.component.ts index 389d9eee..e280a42f 100644 --- a/claims/linking/bulkClaim/bulkClaim.component.ts +++ b/claims/linking/bulkClaim/bulkClaim.component.ts @@ -271,11 +271,9 @@ export class BulkClaimComponent { searchInDatacite(id: string, accessMode: string, date: string, row: number) { this._searchDataciteService.getDataciteResultByDOI(id, this.properties, true).subscribe( - items => { - - if (items[1].length > 0) { - var result = items[1][0]; + result => { + if (result) { this.foundIds.push(id); result.result.accessRights = accessMode; result.result.embargoEndDate = date; diff --git a/claims/linking/insertClaim/insertClaim.component.ts b/claims/linking/insertClaim/insertClaim.component.ts index 3b07981b..fa266018 100644 --- a/claims/linking/insertClaim/insertClaim.component.ts +++ b/claims/linking/insertClaim/insertClaim.component.ts @@ -37,8 +37,8 @@ import {
CONFIRM LINKING - + [class]="getButtonClass()">CONFIRM LINKING + @@ -71,6 +71,7 @@ export class ClaimInsertComponent { @ViewChild(AlertModal) alert; @Input() errors: ClaimsErrorMessage[]; @Output() insertFinished = new EventEmitter(); + @Input() defaultColors:boolean; public claiming = false; @@ -491,4 +492,27 @@ export class ClaimInsertComponent { console.error("Insert Claim (component): " + message, error); } + + getButtonClass(){ + // [class]="(((sources.length>0||inlineEntity) && results.length > 0 && (!claiming && errors.length == 0))?' ':'uk-disabled')+ ' uk-button uk-button-large uk-text-center'+((defaultColors)?'':'')">CONFIRM LINKING + // } + // [class]="(((sources.length>0||inlineEntity) && results.length > 0 && (!claiming && errors.length == 0))?'linksbaskettitlesPortalColor ':'uk-disabled')+ ' linksbaskettitles uk-padding-small uk-text-center'">CONFIRM LINKING + // + let buttonClass= ""; + if((this.sources.length>0||this.inlineEntity) && this.results.length > 0 && (!this.claiming && this.errors.length == 0)){ + if(this.defaultColors){ + buttonClass+=" linksbaskettitlesPortalColor "; + } + }else{ + buttonClass+=" uk-disabled "; + + } + if(this.defaultColors){ + buttonClass+=" linksbaskettitles uk-padding-small "; + }else{ + buttonClass+=" uk-button uk-button-large "; + } + return buttonClass + "uk-text-center "; + } } + diff --git a/claims/linking/linkingGeneric.component.html b/claims/linking/linkingGeneric.component.html index f7cc9d32..66b7d38c 100644 --- a/claims/linking/linkingGeneric.component.html +++ b/claims/linking/linkingGeneric.component.html @@ -1,7 +1,9 @@ + [showOptions]="showOptions" [properties]=properties [pageContents]="pageContents" + [defaultColors]="(communityId?false:true)" +>
@@ -213,7 +215,7 @@ class="uk-alert uk-alert-warning uk-text-center"> Basket reached the size limit. No more entities can be added.
-
diff --git a/claims/linking/linkingGeneric.component.ts b/claims/linking/linkingGeneric.component.ts index 1b9615dc..4bf52dac 100644 --- a/claims/linking/linkingGeneric.component.ts +++ b/claims/linking/linkingGeneric.component.ts @@ -21,7 +21,7 @@ declare var UIkit:any; }) export class LinkingGenericComponent { @Input() piwikSiteId = null; - @Input() title: string = null; + @Input() pageTitle: string = null; piwiksub:any; @Input() communityId:string= null; @@ -64,14 +64,14 @@ export class LinkingGenericComponent { this.url = data.envSpecific.baseLink+this._router.url; var description = "Openaire, linking, claim, publication, research data, software, other research product, project, community"; - this.updateTitle(this.title); + this.updateTitle(this.pageTitle); this.updateDescription(description); this.updateUrl(this.url); this.seoService.createLinkForCanonicalURL(this.url, false); if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){ - this.piwiksub = this._piwikService.trackView(this.properties, this.title, this.piwikSiteId).subscribe(); + this.piwiksub = this._piwikService.trackView(this.properties, this.pageTitle, this.piwikSiteId).subscribe(); } this.helper.getPageHelpContents(this._router.url, this.properties, this.communityId).subscribe(contents => { diff --git a/claims/linking/selected/metadataPreview.component.html b/claims/linking/selected/metadataPreview.component.html index 0a2bbbfd..38ea2ae2 100644 --- a/claims/linking/selected/metadataPreview.component.html +++ b/claims/linking/selected/metadataPreview.component.html @@ -1,8 +1,9 @@ -
-
+
+
-
+ + class=" " [errors]="errors" (insertFinished)="runValidation(false); updateLocalStorage();" + [defaultColors]="defaultColors">
diff --git a/claims/linking/selected/metadataPreview.component.ts b/claims/linking/selected/metadataPreview.component.ts index caeb681d..050b9eb3 100644 --- a/claims/linking/selected/metadataPreview.component.ts +++ b/claims/linking/selected/metadataPreview.component.ts @@ -24,7 +24,7 @@ export class MetadataPreviewComponent { @Input() showOptions:ShowOptions; @Input() public properties: EnvProperties; @Input() pageContents; - + @Input() defaultColors:boolean=true; @ViewChild(AlertModal) alertApplyAll; @Input() localStoragePrefix: string = ""; errors:ClaimsErrorMessage[] = []; diff --git a/claims/linking/selected/selectedResults.component.ts b/claims/linking/selected/selectedResults.component.ts index 730175b6..25feb408 100644 --- a/claims/linking/selected/selectedResults.component.ts +++ b/claims/linking/selected/selectedResults.component.ts @@ -8,7 +8,7 @@ import {ClaimEntity} from '../../claim-utils/claimHelper.class'; }) export class ClaimSelectedResultsComponent { @Input() results: ClaimEntity[]; - @Input() title: string = "Research Results"; + @Input() sectionTitle: string = "Research Results"; @Input() localStoragePrefix: string = ""; @Input() enableRemove:boolean = true;