From b8e5ea1d4cbd45503d88e0036f85e40e91402fb4 Mon Sep 17 00:00:00 2001 From: "argiro.kokogiannaki" Date: Thu, 22 Nov 2018 15:10:41 +0000 Subject: [PATCH] zenodo communities: fix table issues set proper messages (loading, error) show the id when master exists but not in zenodo FAB: change uk-icon-button to uk-button -> avoid chrome losing svg when there is padding CSS: Menu items color : get the proper color if it is fixed or sticky git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@53925 d315682c-612b-4755-9ff5-7f18f6832af3 --- .../manage-zenodo-communities.component.html | 72 +++++----- .../manage-zenodo-communities.component.ts | 131 +++++------------- .../remove-projects.component.html | 94 ------------- .../zenodo-communities.component.ts | 131 ++++++++++++------ src/app/utils/fab.component.ts | 9 +- src/assets/css/connect-custom.css | 2 +- 6 files changed, 163 insertions(+), 276 deletions(-) delete mode 100644 src/app/pages/zenodo-communities/remove-projects.component.html diff --git a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html index 2d408fd..60143c8 100644 --- a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html +++ b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.html @@ -1,7 +1,37 @@ -
+
+
+
Master Zenodo community
+
+ +
+ + + +
+
+

+ + {{masterCommunity.title}} + [no name available] + +
+ {{masterCommunity.title}} + [no name available] +
+

+
+ last update: {{masterCommunity.date | date:'yyyy/MM/dd'}} +
+ +
+
+
+

{{masterCommunity.description}}

+
+
- +
-
-
Master Zenodo community
-
-
- - - -
-
-

- {{masterCommunity.title}} - [no name available] - - - -

-
- last update: {{masterCommunity.date | date:'yyyy/MM/dd'}} -
-
-
-
-

{{masterCommunity.description}}

-
-
-
+
- {{zenodoCommunitySearchUtils.totalResults | number}} projects, page {{zenodoCommunitySearchUtils.page | number}} of {{(totalPages()) | number}} + {{searchUtils.totalResults | number}} zenodo communities, page {{searchUtils.page | number}} of {{(totalPages()) | number}} - +
diff --git a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts index 31d1135..b48c503 100644 --- a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts @@ -1,4 +1,4 @@ -import {Component, OnInit, Input, ViewChild} from '@angular/core'; +import {Component, OnInit, Input, ViewChild, ViewEncapsulation} from '@angular/core'; import {SimpleChanges, OnChanges} from '@angular/core'; import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; @@ -26,14 +26,15 @@ import{ManageZenodoCommunitiesService} from '../../services/manageZenodoCommunit display: none; } - `] + `], + encapsulation: ViewEncapsulation.None // this used in order styles to work }) export class ManageZenodoCommunitiesComponent implements OnInit { @Input() properties:EnvProperties = null; @Input() communityId = null; - public zenodoCommunitySearchUtils:SearchUtilsClass = new SearchUtilsClass(); + @Input() searchUtils:SearchUtilsClass = null; private errorCodes: ErrorCodes; public rowsOnPage = 10; @@ -55,37 +56,13 @@ export class ManageZenodoCommunitiesComponent implements OnInit { private _manageZenodoCommunitiesService: ManageZenodoCommunitiesService) { this.errorCodes = new ErrorCodes(); - this.zenodoCommunitySearchUtils.status = this.errorCodes.LOADING; - this.zenodoCommunitySearchUtils.totalResults = this.selectedCommunities.length; + } ngOnInit() { - // this.route.queryParams.subscribe( - // communityId => { - // this.communityId = communityId['communityId']; - // if(!Session.isLoggedIn()){ - // console.info(this._router.url); - // this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - // } else { - // if (this.communityId != null && this.communityId != '') { - // this._ΖenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities+"?page="+this.zenodoCommunitySearchUtils.page+"&size="+this.rowsOnPage).subscribe( - // zenodoCommunities => { - // this.zenodoCommunities = zenodoCommunities; - // console.log(zenodoCommunities); - // console.log(this.zenodoCommunitySearchUtils.page); - // }); - // this._ΖenodoCommunitieService.getTotalZenodoCommunities(this.properties, this.properties.zenodoCommunities).subscribe( - // totalZenodoCommunities => { - // this.totalZenodoCommunities = totalZenodoCommunities; - // this.zenodoCommunitySearchUtils.totalResults = totalZenodoCommunities; - // console.log(totalZenodoCommunities); - // }); - // } - // } - // }); - this.zenodoCommunitySearchUtils.keyword = ""; + this.searchUtils.keyword = ""; this.dtOptions = { // "paging": true, // "searching": true, @@ -94,7 +71,7 @@ export class ManageZenodoCommunitiesComponent implements OnInit { "language": { "search": "", "searchPlaceholder": "Search projects..." - } + } }; if(!this.triggered) { @@ -106,7 +83,7 @@ export class ManageZenodoCommunitiesComponent implements OnInit { this.rerender(); } - + this.searchUtils.totalResults = this.selectedCommunities.length; } public ngOnDestroy() { @@ -114,25 +91,29 @@ export class ManageZenodoCommunitiesComponent implements OnInit { $.fn['dataTable'].ext.search.pop(); } rerender(): void { - this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => { - // Destroy the table first - dtInstance.destroy(); + if(this.datatableElement.dtInstance){ + this.datatableElement.dtInstance.then((dtInstance: DataTables.Api) => { + // Destroy the table first + dtInstance.destroy(); - // Call the dtTrigger to rerender again - this.dtTrigger.next(); - }); + // Call the dtTrigger to rerender again + this.dtTrigger.next(); + }); + } } ngAfterViewInit(): void { $.fn['dataTable'].ext.search.push((settings, data, dataIndex) => { - if (this.filterData(data, this.zenodoCommunitySearchUtils.keyword )) { + if (this.filterData(data, this.searchUtils.keyword )) { return true; } return false; }); console.info("ngAfterViewInit"); + this.searchUtils.totalResults = this.selectedCommunities.length; + } filterData(row: any, query: string) { @@ -178,43 +159,18 @@ export class ManageZenodoCommunitiesComponent implements OnInit { } goTo(page:number = 1){ - this.zenodoCommunitySearchUtils.page=page; + this.searchUtils.page=page; var table = $('#dpTable').DataTable(); table.page( page - 1 ).draw( false ); var info = table.page.info(); console.info("records: "+info.recordsDisplay); - this.zenodoCommunitySearchUtils.totalResults = info.recordsDisplay; + this.searchUtils.totalResults = info.recordsDisplay; } public confirmedDeleteCommunity(data : any) { - // if(!Session.isLoggedIn()){ - // console.info(this._router.url); - // this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - // } else { - // console.info("REMOVE: "+ this.selectedCommunityProject.id); - // this.subRemove = this._manageCommunityProjectsService.removeProject(this.properties, this.community, this.selectedCommunityProject.id).subscribe( - // data => { - // console.info("data REMOVE"); - // console.info(data); - // }, - // err => { - // console.info("error REMOVE"); - // console.log(err); - // }, - // () => { - // console.info("completed REMOVE"); - // let index = this.communityProjects.indexOf(this.selectedCommunityProject); - // this.communityProjects.splice(index, 1); - // - // this.communitySearchUtils.totalResults--; - // this.communitySearchUtils.page=1; - // - // this.rerender(); - // } - // ) - // } + if(!Session.isLoggedIn()){ console.info(this._router.url); this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); @@ -231,11 +187,11 @@ export class ManageZenodoCommunitiesComponent implements OnInit { } if(pos != -1){ this.selectedCommunities.splice(pos, 1); + this.searchUtils.totalResults = this.selectedCommunities.length; } - + this.searchUtils.totalResults = this.selectedCommunities.length; var table = $('#dpTable').DataTable(); table.clear(); - this.rerender(); }, @@ -275,35 +231,14 @@ export class ManageZenodoCommunitiesComponent implements OnInit { } } - // public removeCommunity( comm) { - // if(!Session.isLoggedIn()){ - // console.info(this._router.url); - // this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); - // } else { - // console.info("REMOVE: "+ this.communityId + " "+comm.openaireId); - // this._manageZenodoCommunitiesService.removeZCommunity(this.properties, this.communityId,comm.openaireId ).subscribe( - // data => { - // var pos = -1; - // for(var i=0; i< this.selectedCommunities.length;i++) { - // if( this.selectedCommunities[i].id == comm.id) { - // pos= i; - // break; - // } - // } - // if(pos != -1){ - // this.selectedCommunities.splice(pos, 1); - // } - // - // }, - // err => { - // console.info("error remove"); - // console.log(err.status); - // }, - // () => { - // console.info("completed remove"); - // } - // ) - // } - // } + + totalPages(): number { + let totalPages:any = this.searchUtils.totalResults/(this.rowsOnPage); + if(!(Number.isInteger(totalPages))) { + totalPages = (parseInt(totalPages, 10) + 1); + } + return totalPages; + } + } diff --git a/src/app/pages/zenodo-communities/remove-projects.component.html b/src/app/pages/zenodo-communities/remove-projects.component.html deleted file mode 100644 index 99b608d..0000000 --- a/src/app/pages/zenodo-communities/remove-projects.component.html +++ /dev/null @@ -1,94 +0,0 @@ -
-
-
-
- -
-
-
-
-
-
- - -
-
-
-
- - - -
-
- - {{communitySearchUtils.totalResults | number}} projects, page {{communitySearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- - -
-
- - - - - - - - - - - - - - - - - - -
ProjectGrant IdFunderAction
- - {{result.name}} - ({{result.acronym}}) - [no title available] - - - {{result.grantId}} - - - - {{result.funder}} - - - - -
-
-
- -
-
- - {{communitySearchUtils.totalResults | number}} projects, page {{communitySearchUtils.page | number}} of {{(totalPages()) | number}} - - - - -
-
- - - - diff --git a/src/app/pages/zenodo-communities/zenodo-communities.component.ts b/src/app/pages/zenodo-communities/zenodo-communities.component.ts index 76d884b..b7a82c2 100644 --- a/src/app/pages/zenodo-communities/zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/zenodo-communities.component.ts @@ -11,29 +11,40 @@ import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoComm import { SearchZenodoCommunitiesService } from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service'; import {CommunityService} from "../../openaireLibrary/connect/community/community.service"; -import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; +import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo'; +import {ZenodoCommunityInfo} from '../../openaireLibrary/connect/zenodoCommunities/zenodoCommunityInfo'; +import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class'; +import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes'; @Component({ selector: 'zenodo-communities', template: `
-
+
+ + - - + +
- ` }) -// + export class ZenodoCommunitiesComponent implements OnInit { private communityId: string = null; private community:CommunityInfo = null; @@ -56,8 +67,14 @@ export class ZenodoCommunitiesComponent implements OnInit { selectedCommunityIds = null;//["ecfunded", "zenodo", "lory_hslu", "cs19", "","hbp","dighl", "wind_energy", "lory", "fp7-bmc","fp7postgrantoapilotoutputs","cernopenlab"]; selectedCommunities = []; + + zenodocommunitiesloadedCount = 0; + zenodoSearchUtils:SearchUtilsClass = new SearchUtilsClass(); + private errorCodes: ErrorCodes = new ErrorCodes();; + constructor(private route: ActivatedRoute, private _router: Router, private _ΖenodoCommunitieService: ZenodoCommunitiesService,private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {} ngOnInit() { + this.zenodoSearchUtils.status = this.errorCodes.LOADING;; this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { this.properties = data.envSpecific; this.route.queryParams.subscribe(params => { @@ -68,44 +85,54 @@ export class ZenodoCommunitiesComponent implements OnInit { this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); } else { if (this.communityId != null && this.communityId != '') { - //TODO - // this.showLoading = true; - // this.updateErrorMessage = ""; - // this.errorMessage = ""; this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe ( community => { this.community = community; this.masterZenodoCommunityId = this.community.zenodoCommunity; - console.log if(this.masterZenodoCommunityId){ this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+this.masterZenodoCommunityId, null).subscribe( result => { this.masterZenodoCommunity = result; - }); + }, + error => { + var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo(); + emptyCommunity.id = this.masterZenodoCommunityId; + emptyCommunity.title = this.masterZenodoCommunityId; + this.masterZenodoCommunity = emptyCommunity; + console.log("Master Zenodo community'"+this.masterZenodoCommunityId+"' couldn't be loaded"); + + + } + ); } - // this.showLoading = false; - }, - error => {} //this.handleError('System error retrieving community profile', error) + this.zenodoSearchUtils.status = this.errorCodes.LOADING;; + this._searchZenodoCommunitiesService.searchZCommunities(this.properties,this.communityId).subscribe ( + result => { + this.selectedCommunityIds = result; + this.zenodoSearchUtils.totalResults = this.selectedCommunityIds.length; + if(this.selectedCommunityIds.length == 0){ + this.zenodoSearchUtils.status = this.errorCodes.NONE; + } + for(let i=0; i< this.selectedCommunityIds.length; i++){ + this.getZenodoCommunityById(this.selectedCommunityIds[i]["zenodoid"], this.selectedCommunityIds[i]["id"]); + } + + }, + error => { + console.log("list of zenodo communities couldn't be loaded"); + this.zenodoSearchUtils.status = this.errorCodes.ERROR; + } //this.handleError('System error retrieving community profile', error) + ); + + }, + error => { + console.log("Community couldn't be loaded"); + this.zenodoSearchUtils.status = this.errorCodes.ERROR; + } ); - this._searchZenodoCommunitiesService.searchZCommunities(this.properties,this.communityId).subscribe ( - result => { - this.selectedCommunityIds = result; - - for(let i=0; i< this.selectedCommunityIds.length; i++){ - this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+this.selectedCommunityIds[i]["zenodoid"], this.selectedCommunityIds[i]["id"]).subscribe( - result => { - this.selectedCommunities.push(result); - - }); - } - // this.showLoading = false; - }, - error => {} //this.handleError('System error retrieving community profile', error) - ); -//https://dev-openaire.d4science.org/openaire/community/dh-ch/zenodocommunities } } @@ -120,7 +147,7 @@ export class ZenodoCommunitiesComponent implements OnInit { public ngOnDestroy() {} - public updateCommunityProjects() { + public toggleAction() { if(!Session.isLoggedIn()){ console.info(this._router.url); this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} }); @@ -128,23 +155,39 @@ export class ZenodoCommunitiesComponent implements OnInit { this.toggle = !this.toggle; if(this.toggle) { this.pageTitle = "Manage zenodo communities"; - //TODO - // this.manageProjectsComponent._getCommunityProjects(); - // this.addProjectsComponent.undo = {}; } else { this.updateCommunityProjectsOnToggle = false; this.pageTitle = "Search zenodo communities"; - //this.toggleLinkMessage = "Manage projects"; } } } -//TODO - // public communityProjectsChanged($event) { - // this.communityProjects = $event.value; - // } + getZenodoCommunityById(zenodoid, openaireId){ + this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities+zenodoid, openaireId).subscribe( + result => { + this.selectedCommunities.push(result); + this.zenodocommunitiesloadedCount++; + if(this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length){ + this.zenodoSearchUtils.status = this.errorCodes.DONE; + } + + + }, + error => { + var emptyCommunity:ZenodoCommunityInfo = new ZenodoCommunityInfo(); + emptyCommunity.id = zenodoid; + emptyCommunity.openaireId = openaireId; + emptyCommunity.title = zenodoid; + this.selectedCommunities.push(emptyCommunity); + this.zenodocommunitiesloadedCount++; + if(this.zenodocommunitiesloadedCount >= this.selectedCommunityIds.length){ + this.zenodoSearchUtils.status = this.errorCodes.DONE; + } + console.log("Zenodo community'"+zenodoid+"' couldn't be loaded"); + + + } + ); + } - // public updateCommunityProjects($event) { - // this.updateCommunityProjectsOnToggle = true; - // } } diff --git a/src/app/utils/fab.component.ts b/src/app/utils/fab.component.ts index 28e3052..d7020c6 100644 --- a/src/app/utils/fab.component.ts +++ b/src/app/utils/fab.component.ts @@ -4,8 +4,13 @@ import { Component, EventEmitter, Output } from '@angular/core'; selector: 'fab', template: ` diff --git a/src/assets/css/connect-custom.css b/src/assets/css/connect-custom.css index 4ab152a..85fcae5 100644 --- a/src/assets/css/connect-custom.css +++ b/src/assets/css/connect-custom.css @@ -73,7 +73,7 @@ background-color: var(--portal-main-color); !important; } -.connect-admin-menu .uk-navbar-nav > li > a{ +.connect-admin-menu.uk-navbar-transparent .uk-navbar-nav > li > a{ color: white !important; }