diff --git a/app.component.ts b/app.component.ts
index fe237168..3a973630 100644
--- a/app.component.ts
+++ b/app.component.ts
@@ -9,8 +9,8 @@ import {Observable} from 'rxjs/Observable';
styles: [`
`],
template: `
-
Openaire Lib Component
-
+
+ Openaire Lib Component
{{results.length}} {{searchUtils.totalResults}} content providers, page {{searchUtils.page}} of {{(totalPages())}}
+ {{searchUtils.totalResults}} content providers, page {{searchUtils.page}} of {{(totalPages())}}
@@ -79,10 +79,12 @@
-
+
-
0" datatable class="uk-table uk-table-striped divider-table" [dtOptions]="dtOptions" id="dpTable">
+ [mfData]="results | contentProvidersDatatable : [searchUtils, filters, triggerPipe, cd]"
+
+ -->
+
@@ -106,7 +108,7 @@
-
+
= new Map();
- private sub: any;
public countFilters= 0;
public parameterNames:string[] =[];
public parameterValues:string[] =[];
- public triggerPipe: boolean = false;
-
public rowsOnPage:number = 10;
- // @ViewChild('mf') table: any;//DataTable;
@ViewChild (SearchFilterModalComponent) searchFilterModal : SearchFilterModalComponent ;
public currentFilter: Filter;
public errorCodes:ErrorCodes = new ErrorCodes();
piwiksub: any;
dtOptions: DataTables.Settings = {};
-
-
- constructor (private location: Location , private _meta: Meta, private _piwikService:PiwikService ) { }
+ showTable = false; filteringAdded = false;
+ @ViewChild(DataTableDirective) datatableElement: DataTableDirective;
+ dtTrigger: Subject = new Subject(); //necessary
+ constructor (private location: Location , private _meta: Meta, private _piwikService:PiwikService, private _searchDataprovidersService: SearchDataprovidersService ) { }
ngOnInit() {
+
this.dtOptions = {
"paging": true,
"searching": false,
@@ -82,31 +81,25 @@ export class SearchPageTableViewComponent {
if(OpenaireProperties.isPiwikTrackEnabled() && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.pageTitle).subscribe();
}
- // $.fn['dataTable'].ext.search.push((settings, data, dataIndex) => {
- // const id = parseFloat(data[0]) || 0; // use data for the id column
- // if ((isNaN(this.min) && isNaN(this.max)) ||
- // (isNaN(this.min) && id <= this.max) ||
- // (this.min <= id && isNaN(this.max)) ||
- // (this.min <= id && id <= this.max)) {
- // return true;
- // }
- // return false;
- // });
- }
+ }
ngOnDestroy() {
if(this.piwiksub){
this.piwiksub.unsubscribe();
}
- }
- public createData(){
}
- public sortByOrganization = (dataprovider: any) => {
- if(dataprovider.organizations && dataprovider.organizations.length > 0) {
- return dataprovider.organizations[0].name.toUpperCase();
+ ngAfterViewInit(): void {
+ $.fn['dataTable'].ext.search.push((settings, data, dataIndex) => {
+
+ if (this.filterData(data, this.searchUtils.keyword, this.filters)) {
+ return true;
+ }
+ return false;
+ });
+
+
}
- return "-";
- }
+
totalPages(): number {
let totalPages:any = this.searchUtils.totalResults/(this.rowsOnPage);
@@ -116,20 +109,10 @@ export class SearchPageTableViewComponent {
return totalPages;
}
- refreshTable(page:number) {
- console.log("refreshTable s");
- // if(this.searchUtils.page!=page){
- this.searchUtils.page=page;
-
- var table = $('#dpTable').DataTable();
- table.page( page - 1 ).draw( false );
- console.log("refreshTable e");
- // }
- }
-
toggleModal($event) {
this.currentFilter = $event.value;
this.searchFilterModal.open();
+
}
updateDescription(description:string){
@@ -217,9 +200,6 @@ public getParametersFromUrl(params) {
this.parameterValues.push(this.searchUtils.keyword);
}
- //if(this.searchUtils.page != 1 && includePage){
- // allLimits+=((allLimits.length == 0)?'?':'&') + 'page=' + this.searchUtils.page;
- //}
return allLimits;
}
@@ -241,7 +221,7 @@ public getParametersFromUrl(params) {
if(this.searchUtils.keyword.length > 0 ){
this.searchUtils.keyword ='';
}
- this.goTo(1, true);
+ this.goTo(1);
}
private clearFilters(){
for (var i =0 ; i < this.filters.length; i++) {
@@ -260,26 +240,28 @@ public getParametersFromUrl(params) {
if(value.selected == true){
value.selected = false;
}
- this.goTo(1, true);
+ this.goTo(1);
}
- goTo(page:number = 1, triggerPipe:boolean = true){
- this.filteredResults = this.transform();
+ goTo(page:number = 1){
- this.refreshTable(page);
+ this.searchUtils.page=page;
+ var table = $('#dpTable').DataTable();
+ table.page( page - 1 ).draw( false );
+ // 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;
var urlParameters = this.createUrlParameters(this.filters,true);
this.location.go(location.pathname,urlParameters);
- // if(triggerPipe) {
- // this.triggerPipe = !this.triggerPipe;
- // }
+
}
filterChanged($event){
- this.goTo(1, true);
+ this.goTo(1);
}
keywordChanged($event) {
this.searchUtils.keyword = $event.value;
- this.goTo(1, true);
+ this.goTo(1);
}
/*
downloadClicked($event) {
@@ -306,19 +288,29 @@ public getParametersFromUrl(params) {
return selected;
}
+ /*
+ Trigger a table draw in order to get the initial filtering
+ */
+ triggerInitialLoad(){
+ setTimeout(function(){
+ var table = $('#dpTable').DataTable();
+ table.page( 0 ).draw( false );
- transform(): any {
- if(this.results.length > 0) {
-
-
+ }, 500);
+ }
+/*
+Transform initial - not filtered results to get the filtered number
+*/
+ transform(results): any {
+ if(results.length > 0) {
var errorCodes:ErrorCodes = new ErrorCodes();
this.searchUtils.status = errorCodes.LOADING;
- var result = this.results.filter(row=>this.filterAll(row, this.searchUtils.keyword.toLowerCase(),this.filters));
+ var result = results.filter(row=>this.filterAll(row, this.searchUtils.keyword.toLowerCase(),this.filters));
let oldTotal = this.searchUtils.totalResults;
-
+ console.log(" Length: "+result.length);
this.searchUtils.totalResults = result.length;
var errorCodes:ErrorCodes = new ErrorCodes();
@@ -330,12 +322,13 @@ public getParametersFromUrl(params) {
// if(oldTotal != this.searchUtils.totalResults) {
// args[3].detectChanges();
// }
- return result;
+ return result;
}
- return [];
+ return [];
}
filterAll(row: any, query: string, filters:Filter[]) {
+ // console.log(row);
let returnValue: boolean = false;
if(query) {
@@ -406,6 +399,65 @@ public getParametersFromUrl(params) {
}
}
+ 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) {
+ for(var i=0; i <5; i++){
+ 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;
+ if(filter.title == "Type") {
+ field = 1;
+ } else if(filter.title == "Compatibility Level") {
+ field = 4;
+ }
+ r= this.filterQuery(row[field], value.name);
+ if(r) {
+ returnValue = true;
+ if(filter.filterOperator == "or") {
+ break;
+ }
+ } else {
+ if(filter.filterOperator == "and") {
+ return false;
+ }
+ returnValue = false;
+ }
+ }
+ }
+ if(!returnValue) {
+ return false;
+ }
+ }
+ }
+
return true;
}
}
diff --git a/searchPages/searchUtils/searchPageTableView.module.ts b/searchPages/searchUtils/searchPageTableView.module.ts
index fc3a1c05..d0ea828d 100644
--- a/searchPages/searchUtils/searchPageTableView.module.ts
+++ b/searchPages/searchUtils/searchPageTableView.module.ts
@@ -21,6 +21,7 @@ import {PreviousRouteRecorder} from '../../utils/piwik/previousRouteRecorder.gua
import {HelperModule} from '../../utils/helper/helper.module';
import {ErrorMessagesModule} from '../../utils/errorMessages.module';
+
@NgModule({
imports: [
CommonModule, FormsModule,RouterModule, SearchFormModule, SearchResultsModule, LoadingModalModule,
diff --git a/sharedComponents/bottom.module.ts b/sharedComponents/bottom.module.ts
new file mode 100644
index 00000000..bb7e2883
--- /dev/null
+++ b/sharedComponents/bottom.module.ts
@@ -0,0 +1,20 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+
+import {BottomComponent} from './bottom.component';
+
+@NgModule({
+ imports: [
+ CommonModule, FormsModule
+
+ ],
+ declarations: [
+ BottomComponent
+ ],
+
+ exports: [
+ BottomComponent
+ ]
+})
+export class BottomModule{ }
diff --git a/sharedComponents/feedback/feedback.module.ts b/sharedComponents/feedback/feedback.module.ts
new file mode 100644
index 00000000..b9b35306
--- /dev/null
+++ b/sharedComponents/feedback/feedback.module.ts
@@ -0,0 +1,22 @@
+import { NgModule } from '@angular/core';
+import { CommonModule } from '@angular/common';
+import { FormsModule } from '@angular/forms';
+
+import { RouterModule } from "@angular/router";
+
+import {FeedbackComponent} from './feedback.component';
+
+
+@NgModule({
+ imports: [
+ CommonModule, FormsModule
+
+ ],
+ declarations: [
+ FeedbackComponent
+ ],
+ exports: [
+ FeedbackComponent
+ ]
+})
+export class FeedbackModule{ }
diff --git a/sharedComponents/navigationBar.component.html b/sharedComponents/navigationBar.component.html
index 472eefe3..09bbe7e9 100644
--- a/sharedComponents/navigationBar.component.html
+++ b/sharedComponents/navigationBar.component.html
@@ -1,19 +1,19 @@
|