[Trunk | Library]: Bug fix in deposit pages: Get information for zenodo communities in connect components.

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@56570 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-07-16 11:24:13 +00:00
parent 32e2077319
commit f8f821c393
6 changed files with 44 additions and 173 deletions

View File

@ -1,19 +1,7 @@
import {Component, Input} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
import {ErrorCodes} from '../utils/properties/errorCodes';
import{EnvProperties} from '../utils/properties/env-properties';
import {RouterHelper} from '../utils/routerHelper.class';
import {ZenodoInformationClass} from './utils/zenodoInformation.class';
import {ZenodoCommunitiesService} from "../connect/zenodoCommunities/zenodo-communities.service";
import {CommunityService} from "../connect/community/community.service";
import {SearchZenodoCommunitiesService} from "../connect/zenodoCommunities/searchZenodoCommunities.service";
import {FetchZenodoInformation} from "../../deposit/utils/fetchZenodoInformation.class";
import {ConnectHelper} from "../connect/connectHelper";
import {StringUtils} from "../utils/string-utils.class";
import {SearchFields} from "../utils/properties/searchFields";
import {EnvProperties} from "../utils/properties/env-properties";
import {ActivatedRoute} from "@angular/router";
@Component({
selector: 'deposit-first-page',
@ -153,95 +141,30 @@ import {SearchFields} from "../utils/properties/searchFields";
})
export class DepositFirstPageComponent {
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
fetchZenodoInformation: FetchZenodoInformation;
@Input() compatibility: string = '';
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
@Input() piwikSiteId = null;
// Type of entity: Publication or Research Data
@Input() requestFor: string = "Publications";
public organization: {"name": string, "url": string};
public organizationId: string = "";
// Id of the new selected organization to be searched
public selectedId: string = "";
@Input() subjectResults: boolean = false;
@Input() subject: string = "";
public status: number;
public warningMessage: string = "";
public parameterNames:string[] =[];
public parameterValues:string[] =[];
public routerHelper:RouterHelper = new RouterHelper();
public errorCodes:ErrorCodes = new ErrorCodes();
sub: any; piwiksub: any;
properties:EnvProperties;
url=null;
public keyword: string;
public depositRoute = "/search-deposit";
public searchPlaceHolder = "Search for repositories by title, country, organization, subject...";
properties:EnvProperties;
constructor (private _router: Router,
private route: ActivatedRoute,
private _zenodoCommunitieService: ZenodoCommunitiesService,
private _communityService: CommunityService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
this.fetchZenodoInformation = new FetchZenodoInformation(this._zenodoCommunitieService, this._searchZenodoCommunitiesService);
}
constructor (private route: ActivatedRoute) {}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => {
let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
if (!communityId) {
communityId = params['communityId'];
}
if (communityId) {
if (communityId != null && communityId != '') {
this._communityService.getCommunity(this.properties, this.properties.communityAPI + communityId).subscribe(
community => {
let masterZenodoCommunityId = community.zenodoCommunity;
if (masterZenodoCommunityId) {
this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage+communityId;
//this.fetchZenodoInformation.getZenodoCommunityNameAndUrlById(masterZenodoCommunityId, this.properties, this.zenodoInformation);
} else {
this.zenodoInformation.url = this.properties.zenodo;
this.zenodoInformation.name = "Zenodo";
}
//this.fetchZenodoInformation.searchNumberOfZCommunities(communityId, this.properties, this.zenodoInformation);
},
error => {
this.handleError("Error getting community with id: " + communityId, error);
}
);
}
}
if (!this.zenodoInformation.shareInZenodoUrl) {
this.zenodoInformation.url = this.properties.zenodo;
}
if (!this.zenodoInformation.name) {
this.zenodoInformation.name = "Zenodo";
}
});
if (!this.zenodoInformation) {
this.zenodoInformation = new ZenodoInformationClass();
}
if (!this.zenodoInformation.shareInZenodoUrl) {
this.zenodoInformation.url = this.properties.zenodo;
}
if (!this.zenodoInformation.name) {
this.zenodoInformation.name = "Zenodo";
}
});
}
ngOnDestroy() {}
private handleError(message: string, error) {
console.error("Deposit Result Page: "+message, error);
}
}

View File

@ -7,14 +7,9 @@ import { RouterModule } from '@angular/router';
import {PiwikServiceModule} from '../utils/piwik/piwikService.module';
import {HelperModule} from '../utils/helper/helper.module';
import {IFrameModule} from '../utils/iframe.module';
import {Schema2jsonldModule} from '../sharedComponents/schema2jsonld/schema2jsonld.module';
import { SEOServiceModule } from '../sharedComponents/SEO/SEOService.module';
import {DepositFirstPageComponent} from "./depositFirstPage.component";
import {ZenodoCommunitiesService} from "../connect/zenodoCommunities/zenodo-communities.service";
import {CommunityService} from "../connect/community/community.service";
import {SearchZenodoCommunitiesService} from "../connect/zenodoCommunities/searchZenodoCommunities.service";
@NgModule({
imports: [
@ -22,7 +17,7 @@ import {SearchZenodoCommunitiesService} from "../connect/zenodoCommunities/searc
RouterModule,
PiwikServiceModule,
HelperModule,
IFrameModule, Schema2jsonldModule, SEOServiceModule
Schema2jsonldModule, SEOServiceModule
],
declarations: [
DepositFirstPageComponent
@ -30,8 +25,6 @@ import {SearchZenodoCommunitiesService} from "../connect/zenodoCommunities/searc
exports: [
DepositFirstPageComponent
],
providers: [
ZenodoCommunitiesService, CommunityService, SearchZenodoCommunitiesService
]
providers: []
})
export class DepositFirstPageModule { }

View File

@ -8,14 +8,8 @@ import {SearchFields} from '../utils/properties/searchFields';
import {SearchPageComponent } from '../searchPages/searchUtils/searchPage.component';
import {SearchCustomFilter, SearchUtilsClass} from '../searchPages/searchUtils/searchUtils.class';
import {EnvProperties} from '../utils/properties/env-properties';
import {ZenodoInformationClass} from "./utils/zenodoInformation.class";
import {ConnectHelper} from "../connect/connectHelper";
import {PiwikHelper} from "../../utils/piwikHelper";
import {CommunityService} from "../connect/community/community.service";
import {SearchZenodoCommunitiesService} from "../connect/zenodoCommunities/searchZenodoCommunities.service";
import {FetchZenodoInformation} from "../../deposit/utils/fetchZenodoInformation.class";
import {ZenodoCommunitiesService} from "../connect/zenodoCommunities/zenodo-communities.service";
import {StringUtils} from "../utils/string-utils.class";
import {ZenodoInformationClass} from "./utils/zenodoInformation.class";
@Component({
selector: 'search-dataproviders',
@ -44,7 +38,8 @@ import {StringUtils} from "../utils/string-utils.class";
[usedBy]="'deposit'"
[showMoreFilterValuesInline]=true
[filterValuesNum]=4
[lastIndex]=false>
[lastIndex]=false
[zenodoInformation]="zenodoInformation">
</search-page>
`
})
@ -75,6 +70,8 @@ export class SearchDataprovidersToDepositComponent {
@ViewChild (SearchPageComponent) searchPage : SearchPageComponent ;
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService) {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();

View File

@ -2,15 +2,10 @@ import {Component, Input} from '@angular/core';
import {SearchResult} from '../utils/entities/searchResult';
import {ErrorCodes} from '../utils/properties/errorCodes';
import {RouterHelper} from '../utils/routerHelper.class';
import{EnvProperties} from '../utils/properties/env-properties';
import {ZenodoCommunitiesService} from "../connect/zenodoCommunities/zenodo-communities.service";
import {CommunityService} from "../connect/community/community.service";
import {SearchZenodoCommunitiesService} from "../connect/zenodoCommunities/searchZenodoCommunities.service";
import {EnvProperties} from '../utils/properties/env-properties';
import {ZenodoInformationClass} from "./utils/zenodoInformation.class";
import {FetchZenodoInformation} from "../../deposit/utils/fetchZenodoInformation.class";
import {ConnectHelper} from "../connect/connectHelper";
import {PiwikHelper} from "../../utils/piwikHelper";
import {ActivatedRoute} from "@angular/router";
@Component({
selector: 'deposit-result',
templateUrl:'searchResultsInDeposit.component.html'
@ -20,10 +15,6 @@ export class SearchResultsInDepositComponent {
@Input() results: SearchResult[];
@Input() status: number;
@Input() type: string;
@Input() showLoading: boolean = false;
@Input() showSubjects: boolean = false;
@Input() showOrganizations: boolean = true;
@Input() custom_class: string = "search-results";
@Input() properties:EnvProperties;
@ -33,18 +24,11 @@ export class SearchResultsInDepositComponent {
public routerHelper:RouterHelper = new RouterHelper();
public errorMessage: string = "No results found";
public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
fetchZenodoInformation: FetchZenodoInformation;
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
constructor (private route: ActivatedRoute,
private _ΖenodoCommunitieService: ZenodoCommunitiesService,
private _communityService: CommunityService,
private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
this.fetchZenodoInformation = new FetchZenodoInformation(this._ΖenodoCommunitieService, this._searchZenodoCommunitiesService);
}
constructor (private route: ActivatedRoute) {}
ngOnInit() {
if(this.type == "publication") {
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications;
this.urlParam = "articleId";
@ -68,52 +52,23 @@ export class SearchResultsInDepositComponent {
this.urlParam = "datasourceId";
}
this.route.queryParams.subscribe(params => {
let communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
if (!communityId) {
communityId = params['communityId'];
}
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
if (communityId) {
if (communityId != null && communityId != '') {
this._communityService.getCommunity(this.properties, this.properties.communityAPI + communityId).subscribe(
community => {
var community = community;
var masterZenodoCommunityId = community.zenodoCommunity;
if (masterZenodoCommunityId) {
this.zenodoInformation.shareInZenodoUrl = this.properties.shareInZenodoPage+communityId;
//this.fetchZenodoInformation.getZenodoCommunityNameAndUrlById(masterZenodoCommunityId, this.properties, this.zenodoInformation);
} else {
this.zenodoInformation.url = this.properties.zenodo;
this.zenodoInformation.name = "Zenodo";
}
//this.fetchZenodoInformation.searchNumberOfZCommunities(communityId, this.properties, this.zenodoInformation);
},
error => {
this.handleError("Error getting community with id: " + communityId, error);
}
);
if (!this.zenodoInformation) {
this.zenodoInformation = new ZenodoInformationClass();
}
}
if (!this.zenodoInformation.shareInZenodoUrl) {
this.zenodoInformation.url = this.properties.zenodo;
}
if (!this.zenodoInformation.name) {
this.zenodoInformation.name = "Zenodo";
}
});
if (!this.zenodoInformation.shareInZenodoUrl) {
this.zenodoInformation.url = this.properties.zenodo;
}
if (!this.zenodoInformation.name) {
this.zenodoInformation.name = "Zenodo";
}
});
}
public quote(params: string):string {
return '"'+params+'"';
}
private handleError(message: string, error) {
console.error("search Results in Deposit page: "+message, error);
}
}

View File

@ -170,19 +170,20 @@
[results]="results"
[status]="searchUtils.status"
[type]="entityType"
[showLoading]="true" [(properties)]=properties>
[showLoading]="true" [properties]=properties>
</search-result>
<deposit-result *ngIf="usedBy == 'deposit'"
<deposit-result *ngIf="usedBy == 'deposit'"
[results]="results"
[status]="searchUtils.status"
[type]="entityType"
[showLoading]="true" [(properties)]=properties>
[zenodoInformation]="zenodoInformation"
[properties]=properties>
</deposit-result>
<community-search-result *ngIf="entityType == 'community' && !tableView && usedBy == 'search'"
[results]="results"
[status]="searchUtils.status"
[type]="entityType"
[showLoading]="true" [(properties)]=properties>
[showLoading]="true" [properties]=properties>
</community-search-result>
</div>

View File

@ -16,6 +16,7 @@ import {PiwikService} from '../../utils/piwik/piwik.service';
import {EnvProperties} from '../../utils/properties/env-properties';
import { SEOService } from '../../sharedComponents/SEO/SEO.service';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {ZenodoInformationClass} from "../../deposit/utils/zenodoInformation.class";
@Component({
selector: 'search-page',
@ -33,6 +34,7 @@ export class SearchPageComponent {
@Input() usedBy: string = "search";
@Input() showMoreFilterValuesInline: boolean = false;
@Input() filterValuesNum: number = 5;
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
@Input() searchUtils:SearchUtilsClass = new SearchUtilsClass();
@Output() queryChange = new EventEmitter();
@Input() baseUrl:string = '';