diff --git a/searchPages/searchUtils/highlight/highlight.component.ts b/searchPages/searchUtils/highlight/highlight.component.ts index 2e654be3..d3470b91 100644 --- a/searchPages/searchUtils/highlight/highlight.component.ts +++ b/searchPages/searchUtils/highlight/highlight.component.ts @@ -1,6 +1,6 @@ import {Component, Input, OnInit} from "@angular/core"; import {StringUtils} from "../../../utils/string-utils.class"; -import {Organization, Project} from "../../../utils/entities/searchResult"; +import {Organization, Project} from "../../../utils/result-preview/result-preview"; export interface Keyword { field: string, @@ -68,4 +68,4 @@ export class HighlightComponent implements OnInit{ } return false; } -} \ No newline at end of file +} diff --git a/searchPages/searchUtils/modal-result/modal-result.component.ts b/searchPages/searchUtils/modal-result/modal-result.component.ts new file mode 100644 index 00000000..42641b29 --- /dev/null +++ b/searchPages/searchUtils/modal-result/modal-result.component.ts @@ -0,0 +1,69 @@ +import {Component, EventEmitter, Input, Output} from '@angular/core'; +import {SearchResult} from "../../../utils/entities/searchResult"; +import {ErrorCodes} from "../../../utils/properties/errorCodes"; +import {RouterHelper} from "../../../utils/routerHelper.class"; +import {ResultPreview} from "../../../utils/result-preview/result-preview"; +import {AlertModal} from "../../../utils/modal/alert"; +import {EnvProperties} from "../../../utils/properties/env-properties"; + +@Component({ + selector: 'modal-result', + template: ` + +
+ + + + + +
+ ` +}) +export class ModalResultComponent { + @Input() results: SearchResult[]; + @Input() totalResults: number = 0; + @Input() type: string; + @Input() resultType: string; + @Input() showOrganizations: boolean = true; + @Input() showSubjects: boolean = false; + @Input() modal: AlertModal; + @Input() properties: EnvProperties; + @Input() status: number; + @Input() pageSize: number = 1; + @Output() updatePage: EventEmitter = new EventEmitter(); + + public page: number = 1; + public errorCodes: ErrorCodes = new ErrorCodes(); + public routerHelper: RouterHelper = new RouterHelper(); + public errorMessage: string = "No results found"; + + constructor() { + } + + ngOnInit() { + } + + public getResultPreview(result: SearchResult): ResultPreview { + return ResultPreview.searchResultConvert(result, this.resultType); + } + + public update(event) { + this.page = event.value; + this.updatePage.emit({ + value: event.value + }); + } +} diff --git a/searchPages/searchUtils/modal-result/modal-result.module.ts b/searchPages/searchUtils/modal-result/modal-result.module.ts new file mode 100644 index 00000000..2a44f5e4 --- /dev/null +++ b/searchPages/searchUtils/modal-result/modal-result.module.ts @@ -0,0 +1,23 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; +import {ModalResultComponent} from './modal-result.component'; +import {RouterModule} from '@angular/router'; +import {ErrorMessagesModule} from "../../../utils/errorMessages.module"; +import {ResultPreviewModule} from "../../../utils/result-preview/result-preview.module"; +import {NoLoadPaging} from "../no-load-paging.module"; + +@NgModule({ + imports: [ + CommonModule, FormsModule, + RouterModule, ErrorMessagesModule, ResultPreviewModule, NoLoadPaging + ], + declarations: [ + ModalResultComponent, + ], + exports: [ + ModalResultComponent + ] +}) +export class ModalResultModule { +} diff --git a/searchPages/searchUtils/newSearchPage.module.ts b/searchPages/searchUtils/newSearchPage.module.ts index 40b6d1f2..613a68dd 100644 --- a/searchPages/searchUtils/newSearchPage.module.ts +++ b/searchPages/searchUtils/newSearchPage.module.ts @@ -1,15 +1,15 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; +import {RouterModule} from '@angular/router'; -import{NewSearchPageComponent} from './newSearchPage.component'; -import{SearchFormModule} from './searchForm.module'; +import {NewSearchPageComponent} from './newSearchPage.component'; +import {SearchFormModule} from './searchForm.module'; import {SearchFilterModule} from './searchFilter.module'; import {RangeFilterModule} from "../../utils/rangeFilter/rangeFilter.module"; import {LoadingModalModule} from '../../utils/modal/loadingModal.module'; import {ReportsServiceModule} from '../../services/reportsService.module'; -import{SearchPagingModule} from './searchPaging.module'; +import {SearchPagingModule} from './searchPaging.module'; import {SearchResultsPerPageModule} from './searchResultsPerPage.module'; import {SearchSortingModule} from './searchSorting.module'; import {SearchDownloadModule} from './searchDownload.module'; @@ -18,8 +18,8 @@ import {PiwikServiceModule} from '../../utils/piwik/piwikService.module'; import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.guard'; import {HelperModule} from '../../utils/helper/helper.module'; import {Schema2jsonldModule} from '../../sharedComponents/schema2jsonld/schema2jsonld.module'; -import { SEOServiceModule } from '../../sharedComponents/SEO/SEOService.module'; -import { SearchDataproviderMapModule } from './searchDataproviderMap.module'; +import {SEOServiceModule} from '../../sharedComponents/SEO/SEOService.module'; +import {SearchDataproviderMapModule} from './searchDataproviderMap.module'; import {CommunitySearchResultsModule} from "./communitySearchResults.module"; import {SearchResultsModule} from "./searchResults.module"; import {SearchResultsInDepositModule} from "../../deposit/searchResultsInDeposit.module"; diff --git a/searchPages/searchUtils/no-load-paging.component.ts b/searchPages/searchUtils/no-load-paging.component.ts new file mode 100644 index 00000000..932dacd6 --- /dev/null +++ b/searchPages/searchUtils/no-load-paging.component.ts @@ -0,0 +1,40 @@ +import {Component, Input, Output, EventEmitter} from '@angular/core'; +import {Observable} from 'rxjs'; +import {ErrorCodes} from '../../utils/properties/errorCodes'; + +@Component({ + selector: 'no-load-paging', + template: ` +
+
+
+ {{totalResults | number}} + {{type}}, page + {{page}} + of + {{paging.getTotalPages()}} +
+
+ + +
+
+
+ ` +}) +export class NoLoadPagingComponent { + @Input() type: string; + @Input() page: number = 1; + @Input() pageSize: number = 10; + @Input() totalResults: number; + @Output() pageChange: EventEmitter = new EventEmitter(); + + public updatePage(event) { + this.pageChange.emit({ + value: event.value + }); + } +} diff --git a/searchPages/searchUtils/no-load-paging.module.ts b/searchPages/searchUtils/no-load-paging.module.ts new file mode 100644 index 00000000..1acec71a --- /dev/null +++ b/searchPages/searchUtils/no-load-paging.module.ts @@ -0,0 +1,19 @@ +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; +import {PagingModule} from '../../utils/paging.module'; +import {NoLoadPagingComponent} from "./no-load-paging.component"; + +@NgModule({ + imports: [ + CommonModule, FormsModule, PagingModule + ], + declarations: [ + NoLoadPagingComponent + ], + exports: [ + NoLoadPagingComponent + ] +}) +export class NoLoadPaging { +} diff --git a/searchPages/searchUtils/quick-selections.component.ts b/searchPages/searchUtils/quick-selections.component.ts index e41d6914..5cd35bfe 100644 --- a/searchPages/searchUtils/quick-selections.component.ts +++ b/searchPages/searchUtils/quick-selections.component.ts @@ -20,7 +20,7 @@ import {ConfigurationService} from "../../utils/configuration/configuration.serv Publications Research data Software - Other research outcomes + Other research products diff --git a/searchPages/searchUtils/searchPaging.component.ts b/searchPages/searchUtils/searchPaging.component.ts index c25e8cc7..fc4f52fc 100644 --- a/searchPages/searchUtils/searchPaging.component.ts +++ b/searchPages/searchUtils/searchPaging.component.ts @@ -30,10 +30,10 @@ import {ErrorCodes} from '../../utils/properties/errorCodes';
{{oldTotalResults|number}} {{type}}, page {{searchUtils.page | number}} of {{(totalPages(oldTotalResults)|number)}} -
+
-
+
diff --git a/searchPages/searchUtils/searchPaging.module.ts b/searchPages/searchUtils/searchPaging.module.ts index 4a403bd1..122a35e5 100644 --- a/searchPages/searchUtils/searchPaging.module.ts +++ b/searchPages/searchUtils/searchPaging.module.ts @@ -1,9 +1,9 @@ -import { NgModule} from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; -import{SearchPagingComponent} from './searchPaging.component'; -import{PagingModule} from '../../utils/paging.module'; +import {SearchPagingComponent} from './searchPaging.component'; +import {PagingModule} from '../../utils/paging.module'; @NgModule({ imports: [ @@ -11,13 +11,10 @@ import{PagingModule} from '../../utils/paging.module'; ], declarations: [ SearchPagingComponent -], - - providers:[ ], exports: [ SearchPagingComponent - - ] + ] }) -export class SearchPagingModule { } +export class SearchPagingModule { +} diff --git a/searchPages/searchUtils/searchResult.component.html b/searchPages/searchUtils/searchResult.component.html index 66e062ea..03a74efe 100644 --- a/searchPages/searchUtils/searchResult.component.html +++ b/searchPages/searchUtils/searchResult.component.html @@ -2,199 +2,9 @@
  • - -
    - - {{(result.entityType) ? getTypeName(result.entityType) : getTypeName(type)}} - - . {{result.type}} - - {{' . '}} - - - {{' . '}} - - {{' . ' + result.year.toString()}} - . {{result.startYear}} - {{result.endYear}} - - . Embargo End Date: {{result.embargoEndDate | date: 'dd MMM yyyy'}} - -
    - - - -
    - -
    - -
    - - Funder: - - - - Project Code: - - -
    - -
    - - {{result.title.accessMode}} - {{' '}} - - {{result.title.accessMode}} - {{' '}} - - Open Access mandate for Publications - {{' '}} - - Open Access mandate for Research Data - {{' '}} - - Open Access mandate for Publications and Research Data - {{' '}} - - - - {{' '}} - - - - - {{' '}} - - Special Clause 39 - {{' '}} - - {{result.compatibility}} - {{' '}} -
    - -
    - Publisher: - -
    - -
    - Country: - -
    -
    - Country: - -
    -
    - Country: - {{country}}{{(i < (result['countries'].slice(0, 10).length - 1)) ? ", " : ""}} - {{(i == result['countries'].slice(0, 10).length - 1 && result['countries'].length > 10) ? "..." : ""}} -
    - -
    - Programming language: {{result.programmingLanguages.join(", ")}} -
    - -
    - Project: - - - {{project['funderShortname'] ? project['funderShortname'] : project['funderName']}} - - - | {{ project['acronym'] ? project['acronym'] : (project['title'].length > 25 ? - project['title'].substring(0, 25) + '...' : project['title'])}} - - ({{project.code}}) - , - - ... -
    - -
    - Organization: - - {{organization.name}} - , - - ... -
    - -
    - Website URL: - - - {{result.websiteURL}} - - -
    - -
    - OAI-PMH URL: - - - {{result.OAIPMHURL}} - - -
    - -
    - Subject: - {{subject}} - {{(i < (result.subjects.slice(0, 10).length - 1)) ? ", " : ""}} - {{(i == result.subjects.slice(0, 10).length - 1 && result.subjects.length > 10) ? "..." : ""}} - -
    - -
    -

    - -

    -
    + +
  • diff --git a/searchPages/searchUtils/searchResult.component.ts b/searchPages/searchUtils/searchResult.component.ts index 7c709b92..a7e7fd59 100644 --- a/searchPages/searchUtils/searchResult.component.ts +++ b/searchPages/searchUtils/searchResult.component.ts @@ -4,13 +4,13 @@ import {ErrorCodes} from '../../utils/properties/errorCodes'; import {RouterHelper} from '../../utils/routerHelper.class'; import {EnvProperties} from '../../utils/properties/env-properties'; import {Keyword} from "./highlight/highlight.component"; +import {ResultPreview} from "../../utils/result-preview/result-preview"; @Component({ selector: 'search-result', templateUrl: 'searchResult.component.html' }) export class SearchResultComponent implements OnInit { - @Input() keywords: Keyword[]; @Input() results: SearchResult[]; @Input() status: number; @Input() type: string; @@ -19,77 +19,18 @@ export class SearchResultComponent implements OnInit { @Input() showOrganizations: boolean = true; @Input() custom_class: string = "search-results"; @Input() properties: EnvProperties; - public urlParam: string; - public errorCodes: ErrorCodes = new ErrorCodes(); - public routerHelper: RouterHelper = new RouterHelper(); - public errorMessage: string = "No results found"; constructor() { } - ngOnInit() { - if (this.type == "project") { - this.urlParam = "projectId"; - } else if (this.type == "organization") { - this.urlParam = "organizationId"; - } else if (this.type == "dataprovider") { - this.urlParam = "datasourceId"; - } + ngOnInit() {} + + public getResultPreview(result: SearchResult): ResultPreview { + return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type); } - /** - * Returns query param name base on result's entity type - * - * @param type - */ - public queryParamName(type: string): string { - if (type === "publication") { - return "articleId"; - } else if (type === "dataset") { - return "datasetId"; - } else if (type === "software") { - return "softwareId"; - } else if (type === "other") { - return "orpId"; - } - } - - public getTypeName(type: string): string { - if (type === "dataset") { - return "research data"; - } else if (type === "other") { - return "other research outcome"; - } else if (type === "dataprovider") { - return "content provider"; - } else { - return type; - } - } - - public removeUnknown(array: string[], type: string = null): string[] { - if (type) { - return this.removeDuplicates(array, type).filter(value => value.toLowerCase() !== 'unknown'); - } else { - return array.filter(value => value.toLowerCase() !== 'unknown'); - } - } - - public removeDuplicates(array: string[], type: string): string[] { - type = this.getTypeName(type); - return array.filter(value => value.toLowerCase() !== type); - } public quote(params: string): string { return '"' + params + '"'; } - - public accessClass(accessMode: string): string { - if(accessMode.toLowerCase().indexOf('open') !== -1) { - return 'open'; - } else if(accessMode.toLowerCase() === 'not available') { - return 'unknown'; - } else { - return 'closed'; - } - } } diff --git a/searchPages/searchUtils/searchResults.module.ts b/searchPages/searchUtils/searchResults.module.ts index a944b5d7..94ce2e92 100644 --- a/searchPages/searchUtils/searchResults.module.ts +++ b/searchPages/searchUtils/searchResults.module.ts @@ -8,13 +8,14 @@ import {SearchResultComponent} from './searchResult.component'; import {ApprovedByCommunityModule} from '../../connect/approvedByCommunity/approved.module'; import {ShowAuthorsModule} from "../../utils/authors/showAuthors.module"; import {HighlightModule} from "./highlight/highlight.module"; +import {ResultPreviewModule} from "../../utils/result-preview/result-preview.module"; @NgModule({ imports: [ CommonModule, FormsModule, RouterModule, ErrorMessagesModule, ApprovedByCommunityModule, - ShowAuthorsModule, HighlightModule + ShowAuthorsModule, HighlightModule, ResultPreviewModule ], declarations: [ SearchResultComponent diff --git a/utils/altmetrics.component.ts b/utils/altmetrics.component.ts index ab3c7292..71104099 100644 --- a/utils/altmetrics.component.ts +++ b/utils/altmetrics.component.ts @@ -1,6 +1,6 @@ -import {Component, ElementRef, Input} from '@angular/core'; - import {SafeHtmlPipe} from '../utils/pipes/safeHTML.pipe'; - import {ActivatedRoute} from '@angular/router'; +import {Component, Input} from '@angular/core'; +import {ActivatedRoute} from '@angular/router'; + declare var loadAltmetrics:any; // @Component({ @@ -34,8 +34,9 @@ export class AltMetricsComponent { // let yourModule = require('../utils/altmetrics.js'); loadAltmetrics("altmetric-embed-js","https://d1bxh8uas1mnw7.cloudfront.net/assets/altmetric_badges-8f271adb184c21cc5169a7f67f7fe5ab.js"); } - }); + }); } + ngOnDestroy() { this.sub.unsubscribe(); } diff --git a/utils/entities/searchResult.ts b/utils/entities/searchResult.ts index acea3e27..099f6c9c 100644 --- a/utils/entities/searchResult.ts +++ b/utils/entities/searchResult.ts @@ -1,27 +1,4 @@ -export class Project { - funderShortname: string; - funderName: string; - acronym: string; - title: string; - code: string; - id: string; -} - -export class Author { - fullName: string; - orcid: string; -} - -export class ResultTitle { - name: string; - accessMode: string; - sc39: string; -} - -export class Organization { - id: string; - name: string; -} +import {Author, Organization, Project, ResultTitle} from "../result-preview/result-preview"; export class SearchResult { title: ResultTitle; @@ -54,6 +31,9 @@ export class SearchResult { acronym: string; code: string; funderShortname: string; + budget?: string; + contribution?: string; + currency?: string; startYear: number; endYear: number; openAccessMandatePublications: boolean; diff --git a/utils/paging.module.ts b/utils/paging.module.ts index dbf53c87..942cc50e 100644 --- a/utils/paging.module.ts +++ b/utils/paging.module.ts @@ -1,7 +1,7 @@ -import { NgModule } from '@angular/core'; -import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; -import { RouterModule } from '@angular/router'; +import {NgModule} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {FormsModule} from '@angular/forms'; +import {RouterModule} from '@angular/router'; import {pagingFormatterNoLoad} from './pagingFormatterNoLoad.component'; @@ -15,14 +15,10 @@ import {PagingFormatter} from './pagingFormatter.component'; declarations: [ pagingFormatterNoLoad, PagingFormatter, - - ], exports: [ - pagingFormatterNoLoad, - PagingFormatter, - - - ] + pagingFormatterNoLoad, + PagingFormatter, + ] }) -export class PagingModule { } +export class PagingModule {} diff --git a/utils/pagingFormatterNoLoad.component.ts b/utils/pagingFormatterNoLoad.component.ts index 89a8aaa8..ad3518c5 100644 --- a/utils/pagingFormatterNoLoad.component.ts +++ b/utils/pagingFormatterNoLoad.component.ts @@ -7,7 +7,8 @@ import{EnvProperties} from './properties/env-properties'; @Component({ selector: 'paging-no-load', template: ` -
      +
      • @@ -18,11 +19,12 @@ import{EnvProperties} from './properties/env-properties';
      • {{(currentPage +2) | number}}
      • {{(currentPage +3) | number}}
      • {{(currentPage +4) | number}}
      • -
      • - - - - +
      • + + + + +
      • @@ -33,6 +35,7 @@ import{EnvProperties} from './properties/env-properties'; export class pagingFormatterNoLoad { @Input() public currentPage: number = 1; + @Input() public customClasses: string = ''; // @Input() public navigateTo: string; @Input() public term: string=''; @Input() public size: number=10; diff --git a/utils/result-preview/result-preview.component.html b/utils/result-preview/result-preview.component.html new file mode 100644 index 00000000..b587b678 --- /dev/null +++ b/utils/result-preview/result-preview.component.html @@ -0,0 +1,257 @@ + +
        +
        +
        + + {{getTypeName(result.resultType)}} + + + {{' . ' + removeDuplicates(result.types).join(' . ')}} + + + {{' . ' + removeDuplicates(removeDuplicates(result.types)).join(' . ')}} + + {{' . ' + result.year.toString()}} + . {{result.startYear}} - {{result.endYear}} + + . Embargo End Date: {{result.embargoEndDate | date: 'dd MMM yyyy'}} + +
        + +
        +
        + +
        + + {{result.acronym}} + + ( + + ) +
        +
        + [no title available] +
        +
        +
        +
        + + {{result.acronym}} + + ( + + ) +
        +
        + [no title available] +
        +
        +
        + +
        +
        + + Download from: + + {{from.downloadName}} + + + + {{from.downloadName}} + + + + Provider: + + {{from.collectedName}} + + + {{from.collectedName}} + + +
        +
        + +
        + +
        +
        + +
        + + Funder: + {{result.funderShortname}} + + + Project Code: + {{result.code}} + +
        + +
        + + Overall Budget: + {{result.budget | number}} + {{result.currency}} + + + Funder Contribution: + {{result.contribution | number}} + {{result.currency}} + +
        + +
        + + {{result.accessMode}} + {{' '}} + + {{result.accessMode}} + {{' '}} + + Open Access mandate for Publications + {{' '}} + + Open Access mandate for Research Data + {{' '}} + + Open Access mandate for Publications and Research Data + {{' '}} + + + {{language}} + {{' '}} + + + + {{language}} + {{' '}} + + + + {{programmingLanguage}} + {{" "}} + + + Special Clause 39 + {{' '}} + + {{result.compatibility}} + {{' '}} +
        + +
        + +
        + +
        + Publisher: + {{result.publisher}} +
        + +
        + {{(result.countries.length == 1) ? 'Country' : 'Countries'}}: + + {{country}}{{(i < (result.countries.slice(0, 10).length - 1)) ? ", " : ""}} + {{(i == result.countries.slice(0, 10).length - 1 && result.countries.length > 10) ? "..." : ""}} + +
        + +
        + Project: + + + {{project.funderShortname ? project.funderShortname : project.funderName}} + + + | {{ project.acronym ? project.acronym : (project.title.length > 25 ? + project.title.substring(0, 25) + '...' : project.title)}} + + ({{project.code}}) + , + + ... +
        + +
        + Organization: + + {{organization.name}} + , + + ... +
        + +
        + Website URL: + + + {{result.websiteURL}} + + +
        + +
        + OAI-PMH URL: + + + {{result.OAIPMHURL}} + + +
        + +
        + Subject: + {{subject}} + {{(i < (result.subjects.slice(0, 10).length - 1)) ? ", " : ""}} + {{(i == result.subjects.slice(0, 10).length - 1 && result.subjects.length > 10) ? "..." : ""}} + +
        +
        +
        +
        +
        + {{result.relation}}: + {{result.percentage}}% +
        + +
        +
        + {{result.provenanceAction}} +
        +
        +
        + +
        +

        + {{result.description}} +

        +
        \ No newline at end of file diff --git a/utils/result-preview/result-preview.component.ts b/utils/result-preview/result-preview.component.ts new file mode 100644 index 00000000..583afb55 --- /dev/null +++ b/utils/result-preview/result-preview.component.ts @@ -0,0 +1,73 @@ +import {Component, Input, OnInit} from "@angular/core"; +import {ResultPreview} from "./result-preview"; +import {EnvProperties} from "../properties/env-properties"; +import {RouterHelper} from "../routerHelper.class"; +import {AlertModal} from "../modal/alert"; + +@Component({ + selector: 'result-preview', + templateUrl: 'result-preview.component.html' +}) +export class ResultPreviewComponent implements OnInit{ + @Input() result: ResultPreview; + @Input() properties: EnvProperties; + @Input() showSubjects: boolean = true; + @Input() showOrganizations: boolean = true; + @Input() modal: AlertModal = null; + public routerHelper: RouterHelper = new RouterHelper(); + public urlParam: string; + + ngOnInit(): void { + if (this.result.resultType === "publication") { + this.urlParam = "articleId"; + } else if (this.result.resultType === "dataset") { + this.urlParam = "datasetId"; + } else if (this.result.resultType === "software") { + this.urlParam = "softwareId"; + } else if (this.result.resultType === "other") { + this.urlParam = "orpId"; + } else if (this.result.resultType == "project") { + this.urlParam = "projectId"; + } else if (this.result.resultType == "organization") { + this.urlParam = "organizationId"; + } else if (this.result.resultType == "dataprovider") { + this.urlParam = "datasourceId"; + } + } + + public getTypeName(type: string): string { + if (type === "dataset") { + return "research data"; + } else if (type === "other") { + return "other research product"; + } else if (type === "dataprovider") { + return "content provider"; + } else { + return type; + } + } + + public removeUnknown(array: string[]): string[] { + return array.filter(value => value.toLowerCase() !== 'unknown'); + } + + public removeDuplicates(array: string[]): string[] { + return array.filter(value => value.toLowerCase() !== this.result.resultType); + } + + public accessClass(accessMode: string): string { + if(accessMode.toLowerCase().indexOf('open') !== -1) { + return 'open'; + } else if(accessMode.toLowerCase() === 'not available') { + return 'unknown'; + } else { + return 'closed'; + } + } + + public onTitleClick() { + if(this.modal) { + this.modal.cancel(); + } + } +} \ No newline at end of file diff --git a/utils/result-preview/result-preview.module.ts b/utils/result-preview/result-preview.module.ts new file mode 100644 index 00000000..a772d949 --- /dev/null +++ b/utils/result-preview/result-preview.module.ts @@ -0,0 +1,13 @@ +import {NgModule} from "@angular/core"; +import {CommonModule} from "@angular/common"; +import {ResultPreviewComponent} from "./result-preview.component"; +import {RouterModule} from "@angular/router"; +import {ShowAuthorsModule} from "../authors/showAuthors.module"; +import {ResultLandingUtilsModule} from "../../landingPages/landing-utils/resultLandingUtils.module"; + +@NgModule({ + imports: [CommonModule, RouterModule, ShowAuthorsModule, ResultLandingUtilsModule], + declarations: [ResultPreviewComponent], + exports: [ResultPreviewComponent] +}) +export class ResultPreviewModule {} \ No newline at end of file diff --git a/utils/result-preview/result-preview.ts b/utils/result-preview/result-preview.ts new file mode 100644 index 00000000..5d0a3089 --- /dev/null +++ b/utils/result-preview/result-preview.ts @@ -0,0 +1,256 @@ +import {SearchResult} from "../entities/searchResult"; +import {ResultLandingInfo} from "../entities/resultLandingInfo"; +import {OrganizationInfo} from "../entities/organizationInfo"; + +export interface HostedByCollectedFrom { + downloadName: string; + downloadUrl: string[]; + collectedName: string; + collectedId: string; + accessMode: string[]; + bestAccessMode: string; + type: string; + year: string; +} + +export interface Journal { + journal?: string; + issn?: string; + lissn: string; + eissn?: string; + issue?: string; + volume?: string; + start_page?: string; + end_page?: string; +} + +export interface RelationResult { + name: string; + id: string; + date: string; + percentage: number; + class: string + provenanceAction?: string; +} + +export interface Project { + id: string; + acronym: string; + title: string; + funderShortname: string; + funderName: string; + funding?: string; + code: string; + budget?: string; + contribution?: string; + currency?: string; + provenanceAction?: string; + inline?: boolean +} + +export interface Author { + fullName: string; + orcid: string; +} + +export interface ResultTitle { + name: string; + accessMode: string; + sc39: string; +} + +export interface Organization { + id: string; + name: string; + shortname?: string; + websiteUrl?: string; + country?: string; + trust?: number; +} + +export class ResultPreview { + id: string; + title: string; + accessMode: string; + sc39: string; + countries: string[]; + + //publications & datasets & orp & software & organizations: + projects: Project[]; + + //datasets & orp & publications & software + description: string; + year: string; + embargoEndDate: Date | string; + authors: Author[]; + languages: string[]; + identifiers: Map; //key is the classname + hostedBy_collectedFrom: HostedByCollectedFrom[]; + + //datasets & orp & software: + publisher: string; + + //software + programmingLanguages: string[]; + + //dataproviders & projects: + organizations: Organization[]; + + //projects: + acronym: string; + code: string; + funderShortname: string; + budget: string; + contribution: string; + currency: string; + startYear: number; + endYear: number; + openAccessMandatePublications: boolean; + openAccessMandateDatasets: boolean; + + //organizations: + country: string; + + //dataproviders: + englishname: string; + websiteURL: string; + OAIPMHURL: string; + compatibility: string; + compatibilityUNKNOWN: boolean; + subjects: string[]; + + resultType: string; + types: string[]; + + // Relation result + relation: string; + percentage: number; + provenanceAction: string; + + public static searchResultConvert(result: SearchResult, type: string): ResultPreview { + let resultPreview: ResultPreview = new ResultPreview(); + resultPreview.id = result.id; + resultPreview.title = result.title.name; + resultPreview.accessMode = result.title.accessMode; + resultPreview.sc39 = result.title.sc39; + if(result.countriesForResults) { + resultPreview.countries = result.countries; + } else if(result.country) { + resultPreview.countries = [result.country]; + } else { + resultPreview.countries = result.countries; + } + resultPreview.projects = result.projects; + resultPreview.description = result.description; + resultPreview.year = result.year; + resultPreview.embargoEndDate = result.embargoEndDate; + resultPreview.authors = result.authors; + resultPreview.languages = result.languages; + resultPreview.publisher = result.publisher; + resultPreview.programmingLanguages = result.programmingLanguages; + resultPreview.organizations = result.organizations; + resultPreview.acronym = result.acronym; + resultPreview.code = result.code; + resultPreview.funderShortname = result.funderShortname; + resultPreview.budget = result.budget; + resultPreview.contribution = result.contribution; + resultPreview.currency = result.currency; + resultPreview.startYear = result.startYear; + resultPreview.endYear = result.endYear; + resultPreview.openAccessMandatePublications = result.openAccessMandatePublications; + resultPreview.openAccessMandateDatasets = result.openAccessMandateDatasets; + resultPreview.englishname = result.englishname; + if(result.type) { + resultPreview.types = [result.type]; + } else { + resultPreview.types = result.types; + } + resultPreview.websiteURL = result.websiteURL; + resultPreview.OAIPMHURL = result.OAIPMHURL; + resultPreview.compatibility = result.compatibility; + resultPreview.compatibilityUNKNOWN = result.compatibilityUNKNOWN; + resultPreview.subjects = result.subjects; + resultPreview.resultType = type; + return resultPreview; + } + + public static resultLandingInfoConvert(result: ResultLandingInfo, type: string): ResultPreview { + let resultPreview: ResultPreview = new ResultPreview(); + resultPreview.title = result.title; + resultPreview.accessMode = result.accessMode; + resultPreview.countries = result.countries; + resultPreview.projects = result.fundedByProjects; + resultPreview.description = result.description; + if(result.dateofacceptance) { + resultPreview.year = new Date(result.dateofacceptance).getFullYear().toString(); + } + resultPreview.embargoEndDate = result.embargoEndDate; + resultPreview.authors = result.authors; + resultPreview.languages = result.languages; + resultPreview.publisher = result.publisher; + resultPreview.programmingLanguages = result.programmingLanguages; + resultPreview.organizations = result.organizations; + resultPreview.types = result.types; + resultPreview.subjects = result.subjects; + resultPreview.resultType = type; + resultPreview.identifiers = result.identifiers; + resultPreview.hostedBy_collectedFrom = result.hostedBy_collectedFrom; + return resultPreview; + } + + public static relationResultConvert(result: RelationResult, relation: string = 'trust'): ResultPreview { + let resultPreview: ResultPreview = new ResultPreview(); + resultPreview.id = result.id; + resultPreview.title = result.name; + resultPreview.resultType = result.class; + if(result.date) { + resultPreview.year = result.date.toString(); + } + resultPreview.relation = relation; + resultPreview.percentage = result.percentage; + resultPreview.provenanceAction = result.provenanceAction; + return resultPreview; + } + + public static organizationConvert(result: Organization, relation: string = 'trust'): ResultPreview { + let resultPreview: ResultPreview = new ResultPreview(); + resultPreview.id = result.id; + if(result.name) { + resultPreview.title = result.name; + if(result.shortname) { + resultPreview.title += ' (' + result.shortname + ')'; + } + } else if(result.shortname) { + resultPreview.title = result.shortname; + } + if(result.country) { + resultPreview.countries = [result.country]; + } + resultPreview.relation = relation; + resultPreview.percentage = result.trust; + resultPreview.websiteURL = result.websiteUrl; + resultPreview.resultType = 'organization'; + return resultPreview; + } + + public static organizationInfoConvert(result: OrganizationInfo): ResultPreview { + let resultPreview: ResultPreview = new ResultPreview(); + if(result.title && result.title.name) { + resultPreview.title = result.title.name; + if(result.name) { + resultPreview.title += ' (' + result.name + ')'; + } + } else if(result.name) { + resultPreview.title = result.name; + } + if(result.country) { + resultPreview.countries = [result.country]; + } + if(result.title && result.title.url) { + resultPreview.websiteURL = result.title.url; + } + resultPreview.resultType = 'organization'; + return resultPreview; + } + + }