diff --git a/portal-2/src/app/landingPages/project/project.component.html b/portal-2/src/app/landingPages/project/project.component.html index 014da05f..f725ec8a 100644 --- a/portal-2/src/app/landingPages/project/project.component.html +++ b/portal-2/src/app/landingPages/project/project.component.html @@ -140,13 +140,13 @@ - - - -
diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts index 4120b092..d54c9b83 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProviders.component.ts @@ -144,11 +144,17 @@ export class SearchCompatibleDataprovidersComponent { var searchFields = new SearchFields(); var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; var value_names=[ - [ + /*[ "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", "Institutional Repositories Aggregators", "Thematic Repositories Aggregators", "Other Repositories Aggregators", "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], + */ + [ + "Institutional Repository", "Thematic Repository", "Publication Repository", + "Institutional Repository Aggregator", + "Thematic Repositories Aggregators", "Publication Repository Aggregator", + "Data Repository", "Data Repository Aggregator", "Journal", "Journal Aggregator\/Publisher", "CRIS Systems", "Publication Catalogue"], ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; var value_original_ids=[ diff --git a/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts b/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts index eaa898c5..043ac071 100644 --- a/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/compatibleDataProvidersTable.component.ts @@ -15,18 +15,13 @@ import {ExportCSVComponent} from '../../utils/exportCSV.class'; selector: 'search-content-providers-table', template: ` - - - ` }) @@ -39,17 +34,14 @@ export class SearchCompatibleDataprovidersTableComponent { public _location:Location; public searchFields:SearchFields = new SearchFields(); public refineFields: string[] = this.searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; - public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; - public _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[{field:"compatibility",opName:"cm",opValue:"not", values:["UNKNOWN","hostedBy","notCompatible"]},{field:"type",opName:"tp",opValue:"not",values: ["other"]}]; - // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; - public _prefixQuery: string = ""; - public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], + /*public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], "export":[] }; public CSVDownloaded = false; - public resourcesQuery = "&query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))"; public csvParams: string; + public resourcesQuery = "&query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))";*/ + public disableForms: boolean = false; @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; @@ -58,25 +50,16 @@ export class SearchCompatibleDataprovidersTableComponent { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status =errorCodes.LOADING; this.baseUrl = OpenaireProperties.getLinkToSearchCompatibleDataProvidersTable(); - for(var i = 0; i < this._prefixQueryFields.length; i++ ){ - for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ - this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" - + this._prefixQueryFields[i].values[j] + "&" + - this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; - } - } - this._prefixQuery+="&"; } public ngOnInit() { this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + //this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; this.filters = this.createFilters(); - var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); - this._getResults(queryParameters, false, this.searchUtils.page); + this.searchPage.getParametersFromUrl(params); + this._getResults(); }); } @@ -87,36 +70,34 @@ export class SearchCompatibleDataprovidersTableComponent { if(this.subResults){ this.subResults.unsubscribe(); } } - private _getResults(parameters:string,refine:boolean, page: number){ - this.csvParams = parameters+this.resourcesQuery+"&type=datasources"; + private _getResults(){ + //this.csvParams = this.resourcesQuery+"&type=datasources"; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.LOADING; - //this.searchPage.openLoading(); this.disableForms = true; this.results = []; this.searchUtils.totalResults = 0; let size: number = 0; - this.subResults = this._searchDataprovidersService.searchCompatibleDataprovidersTable(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null).subscribe( + this.subResults = this._searchDataprovidersService.searchCompatibleDataprovidersTable().subscribe( data => { size = data; if(size > 0) { - this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( + this.subResults = this._searchDataprovidersService.searchCompatibleDataproviders("", null, 1, size, []).subscribe( data => { this.searchUtils.totalResults = data[0]; - console.info("search Data Providers: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + console.info("search Data Providers [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; + this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } - //this.searchPage.closeLoading(); this.disableForms = false; - }, err => { console.log(err); @@ -126,14 +107,12 @@ export class SearchCompatibleDataprovidersTableComponent { // } var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.ERROR; - //this.searchPage.closeLoading(); this.disableForms = false; } ); } else { this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.NONE; @@ -148,7 +127,6 @@ export class SearchCompatibleDataprovidersTableComponent { // } var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.ERROR; - //this.searchPage.closeLoading(); } ); @@ -157,26 +135,31 @@ export class SearchCompatibleDataprovidersTableComponent { //TODO set filters from } - public queryChanged($event) { - var parameters = $event.index; - console.info("queryChanged: Execute search query "+parameters); - this._getResults(parameters, false, this.searchUtils.page); - } private createFilters():Filter[] { var filter_names=["Type","Compatibility Level"]; var filter_ids=["datasourcetypeuiid","datasourcecompatibilityname"]; var searchFields = new SearchFields(); var filter_original_ids = searchFields.COMPATIBLE_DATAPROVIDER_FIELDS; var value_names=[ - [ + /*[ "Institutional Publication Repository","Thematic Publication Repository", "Other Publication Repository", "Institutional Repositories Aggregators", "Thematic Repositories Aggregators", "Other Repositories Aggregators", "Data Repositories", "Data Repositories Aggregators", "Journals", "Journals Aggregators", "CRIS Systems", "Publication Catalogues"], + */ + [ + "Institutional Repository", "Thematic Repository", "Publication Repository", + "Institutional Repository Aggregator", + "Thematic Repositories Aggregators", "Publication Repository Aggregator", + "Data Repository", "Data Repository Aggregator", "Journal", "Journal Aggregator\/Publisher", "CRIS Systems", "Publication Catalogue"], + + + + ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; var value_original_ids=[ - ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::thematic","aggregator::pubsrepository::institutional","aggregator::pubsrepository::unknown", + ["pubsrepository::institutional","pubsrepository::thematic", "pubsrepository::unknown", "aggregator::pubsrepository::institutional","aggregator::pubsrepository::thematic","aggregator::pubsrepository::unknown", "datarepository::unknown", "aggregator::datarepository", "pubsrepository::journal", "aggregator::pubsrepository::journals", "cris", "pubscatalogue::unknown"], //["driver","openaire2.0", "driver-openaire2.0", "openaire3.0","openaire2.0_data"] ["OpenAIRE Basic (DRIVER OA)","OpenAIRE 2.0 (EC funding)", "OpenAIRE 2.0+ (DRIVER OA, EC funding)", "OpenAIRE 3.0 (OA, funding)","OpenAIRE Data (funded, referenced datasets)"]]; @@ -192,15 +175,13 @@ export class SearchCompatibleDataprovidersTableComponent { } return filters; } - +/* public downloadClicked($event) { if(!this.CSVDownloaded) { this.CSVDownloaded = false; var parameters = $event.value; - //this.getResultsCSV(parameters, false, 1, 1000); - this._searchDataprovidersService.searchCompatibleDataprovidersCSV(parameters,this.searchPage.getRefineFieldsQuery(), 1, 1000).subscribe( data => { this.CSV.export = data; @@ -221,5 +202,5 @@ export class SearchCompatibleDataprovidersTableComponent { ); } } - +*/ } diff --git a/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts b/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts index 22943d16..3d40dbc6 100644 --- a/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts +++ b/portal-2/src/app/searchPages/dataProviders/entityRegistriesTable.component.ts @@ -18,10 +18,7 @@ import {ExportCSVComponent} from '../../utils/exportCSV.class'; @@ -38,46 +35,32 @@ export class SearchEntityRegistriesTableComponent { public _location:Location; public searchFields:SearchFields = new SearchFields(); public refineFields: string[] = this.searchFields.ENTITY_REGISTRIES_FIELDS; - public fieldIdsMap= this.searchFields.DATASOURCE_FIELDS; - public _prefixQueryFields: {field:string,opName:string,opValue:string,values:string[]}[] =[ - {field:"type",opName:"tp",opValue:"and",values: ["other"]}]; - // ["entityregistry","entityregistry::projects","entityregistry::repositories"]}]; - public _prefixQuery: string = ""; - public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], + /*public CSV: any = { "columnNames": [ "Title", "Type", "Coutries", "Compatibility" ], "export":[] }; public CSVDownloaded = false; + public resourcesQuery = "&query=((oaftype exact datasource) and(datasourcetypeuiid = other))"; + public csvParams: string; + */ public disableForms: boolean = false; @ViewChild (SearchPageTableViewComponent) searchPage : SearchPageTableViewComponent ; - public resourcesQuery = "&query=((oaftype exact datasource) and(datasourcetypeuiid = other))"; - public csvParams: string; constructor (private route: ActivatedRoute, private _searchDataprovidersService: SearchDataprovidersService ) { var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status =errorCodes.LOADING; - this.baseUrl = OpenaireProperties.getLinkToSearchEntityRegistriesTable(); - for(var i = 0; i < this._prefixQueryFields.length; i++ ){ - for(var j =0; j < this._prefixQueryFields[i].values.length; j++){ - this._prefixQuery+="&" + this._prefixQueryFields[i].field + "=" - + this._prefixQueryFields[i].values[j] + "&" + - this._prefixQueryFields[i].opName + "=" + this._prefixQueryFields[i].opValue; - } - } - this._prefixQuery+="&"; } public ngOnInit() { this.searchPage.refineFields = this.refineFields; - this.searchPage.fieldIdsMap = this.fieldIdsMap; this.sub = this.route.queryParams.subscribe(params => { this.searchUtils.keyword = (params['keyword']?params['keyword']:''); - this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; + //this.searchUtils.page = (params['page']=== undefined)?1:+params['page']; this.filters = this.createFilters(); - var queryParameters = this.searchPage.getIndexQueryParametersFromUrl(params); - this._getResults(queryParameters, false, this.searchUtils.page); + this.searchPage.getParametersFromUrl(params); + this._getResults("", false, this.searchUtils.page); }); } @@ -89,33 +72,31 @@ export class SearchEntityRegistriesTableComponent { this.subResults.unsubscribe(); } } private _getResults(parameters:string,refine:boolean, page: number){ - this.csvParams = parameters+this.resourcesQuery+"&type=datasources"; + //this.csvParams = parameters+this.resourcesQuery+"&type=datasources"; var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.LOADING; - //this.searchPage.openLoading(); this.disableForms = true; this.results = []; this.searchUtils.totalResults = 0; let size: number = 0; - this.subResults = this._searchDataprovidersService.searchEntityRegistriesTable(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null).subscribe( + this.subResults = this._searchDataprovidersService.searchEntityRegistriesTable().subscribe( data => { size = data; if(size > 0) { - this.subResults = this._searchDataprovidersService.searchEntityRegistries(parameters,(refine)?this.searchPage.getRefineFieldsQuery():null, page, size, []).subscribe( + this.subResults = this._searchDataprovidersService.searchEntityRegistries("",null, page, size, []).subscribe( data => { this.searchUtils.totalResults = data[0]; - console.info("search Entity Registries: [Parameters:"+parameters+" ] [total results:"+this.searchUtils.totalResults+"]"); + console.info("search Entity Registries [total results:"+this.searchUtils.totalResults+"]"); this.results = data[1]; this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); + var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.DONE; if(this.searchUtils.totalResults == 0 ){ this.searchUtils.status = errorCodes.NONE; } - //this.searchPage.closeLoading(); this.disableForms = false; }, @@ -127,14 +108,12 @@ export class SearchEntityRegistriesTableComponent { // } var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.ERROR; - //this.searchPage.closeLoading(); this.disableForms = false; } ); } else { this.searchPage.checkSelectedFilters(this.filters); - this.searchPage.updateBaseUrlWithParameters(this.filters); var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.NONE; @@ -149,7 +128,6 @@ export class SearchEntityRegistriesTableComponent { // } var errorCodes:ErrorCodes = new ErrorCodes(); this.searchUtils.status = errorCodes.ERROR; - //this.searchPage.closeLoading(); } ); /* @@ -188,11 +166,7 @@ export class SearchEntityRegistriesTableComponent { //TODO set filters from } - public queryChanged($event) { - var parameters = $event.index; - console.info("queryChanged: Execute search query "+parameters); - this._getResults(parameters, false, this.searchUtils.page); - } + private createFilters():Filter[] { var filter_names=["Type","Compatibility Level"]; var filter_ids=["datasourcetypename","datasourcecompatibilityname"]; @@ -223,7 +197,7 @@ export class SearchEntityRegistriesTableComponent { } - +/* public downloadClicked($event) { if(!this.CSVDownloaded) { this.CSVDownloaded = false; @@ -252,4 +226,5 @@ export class SearchEntityRegistriesTableComponent { ); } } +*/ } diff --git a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts index abee881f..3e6ed698 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPage.component.ts @@ -59,7 +59,7 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';

- Show results in table view + Show results in table view

- More search options
@@ -48,25 +48,25 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
+
+ - - - - + + + + -
-
- - + - - + - + - - - - -
- {{searchUtils.totalResults}} datasources, page {{searchUtils.page}} of {{(totalPages())}} - - + + {{searchUtils.totalResults}} datasources, page {{searchUtils.page}} of {{(totalPages())}} + +
+

Show results in default view @@ -78,12 +78,12 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';

Name Type CountryInstitutionInstitution Compatibility
@@ -115,21 +115,8 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
- -
@@ -138,45 +125,37 @@ import {OpenaireProperties} from '../../utils/properties/openaireProperties';
- - ` }) export class SearchPageTableViewComponent { @Input() pageTitle = ""; - @Input() results = []; + @Input() results; @Input() filters = []; @Input() type:string = ""; @Input() entityType: string = ""; @Input() searchUtils:SearchUtilsClass = new SearchUtilsClass(); - @Output() queryChange = new EventEmitter(); - @Output() downloadClick = new EventEmitter(); - @Input() baseUrl:string = ''; + //@Output() downloadClick = new EventEmitter(); @Input() showResultCount:boolean = true; @Input() showRefine:boolean = true; @Input() refineFields = []; - @Input() csvParams: string; - @Input() csvPath: string; - @Input() advancedSearchLink: string = ""; + //@Input() csvParams: string; + //@Input() csvPath: string; @Input() searchViewLink: string; @Input() disableForms: boolean = false; @ViewChild (ModalLoading) loading : ModalLoading ; - public fieldIdsMap;//: { [key:string]:{ name:string, operator:string, type:string, indexField:string, equalityOperator:string }}; private searchFieldsHelper:SearchFields = new SearchFields(); private queryParameters: Map = new Map(); - private baseURLWithParameters:string = ''; private sub: any; public countFilters= 0; - public urlParam: string; public parameterNames:string[] =[]; public parameterValues:string[] =[]; - //public activePage: number = 1; - public rowsOnPage = 10; - public sortOrder = "asc"; + public triggerPipe: boolean = false; + + public rowsOnPage:number = 10; @ViewChild('mf') table: any;//DataTable; @ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ; @@ -187,16 +166,16 @@ export class SearchPageTableViewComponent { } ngOnInit() { - this.updateBaseUrlWithParameters(this.filters); - this.defineUrlParam(); this.updateTitle(this.pageTitle); this.updateDescription("Openaire, search, repositories, open access, type, data provider, funder, project, " + this.type + "," +this.pageTitle); this.updateUrl(OpenaireProperties.getBaseLink()+location.pathname); - - // console.info(this.entityType + " " + this.urlParam + this.type); } - ngAfterViewChecked(){ + public sortByOrganization = (dataprovider: any) => { + if(dataprovider.organizations && dataprovider.organizations.length > 0) { + return dataprovider.organizations[0].name.toUpperCase(); + } + return "-"; } totalPages(): number { @@ -207,10 +186,10 @@ export class SearchPageTableViewComponent { return totalPages; } - refreshTable($event:any) { - this.searchUtils.page=$event.value; - this.table.mfActivePage=$event.value; - this.table.setPage(this.table.mfActivePage, this.rowsOnPage); + refreshTable(page:number) { + this.searchUtils.page=page; + //this.table.mfActivePage=$event.value; + this.table.setPage(this.searchUtils.page, this.rowsOnPage); } toggleModal($event) { @@ -231,131 +210,28 @@ export class SearchPageTableViewComponent { updateUrl(url:string){ this._meta.updateProperty("og:url", url); } - private defineUrlParam() { - if(this.entityType == "publication") { - this.urlParam = "articleId"; - } else if(this.entityType == "dataset") { - this.urlParam = "datasetId"; - } else if(this.entityType == "project") { - this.urlParam = "projectId"; - } else if(this.entityType == "organization") { - this.urlParam = "organizationId"; - } else if(this.entityType == "person") { - this.urlParam = "personId"; - } else { - this.urlParam = "datasourceId"; + +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(); } - } - - public getQueryParametersFromUrl(params){ - // var parameters = ""; - var allFqs = ""; - - 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(); - } - this.queryParameters[filterId]=StringUtils.URIDecode(params[filterId]); - let values = (StringUtils.URIDecode(this.queryParameters[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); - var countvalues = 0; - var fq = ""; - for(let value of values) { - countvalues++; - var paramId = this.fieldIdsMap[filterId].param; - // parameters+='&' + paramId+ '='+ value;//+"&" + this.fieldIdsMap[paramId].operator + "="+((countvalues == 1)?"and":"or"); - fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId +" exact " +value;// StringUtils.quote(value) ; - } - if(countvalues > 0){ - fq="&fq="+fq; - } - allFqs += fq; - } - - - } - var keyword = params['keyword']; - var doiQuery = ""; - var keywordQuery = ""; - if((keyword && keyword.length > 0)){ - if((this.type == 'publications' ||this.type == 'datasets')){ - var DOIs:string[] = DOI.getDOIsFromString(keyword); - var doisParams = ""; - - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - doiQuery += "&"+doisParams; - }else { - keywordQuery += "&q="+StringUtils.URIEncode(keyword); - } - }else{ - keywordQuery += "&q="+StringUtils.URIEncode(keyword); - - } - } - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; - } - public getIndexQueryParametersFromUrl(params){ - // var parameters = ""; - var allFqs = ""; - - for(var i=0; i< this.refineFields.length ; i++){ - var filterId = this.refineFields[i]; - var fq = ""; - if(params[filterId] != undefined) { - if(this.queryParameters == undefined){ - this.queryParameters = new Map(); - } - this.queryParameters[filterId]=decodeURIComponent(params[filterId]); - let values = (decodeURIComponent(this.queryParameters[filterId])).split(/,(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)/,-1); - var countvalues = 0 - for(let value of values) { - countvalues++; - // parameters+= ((countvalues == 1)?" and (":" or ")+ filterId+ '='+ value; - fq+=(fq.length > 0 ? " " + "or" + " ":"" ) + filterId + " exact " + value;//StringUtils.quote(value); - } - // parameters+= " ) "; - if(countvalues > 0){ - fq="&fq="+fq; - } - allFqs += fq; - } - - } - var keyword = params['keyword']; - var doiQuery = ""; - var keywordQuery = ""; - if((keyword && keyword.length > 0)){ - if((this.type == 'publications' ||this.type == 'datasets')){ - var DOIs:string[] = DOI.getDOIsFromString(keyword); - var doisParams = ""; - - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - doiQuery += "&"+doisParams; - } - }else{ - keywordQuery += "and ("+StringUtils.quote(StringUtils.URIEncode(keyword)) +")"; - + this.queryParameters[filterId]=decodeURIComponent(params[filterId]); } } - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; - } /* * 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) { @@ -364,7 +240,6 @@ export class SearchPageTableViewComponent { filter.countSelectedValues++; }else{ filterValue.selected = false; - } } }else{ @@ -376,12 +251,7 @@ export class SearchPageTableViewComponent { return filters; } - /* - * Update the url with proper parameters. This is used as base url in Paging Component - */ - public updateBaseUrlWithParameters(filters:Filter[]){ - this.baseURLWithParameters = this.baseUrl + this.createUrlParameters(filters,false); - } + /* * */ @@ -411,92 +281,14 @@ export class SearchPageTableViewComponent { this.parameterNames.push("keyword"); this.parameterValues.push(this.searchUtils.keyword); } - if(this.searchUtils.page != 1 && includePage){ - allLimits+=((allLimits.length == 0)?'?':'&') + 'page=' + this.searchUtils.page; - } + + //if(this.searchUtils.page != 1 && includePage){ + // allLimits+=((allLimits.length == 0)?'?':'&') + 'page=' + this.searchUtils.page; + //} return allLimits; } - /* - * - */ - private createSearchQueryParameters(filters:Filter[]){ - var allFqs = ""; - for (let filter of filters){ - if(filter.countSelectedValues > 0){ - var fq = ""; - var count_selected=0; - for (let value of filter.values){ - if(value.selected == true){ - count_selected++; - fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote(StringUtils.URIEncode(value.id)); - } - } - fq="&fq="+fq; - allFqs += fq; - } - } - var doiQuery = ""; - var keywordQuery = ""; - if((this.searchUtils.keyword && this.searchUtils.keyword.length > 0)){ - if((this.type == 'publications' ||this.type == 'datasets')){ - var DOIs:string[] = DOI.getDOIsFromString(this.searchUtils.keyword); - var doisParams = ""; - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - doiQuery += "&"+doisParams; - }else{ - keywordQuery += "&q="+StringUtils.URIEncode(this.searchUtils.keyword); - } - }else{ - keywordQuery += "&q="+StringUtils.URIEncode(this.searchUtils.keyword); - } - } - - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; - - } - private createIndexQueryParameters(filters:Filter[]){ - var allFqs = ""; - for (let filter of filters){ - if(filter.countSelectedValues > 0){ - var count_selected=0; - var fq = ""; - for (let value of filter.values){ - if(value.selected == true){ - count_selected++; - fq+=(fq.length > 0 ? " " + filter.filterOperator + " ":"" ) + filter.filterId + " exact " + StringUtils.quote(StringUtils.URIEncode(value.id)); - } - } - if(count_selected > 0){ - fq="&fq="+fq; - allFqs += fq; - } - } - } - var doiQuery = ""; - var keywordQuery = ""; - if((this.searchUtils.keyword && this.searchUtils.keyword.length > 0)){ - if((this.type == 'publications' ||this.type == 'datasets')){ - var DOIs:string[] = DOI.getDOIsFromString(this.searchUtils.keyword); - var doisParams = ""; - for(var i =0 ;i < DOIs.length; i++){ - doisParams+=(doisParams.length > 0?"&":"")+'doi="'+ DOIs[i]+'"'; - } - if(doisParams.length > 0){ - doiQuery += "&"+doisParams; - } - }else{ - keywordQuery += " and ("+StringUtils.quote(StringUtils.URIEncode(this.searchUtils.keyword)) +")" - - } - } - return (doiQuery.length > 0 ? doiQuery:keywordQuery) + allFqs; - - } private isFiltered(){ var filtered=false; for (let filter of this.filters){ @@ -514,57 +306,47 @@ export class SearchPageTableViewComponent { if(this.searchUtils.keyword.length > 0 ){ this.searchUtils.keyword =''; } - this.goTo(1); + this.goTo(1, true); } private clearFilters(){ - for (var i =0 ; i < this.filters.length; i++){ - for (var j=0; j < this.filters[i].countSelectedValues; j++){ - if(this.filters[i].values[j].selected){ + 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; - } } this.clearKeywords(); } + private removeFilter(value:Value,filter:Filter){ filter.countSelectedValues--; if(value.selected == true){ value.selected = false; } - this.goTo(1); - + this.goTo(1, true); } - goTo(page:number = 1){ - this.searchUtils.page = page; - console.info("searchUtils.page goto = "+this.searchUtils.page); - this.queryParameters = new Map(); + goTo(page:number = 1, triggerPipe:boolean = true){ + this.refreshTable(page); + if(triggerPipe) { + this.triggerPipe = !this.triggerPipe; + } + var urlParameters = this.createUrlParameters(this.filters,true); - console.info("urlParams : "+urlParameters); - this.updateBaseUrlWithParameters(this.filters); - var queryParameters = this.createSearchQueryParameters(this.filters); - console.info("queryParams : "+queryParameters); - var indexQuery = this.createIndexQueryParameters(this.filters); - this.location.go(location.pathname,urlParameters); - - this.queryChange.emit({ - value: queryParameters, - index:indexQuery - - }); - } + filterChanged($event){ console.info("filter Changed"); - this.goTo(1); + this.goTo(1, true); } keywordChanged($event) { this.searchUtils.keyword = $event.value; - this.goTo(1); + this.goTo(1, true); } - +/* downloadClicked($event) { if($event.value == true) { var queryParameters = this.createSearchQueryParameters(this.filters); @@ -574,76 +356,9 @@ export class SearchPageTableViewComponent { }); } } +*/ - /* - * Get A sub-array of this.refineFields array, which contains the ids of the selected filters - */ - public getSelectedFilters():string[] { - var selected:string[] = []; - for(var i=0; i < this.filters.length; i++){ - var filter:Filter = this.filters[i]; - if(filter.countSelectedValues > 0){ - selected.push(filter.filterId); - } - } - return selected; - } - /* - * Get A sub-array of this.refineFields array, which contains the ids of the selected parameters - */ - private getSelectedParameters():string[] { - var selected:string[] = []; - var params:string[] = Object.keys(this.queryParameters); - for(var i=0; i < params.length; i++){ - if(this.refineFields.indexOf(params[i]) > -1){ - selected.push(params[i]); - } - } - return selected; - } - /* - * Get A sub-array of this.refineFields array, which hides hidden fields (e.g Funding level 0,1,2,..), and contains those that depend on another fields (e.g Funding level 0 if Funder is selected ) - */ - public getFields():string[] { - var selected_filters:string[] = this.getSelectedFilters(); - if(selected_filters.length == 0){ - selected_filters = this.getSelectedParameters(); - } - var fields:string[] = []; - for(var i =0 ; i < this.refineFields.length;i++){ - var dependentTo = this.searchFieldsHelper.DEPENDENT_FIELDS[this.refineFields[i]]; - //if filter is not marked as hidden OR it is hidden but it is dependent to a field that it IS selected - if(this.searchFieldsHelper.HIDDEN_FIELDS.indexOf(this.refineFields[i]) == -1 || (selected_filters.indexOf(dependentTo) != -1) ){ - fields.push(this.refineFields[i]); - } - } - return fields; - } - /* - * Get a query string of all fields, that want to get from search (e.g. &fields=funderid&fields=projectstartyear&...)) - */ - public getRefineFieldsQuery():string{ - - var fields:string[] = this.getFields(); - var fieldsStr = "" - for(var i =0 ; i < fields.length ;i++){ - fieldsStr+="&fields="+fields[i]; - } - return "&refine=true"+fieldsStr; - } - - // for loading - public openLoading(){ - if(this.loading){ - this.loading.open(); - } - } - public closeLoading(){ - if(this.loading){ - this.loading.close(); - } - } getSelectedValues(filter):any{ var selected = []; if(filter.countSelectedValues >0){ diff --git a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts index 144d36df..b02c898d 100644 --- a/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts +++ b/portal-2/src/app/searchPages/searchUtils/searchPageTableView.module.ts @@ -17,6 +17,7 @@ import {SearchDownloadModule} from './searchDownload.module'; import {ModalModule} from '../../utils/modal/modal.module'; import {PagingModule} from '../../utils/paging.module'; import {DataTableModule} from "angular2-datatable"; +import {ContentProvidersDatatablePipe} from '../../utils/pipes/contentProvidersDatatable.pipe'; @NgModule({ @@ -29,6 +30,7 @@ import {DataTableModule} from "angular2-datatable"; //SearchFilterComponent, //SearchFilterModalComponent , + ContentProvidersDatatablePipe ], providers:[ @@ -37,6 +39,8 @@ import {DataTableModule} from "angular2-datatable"; SearchPageTableViewComponent//, //SearchFilterComponent, //SearchFilterModalComponent + , + ContentProvidersDatatablePipe ] }) export class SearchPageTableViewModule { } diff --git a/portal-2/src/app/services/searchDataproviders.service.ts b/portal-2/src/app/services/searchDataproviders.service.ts index 4bcd1a5c..43893cb3 100644 --- a/portal-2/src/app/services/searchDataproviders.service.ts +++ b/portal-2/src/app/services/searchDataproviders.service.ts @@ -63,16 +63,10 @@ export class SearchDataprovidersService { .map(res => [res['meta'].total, this.parseResults(res['results'])]) } - searchCompatibleDataprovidersTable (params: string,refineParams:string):any { + searchCompatibleDataprovidersTable ():any { let size: number = 0; let url: string= OpenaireProperties.getSearchResourcesAPIURL(); url += "?query=((oaftype exact datasource) not(datasourcecompatibilityid = UNKNOWN) not(datasourcecompatibilityid = notCompatible) not(datasourcetypeuiid = other))" - if(params!= null && params != '' ) { - url += params; - } - if(refineParams!= null && refineParams != '' ) { - url += refineParams; - } url += "&page=0&size=1&format=json"; let key = url; @@ -111,16 +105,10 @@ export class SearchDataprovidersService { .map(res => [res['meta'].total, this.parseResults(res['results']),RefineResultsUtils.parse(res['refineResults'],refineFields, "datasource")]); } - searchEntityRegistriesTable (params: string,refineParams:string):any { + searchEntityRegistriesTable ():any { let size: number = 0; let url: string= OpenaireProperties.getSearchResourcesAPIURL(); url += "?query=((oaftype exact datasource) and(datasourcetypeuiid = other))"; - if(params!= null && params != '' ) { - url += params; - } - if(refineParams!= null && refineParams != '' ) { - url += refineParams; - } url += "&page=0&size=1&format=json"; let key = url; diff --git a/portal-2/src/app/utils/pipes/contentProvidersDatatable.pipe.ts b/portal-2/src/app/utils/pipes/contentProvidersDatatable.pipe.ts new file mode 100644 index 00000000..ef1b074a --- /dev/null +++ b/portal-2/src/app/utils/pipes/contentProvidersDatatable.pipe.ts @@ -0,0 +1,102 @@ +import { Pipe, PipeTransform} from '@angular/core'; +import { Filter, Value} from '../../searchPages/searchUtils/searchHelperClasses.class'; +import { SearchUtilsClass } from '../../searchPages/searchUtils/searchUtils.class'; +import { ErrorCodes} from '../properties/openaireProperties'; + +@Pipe({ + name: 'contentProvidersDatatable' +}) +export class ContentProvidersDatatablePipe implements PipeTransform { + + transform(array: any[], args: any[]): any { + if(array.length > 0) { + let searchUtils: SearchUtilsClass = args[0]; + let filters:Filter[] = args[1]; + + + var errorCodes:ErrorCodes = new ErrorCodes(); + searchUtils.status = errorCodes.LOADING; + + var result = array.filter(row=>this.filterAll(row, searchUtils.keyword, filters)); + + searchUtils.totalResults = result.length; + + var errorCodes:ErrorCodes = new ErrorCodes(); + searchUtils.status = errorCodes.DONE; + if(searchUtils.totalResults == 0 ){ + searchUtils.status = errorCodes.NONE; + } + return result; + } + return []; + } + + filterAll(row: any, query: string, filters:Filter[]) { + let returnValue: boolean = false; + + if(query) { + if(row.title.name.indexOf(query) > -1) { + returnValue = true; + } + + if(row.type.indexOf(query) > -1) { + returnValue = true; + } + + if(row.countries.indexOf(query) > -1) { + returnValue = true; + } + + if(row.compatibility.indexOf(query) > -1) { + returnValue = true; + } + + if(row.organizations > 0) { + for(let organization of row.organizations) { + if(row.organization.indexOf(query) > -1) { + 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){ + + // make it generic in future commit + let field:string = ""; + if(filter.title == "Type") { + field = "type"; + } else if(filter.title == "Compatibility Level") { + field = "compatibility"; + } + + if(row[field] == value.name) { + returnValue = true; + if(filter.filterOperator == "or") { + break; + } + } else { + if(filter.filterOperator == "and") { + return false; + } + returnValue = false; + } + } + } + if(!returnValue) { + return false; + } + } + } + + return true; + } +}