From 27794606e85abb50acf38254eb8ae189867e850c Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Thu, 11 Jan 2018 10:55:54 +0000 Subject: [PATCH] Clear some files | use new version of datatables for dataproviders tables git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@50277 d315682c-612b-4755-9ff5-7f18f6832af3 --- app.component.ts | 4 +- app.module.ts | 21 ++- login/utils/helper.class.ts | 4 +- .../compatibleDataProvidersTable.component.ts | 2 + .../entityRegistriesTable.component.ts | 5 +- .../dataProviders/journalsTable.component.ts | 2 + .../searchPageTableView.component.html | 14 +- .../searchPageTableView.component.ts | 178 +++++++++++------- .../searchUtils/searchPageTableView.module.ts | 1 + sharedComponents/bottom.module.ts | 20 ++ sharedComponents/feedback/feedback.module.ts | 22 +++ sharedComponents/navigationBar.component.html | 52 ++--- sharedComponents/navigationBar.component.ts | 31 ++- ...ents.module.ts => navigationBar.module.ts} | 15 +- utils/properties/openaireProperties.ts | 3 +- 15 files changed, 244 insertions(+), 130 deletions(-) create mode 100644 sharedComponents/bottom.module.ts create mode 100644 sharedComponents/feedback/feedback.module.ts rename sharedComponents/{sharedComponents.module.ts => navigationBar.module.ts} (51%) 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 @@ -
+
- + [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 @@
-
+
@@ -57,7 +57,9 @@
  • Browse all
  • - + + +
    @@ -69,7 +71,7 @@
    -
    +
    @@ -78,13 +80,12 @@
    @@ -101,13 +102,13 @@
    - +
    diff --git a/sharedComponents/navigationBar.component.ts b/sharedComponents/navigationBar.component.ts index 978831c5..4a3ef65a 100644 --- a/sharedComponents/navigationBar.component.ts +++ b/sharedComponents/navigationBar.component.ts @@ -1,4 +1,4 @@ -import { Component } from '@angular/core'; +import { Component, Input } from '@angular/core'; // import 'rxjs/Rx'; import {ActivatedRoute, Router} from '@angular/router'; import {Observable} from 'rxjs/Observable'; @@ -11,6 +11,10 @@ import { ConfigurationService } from '../utils/configuration/configuration.servi templateUrl: 'navigationBar.component.html' }) export class NavigationBarComponent { + @Input() portal:string = "connect"; + @Input() onlyTop ; + @Input() logoPath:string = "assets/"; + @Input() userMenu; public isAuthorized: boolean = false; sub:any; isClient:boolean = false; @@ -40,7 +44,27 @@ export class NavigationBarComponent { this.sub = this.route.queryParams.subscribe(params => { this.initialize(); }); - console.log("Before get entities"); + + if(this.userMenu == "true"){ + this.userMenu = true; + } + else if(this.userMenu == "false"){ + this.userMenu = false; + } + else{ + this.userMenu = true; + } + + if(this.onlyTop == "true"){ + this.onlyTop = true; + } + else if(this.onlyTop == "false"){ + this.onlyTop = false; + } + else{ + this.onlyTop = false; + } + // const entityOne = this.config.isEntityEnabled("publication"); // const entityTwo = this.config.isEntityEnabled("dataset"); @@ -76,8 +100,7 @@ export class NavigationBarComponent { this.isAuthorized = false; } this.config.isEntityEnabled("publication").subscribe(data => { - console.log("heree"); - this.showPublications = data; + this.showPublications = data; }); this.config.isEntityEnabled("dataset").subscribe(data => { this.showDatasets = data;}); this.config.isEntityEnabled("software").subscribe(data => { this.showSoftware = data;}) diff --git a/sharedComponents/sharedComponents.module.ts b/sharedComponents/navigationBar.module.ts similarity index 51% rename from sharedComponents/sharedComponents.module.ts rename to sharedComponents/navigationBar.module.ts index 1db38be7..20880460 100644 --- a/sharedComponents/sharedComponents.module.ts +++ b/sharedComponents/navigationBar.module.ts @@ -5,27 +5,22 @@ import { FormsModule } from '@angular/forms'; import { RouterModule } from "@angular/router"; import {NavigationBarComponent} from './navigationBar.component'; -import {BottomComponent} from './bottom.component'; -import {FeedbackComponent} from './feedback/feedback.component'; import {UserMiniComponent} from '../login/userMini.component'; import {LogoutOpenaireService} from '../login/utils/logoutOpenaire.service'; -import {MetaModule} from '../../meta.module'; -import { ConfigurationServiceModule } from '../utils/configuration/configurationService.module'; + import { ConfigurationServiceModule } from '../utils/configuration/configurationService.module'; @NgModule({ imports: [ CommonModule, FormsModule, - RouterModule, MetaModule, ConfigurationServiceModule + RouterModule, ConfigurationServiceModule ], declarations: [ - NavigationBarComponent, - BottomComponent,UserMiniComponent, FeedbackComponent + NavigationBarComponent, UserMiniComponent ], providers:[LogoutOpenaireService], exports: [ - NavigationBarComponent, - BottomComponent,UserMiniComponent, FeedbackComponent + NavigationBarComponent,UserMiniComponent ] }) -export class SharedComponentsModule{ } +export class NavigationBarModule{ } diff --git a/utils/properties/openaireProperties.ts b/utils/properties/openaireProperties.ts index 412fe887..7f6fcda8 100644 --- a/utils/properties/openaireProperties.ts +++ b/utils/properties/openaireProperties.ts @@ -99,7 +99,8 @@ export class OpenaireProperties { private static piwikBaseUrl =" https://analytics.openaire.eu/piwik.php?idsite=6"; - private static loginUrl ="http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login"; + private static loginUrl ="http://rudie.di.uoa.gr:8080/dnet-openaire-users-2.0.0-SNAPSHOT/openid_connect_login"; + //"http://mpagasas.di.uoa.gr:8080/dnet-openaire-users-1.0.0-SNAPSHOT/openid_connect_login"; private static loginUrl_pm ="https://beta.services.openaire.eu/uoa-user-management/openid_connect_login"; private static logoutUrl ="https://aai.openminted.eu/proxy/saml2/idp/SingleLogoutService.php?ReturnTo=";