[Trunk|Connect]: 1. SearchCommunities: change getSubscribe method. 2. replace scroll with new helper function. 3. SubscribeModule: add forRoot for service

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@55417 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-04-24 12:02:11 +00:00
parent e92220bd31
commit 6b5c935300
12 changed files with 388 additions and 414 deletions

View File

@ -333,10 +333,6 @@ export class AppComponent {
console.error("Error fetching your subscribed communities")
});
}
// if(this.subscriberOfCommunities){
// myCommunities.push( new MenuItem("","Subscribed to communities","","/search/find/communities",false,[],[],{status:"%22subscribed%22"}))
// }
this.menuItems.push({rootItem: new MenuItem("communities","Communities","","/search/find/communities",false,[],null,{}), items: []});
if(this.managerOfCommunities || this.subscriberOfCommunities){
this.menuItems.push({rootItem: new MenuItem("myCommunities","My Communities","","",false,[],[],{}), items: myCommunities});

View File

@ -1,8 +1,7 @@
import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms';
import {APP_BASE_HREF, CommonModule} from '@angular/common';
import {CommonModule} from '@angular/common';
import {HttpModule} from '@angular/http';
import {RouterModule} from '@angular/router';
import {BrowserModule} from '@angular/platform-browser';
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
@ -15,7 +14,6 @@ import {AppRoutingModule} from './app-routing.module';
import {SharedModule} from './shared/shared.module';
import {CookieLawModule} from './openaireLibrary/sharedComponents/cookie-law/cookie-law.module';
import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module';
import {FeedbackModule} from './openaireLibrary/sharedComponents/feedback/feedback.module';
import {ErrorModule} from './openaireLibrary/error/error.module';
import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module';
@ -35,10 +33,10 @@ import {SubscribeModule} from './utils/subscribe/subscribe.module';
ErrorModule,
CKEditorModule,
FormsModule,
NavigationBarModule, //FeedbackModule,
NavigationBarModule,
BottomModule,
CookieLawModule,
SubscribeModule,
SubscribeModule.forRoot(),
BrowserModule.withServerTransition({appId: 'my-app'}),
AppRoutingModule
],

View File

@ -2,7 +2,6 @@ import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router';
import {SubscribeModule} from '../utils/subscribe/subscribe.module';
import {ManageModule} from '../openaireLibrary/utils/manage/manage.module';
import {CommunitiesComponent} from './communities.component';
@ -19,14 +18,14 @@ import {BrowseCommunityModule} from './browseCommunity/browse-community.modul
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule,
SubscribeModule, ManageModule, ErrorMessagesModule,
ManageModule, ErrorMessagesModule,
SearchFormModule, BrowseCommunityModule
],
declarations: [
CommunitiesComponent
],
providers:[
FreeGuard, PreviousRouteRecorder, ConfigurationService,
FreeGuard, PreviousRouteRecorder,
PiwikService
],
exports: [

View File

@ -1,17 +1,11 @@
import {Component, Input, Output, ElementRef} from '@angular/core';
import {EventEmitter, ViewChild} from '@angular/core';
import {ChangeDetectionStrategy} from '@angular/core';
import {ViewEncapsulation} from '@angular/core';
import {Component, ElementRef, Input, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Location} from '@angular/common';
import {Title, Meta} from '@angular/platform-browser';
import {Observable} from 'rxjs/Observable';
import {Meta, Title} from '@angular/platform-browser';
import "rxjs/add/observable/zip";
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {ErrorCodes} from '../openaireLibrary/utils/properties/errorCodes';
import {CommunityService} from "../openaireLibrary/connect/community/community.service";
import {ConfigurationService} from '../openaireLibrary/utils/configuration/configuration.service';
@ -24,6 +18,8 @@ import {StatisticsForDashboardComponent} from '../statistics/statistics.componen
import {StringUtils} from '../openaireLibrary/utils/string-utils.class';
import {PiwikHelper} from '../utils/piwikHelper';
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'community',
templateUrl: 'community.component.html',
@ -66,6 +62,7 @@ export class CommunityComponent {
public subOrps;
@ViewChild(StatisticsForDashboardComponent) statistics: StatisticsForDashboardComponent = null;
public activeTab = "publication";
constructor(
private element: ElementRef,
private route: ActivatedRoute,
@ -100,7 +97,7 @@ public activeTab = "publication";
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
HelperFunctions.scroll();
}
this.community = community;
if (this.properties.environment == "development") {
@ -135,7 +132,6 @@ public activeTab = "publication";
this.zenodoCommunityIdS = result;
},
error => {
//console.error("list of zenodo communities couldn't be loaded");
@ -147,7 +143,6 @@ public activeTab = "publication";
});
this._searchEntriesService.getTotal(this.properties.searchAPIURLLAst + 'publications/count?format=json&fq=communityid=' + this.communityId).subscribe(
publicationTotal => {
this.publicationTotal = publicationTotal;
@ -297,9 +292,11 @@ public activeTab = "publication";
isEntityEnabled(entity: string) {
return this.communityInfo.entities.some(x => x['pid'] == entity && x['isEnabled'] === true);
}
isRouteEnabled(route: string) {
return this.communityInfo.pages.some(x => x['route'] == route && x['isEnabled'] === true);
}
showInvite() {
@ -348,6 +345,7 @@ countOtherGraphs(){
}
return count;
}
createParams(param) {
return StringUtils.quote(StringUtils.URIEncode(param));
}

View File

@ -31,7 +31,7 @@ import {SearchFormModule} from '../openaireLibrary/searchPages/searchUti
CommunityComponent, ResultsComponent
],
providers:[
FreeGuard, PreviousRouteRecorder, ConfigurationService,
FreeGuard, PreviousRouteRecorder,
PiwikService, CommunityService, SearchEntriesService
],
exports: [

View File

@ -8,6 +8,7 @@ import {ContactForm} from "../openaireLibrary/utils/email/contact-form";
import {Composer} from "../openaireLibrary/utils/email/composer";
import {Title} from "@angular/platform-browser";
import {PiwikService} from "../openaireLibrary/utils/piwik/piwik.service";
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'contact',
@ -36,8 +37,7 @@ export class ContactComponent implements OnInit {
@ViewChild('message') message;
@ViewChild('recaptcha') recaptcha;
constructor(private element: ElementRef,
private route: ActivatedRoute,
constructor(private route: ActivatedRoute,
private _router: Router,
private _emailService: EmailService,
private _title: Title,
@ -53,19 +53,13 @@ export class ContactComponent implements OnInit {
if(this.properties.enablePiwikTrack && (typeof document !== 'undefined')){
this.piwiksub = this._piwikService.trackView(this.properties, "OpenAIRE Connect|Contact Us", this.properties.piwikSiteId).subscribe();
}
this.scroll();
HelperFunctions.scroll();
this.showLoading = false;
});
}
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
public send() {
this.scroll();
HelperFunctions.scroll();
if(!this.name.invalid && !this.surname.invalid && !this.sender.invalid &&
this.contactForm.email.match('^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$') &&
!this.affiliation.invalid && !this.message.invalid && this.contactForm.recaptcha != '') {

View File

@ -4,7 +4,6 @@ import {Title, Meta} from '@angular/platform-browser';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {AppElementService} from "../appElementService.service";
declare var UIkit: any;
@ -277,8 +276,7 @@ export class CommunityCreationInstructionsComponent {
private route: ActivatedRoute,
private _router: Router,
private _title: Title,
private _piwikService:PiwikService,
private appElementsService: AppElementService) {
private _piwikService:PiwikService) {
var description = "OpenAIRE - Connect, Community Dashboard, research community";
var title = "OpenAIRE - Connect | Create and manage your community page";
@ -345,7 +343,7 @@ export class CommunityCreationInstructionsComponent {
*/
/*UIkit.util.on('#logo', 'beforehide', function () {
// do something
if(this.hide == false) {
if(this.hide =http://www.equp4.wf/= false) {
return false;
}
});*/

View File

@ -1,7 +1,6 @@
import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Component} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import {Meta, Title} from '@angular/platform-browser';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {ZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/zenodo-communities.service';
import {SearchZenodoCommunitiesService} from '../../openaireLibrary/connect/zenodoCommunities/searchZenodoCommunities.service';
@ -9,9 +8,9 @@ import {CommunityService} from '../../openaireLibrary/connect/community/communit
import {ConnectHelper} from '../../openaireLibrary/connect/connectHelper';
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';
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'share-in-zenodo',
@ -34,15 +33,17 @@ export class ShareInZenodoComponent {
zenodocommunitiesloadedCount = 0;
zenodoSearchUtils: SearchUtilsClass = new SearchUtilsClass();
errorCodes: ErrorCodes = new ErrorCodes();;
errorCodes: ErrorCodes = new ErrorCodes();
depositLink = "https://zenodo.org/deposit/new?c=";
constructor (private element: ElementRef, private route: ActivatedRoute, private _router: Router,
private _meta: Meta, private _title: Title, private _ΖenodoCommunitieService: ZenodoCommunitiesService,private _communityService: CommunityService,private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {}
constructor(private route: ActivatedRoute, private _router: Router,
private _meta: Meta, private _title: Title, private _ΖenodoCommunitieService: ZenodoCommunitiesService, private _communityService: CommunityService, private _searchZenodoCommunitiesService: SearchZenodoCommunitiesService) {
}
public ngOnInit() {
this.zenodoSearchUtils.status = this.errorCodes.LOADING;;
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
;
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.updateUrl(data.envSpecific.baseLink + this._router.url);
@ -64,7 +65,7 @@ export class ShareInZenodoComponent {
this.community = community;
this.masterZenodoCommunityId = this.community.zenodoCommunity;
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
HelperFunctions.scroll();
}
if (this.masterZenodoCommunityId) {
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + this.masterZenodoCommunityId, null).subscribe(
@ -83,7 +84,8 @@ export class ShareInZenodoComponent {
}
);
}
this.zenodoSearchUtils.status = this.errorCodes.LOADING;;
this.zenodoSearchUtils.status = this.errorCodes.LOADING;
;
this._searchZenodoCommunitiesService.searchZCommunities(this.properties, this.communityId).subscribe(
result => {
this.CommunityIds = result;
@ -125,15 +127,18 @@ export class ShareInZenodoComponent {
this._meta.updateTag({content: description}, "name='description'");
this._meta.updateTag({content: description}, "property='og:description'");
}
private updateTitle(title: string) {
var _prefix = "OpenAIRE | ";
var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title);
this._meta.updateTag({content: _title}, "property='og:title'");
}
private updateUrl(url: string) {
this._meta.updateTag({content: url}, "property='og:url'");
}
getZenodoCommunityById(zenodoid, openaireId) {
this._ΖenodoCommunitieService.getZenodoCommunityById(this.properties, this.properties.zenodoCommunities + zenodoid, openaireId).subscribe(
result => {

View File

@ -1,4 +1,4 @@
import {Component, ElementRef, ViewChild} from "@angular/core";
import {Component, ViewChild} from "@angular/core";
import {SearchUtilsClass} from "../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ErrorMessagesComponent} from "../../openaireLibrary/utils/errorMessages.component";
import {ErrorCodes} from "../../openaireLibrary/utils/properties/errorCodes";
@ -11,11 +11,9 @@ import {CommunitiesService} from "../../openaireLibrary/connect/communities/comm
import {Session} from "../../openaireLibrary/login/utils/helper.class";
import {CommunityInfo} from "../../openaireLibrary/connect/community/communityInfo";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
import {Observable} from "rxjs";
import {StringUtils} from "../../openaireLibrary/utils/string-utils.class";
import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
import {catchError} from "rxjs/operators";
import {of} from "rxjs/observable/of";
import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'search-communities',
@ -51,7 +49,6 @@ export class SearchCommunitiesComponent {
constructor (private route: ActivatedRoute,
private _communitiesService: CommunitiesService,
private _subscribeService: SubscribeService,
private element: ElementRef,
private _piwikService: PiwikService) {
this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent();
@ -104,7 +101,6 @@ export class SearchCommunitiesComponent {
private initCommunities(params: Map<string, string>) {
this.subResults = this._communitiesService.getCommunitiesState().subscribe(
data => {
let observables: Observable<boolean>[] = [];
for(let i = 0; i < data.length; i++) {
this.totalResults[i] = data[i];
this.totalResults[i].isManager = false;
@ -113,18 +109,14 @@ export class SearchCommunitiesComponent {
//this.results[i].description = "EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation.EGI is a federated e-Infrastructure set up to provide advanced computing services for research and innovation."
//this.results[i].date = new Date(new Date(2012, 0, 1).getTime() + Math.random() * (new Date().getTime() - new Date(2012, 0, 1).getTime()));
if(Session.isLoggedIn()) {
let observable: Observable<boolean> = this._subscribeService.isSubscribedToCommunity(this.totalResults[i].communityId, Session.getUserEmail(), this.properties["adminToolsAPIURL"]);
observables.push(observable.pipe(catchError(err => {
return of(false);
})));
this.totalResults[i].isManager = this.isCommunityManager(this.totalResults[i]);
}
}
if (observables.length > 0) {
Observable.forkJoin(observables).subscribe(
if(Session.isLoggedIn()) {
this._subscribeService.getCommunitiesSubscribedTo(Session.getUserEmail(), this.properties["adminToolsAPIURL"]).subscribe(
res => {
for (let i = 0; i < res.length; i++) {
this.totalResults[i].isSubscribed = res[i];
for (let i = 0; i < this.totalResults.length; i++) {
this.totalResults[i].isSubscribed = (res.indexOf(this.totalResults[i].communityId) != -1);
}
this._getResults(params);
}
@ -138,7 +130,7 @@ export class SearchCommunitiesComponent {
this.handleError('Error getting communities', err);
this.searchUtils.status = this.errorMessages.getErrorCode(err.status);
this.disableForms = false;
this.scroll();
HelperFunctions.scroll();
}
);
}
@ -217,7 +209,7 @@ export class SearchCommunitiesComponent {
this.searchUtils.status = this.errorCodes.OUT_OF_BOUND;
}
}
this.scroll();
HelperFunctions.scroll();
}
@ -481,9 +473,4 @@ export class SearchCommunitiesComponent {
console.error('Communities Search Page: ' + message, error);
}
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
}

View File

@ -4,10 +4,8 @@ import {FormsModule} from "@angular/forms";
import {SearchCommunitiesComponent} from "./searchCommunities.component";
import {SearchPageModule} from "../../openaireLibrary/searchPages/searchUtils/searchPage.module";
import {SearchFormModule} from "../../openaireLibrary/searchPages/searchUtils/searchForm.module";
import {CommunitiesService} from "../../openaireLibrary/connect/communities/communities.service";
import {SearchCommunitiesRoutingModule} from "./searchCommunities-routing.module";
import {PreviousRouteRecorder} from "../../openaireLibrary/utils/piwik/previousRouteRecorder.guard";
import {SubscribeService} from "../../openaireLibrary/utils/subscribe/subscribe.service";
import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
@NgModule({
@ -19,7 +17,7 @@ import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service";
declarations: [
SearchCommunitiesComponent
],
providers:[ SubscribeService, PreviousRouteRecorder, PiwikService],
providers:[ PreviousRouteRecorder, PiwikService],
exports: [
SearchCommunitiesComponent
]

View File

@ -16,6 +16,7 @@ import {CommunityService} from "../../../openaire
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';
import {ErrorMessagesComponent} from '../../../openaireLibrary/utils/errorMessages.component';
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.class";
@Component({
selector: 'invite',
@ -59,7 +60,6 @@ export class InviteComponent implements OnInit {
private errorMessages: ErrorMessagesComponent;
constructor (
private element: ElementRef,
private route: ActivatedRoute,
private _router: Router,
public _fb: FormBuilder,
@ -112,22 +112,17 @@ export class InviteComponent implements OnInit {
});
this.scroll();
HelperFunctions.scroll();
});
}
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
public invite() {
this.successfulSentMessage = "";
this.failureSentMessage = "";
this.inviteErrorMessage = "";
this.status = this.errorCodes.LOADING;
this.scroll();
HelperFunctions.scroll();
if (!this.isEmpty(this.recipients) && this.body.fromName != "") {
if (this.validateEmails()) {
this.composeEmail();

View File

@ -1,4 +1,4 @@
import { NgModule} from '@angular/core';
import {ModuleWithProviders, NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule} from '@angular/router';
@ -16,11 +16,17 @@ import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.mod
declarations: [
SubscribeComponent
],
providers:[
SubscribeService, EmailService, CommunityService
],
exports: [
SubscribeComponent
]
})
export class SubscribeModule { }
export class SubscribeModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SubscribeModule,
providers: [
SubscribeService, EmailService, CommunityService
]
}
}
}