[Trunk | Library]: Original versions in Organization Landing Page

1. landingPages/organization/deletedByInference: Create folder and files for organizations deleted by Inference (original versions).
2. organizationInfo.ts: Add string array field 'deletedByInferenceIds'.
3. organization.service.ts: Parse deletedByInferenceIds (children which are organizations).
4. organization.component: Show (only in 'non production' environments) original versions and request them on click.


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@57238 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2019-10-02 14:15:08 +00:00
parent 1ba65bcbe7
commit a8f4a8f438
8 changed files with 268 additions and 3 deletions

View File

@ -0,0 +1,130 @@
import {Component, ViewChild} from '@angular/core';
import {ElementRef, Input} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {OrganizationInfo} from '../../../utils/entities/organizationInfo';
import {RouterHelper} from '../../../utils/routerHelper.class';
import {ErrorCodes} from '../../../utils/properties/errorCodes';
import {OrganizationsDeletedByInferenceService} from './deletedByInference.service';
@Component({
selector: 'deletedByInference',
template: `
<errorMessages [status]="[status]" [type]="type" tab_error_class=true></errorMessages>
<div>
<div *ngIf="results.length > pageSize" class="uk-margin-bottom">
<span class="uk-h6">{{results.length | number}} {{type}}, page {{page | number}} of {{totalPages(results.length) | number}}</span>
<paging-no-load class="uk-float-right" [currentPage]="page" [totalResults]="results.length" [size]="pageSize" (pageChange)="updatePage($event)"></paging-no-load>
</div>
<ul class="uk-list uk-list-divider uk-margin">
<li *ngFor="let result of results.slice((page-1)*pageSize, page*pageSize)" class="uk-margin-bottom">
<h5 *ngIf="result.title['url'] != undefined && result.title['url'] != null && result.title['url'] != ''"
class="custom-external uk-margin-remove-bottom">
<a *ngIf="result.title['name'] != undefined && result.title['name'] != ''"
href="{{result.title['url']}}" target="_blank"
[innerHTML]="result.title['name']">
</a>
<a *ngIf="result.title['name'] == undefined || result.title['name'] == ''"
href="{{result.title['url']}}" target="_blank">
[no title available]
</a>
</h5>
<h5 *ngIf="(result.title['name'] != undefined && result.title['name'] != '') &&
(result.title['url'] == undefined || result.title['url'] == null || result.title['url'] == '')"
class="uk-margin-remove-bottom"
[innerHTML]="result.title['name']">
</h5>
<h5 *ngIf="(result.title['name'] == undefined || result.title['name'] == '') &&
(result.title['url'] == undefined || result.title['url'] == null || result.title['url'] == '')"
class="uk-margin-remove-bottom">
[no title available]
</h5>
<div *ngIf="result.title.name && result.title.name != result.name ">{{result.name}}</div>
<span class="uk-label custom-label label-blue label-organization" title="Type">Organization</span>{{" "}}
<span *ngIf="result.country" class="uk-label custom-label label-country "
title="Country">{{result.country}}</span>{{" "}}
</li>
</ul>
</div>
`
})
export class OrganizationsDeletedByInferenceComponent {
public results: OrganizationInfo[] = [];
@Input() id: string;
@Input() ids: string[] = [];
@Input() type: string;
// Custom tab paging variables
public page: number = 1;
public pageSize: number = 5;
public status: number;
public routerHelper:RouterHelper = new RouterHelper();
public errorCodes:ErrorCodes = new ErrorCodes();
sub: any;
properties:EnvProperties;
constructor ( private element: ElementRef,
private _deletedByInferenceService: OrganizationsDeletedByInferenceService,
private route: ActivatedRoute,
private _router: Router) {
}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
});
this.sub = this.route.queryParams.subscribe(data => {
this.errorCodes = new ErrorCodes();
this.status = this.errorCodes.LOADING;
this.getDeletedByInference();
});
}
ngOnDestroy() {}
getDeletedByInference() {
this.results = [];
this.status = this.errorCodes.LOADING;
this._deletedByInferenceService.getDeletedByInferenceResults(this.id, String(this.ids.length), this.properties).subscribe(
data => {
this.results = data;
this.status = this.errorCodes.DONE;
},
error => {
if(error.status == '404') {
this.status = this.errorCodes.NOT_FOUND;
} else if(error.status == '500') {
this.status = this.errorCodes.ERROR;
} else {
this.status = this.errorCodes.NOT_AVAILABLE;
}
}
);
}
public totalPages(totalResults: number): number {
let totalPages:any = totalResults/this.pageSize;
if(!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, this.pageSize) + 1);
}
return totalPages;
}
public updatePage($event) {
this.page = $event.value;
}
}

View File

@ -0,0 +1,31 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { OrganizationsDeletedByInferenceComponent } from './deletedByInference.component';
import { OrganizationsDeletedByInferenceService } from './deletedByInference.service';
import {ResultLandingUtilsModule} from '../../landing-utils/resultLandingUtils.module';
import {PagingModule} from '../../../utils/paging.module';
import {ErrorMessagesModule} from '../../../utils/errorMessages.module';
import {ShowAuthorsModule} from "../../../utils/authors/showAuthors.module";
import {LandingModule} from "../../landing-utils/landing.module";
@NgModule({
imports: [
CommonModule, FormsModule, ResultLandingUtilsModule,
PagingModule, ErrorMessagesModule, ShowAuthorsModule, LandingModule
],
declarations: [
OrganizationsDeletedByInferenceComponent
],
providers:[
OrganizationsDeletedByInferenceService
],
exports: [
OrganizationsDeletedByInferenceComponent
]
})
export class OrganizationsDeletedByInferenceModule { }

View File

@ -0,0 +1,65 @@
import {Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http";
import {OrganizationInfo} from '../../../utils/entities/organizationInfo';
import {EnvProperties} from '../../../utils/properties/env-properties';
import {ParsingFunctions} from '../../landing-utils/parsingFunctions.class';
import {map} from "rxjs/operators";
@Injectable()
export class OrganizationsDeletedByInferenceService {
constructor(private http: HttpClient) {
this.parsingFunctions = new ParsingFunctions();
}
public parsingFunctions: ParsingFunctions;
getDeletedByInferenceResults(id: string, size: string, properties: EnvProperties): any {
let url = properties.searchAPIURLLAst + 'deletedByInferenceOrganizations/' + id + "?format=json&size=" + size;
return this.http.get((properties.useCache) ? (properties.cacheUrl + encodeURIComponent(url)) : url)
.pipe(map(res => res['results']))
.pipe(map(res => this.parseDeletedByInferenceResults(res, properties)));
}
parseDeletedByInferenceResults(_results: any, properties: EnvProperties): OrganizationInfo[] {
let results: OrganizationInfo[] = [];
if (_results) {
let organization: OrganizationInfo;
let length = Array.isArray(_results) ? _results.length : 1;
for (let i = 0; i < length; i++) {
organization = new OrganizationInfo();
var _result = Array.isArray(_results) ? _results[i]['result']['metadata']['oaf:entity'] : _results['result']['metadata']['oaf:entity'];
organization.objIdentifier = Array.isArray(_results) ? _results[i]['result']["header"]["dri:objIdentifier"] : _results['result']["header"]["dri:objIdentifier"];
if (_result) {
if (_result['oaf:organization']) {
let data = _result['oaf:organization'];
if(data.hasOwnProperty("websiteurl")) {
organization.title = {"name": data.legalshortname, "url": data.websiteurl};
} else {
organization.title = {"name": data.legalshortname, "url": ''};
}
organization.name = data.legalname;
if(organization.title.name == '') {
organization.title.name = organization.name;
}
if(data.hasOwnProperty("country")) {
organization.country = data['country'].classname;
}
}
results.push(organization);
}
}
return results;
}
}
}

View File

@ -19,7 +19,14 @@
[URL]="properties.baseLink+'/search/organization?organizationId='+organizationId"
type="organization"></schema2jsonld>
<showTitle [title]="organizationInfo.title"></showTitle>
<!-- <showTitle [title]="organizationInfo.title"></showTitle>-->
<showTitle [title]="organizationInfo.title" [classNames]="(properties.environment != 'production' && organizationInfo.deletedByInferenceIds) ? 'uk-margin-remove-bottom' : ''"></showTitle>
<div *ngIf="properties.environment != 'production' && organizationInfo.deletedByInferenceIds"
class="uk-text-muted uk-text-small uk-margin-bottom" (click)="openDeletedByInference()">
The following information is the result of merging
<a>{{organizationInfo.deletedByInferenceIds.length}} original versions</a>
</div>
<div class="uk-text-large "
*ngIf="organizationInfo.title.name && organizationInfo.title.name != organizationInfo.name ">{{organizationInfo.name}}</div>
<span class="uk-label custom-label label-blue label-organization" title="Type">Organization</span>{{" "}}
@ -193,6 +200,11 @@
</div>
<modal-alert *ngIf="organizationInfo.deletedByInferenceIds"
#AlertModalDeletedByInference classBody="uk-width-xxlarge">
<deletedByInference *ngIf="deleteByInferenceOpened"
[id]="organizationInfo.objIdentifier" [ids]="organizationInfo.deletedByInferenceIds" [type]="'organizations'"></deletedByInference>
</modal-alert>
</div>
<helper *ngIf="pageContents && pageContents['bottom'] && pageContents['bottom'].length > 0"
[texts]="pageContents['bottom']"></helper>

View File

@ -100,6 +100,9 @@ export class OrganizationComponent {
downloadProjectPublSub: any;
properties: EnvProperties;
@ViewChild('AlertModalDeletedByInference') alertModalDeletedByInference;
public deleteByInferenceOpened: boolean = false;
//private ngUnsubscribe: Subject<void> = new Subject<void>();
constructor(private element: ElementRef,
@ -552,4 +555,12 @@ export class OrganizationComponent {
private handleError(message: string, error) {
console.error("Organizaton Landing Page: " + message, error);
}
openDeletedByInference() {
this.deleteByInferenceOpened = true;
this.alertModalDeletedByInference.cancelButton = false;
this.alertModalDeletedByInference.okButton = false;
this.alertModalDeletedByInference.alertTitle = "Original sources";
this.alertModalDeletedByInference.open();
}
}

View File

@ -22,6 +22,7 @@ import {IsRouteEnabled} from '../../error/isRouteEnabled.guard';
import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module';
import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module';
import {HelperModule} from "../../utils/helper/helper.module";
import {OrganizationsDeletedByInferenceModule} from "./deletedByInference/deletedByInference.module";
@NgModule({
@ -37,8 +38,8 @@ import {HelperModule} from "../../utils/helper/helper.module";
OrganizationServiceModule,
SearchResearchResultsServiceModule,
ProjectsServiceModule,
Schema2jsonldModule, SEOServiceModule, HelperModule
Schema2jsonldModule, SEOServiceModule, HelperModule,
OrganizationsDeletedByInferenceModule
],
declarations: [
OrganizationComponent,

View File

@ -75,6 +75,19 @@ export class OrganizationService {
if(organization.hasOwnProperty("country")) {
this.organizationInfo.country = organization['country'].classname;
}
if (organization.hasOwnProperty("children")) {
let children = organization['children'];
if( children.hasOwnProperty("organization")) {
this.organizationInfo.deletedByInferenceIds = [];
let length = Array.isArray(children['organization']) ? children['organization'].length : 1;
for (let i = 0; i < length; i++) {
let result = Array.isArray(children['organization']) ? children['organization'][i] : children['organization'];
this.organizationInfo.deletedByInferenceIds.push(result.objidentifier);
}
}
}
}
//Comment Parsing Projects info

View File

@ -11,4 +11,6 @@ export class OrganizationInfo {
"sc39": string, "startDate": string, "endDate": string }[]>;
//dataProviders: { "name": string, "url": string, "type": string, "websiteUrl": string,
// "organizations": {"name": string, "url": string}[]}[];
deletedByInferenceIds: string[];
}