Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
import {Component, Input} from '@angular/core';
|
2020-04-03 18:00:19 +02:00
|
|
|
import {ViewChild} from '@angular/core';
|
|
|
|
import {ViewEncapsulation} from '@angular/core';
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
import {OnInit, AfterViewInit} from '@angular/core';
|
|
|
|
import {Location} from '@angular/common';
|
2019-02-11 16:03:38 +01:00
|
|
|
import {ActivatedRoute, Router} from '@angular/router';
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
import {Title, Meta} from '@angular/platform-browser';
|
2020-04-03 18:00:19 +02:00
|
|
|
import {Subject} from 'rxjs';
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
import {DataTableDirective } from 'angular-datatables';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {Filter, Value} from './searchHelperClasses.class';
|
2020-04-03 18:00:19 +02:00
|
|
|
import {SearchFields} from '../../utils/properties/searchFields';
|
2020-04-02 11:52:57 +02:00
|
|
|
import {SearchCustomFilter, SearchUtilsClass} from './searchUtils.class';
|
2020-04-03 18:00:19 +02:00
|
|
|
import {StringUtils} from '../../utils/string-utils.class';
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
import {ModalLoading} from '../../utils/modal/loading.component';
|
|
|
|
import {SearchFilterModalComponent} from './searchFilterModal.component';
|
|
|
|
import {ErrorCodes} from '../../utils/properties/errorCodes';
|
|
|
|
import {PiwikService} from '../../utils/piwik/piwik.service';
|
2018-11-14 11:38:53 +01:00
|
|
|
import { SEOService } from '../../sharedComponents/SEO/SEO.service';
|
2020-04-02 11:52:57 +02:00
|
|
|
import {HelperService} from "../../utils/helper/helper.service";
|
2020-04-27 10:14:05 +02:00
|
|
|
import {Breadcrumb} from "../../utils/breadcrumbs/breadcrumbs.component";
|
2018-01-11 11:55:54 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'search-page-table',
|
2018-01-03 14:12:31 +01:00
|
|
|
templateUrl:'searchPageTableView.component.html',
|
|
|
|
styles: [`
|
2018-01-11 11:55:54 +01:00
|
|
|
#dpTable_info, #dpTable_paginate, #dpTable_length, #dpTable_filter{
|
|
|
|
display: none;
|
2018-01-03 14:12:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
`],
|
|
|
|
encapsulation: ViewEncapsulation.None // this used in order styles to work
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
2018-01-11 11:55:54 +01:00
|
|
|
export class SearchPageTableViewComponent implements OnInit, AfterViewInit {
|
2018-04-11 10:59:01 +02:00
|
|
|
@Input() piwikSiteId = null;
|
2019-08-02 16:55:32 +02:00
|
|
|
@Input() hasPrefix: boolean = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
@Input() pageTitle = "";
|
|
|
|
@Input() results;
|
|
|
|
@Input() filters = [];
|
2018-03-01 13:03:40 +01:00
|
|
|
@Input() columnNames = [];
|
2017-12-19 13:53:46 +01:00
|
|
|
@Input() type:string = "";
|
|
|
|
@Input() entityType: string = "";
|
|
|
|
@Input() searchUtils:SearchUtilsClass;// = new SearchUtilsClass();
|
|
|
|
//@Output() downloadClick = new EventEmitter();
|
|
|
|
@Input() showResultCount:boolean = true;
|
|
|
|
@Input() showRefine:boolean = true;
|
|
|
|
@Input() refineFields = [];
|
|
|
|
//@Input() csvParams: string;
|
|
|
|
//@Input() csvPath: string;
|
2018-05-23 15:48:32 +02:00
|
|
|
@Input() openaireLink: string;
|
2017-12-19 13:53:46 +01:00
|
|
|
@Input() searchViewLink: string;
|
|
|
|
@Input() disableForms: boolean = false;
|
2018-05-23 15:24:13 +02:00
|
|
|
@Input() enableSearchView: boolean = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
@Input() searchFormClass: string = "searchForm";
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
@Input() formPlaceholderText = "Type Keywords...";
|
2019-02-12 12:15:21 +01:00
|
|
|
@Input() mapUrl: string = "";
|
|
|
|
@Input() mapTooltipType: string ="content providers";
|
2017-12-19 13:53:46 +01:00
|
|
|
@ViewChild (ModalLoading) loading : ModalLoading ;
|
|
|
|
private searchFieldsHelper:SearchFields = new SearchFields();
|
|
|
|
private queryParameters: Map<string, string> = new Map<string,string>();
|
|
|
|
public parameterNames:string[] =[];
|
|
|
|
public parameterValues:string[] =[];
|
|
|
|
|
2018-02-05 14:14:59 +01:00
|
|
|
public isPiwikEnabled;
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
@ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ;
|
|
|
|
public currentFilter: Filter;
|
|
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
piwiksub: any;
|
2018-01-03 14:12:31 +01:00
|
|
|
dtOptions: DataTables.Settings = {};
|
2018-01-11 11:55:54 +01:00
|
|
|
showTable = false; filteringAdded = false;
|
|
|
|
@ViewChild(DataTableDirective) datatableElement: DataTableDirective;
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
dtTrigger: Subject<any> = new Subject(); //necessary
|
2018-10-16 13:21:56 +02:00
|
|
|
properties:EnvProperties;
|
2018-11-14 11:38:53 +01:00
|
|
|
url = null;
|
2020-04-02 11:52:57 +02:00
|
|
|
public pageContents = null;
|
|
|
|
@Input() customFilter: SearchCustomFilter = null;
|
2020-04-03 18:00:19 +02:00
|
|
|
@Input() enableEntitySelection: boolean = false;
|
2020-04-27 10:14:05 +02:00
|
|
|
@Input() includeOnlyResultsAndFilter:boolean = false;
|
|
|
|
@Input() showBreadcrumb:boolean = false;
|
|
|
|
breadcrumbs:Breadcrumb[] = [];
|
|
|
|
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
constructor (private route: ActivatedRoute,
|
2019-02-11 16:03:38 +01:00
|
|
|
private router: Router,
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
private location: Location,
|
|
|
|
private _meta: Meta,
|
|
|
|
private _title: Title,
|
2018-11-14 11:38:53 +01:00
|
|
|
private _piwikService:PiwikService,
|
2020-04-02 11:52:57 +02:00
|
|
|
private seoService: SEOService,
|
|
|
|
private helper: HelperService) { }
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
ngOnInit() {
|
2018-02-05 14:14:59 +01:00
|
|
|
this.route.data
|
|
|
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
2018-10-16 13:21:56 +02:00
|
|
|
this.properties = data.envSpecific;
|
2020-04-02 11:52:57 +02:00
|
|
|
this.getPageContents();
|
2018-02-05 14:14:59 +01:00
|
|
|
this.isPiwikEnabled = data.envSpecific.enablePiwikTrack;
|
|
|
|
if(typeof window !== 'undefined') {
|
2020-09-18 12:10:18 +02:00
|
|
|
this.updateUrl(this.properties.domain+this.properties.baseLink+location.pathname);
|
|
|
|
this.url =this.properties.domain+this.properties.baseLink+location.pathname;
|
2018-02-05 14:14:59 +01:00
|
|
|
}
|
|
|
|
if(typeof document !== 'undefined' && this.isPiwikEnabled){
|
2018-04-11 10:59:01 +02:00
|
|
|
this.piwiksub = this._piwikService.trackView(data.envSpecific, this.pageTitle, this.piwikSiteId).subscribe();
|
2018-02-05 14:14:59 +01:00
|
|
|
}
|
|
|
|
});
|
2018-01-03 14:12:31 +01:00
|
|
|
this.dtOptions = {
|
|
|
|
"paging": true,
|
|
|
|
"searching": false,
|
|
|
|
"lengthChange": false,
|
2018-11-21 16:28:38 +01:00
|
|
|
"pageLength": this.searchUtils.size
|
2018-01-03 14:12:31 +01:00
|
|
|
};
|
2017-12-19 13:53:46 +01:00
|
|
|
this.updateTitle(this.pageTitle);
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
var description = "Openaire, search, repositories, open access, type, content provider, funder, project, " + this.type + "," +this.pageTitle;
|
|
|
|
this.updateDescription(description);
|
2020-09-18 09:57:42 +02:00
|
|
|
this.seoService.createLinkForCanonicalURL(this.properties.domain+ this.properties.baseLink +this.router.url,false);
|
2020-04-27 14:54:48 +02:00
|
|
|
this.breadcrumbs.push({name: 'home', route: '/'}, {name: this.pageTitle, route: null});
|
2018-11-14 11:38:53 +01:00
|
|
|
|
2018-02-15 11:36:12 +01:00
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
ngOnDestroy() {
|
|
|
|
if(this.piwiksub){
|
2018-01-03 14:12:31 +01:00
|
|
|
this.piwiksub.unsubscribe();
|
|
|
|
}
|
2018-11-07 10:11:20 +01:00
|
|
|
try{
|
|
|
|
$.fn['dataTable'].ext.search.pop();
|
|
|
|
}catch(e){
|
|
|
|
console.error("An error occured in ngOnDestroy of SearchPageTableViewComponent ", e)
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
ngAfterViewInit(): void {
|
2018-11-07 10:11:20 +01:00
|
|
|
try{
|
2018-01-11 11:55:54 +01:00
|
|
|
$.fn['dataTable'].ext.search.push((settings, data, dataIndex) => {
|
2019-02-12 12:15:21 +01:00
|
|
|
//console.info(dataIndex+": "+data);
|
|
|
|
//console.info(this.results);
|
|
|
|
//if (this.filterData(this.results[dataIndex], this.searchUtils.keyword, this.filters)) {
|
|
|
|
if(this.filterAll(this.results[dataIndex], this.searchUtils.keyword.toLowerCase(),this.filters)) {
|
2018-11-07 10:11:20 +01:00
|
|
|
// console.info("filter true (keyword:"+this.searchUtils.keyword+")");
|
2018-07-28 01:13:40 +02:00
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
return true;
|
|
|
|
}
|
2018-11-07 10:11:20 +01:00
|
|
|
// console.info("filter false (keyword:"+this.searchUtils.keyword+")");
|
2018-07-28 01:13:40 +02:00
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
return false;
|
|
|
|
});
|
2018-11-07 10:11:20 +01:00
|
|
|
}catch(e){
|
|
|
|
console.error("An error occured in ngAfterViewInit of SearchPageTableViewComponent ", e)
|
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
totalPages(): number {
|
2018-11-21 16:28:38 +01:00
|
|
|
let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
|
2017-12-19 13:53:46 +01:00
|
|
|
if(!(Number.isInteger(totalPages))) {
|
|
|
|
totalPages = (parseInt(totalPages, 10) + 1);
|
|
|
|
}
|
|
|
|
return totalPages;
|
|
|
|
}
|
|
|
|
|
|
|
|
toggleModal($event) {
|
|
|
|
this.currentFilter = $event.value;
|
|
|
|
this.searchFilterModal.open();
|
2018-01-11 11:55:54 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
updateDescription(description:string) {
|
|
|
|
this._meta.updateTag({content:description},"name='description'");
|
|
|
|
this._meta.updateTag({content:description},"property='og:description'");
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
updateTitle(title:string) {
|
2019-08-02 16:55:32 +02:00
|
|
|
var _prefix: string = "";
|
|
|
|
if(this.hasPrefix) {
|
|
|
|
_prefix = "OpenAIRE | ";
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
this._title.setTitle(_title);
|
|
|
|
this._meta.updateTag({content:_title},"property='og:title'");
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
Replace meta service import and use with meta and title from angular/platform-browser for user, publication, claimAdmin,claimsByToken, directLinking, linkingGeneric, myClaims, depositBySubject, depositBySubjectResult, deposit, depositResult, dataProvider, htmlProjectReport, organization, project, software, search, advancedSearchPage, searchPage and searchPageTableView component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@51835 d315682c-612b-4755-9ff5-7f18f6832af3
2018-04-17 15:00:23 +02:00
|
|
|
updateUrl(url:string) {
|
|
|
|
this._meta.updateTag({content:url},"property='og:url'");
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public getParametersFromUrl(params) {
|
|
|
|
for(var i=0; i< this.refineFields.length ; i++) {
|
|
|
|
var filterId = this.refineFields[i];
|
|
|
|
if(params[filterId] != undefined) {
|
|
|
|
if(this.queryParameters == undefined){
|
|
|
|
this.queryParameters = new Map<string,string>();
|
|
|
|
}
|
|
|
|
this.queryParameters[filterId]=decodeURIComponent(params[filterId]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Mark as check the new filters that are selected, when you get them from search
|
|
|
|
*/
|
|
|
|
public checkSelectedFilters(filters:Filter[]){
|
|
|
|
|
|
|
|
this.filters = filters;
|
|
|
|
for(var i=0; i< filters.length ; i++){
|
|
|
|
var filter:Filter = filters[i];
|
|
|
|
filter.countSelectedValues = 0;
|
|
|
|
|
|
|
|
if(this.queryParameters[filter.filterId] != undefined) {
|
|
|
|
let values = (decodeURIComponent(this.queryParameters[filter.filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1);
|
|
|
|
for(let filterValue of filter.values) {
|
|
|
|
if(values.indexOf(StringUtils.quote(filterValue.id)) > -1) {
|
|
|
|
filterValue.selected = true;
|
|
|
|
filter.countSelectedValues++;
|
|
|
|
}else{
|
|
|
|
filterValue.selected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
for(let filterValue of filter.values) {
|
|
|
|
filterValue.selected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return filters;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
private createUrlParameters(filters:Filter[], includePage:boolean){
|
|
|
|
var allLimits="";//location.search.slice(1);
|
|
|
|
this.parameterNames.splice(0,this.parameterNames.length);
|
|
|
|
this.parameterValues.splice(0,this.parameterValues.length);
|
|
|
|
|
|
|
|
for (let filter of filters){
|
|
|
|
var filterLimits="";
|
|
|
|
if(filter.countSelectedValues > 0){
|
|
|
|
for (let value of filter.values){
|
|
|
|
if(value.selected == true){
|
|
|
|
filterLimits+=((filterLimits.length == 0)?'':',') +'"'+ StringUtils.URIEncode(value.id)+'"';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.queryParameters[filter.filterId]=filterLimits;
|
|
|
|
if(filterLimits.length > 0){
|
|
|
|
this.parameterNames.push(filter.filterId);
|
|
|
|
this.parameterValues.push(filterLimits);
|
|
|
|
}
|
|
|
|
allLimits+=(allLimits.length==0?"?":"&")+((filterLimits.length == 0 )?'':filter.filterId + '='+ filterLimits) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.searchUtils.keyword.length > 0 ){
|
2020-04-23 15:21:39 +02:00
|
|
|
allLimits+=(allLimits.length==0?"?":"&")+'fv0=' + this.searchUtils.keyword;
|
|
|
|
this.parameterNames.push("fv0");
|
2017-12-19 13:53:46 +01:00
|
|
|
this.parameterValues.push(this.searchUtils.keyword);
|
|
|
|
}
|
|
|
|
|
|
|
|
return allLimits;
|
|
|
|
}
|
|
|
|
|
|
|
|
public isFiltered(){
|
|
|
|
var filtered=false;
|
|
|
|
for (let filter of this.filters){
|
|
|
|
if(filter.countSelectedValues > 0){
|
|
|
|
filtered = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(this.searchUtils.keyword.length > 0 ){
|
|
|
|
filtered = true;
|
|
|
|
}
|
|
|
|
return filtered;
|
|
|
|
}
|
|
|
|
private clearKeywords(){
|
|
|
|
if(this.searchUtils.keyword.length > 0 ){
|
|
|
|
this.searchUtils.keyword ='';
|
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
this.goTo(1);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
private clearFilters(){
|
|
|
|
for (var i =0 ; i < this.filters.length; i++) {
|
|
|
|
for (var j=0; j < this.filters[i].values.length; j++) {
|
|
|
|
if(this.filters[i].values[j].selected) {
|
|
|
|
this.filters[i].values[j].selected = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.filters[i].countSelectedValues = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private removeFilter(value:Value,filter:Filter){
|
|
|
|
filter.countSelectedValues--;
|
|
|
|
if(value.selected == true){
|
|
|
|
value.selected = false;
|
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
this.goTo(1);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
goTo(page:number = 1){
|
2018-01-03 14:12:31 +01:00
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
this.searchUtils.page=page;
|
|
|
|
var table = $('#dpTable').DataTable();
|
2018-03-01 13:03:40 +01:00
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
table.page( page - 1 ).draw( false );
|
2018-03-01 13:03:40 +01:00
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
// Object { page: 0, pages: 3, start: 0, end: 10, length: 10, recordsTotal: 28, recordsDisplay: 21, serverSide: false }
|
|
|
|
var info = table.page.info();
|
|
|
|
this.searchUtils.totalResults = info.recordsDisplay;
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
var urlParameters = this.createUrlParameters(this.filters,true);
|
|
|
|
this.location.go(location.pathname,urlParameters);
|
|
|
|
}
|
|
|
|
|
|
|
|
filterChanged($event){
|
2018-01-11 11:55:54 +01:00
|
|
|
this.goTo(1);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
keywordChanged($event) {
|
|
|
|
this.searchUtils.keyword = $event.value;
|
2018-01-11 11:55:54 +01:00
|
|
|
this.goTo(1);
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2018-11-21 16:28:38 +01:00
|
|
|
|
|
|
|
sizeChanged($event) {
|
2020-07-24 15:57:13 +02:00
|
|
|
this.searchUtils.size = $event;
|
2018-11-21 16:28:38 +01:00
|
|
|
var table = $('#dpTable').DataTable();
|
|
|
|
table.page.len( this.searchUtils.size ).draw();
|
|
|
|
this.goTo(1);
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
/*
|
|
|
|
downloadClicked($event) {
|
|
|
|
if($event.value == true) {
|
|
|
|
var queryParameters = this.createSearchQueryParameters(this.filters);
|
|
|
|
|
|
|
|
this.downloadClick.emit({
|
|
|
|
value: queryParameters
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
getSelectedValues(filter):any{
|
|
|
|
var selected = [];
|
|
|
|
if(filter.countSelectedValues >0){
|
|
|
|
for (var i=0; i < filter.values.length; i++){
|
|
|
|
if(filter.values[i].selected){
|
|
|
|
selected.push(filter.values[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return selected;
|
|
|
|
|
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
/*
|
|
|
|
Trigger a table draw in order to get the initial filtering
|
|
|
|
*/
|
|
|
|
triggerInitialLoad(){
|
|
|
|
setTimeout(function(){
|
|
|
|
var table = $('#dpTable').DataTable();
|
|
|
|
table.page( 0 ).draw( false );
|
2018-01-03 14:12:31 +01:00
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
}, 500);
|
|
|
|
}
|
2018-01-03 14:12:31 +01:00
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
/*
|
|
|
|
Transform initial - not filtered results to get the filtered number
|
|
|
|
*/
|
2020-04-02 11:52:57 +02:00
|
|
|
transform(results, searchUtils:SearchUtilsClass = null ): any {
|
|
|
|
if(searchUtils!=null) {
|
|
|
|
this.searchUtils = searchUtils;
|
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
if(results.length > 0) {
|
2018-01-03 14:12:31 +01:00
|
|
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = errorCodes.LOADING;
|
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
var result = results.filter(row=>this.filterAll(row, this.searchUtils.keyword.toLowerCase(),this.filters));
|
2018-01-03 14:12:31 +01:00
|
|
|
|
|
|
|
let oldTotal = this.searchUtils.totalResults;
|
2019-02-12 12:15:21 +01:00
|
|
|
//console.info(result);
|
2018-01-03 14:12:31 +01:00
|
|
|
this.searchUtils.totalResults = result.length;
|
|
|
|
|
|
|
|
var errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
this.searchUtils.status = errorCodes.DONE;
|
|
|
|
if(this.searchUtils.totalResults == 0 ){
|
2019-02-12 12:15:21 +01:00
|
|
|
//this.searchUtils.status = errorCodes.NONE;
|
2018-01-03 14:12:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// if(oldTotal != this.searchUtils.totalResults) {
|
|
|
|
// args[3].detectChanges();
|
|
|
|
// }
|
2018-01-11 11:55:54 +01:00
|
|
|
return result;
|
2018-01-03 14:12:31 +01:00
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
return [];
|
2018-01-03 14:12:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
filterAll(row: any, query: string, filters:Filter[]) {
|
|
|
|
let returnValue: boolean = false;
|
|
|
|
|
|
|
|
if(query) {
|
2018-03-01 13:03:40 +01:00
|
|
|
if(row.title && row.title.name.toLowerCase().indexOf(query) > -1) {
|
2018-01-03 14:12:31 +01:00
|
|
|
returnValue = true;
|
|
|
|
}
|
|
|
|
|
2018-03-01 13:03:40 +01:00
|
|
|
if(row.type && row.type.toLowerCase().indexOf(query) > -1) {
|
2018-01-03 14:12:31 +01:00
|
|
|
returnValue = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(row.countries && row.countries.length > 0) {
|
|
|
|
for(let country of row.countries) {
|
|
|
|
if(country.toLowerCase().indexOf(query) > -1) {
|
|
|
|
returnValue = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(row.compatibility && row.compatibility.toLowerCase().indexOf(query) > -1) {
|
|
|
|
returnValue = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(row.organizations && row.organizations.length > 0) {
|
|
|
|
for(let organization of row.organizations) {
|
|
|
|
if(organization.name.toLowerCase().indexOf(query) > -1) {
|
|
|
|
returnValue = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-01 13:03:40 +01:00
|
|
|
if(row.name && row.name.toLowerCase().indexOf(query) > -1) {
|
|
|
|
returnValue = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(row.acronym && row.acronym.toLowerCase().indexOf(query) > -1) {
|
|
|
|
returnValue = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(row.grantId && row.grantId.toLowerCase().indexOf(query) > -1) {
|
|
|
|
returnValue = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(row.funder && row.funder.toLowerCase().indexOf(query) > -1) {
|
|
|
|
returnValue = true;
|
|
|
|
}
|
|
|
|
|
2018-01-03 14:12:31 +01:00
|
|
|
if(!returnValue) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let filter of filters){
|
|
|
|
if(filter.countSelectedValues > 0){
|
|
|
|
for (let value of filter.values){
|
|
|
|
if(value.selected == true){
|
|
|
|
|
|
|
|
// make it generic in future commit
|
|
|
|
let field:string = "";
|
2018-07-05 17:50:43 +02:00
|
|
|
/*
|
|
|
|
let index: number = -1;
|
|
|
|
for(let i=0; i<this.columnNames.length; i++) {
|
|
|
|
if(filter.title == this.columnNames[i]) {
|
|
|
|
index = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2018-01-03 14:12:31 +01:00
|
|
|
if(filter.title == "Type") {
|
|
|
|
field = "type";
|
2018-10-11 11:11:56 +02:00
|
|
|
} else if(filter.title == "Compatibility") {
|
2018-01-03 14:12:31 +01:00
|
|
|
field = "compatibility";
|
2018-03-01 13:03:40 +01:00
|
|
|
} else if(filter.title == "Funder") {
|
|
|
|
field = "funder";
|
2019-02-12 12:15:21 +01:00
|
|
|
} else if(filter.title == "Country") {
|
|
|
|
field = "countries";
|
2018-01-03 14:12:31 +01:00
|
|
|
}
|
2019-02-12 12:15:21 +01:00
|
|
|
//console.info(row);
|
2019-02-14 11:15:44 +01:00
|
|
|
//console.info("|"+row[field]+"|"+" "+"|"+value.name+"|");
|
2019-02-12 12:15:21 +01:00
|
|
|
//if(row[field] == value.name) {
|
|
|
|
if(row[field] &&
|
|
|
|
((filter.valueIsExact && (row[field].trim() == value.name.trim()))
|
|
|
|
|| (!filter.valueIsExact && (row[field].includes(value.name))))){
|
2018-01-03 14:12:31 +01:00
|
|
|
|
|
|
|
returnValue = true;
|
|
|
|
if(filter.filterOperator == "or") {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(filter.filterOperator == "and") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
returnValue = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!returnValue) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-11 11:55:54 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
filterQuery(data, query){
|
|
|
|
if(data.toLowerCase().indexOf(query.toLowerCase()) > -1){
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
filterData(row: any, query: string, filters:Filter[]) {
|
|
|
|
|
|
|
|
|
|
|
|
let returnValue: boolean = false;
|
|
|
|
|
|
|
|
if(query) {
|
2018-03-01 13:03:40 +01:00
|
|
|
for(var i=0; i <this.columnNames.length; i++){
|
2018-01-11 11:55:54 +01:00
|
|
|
var r= this.filterQuery(row[i], query);
|
|
|
|
// console.log(query+" "+ row+" "+r);
|
|
|
|
if(r) {
|
|
|
|
returnValue = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(!returnValue) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (let filter of filters){
|
|
|
|
if(filter.countSelectedValues > 0){
|
|
|
|
for (let value of filter.values){
|
|
|
|
if(value.selected == true){
|
|
|
|
let field = 1;
|
2018-07-05 17:50:43 +02:00
|
|
|
/*if(filter.title == "Type") {
|
2018-01-11 11:55:54 +01:00
|
|
|
field = 1;
|
|
|
|
} else if(filter.title == "Compatibility Level") {
|
|
|
|
field = 4;
|
2018-03-01 13:03:40 +01:00
|
|
|
} else if(filter.title == "Funder") {
|
|
|
|
field = 3
|
2018-07-05 17:50:43 +02:00
|
|
|
}*/
|
|
|
|
for(let i=0; i<this.columnNames.length; i++) {
|
|
|
|
if(filter.title == this.columnNames[i]) {
|
|
|
|
field = i;
|
|
|
|
}
|
2018-01-11 11:55:54 +01:00
|
|
|
}
|
2018-07-05 17:50:43 +02:00
|
|
|
|
2019-02-12 12:15:21 +01:00
|
|
|
//if(row[field].trim() == value.name.trim()) {
|
|
|
|
if((filter.valueIsExact && (row[field].trim() == value.name.trim()))
|
|
|
|
|| (!filter.valueIsExact && (row[field].includes(value.name)))){
|
2018-01-11 11:55:54 +01:00
|
|
|
returnValue = true;
|
|
|
|
if(filter.filterOperator == "or") {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(filter.filterOperator == "and") {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
returnValue = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!returnValue) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-03 14:12:31 +01:00
|
|
|
return true;
|
|
|
|
}
|
2018-03-27 16:35:05 +02:00
|
|
|
|
|
|
|
public encode(param: string): string {
|
|
|
|
return StringUtils.URIEncode(param);
|
|
|
|
}
|
2018-10-03 16:12:42 +02:00
|
|
|
public countFilters():number{
|
|
|
|
var filters=0;
|
|
|
|
for (let filter of this.filters){
|
|
|
|
if(filter.countSelectedValues > 0){
|
|
|
|
filters+=filter.countSelectedValues;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return filters;
|
|
|
|
}
|
2020-04-02 11:52:57 +02:00
|
|
|
private getPageContents() {
|
2020-04-07 13:15:28 +02:00
|
|
|
this.helper.getPageHelpContents(this.properties, (this.customFilter) ? this.customFilter.valueId : null, this.router.url).subscribe(contents => {
|
2020-04-02 11:52:57 +02:00
|
|
|
|
|
|
|
this.pageContents = contents;
|
|
|
|
})
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|