[Monitor Dashboard | Trunk]

code cleaning:
-remove unused imports, files
- add unsubscribe calls



git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@59847 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
Argiro Kokogiannaki 2020-11-13 16:42:12 +00:00
parent e839c41b49
commit 5404b8575a
46 changed files with 472 additions and 770 deletions

View File

@ -112,7 +112,7 @@ export class AppComponent implements OnInit, OnDestroy {
if (params && params['stakeholder']) { if (params && params['stakeholder']) {
this.stakeholder = this.stakeholderService.stakeholder; this.stakeholder = this.stakeholderService.stakeholder;
if (!this.stakeholder || this.stakeholderService.stakeholder.alias !== params['stakeholder']) { if (!this.stakeholder || this.stakeholderService.stakeholder.alias !== params['stakeholder']) {
this.stakeholderService.getStakeholder(params['stakeholder']).subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholder(params['stakeholder']).subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.stakeholder = stakeholder; this.stakeholder = stakeholder;
LinksResolver.setProperties(this.stakeholder.alias); LinksResolver.setProperties(this.stakeholder.alias);
@ -137,7 +137,7 @@ export class AppComponent implements OnInit, OnDestroy {
this.navigateToError(); this.navigateToError();
this.buildMenu(); this.buildMenu();
this.loading = false; this.loading = false;
}); }));
} else { } else {
this.buildMenu(); this.buildMenu();
if (isSearch) { if (isSearch) {
@ -177,6 +177,9 @@ export class AppComponent implements OnInit, OnDestroy {
value.unsubscribe(); value.unsubscribe();
} }
}); });
this.userManagementService.clearSubscriptions();
this.layoutService.clearSubscriptions();
this.stakeholderService.clearSubscriptions();
} }
private navigateToError() { private navigateToError() {

View File

@ -1,7 +1,7 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {HttpClientModule} from "@angular/common/http"; import {HTTP_INTERCEPTORS, HttpClientModule} from "@angular/common/http";
import {BrowserModule} from '@angular/platform-browser'; import {BrowserModule} from '@angular/platform-browser';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
@ -14,13 +14,13 @@ import {ErrorModule} from './openaireLibrary/error/error.module';
import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module'; import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module';
import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver';
import {SubscribeModule} from './utils/subscribe/subscribe.module';
import {UserMiniModule} from "./openaireLibrary/login/userMiniModule.module"; import {UserMiniModule} from "./openaireLibrary/login/userMiniModule.module";
import {SideBarModule} from "./openaireLibrary/dashboard/sharedComponents/sidebar/sideBar.module"; import {SideBarModule} from "./openaireLibrary/dashboard/sharedComponents/sidebar/sideBar.module";
import {SharedModule} from "./openaireLibrary/shared/shared.module"; import {SharedModule} from "./openaireLibrary/shared/shared.module";
import {Schema2jsonldModule} from "./openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module"; import {Schema2jsonldModule} from "./openaireLibrary/sharedComponents/schema2jsonld/schema2jsonld.module";
import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-verification.module"; import {RoleVerificationModule} from "./openaireLibrary/role-verification/role-verification.module";
import {LoadingModule} from "./openaireLibrary/utils/loading/loading.module"; import {LoadingModule} from "./openaireLibrary/utils/loading/loading.module";
import {DEFAULT_TIMEOUT, TimeoutInterceptor} from "./openaireLibrary/timeout-interceptor.service";
@NgModule({ @NgModule({
@ -34,14 +34,15 @@ import {LoadingModule} from "./openaireLibrary/utils/loading/loading.module";
NavigationBarModule, NavigationBarModule,
BottomModule, BottomModule,
CookieLawModule, CookieLawModule,
SubscribeModule.forRoot(),
BrowserModule.withServerTransition({appId: 'my-app'}), BrowserModule.withServerTransition({appId: 'my-app'}),
AppRoutingModule, AppRoutingModule,
UserMiniModule, SideBarModule, Schema2jsonldModule, RoleVerificationModule, LoadingModule UserMiniModule, SideBarModule, Schema2jsonldModule, RoleVerificationModule, LoadingModule
], ],
declarations: [AppComponent, OpenaireErrorPageComponent], declarations: [AppComponent, OpenaireErrorPageComponent],
exports: [AppComponent], exports: [AppComponent],
providers: [EnvironmentSpecificResolver], providers: [EnvironmentSpecificResolver,
[{ provide: HTTP_INTERCEPTORS, useClass: TimeoutInterceptor, multi: true }],
[{ provide: DEFAULT_TIMEOUT, useValue: 30000 }]],
bootstrap: [AppComponent] bootstrap: [AppComponent]
}) })
// //

View File

@ -3,7 +3,7 @@ import {Stakeholder} from "../../openaireLibrary/monitor/entities/stakeholder";
import {FormBuilder, FormGroup, Validators} from "@angular/forms"; import {FormBuilder, FormGroup, Validators} from "@angular/forms";
import {StakeholderUtils} from "../../utils/indicator-utils"; import {StakeholderUtils} from "../../utils/indicator-utils";
import {Option} from "../../openaireLibrary/sharedComponents/input/input.component"; import {Option} from "../../openaireLibrary/sharedComponents/input/input.component";
import {Subscription} from "rxjs"; import {Subscriber, Subscription} from "rxjs";
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties"; import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
import {properties} from "../../../environments/environment"; import {properties} from "../../../environments/environment";
import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../openaireLibrary/monitor/services/stakeholder.service";
@ -242,7 +242,7 @@ export class EditStakeholderComponent implements OnDestroy {
public save(callback: Function, errorCallback: Function = null) { public save(callback: Function, errorCallback: Function = null) {
if (this.file) { if (this.file) {
this.utilsService.uploadPhoto(this.properties.utilsService + "/upload/stakeholder/" + encodeURIComponent(this.stakeholderFb.value.alias), this.file).subscribe(res => { this.subscriptions.push(this.utilsService.uploadPhoto(this.properties.utilsService + "/upload/stakeholder/" + encodeURIComponent(this.stakeholderFb.value.alias), this.file).subscribe(res => {
this.deletePhoto(); this.deletePhoto();
this.removePhoto(); this.removePhoto();
this.stakeholderFb.get('logoUrl').setValue(res.filename); this.stakeholderFb.get('logoUrl').setValue(res.filename);
@ -250,7 +250,7 @@ export class EditStakeholderComponent implements OnDestroy {
}, error => { }, error => {
this.uploadError = "An error has been occurred during upload your image. Try again later"; this.uploadError = "An error has been occurred during upload your image. Try again later";
this.saveStakeholder(callback, errorCallback); this.saveStakeholder(callback, errorCallback);
}); }));
} else if (this.deleteCurrentPhoto) { } else if (this.deleteCurrentPhoto) {
this.deletePhoto(); this.deletePhoto();
this.saveStakeholder(callback, errorCallback); this.saveStakeholder(callback, errorCallback);
@ -267,7 +267,7 @@ export class EditStakeholderComponent implements OnDestroy {
(stakeholder ? stakeholder.topics : []))); (stakeholder ? stakeholder.topics : [])));
} }
this.removePhoto(); this.removePhoto();
this.stakeholderService.buildStakeholder(this.properties.monitorServiceAPIURL, this.subscriptions.push(this.stakeholderService.buildStakeholder(this.properties.monitorServiceAPIURL,
this.stakeholderFb.value).subscribe(stakeholder => { this.stakeholderFb.value).subscribe(stakeholder => {
UIkit.notification(stakeholder.name + '\'s has been successfully created', { UIkit.notification(stakeholder.name + '\'s has been successfully created', {
status: 'success', status: 'success',
@ -284,14 +284,14 @@ export class EditStakeholderComponent implements OnDestroy {
if (errorCallback) { if (errorCallback) {
errorCallback(error) errorCallback(error)
} }
}); }));
} else { } else {
this.stakeholderFb.get('type').enable(); this.stakeholderFb.get('type').enable();
this.stakeholderFb.get('alias').enable(); this.stakeholderFb.get('alias').enable();
this.stakeholderFb.get('index_id').enable(); this.stakeholderFb.get('index_id').enable();
this.stakeholderFb.get('index_name').enable(); this.stakeholderFb.get('index_name').enable();
this.stakeholderFb.get('index_shortName').enable(); this.stakeholderFb.get('index_shortName').enable();
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.stakeholderFb.value).subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.stakeholderFb.value).subscribe(stakeholder => {
UIkit.notification(stakeholder.name + '\'s has been successfully saved', { UIkit.notification(stakeholder.name + '\'s has been successfully saved', {
status: 'success', status: 'success',
timeout: 3000, timeout: 3000,
@ -304,7 +304,7 @@ export class EditStakeholderComponent implements OnDestroy {
timeout: 3000, timeout: 3000,
pos: 'top-left' pos: 'top-left'
}); });
}); }));
} }
} }
@ -362,7 +362,7 @@ export class EditStakeholderComponent implements OnDestroy {
public deletePhoto() { public deletePhoto() {
if (this.stakeholder.logoUrl) { if (this.stakeholder.logoUrl) {
this.utilsService.deletePhoto(this.properties.utilsService + '/delete/stakeholder/' + this.stakeholder.logoUrl).subscribe(); this.subscriptions.push(this.utilsService.deletePhoto(this.properties.utilsService + '/delete/stakeholder/' + this.stakeholder.logoUrl).subscribe());
} }
} }
} }

View File

@ -1,17 +1,8 @@
import {Component, OnDestroy, OnInit, ViewChild} from "@angular/core"; import {Component, OnDestroy, OnInit, ViewChild} from "@angular/core";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties"; import {EnvProperties} from "../openaireLibrary/utils/properties/env-properties";
import {EnvironmentSpecificService} from "../openaireLibrary/utils/properties/environment-specific.service";
import {Stakeholder} from "../openaireLibrary/monitor/entities/stakeholder"; import {Stakeholder} from "../openaireLibrary/monitor/entities/stakeholder";
import {Subscriber, Subscription, zip} from "rxjs"; import { Subscription, zip} from "rxjs";
import {StakeholderUtils} from "../utils/indicator-utils";
import {FormBuilder, FormGroup, Validators} from "@angular/forms";
import {AlertModal} from "../openaireLibrary/utils/modal/alert";
import {Option} from "../openaireLibrary/sharedComponents/input/input.component";
import {Title} from "@angular/platform-browser";
import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {Session} from "../openaireLibrary/login/utils/helper.class";
import {UtilitiesService} from "../openaireLibrary/services/utilities.service";
import {EditStakeholderComponent} from "./edit-stakeholder/edit-stakeholder.component"; import {EditStakeholderComponent} from "./edit-stakeholder/edit-stakeholder.component";
import {properties} from "../../environments/environment"; import {properties} from "../../environments/environment";

View File

@ -11,6 +11,6 @@ import {AdminDashboardGuard} from "../utils/adminDashboard.guard";
CommonModule, RouterModule, CommonModule, RouterModule,
NewPageHelpContentRoutingModule, NewPageHelpContentModule NewPageHelpContentRoutingModule, NewPageHelpContentModule
], ],
providers: [ AdminDashboardGuard], providers: [AdminDashboardGuard],
}) })
export class MonitorNewPageHelpContentModule { } export class MonitorNewPageHelpContentModule { }

View File

@ -9,12 +9,11 @@ import { UserModule} from '../openaireLibrary/login/user.module';
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import { SubscribeService } from '../openaireLibrary/utils/subscribe/subscribe.service'; import { SubscribeService } from '../openaireLibrary/utils/subscribe/subscribe.service';
import {EmailService} from "../openaireLibrary/utils/email/email.service"; import {EmailService} from "../openaireLibrary/utils/email/email.service";
import {SubscribeModule} from "../utils/subscribe/subscribe.module";
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, CommonModule, FormsModule,
UserRoutingModule, UserModule, SubscribeModule UserRoutingModule, UserModule
], ],
providers:[PreviousRouteRecorder, SubscribeService, EmailService], providers:[PreviousRouteRecorder, SubscribeService, EmailService],
declarations: [ declarations: [

View File

@ -1,106 +1,10 @@
import {Component, ElementRef, ViewChild} from '@angular/core'; import {Component} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute} from '@angular/router';
import {UserComponent} from '../openaireLibrary/login/user.component';
import {SubscribeService} from '../openaireLibrary/utils/subscribe/subscribe.service';
import {EmailService} from "../openaireLibrary/utils/email/email.service";
import {Email} from "../openaireLibrary/utils/email/email";
import {Session} from '../openaireLibrary/login/utils/helper.class';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {SubscribeComponent} from '../utils/subscribe/subscribe.component';
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
@Component({ @Component({
selector: 'openaire-user', selector: 'openaire-user',
template: ` template: `<user></user>`
<div id="tm-main" class="uk-section uk-margin-small-top tm-middle">
<user [mainComponent]=false></user>
<div *ngIf="!server" class=" uk-container uk-container-small uk-position-relative">
<div *ngIf="usercomponent.errorCode == '6' && !isSubscribed" class="uk-alert uk-alert-warning">
<span *ngIf="!isSubscribed ">For this action you have to <span *ngIf="!loggedIn">login and</span> subscribe to the research community.
<span *ngIf="subscribe && !subscribeLoading "> <span *ngIf="!loggedIn">Login and </span>Subscribe <a [class]="'' + (subscribe.loading ? ' uk-disabled' : '')" (click)="subscribeTo()" > here</a>.</span>
</span>
<span *ngIf="subscribeLoading ">Subscribing to community....</span>
<span *ngIf="subscribeError ">An error occured while trying to subscribe to community....</span>
</div>
<div *ngIf="usercomponent.errorCode == '7'" class="uk-alert uk-alert-warning">
This action requires authentication.
<span *ngIf="!loggedIn">
Please <a class="" (click)="login()" > sign in</a> to continue.
</span>
</div>
</div>
</div>
<subscribe [communityId]="communityId" [showTemplate]= false class="" (subscribeEvent)="afterSubscibeEvent($event)"></subscribe>
`
}) })
export class OpenaireUserComponent { export class OpenaireUserComponent {
@ViewChild(UserComponent) usercomponent:UserComponent;
@ViewChild(SubscribeComponent) subscribe:SubscribeComponent;
properties:EnvProperties;
communityId = null;
subscribeLoading:boolean = false;
subscribeError:boolean = false;
isSubscribed:boolean = false;
public server: boolean = true;
loggedIn:boolean = false;
constructor(private _subscribeService: SubscribeService,
private _emailService: EmailService, private route: ActivatedRoute){}
public ngOnInit() {
if( typeof document !== 'undefined') {
this.server = false;
this.loggedIn = Session.isLoggedIn();
}
this.route.data
.subscribe((data: { envSpecific: any }) => {
this.route.queryParams.subscribe(
communityId => {
this.communityId = ConnectHelper.getCommunityFromDomain(data.envSpecific.domain);
if(!this.communityId) {
this.communityId = communityId['communityId'];
}
if(this.subscribe.subscribed){
this.usercomponent.redirect();
}
});
});
}
login(){
this.usercomponent.logIn();
}
subscribeTo(){
if(this.subscribe && this.communityId){
this.subscribeLoading = true;
this.subscribe.subscribe();
}
}
afterSubscibeEvent($event){
var res = $event.value;
this.subscribeLoading = false;
this.isSubscribed = this.subscribe.subscribed;
if(res == "ok"){
this.isSubscribed = true;
this.usercomponent.redirect();
}else{
this.subscribeError = true;
}
}
} }

View File

@ -12,7 +12,7 @@ import {Title} from "@angular/platform-browser";
import {UserManagementService} from "../openaireLibrary/services/user-management.service"; import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {Session} from "../openaireLibrary/login/utils/helper.class"; import {Session} from "../openaireLibrary/login/utils/helper.class";
import {EditStakeholderComponent} from "../general/edit-stakeholder/edit-stakeholder.component"; import {EditStakeholderComponent} from "../general/edit-stakeholder/edit-stakeholder.component";
import {StringUtils} from "../openaireLibrary/utils/string-utils.class"; import {properties} from "../../environments/environment";
declare var UIkit; declare var UIkit;
@ -66,25 +66,23 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
ngOnInit(): void { ngOnInit(): void {
this.buildFilters(); this.buildFilters();
this.propertiesService.loadEnvironment()
.then(properties => {
this.properties = properties; this.properties = properties;
this.title.setTitle('Manage profiles'); this.title.setTitle('Manage profiles');
this.userManagementService.getUserInfo().subscribe(user => { this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
}); }));
let data = zip( let data = zip(
this.stakeholderService.getDefaultStakeholders(this.properties.monitorServiceAPIURL), this.stakeholderService.getDefaultStakeholders(this.properties.monitorServiceAPIURL),
this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL) this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL)
); );
data.subscribe(res => { this.subscriptions.push(data.subscribe(res => {
this.defaultStakeholders = res[0]; this.defaultStakeholders = res[0];
this.stakeholders = res[1]; this.stakeholders = res[1];
this.displayDefaultStakeholders = res[0]; this.displayDefaultStakeholders = res[0];
this.displayStakeholders = res[1]; this.displayStakeholders = res[1];
this.loading = false; this.loading = false;
}); }));
});
this.subscriptions.push(UIkit.util.on(document, 'hidden', '#edit_modal', (): void => { this.subscriptions.push(UIkit.util.on(document, 'hidden', '#edit_modal', (): void => {
this.editStakeholderComponent.removePhoto(); this.editStakeholderComponent.removePhoto();
})); }));
@ -204,7 +202,7 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
} else { } else {
this.index = (this.stakeholder) ? this.stakeholders.findIndex(value => value._id === this.stakeholder._id) : -1; this.index = (this.stakeholder) ? this.stakeholders.findIndex(value => value._id === this.stakeholder._id) : -1;
} }
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, [this.stakeholder._id]).subscribe(() => { this.subscriptions.push(this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, [this.stakeholder._id]).subscribe(() => {
UIkit.notification(this.stakeholder.name+ ' has been successfully deleted', { UIkit.notification(this.stakeholder.name+ ' has been successfully deleted', {
status: 'success', status: 'success',
timeout: 3000, timeout: 3000,
@ -221,14 +219,14 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
timeout: 3000, timeout: 3000,
pos: 'top-left' pos: 'top-left'
}); });
}); }));
} }
changeStakeholderStatus(stakeholder: Stakeholder, visibility: Visibility) { changeStakeholderStatus(stakeholder: Stakeholder, visibility: Visibility) {
let path = [ let path = [
stakeholder._id stakeholder._id
]; ];
this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => { this.subscriptions.push(this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
stakeholder.visibility = visibility; stakeholder.visibility = visibility;
UIkit.notification(stakeholder.name+ '\'s status has been successfully changed to ' + stakeholder.visibility.toLowerCase(), { UIkit.notification(stakeholder.name+ '\'s status has been successfully changed to ' + stakeholder.visibility.toLowerCase(), {
status: 'success', status: 'success',
@ -241,7 +239,7 @@ export class ManageStakeholdersComponent implements OnInit, OnDestroy {
timeout: 3000, timeout: 3000,
pos: 'top-left' pos: 'top-left'
}); });
}); }));
} }
public isManager(): boolean { public isManager(): boolean {

View File

@ -1,6 +1,5 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {MonitorComponent} from "./monitor.component"; import {MonitorComponent} from "./monitor.component";
import {EnvironmentSpecificResolver} from "../openaireLibrary/utils/properties/environmentSpecificResolver"; import {EnvironmentSpecificResolver} from "../openaireLibrary/utils/properties/environmentSpecificResolver";
@ -12,7 +11,6 @@ import {EnvironmentSpecificResolver} from "../openaireLibrary/utils/properties/e
{ {
path: ':stakeholder', path: ':stakeholder',
component: MonitorComponent, component: MonitorComponent,
canActivate: [FreeGuard],
canDeactivate: [PreviousRouteRecorder] canDeactivate: [PreviousRouteRecorder]
}, },
{ {
@ -23,19 +21,16 @@ import {EnvironmentSpecificResolver} from "../openaireLibrary/utils/properties/e
{ {
path: ':stakeholder/:topic', path: ':stakeholder/:topic',
component: MonitorComponent, component: MonitorComponent,
canActivate: [FreeGuard],
canDeactivate: [PreviousRouteRecorder] canDeactivate: [PreviousRouteRecorder]
}, },
{ {
path: ':stakeholder/:topic/:category', path: ':stakeholder/:topic/:category',
component: MonitorComponent, component: MonitorComponent,
canActivate: [FreeGuard],
canDeactivate: [PreviousRouteRecorder] canDeactivate: [PreviousRouteRecorder]
}, },
{ {
path: ':stakeholder/:topic/:category/:subCategory', path: ':stakeholder/:topic/:category/:subCategory',
component: MonitorComponent, component: MonitorComponent,
canActivate: [FreeGuard],
canDeactivate: [PreviousRouteRecorder] canDeactivate: [PreviousRouteRecorder]
} }
]) ])

View File

@ -22,11 +22,11 @@ import {StatisticsService} from "../utils/services/statistics.service";
import {IndicatorUtils, StakeholderUtils} from "../utils/indicator-utils"; import {IndicatorUtils, StakeholderUtils} from "../utils/indicator-utils";
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {FormBuilder, FormControl} from "@angular/forms"; import {FormBuilder, FormControl} from "@angular/forms";
import {Subscription} from "rxjs"; import {Subscriber, Subscription} from "rxjs";
import {Session, User} from "../openaireLibrary/login/utils/helper.class"; import {User} from "../openaireLibrary/login/utils/helper.class";
import {UserManagementService} from "../openaireLibrary/services/user-management.service"; import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {RangeFilter} from "../openaireLibrary/utils/rangeFilter/rangeFilterHelperClasses.class"; import {RangeFilter} from "../openaireLibrary/utils/rangeFilter/rangeFilterHelperClasses.class";
import {Filter, Value} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class"; import {Filter} from "../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class";
import {Location} from "@angular/common"; import {Location} from "@angular/common";
import {RouterHelper} from "../openaireLibrary/utils/routerHelper.class"; import {RouterHelper} from "../openaireLibrary/utils/routerHelper.class";
import {properties} from "../../environments/environment"; import {properties} from "../../environments/environment";
@ -76,8 +76,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
private layoutService: LayoutService, private layoutService: LayoutService,
private seoService: SEOService, private seoService: SEOService,
private cdr: ChangeDetectorRef, private cdr: ChangeDetectorRef,
private sanitizer: DomSanitizer, private _fb: FormBuilder, private router: Router, private sanitizer: DomSanitizer, private _fb: FormBuilder, private router: Router) {
private location: Location) {
this.errorCodes = new ErrorCodes(); this.errorCodes = new ErrorCodes();
this.errorMessages = new ErrorMessagesComponent(); this.errorMessages = new ErrorMessagesComponent();
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
@ -85,15 +84,15 @@ export class MonitorComponent implements OnInit, OnDestroy {
public ngOnInit() { public ngOnInit() {
this.keyword = this._fb.control(''); this.keyword = this._fb.control('');
this.keyword.valueChanges.subscribe(value => { this.subscriptions.push(this.keyword.valueChanges.subscribe(value => {
console.log("Keyword Changed!"); console.log("Keyword Changed!");
//TODO do a real action //TODO do a real action
}); }));
let subscription: Subscription; let subscription: Subscription;
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
this.loading = true; this.loading = true;
this.activeTopic = null; this.activeTopic = null;
this.activeCategory = null; this.activeCategory = null;
@ -103,10 +102,10 @@ export class MonitorComponent implements OnInit, OnDestroy {
subscription.unsubscribe(); subscription.unsubscribe();
} }
var url = properties.domain + properties.baseLink + this._router.url; var url = properties.domain + properties.baseLink + this._router.url;
this.route.queryParams.subscribe(params => { this.subscriptions.push(this.route.queryParams.subscribe(params => {
this.queryParams = Object.assign({}, params); this.queryParams = Object.assign({}, params);
this.isViewPublic = (params['view'] == 'public'); this.isViewPublic = (params['view'] == 'public');
}); }));
if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) { if (!this.stakeholder || this.stakeholder.alias !== params['stakeholder']) {
this.status = this.errorCodes.LOADING; this.status = this.errorCodes.LOADING;
this.numberResults = new Map<string, number>(); this.numberResults = new Map<string, number>();
@ -138,7 +137,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
this._meta.updateTag({content: title}, "property='og:title'"); this._meta.updateTag({content: title}, "property='og:title'");
this._title.setTitle(title); this._title.setTitle(title);
if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) { if (this.properties.enablePiwikTrack && (typeof document !== 'undefined')) {
this.piwiksub = this._piwikService.trackView(this.properties, title, this.properties.piwikSiteId).subscribe(); this.subscriptions.push(this._piwikService.trackView(this.properties, title, this.properties.piwikSiteId).subscribe());
} }
if(this.isPublicOrIsMember(stakeholder.visibility)) { if(this.isPublicOrIsMember(stakeholder.visibility)) {
//this.getDivContents(); //this.getDivContents();
@ -160,7 +159,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
this.initializeFilters(); this.initializeFilters();
this.setView(params); this.setView(params);
} }
}); }));
})); }));
} }
@ -245,15 +244,15 @@ export class MonitorComponent implements OnInit, OnDestroy {
} }
private getPageContents() { private getPageContents() {
this.helper.getPageHelpContents(this.properties, 'monitor', this._router.url).subscribe(contents => { this.subscriptions.push(this.helper.getPageHelpContents(this.properties, 'monitor', this._router.url).subscribe(contents => {
this.pageContents = contents; this.pageContents = contents;
}) }));
} }
private getDivContents() { private getDivContents() {
this.helper.getDivHelpContents(this.properties, 'monitor', this._router.url).subscribe(contents => { this.subscriptions.push(this.helper.getDivHelpContents(this.properties, 'monitor', this._router.url).subscribe(contents => {
this.divContents = contents; this.divContents = contents;
}) }));
} }
private setView(params: Params) { private setView(params: Params) {
@ -379,7 +378,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
}); });
urls.forEach((indexes, pair) => { urls.forEach((indexes, pair) => {
pair = JSON.parse(pair); pair = JSON.parse(pair);
this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => { this.subscriptions.push(this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => {
indexes.forEach(([i, j]) => { indexes.forEach(([i, j]) => {
let result = JSON.parse(JSON.stringify(response)); let result = JSON.parse(JSON.stringify(response));
this.activeSubCategory.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => { this.activeSubCategory.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => {
@ -389,7 +388,7 @@ export class MonitorComponent implements OnInit, OnDestroy {
}); });
this.numberResults.set(i + '-' + j, result); this.numberResults.set(i + '-' + j, result);
}); });
}) }));
}); });
this.activeSubCategory.charts.forEach((section, i) => { this.activeSubCategory.charts.forEach((section, i) => {
section.indicators.forEach((indicator, j) => { section.indicators.forEach((indicator, j) => {
@ -433,6 +432,11 @@ export class MonitorComponent implements OnInit, OnDestroy {
if (this.piwiksub) { if (this.piwiksub) {
this.piwiksub.unsubscribe(); this.piwiksub.unsubscribe();
} }
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
} }
public isPublicOrIsMember(visibility: Visibility): boolean { public isPublicOrIsMember(visibility: Visibility): boolean {

View File

@ -3,7 +3,6 @@ import {CommonModule} from '@angular/common';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {RouterModule} from '@angular/router'; import {RouterModule} from '@angular/router';
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';
@ -33,7 +32,7 @@ import {PageContentModule} from "../openaireLibrary/dashboard/sharedComponents/p
MonitorComponent MonitorComponent
], ],
providers: [ providers: [
FreeGuard, PreviousRouteRecorder, PreviousRouteRecorder,
PiwikService, PiwikService,
StatisticsService StatisticsService
], ],

View File

@ -3,11 +3,12 @@ import {RouterModule} from '@angular/router';
import {PagesComponent} from "../openaireLibrary/dashboard/page/pages.component"; import {PagesComponent} from "../openaireLibrary/dashboard/page/pages.component";
import {IsCommunityOrAdmin} from "../openaireLibrary/connect/communityGuard/isCommunityOrAdmin"; import {IsCommunityOrAdmin} from "../openaireLibrary/connect/communityGuard/isCommunityOrAdmin";
import {AdminDashboardGuard} from "../utils/adminDashboard.guard"; import {AdminDashboardGuard} from "../utils/adminDashboard.guard";
import {LoginGuard} from "../openaireLibrary/login/loginGuard.guard";
@NgModule({ @NgModule({
imports: [ imports: [
RouterModule.forChild([ RouterModule.forChild([
{ path: '', canActivate: [IsCommunityOrAdmin, AdminDashboardGuard], component: PagesComponent} { path: '', canActivate: [LoginGuard,IsCommunityOrAdmin, AdminDashboardGuard], component: PagesComponent}
]) ])
] ]
}) })

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-dataprovider', selector: 'monitor-dataprovider',
@ -16,16 +17,23 @@ export class MonitorDataProviderComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -2,14 +2,13 @@ import { NgModule} from '@angular/core';
import { DataProviderModule } from '../../../openaireLibrary/landingPages/dataProvider/dataProvider.module'; import { DataProviderModule } from '../../../openaireLibrary/landingPages/dataProvider/dataProvider.module';
import { MonitorDataProviderComponent } from './dataProvider.component'; import { MonitorDataProviderComponent } from './dataProvider.component';
import {DataProviderRoutingModule} from './dataProvider-routing.module'; import {DataProviderRoutingModule} from './dataProvider-routing.module';
import {FreeGuard} from '../../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {CommonModule} from "@angular/common"; import {CommonModule} from "@angular/common";
@NgModule({ @NgModule({
imports: [DataProviderModule, DataProviderRoutingModule, CommonModule], imports: [DataProviderModule, DataProviderRoutingModule, CommonModule],
declarations:[MonitorDataProviderComponent], declarations:[MonitorDataProviderComponent],
providers:[FreeGuard, PreviousRouteRecorder], providers:[ PreviousRouteRecorder],
exports:[MonitorDataProviderComponent] exports:[MonitorDataProviderComponent]
}) })
export class LibDataProviderModule { } export class LibDataProviderModule { }

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-dataset', selector: 'monitor-dataset',
@ -17,17 +18,24 @@ export class MonitorDatasetComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -1,6 +1,5 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {MonitorDatasetComponent} from './dataset.component'; import {MonitorDatasetComponent} from './dataset.component';
import {FreeGuard} from '../../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {DatasetRoutingModule} from './dataset-routing.module'; import {DatasetRoutingModule} from './dataset-routing.module';
import {ResultLandingModule} from "../../../openaireLibrary/landingPages/result/resultLanding.module"; import {ResultLandingModule} from "../../../openaireLibrary/landingPages/result/resultLanding.module";
@ -9,7 +8,7 @@ import {CommonModule} from "@angular/common";
@NgModule({ @NgModule({
imports: [DatasetRoutingModule, ResultLandingModule, CommonModule], imports: [DatasetRoutingModule, ResultLandingModule, CommonModule],
declarations:[MonitorDatasetComponent], declarations:[MonitorDatasetComponent],
providers:[FreeGuard, PreviousRouteRecorder], providers:[PreviousRouteRecorder],
exports:[MonitorDatasetComponent] exports:[MonitorDatasetComponent]
}) })
export class LibDatasetModule { } export class LibDatasetModule { }

View File

@ -1,6 +1,5 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {OrganizationModule} from '../../../openaireLibrary/landingPages/organization/organization.module'; import {OrganizationModule} from '../../../openaireLibrary/landingPages/organization/organization.module';
import {FreeGuard} from '../../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {MonitorOrganizationComponent} from './organization.component'; import {MonitorOrganizationComponent} from './organization.component';
import {OrganizationRoutingModule} from './organization-routing.module'; import {OrganizationRoutingModule} from './organization-routing.module';
@ -9,7 +8,7 @@ import {CommonModule} from "@angular/common";
@NgModule({ @NgModule({
imports: [OrganizationModule, OrganizationRoutingModule, CommonModule], imports: [OrganizationModule, OrganizationRoutingModule, CommonModule],
declarations:[MonitorOrganizationComponent], declarations:[MonitorOrganizationComponent],
providers:[FreeGuard, PreviousRouteRecorder], providers:[ PreviousRouteRecorder],
exports:[MonitorOrganizationComponent] exports:[MonitorOrganizationComponent]
}) })
export class LibOrganizationModule { } export class LibOrganizationModule { }

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-organization', selector: 'monitor-organization',
@ -16,16 +17,23 @@ export class MonitorOrganizationComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -1,5 +1,4 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {FreeGuard} from '../../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {MonitorOrpComponent} from './orp.component'; import {MonitorOrpComponent} from './orp.component';
import {OrpRoutingModule} from './orp-routing.module'; import {OrpRoutingModule} from './orp-routing.module';
@ -14,7 +13,7 @@ import {CommonModule} from "@angular/common";
MonitorOrpComponent MonitorOrpComponent
], ],
providers: [ providers: [
FreeGuard, PreviousRouteRecorder PreviousRouteRecorder
], ],
exports: [ exports: [
MonitorOrpComponent MonitorOrpComponent

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-orp', selector: 'monitor-orp',
@ -18,16 +19,23 @@ export class MonitorOrpComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -1,6 +1,5 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {ProjectModule} from '../../../openaireLibrary/landingPages/project/project.module'; import {ProjectModule} from '../../../openaireLibrary/landingPages/project/project.module';
import {FreeGuard} from '../../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {MonitorProjectComponent} from './project.component'; import {MonitorProjectComponent} from './project.component';
import {ProjectRoutingModule} from './project-routing.module'; import {ProjectRoutingModule} from './project-routing.module';
@ -9,7 +8,7 @@ import {CommonModule} from "@angular/common";
@NgModule({ @NgModule({
imports: [ProjectModule, ProjectRoutingModule, CommonModule], imports: [ProjectModule, ProjectRoutingModule, CommonModule],
declarations:[MonitorProjectComponent], declarations:[MonitorProjectComponent],
providers:[FreeGuard, PreviousRouteRecorder], providers:[PreviousRouteRecorder],
exports:[MonitorProjectComponent] exports:[MonitorProjectComponent]
}) })
export class LibProjectModule { } export class LibProjectModule { }

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-project', selector: 'monitor-project',
@ -16,17 +17,24 @@ export class MonitorProjectComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -1,5 +1,4 @@
import { NgModule} from '@angular/core'; import { NgModule} from '@angular/core';
import {FreeGuard} from '../../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import { MonitorPublicationComponent } from './publication.component'; import { MonitorPublicationComponent } from './publication.component';
import {PublicationRoutingModule} from './publication-routing.module'; import {PublicationRoutingModule} from './publication-routing.module';
@ -9,7 +8,7 @@ import {CommonModule} from "@angular/common";
@NgModule({ @NgModule({
imports: [PublicationRoutingModule, ResultLandingModule, CommonModule], imports: [PublicationRoutingModule, ResultLandingModule, CommonModule],
declarations:[MonitorPublicationComponent], declarations:[MonitorPublicationComponent],
providers:[FreeGuard, PreviousRouteRecorder], providers:[PreviousRouteRecorder],
exports:[MonitorPublicationComponent] exports:[MonitorPublicationComponent]
}) })
export class LibPublicationModule { } export class LibPublicationModule { }

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-publication', selector: 'monitor-publication',
@ -17,16 +18,23 @@ export class MonitorPublicationComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -1,5 +1,4 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {FreeGuard} from '../../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {MonitorResultComponent} from './result.component'; import {MonitorResultComponent} from './result.component';
import {ResultRoutingModule} from './result-routing.module'; import {ResultRoutingModule} from './result-routing.module';
@ -9,7 +8,7 @@ import {CommonModule} from "@angular/common";
@NgModule({ @NgModule({
imports: [ResultRoutingModule, ResultLandingModule, CommonModule], imports: [ResultRoutingModule, ResultLandingModule, CommonModule],
declarations:[MonitorResultComponent], declarations:[MonitorResultComponent],
providers:[FreeGuard, PreviousRouteRecorder], providers:[PreviousRouteRecorder],
exports:[MonitorResultComponent] exports:[MonitorResultComponent]
}) })
export class LibResultModule { } export class LibResultModule { }

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-result', selector: 'monitor-result',
@ -16,16 +17,23 @@ export class MonitorResultComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -1,5 +1,4 @@
import { NgModule} from '@angular/core'; import { NgModule} from '@angular/core';
import {FreeGuard} from '../../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import { MonitorSoftwareComponent } from './software.component'; import { MonitorSoftwareComponent } from './software.component';
import {SoftwareRoutingModule} from './software-routing.module'; import {SoftwareRoutingModule} from './software-routing.module';
@ -8,7 +7,7 @@ import {CommonModule} from "@angular/common";
@NgModule({ @NgModule({
imports: [SoftwareRoutingModule, ResultLandingModule, CommonModule], imports: [SoftwareRoutingModule, ResultLandingModule, CommonModule],
declarations:[MonitorSoftwareComponent], declarations:[MonitorSoftwareComponent],
providers:[FreeGuard, PreviousRouteRecorder], providers:[ PreviousRouteRecorder],
exports:[MonitorSoftwareComponent] exports:[MonitorSoftwareComponent]
}) })
export class LibSoftwareModule { } export class LibSoftwareModule { }

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-software', selector: 'monitor-software',
@ -17,16 +18,23 @@ export class MonitorSoftwareComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -2,6 +2,7 @@ import {Component} from '@angular/core';
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-advanced-search-dataproviders', selector: 'monitor-advanced-search-dataproviders',
@ -22,11 +23,19 @@ export class MonitorAdvancedSearchDataprovidersComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
if (stakeholder.type === "organization") { if (stakeholder.type === "organization") {
let value = stakeholder.index_id; let value = stakeholder.index_id;
@ -45,12 +54,9 @@ export class MonitorAdvancedSearchDataprovidersComponent {
} }
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
navigateToError() {
this.router.navigate(['/error'], {queryParams: {'page': this.router.url}});
}
} }

View File

@ -2,6 +2,7 @@ import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-advanced-search-organizations', selector: 'monitor-advanced-search-organizations',
@ -20,11 +21,19 @@ export class MonitorAdvancedSearchOrganizationsComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
if (stakeholder.type === "funder") { if (stakeholder.type === "funder") {
let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName; let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName;
@ -41,8 +50,8 @@ export class MonitorAdvancedSearchOrganizationsComponent {
} }
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -2,6 +2,7 @@ import {Component} from '@angular/core';
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-advanced-search-projects', selector: 'monitor-advanced-search-projects',
@ -23,11 +24,19 @@ export class MonitorAdvancedSearchProjectsComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
if (stakeholder.type === "funder") { if (stakeholder.type === "funder") {
let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName; let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName;
@ -48,12 +57,9 @@ export class MonitorAdvancedSearchProjectsComponent {
} }
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
navigateToError() {
this.router.navigate(['/error'], {queryParams: {'page': this.router.url}});
}
} }

View File

@ -2,6 +2,7 @@ import {Component} from '@angular/core';
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-advanced-search-results', selector: 'monitor-advanced-search-results',
@ -22,11 +23,19 @@ export class MonitorAdvancedSearchResearchResultsComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
if (stakeholder.type === "funder") { if (stakeholder.type === "funder") {
let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName; let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName;
@ -46,8 +55,8 @@ export class MonitorAdvancedSearchResearchResultsComponent {
} }
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -2,6 +2,7 @@ import {Component} from '@angular/core';
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-search-dataproviders', selector: 'monitor-search-dataproviders',
@ -22,11 +23,19 @@ export class MonitorSearchDataprovidersComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
if (stakeholder.type === "funder") { if (stakeholder.type === "funder") {
this.navigateToError(); this.navigateToError();
@ -40,9 +49,9 @@ export class MonitorSearchDataprovidersComponent {
} }
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
navigateToError() { navigateToError() {

View File

@ -1,6 +1,7 @@
import {Component} from '@angular/core'; import {Component} from '@angular/core';
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-search-organizations', selector: 'monitor-search-organizations',
@ -18,16 +19,24 @@ export class MonitorSearchOrganizationsComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -2,6 +2,7 @@ import {Component} from '@angular/core';
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-search-projects', selector: 'monitor-search-projects',
@ -23,11 +24,19 @@ export class MonitorSearchProjectsComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
if (stakeholder.type === "funder") { if (stakeholder.type === "funder") {
let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName; let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName;
@ -45,9 +54,9 @@ export class MonitorSearchProjectsComponent {
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
navigateToError() { navigateToError() {

View File

@ -2,6 +2,7 @@ import {Component} from '@angular/core';
import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class"; import {SearchCustomFilter} from "../../../openaireLibrary/searchPages/searchUtils/searchUtils.class";
import {ActivatedRoute, Router} from "@angular/router"; import {ActivatedRoute, Router} from "@angular/router";
import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../../../openaireLibrary/monitor/services/stakeholder.service";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'monitor-search-results', selector: 'monitor-search-results',
@ -22,11 +23,19 @@ export class MonitorSearchResearchResultsComponent {
private router: Router, private router: Router,
private stakeholderService: StakeholderService) { private stakeholderService: StakeholderService) {
} }
subscriptions = [];
ngOnDestroy() {
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscriber) {
subscription.unsubscribe();
}
});
}
ngOnInit() { ngOnInit() {
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (params['stakeholder']) { if (params['stakeholder']) {
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if (stakeholder) { if (stakeholder) {
if (stakeholder.type === "funder") { if (stakeholder.type === "funder") {
let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName; let value = stakeholder.index_id+"||"+stakeholder.index_name+"||"+stakeholder.index_shortName;
@ -46,8 +55,8 @@ export class MonitorSearchResearchResultsComponent {
} }
this.initialized = true; this.initialized = true;
} }
}); }));
} }
}); }));
} }
} }

View File

@ -108,10 +108,10 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
} }
ngOnInit(): void { ngOnInit(): void {
this.userManagementService.getUserInfo().subscribe(user => { this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.user = user; this.user = user;
}); }));
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
this.stakeholder = stakeholder; this.stakeholder = stakeholder;
if (this.stakeholder) { if (this.stakeholder) {
this.buildFilters(); this.buildFilters();
@ -120,7 +120,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.filterNumbers(); this.filterNumbers();
this.setPreview(); this.setPreview();
} }
}); }));
} }
ngOnDestroy(): void { ngOnDestroy(): void {
@ -131,6 +131,11 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
value(); value();
} }
}); });
this.urlSubscriptions.forEach(value => {
if (value instanceof Subscriber) {
value.unsubscribe();
}
});
} }
ngAfterViewInit(): void { ngAfterViewInit(): void {
@ -163,7 +168,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}); });
urls.forEach((indexes, pair) => { urls.forEach((indexes, pair) => {
pair = JSON.parse(pair); pair = JSON.parse(pair);
this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => { this.subscriptions.push(this.statisticsService.getNumbers(this.statisticsService.getSourceType(pair[0]), pair[1]).subscribe(response => {
indexes.forEach(([i, j]) => { indexes.forEach(([i, j]) => {
let result = JSON.parse(JSON.stringify(response)); let result = JSON.parse(JSON.stringify(response));
this.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => { this.numbers[i].indicators[j].indicatorPaths[0].jsonPath.forEach(jsonPath => {
@ -173,7 +178,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
}); });
this.numberResults.set(i + '-' + j, result); this.numberResults.set(i + '-' + j, result);
}); });
}); }));
}); });
} }
@ -427,7 +432,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
let indicatorPath: FormGroup = <FormGroup>this.numberIndicatorPaths.at(index); let indicatorPath: FormGroup = <FormGroup>this.numberIndicatorPaths.at(index);
this.getJsonPath(index).disable(); this.getJsonPath(index).disable();
indicatorPath.get('result').setErrors({validating: true}); indicatorPath.get('result').setErrors({validating: true});
this.statisticsService.getNumbers(null, indicatorPath.get('url').value).subscribe(response => { this.subscriptions.push(this.statisticsService.getNumbers(null, indicatorPath.get('url').value).subscribe(response => {
let result = JSON.parse(JSON.stringify(response)); let result = JSON.parse(JSON.stringify(response));
this.getJsonPath(index).controls.forEach(jsonPath => { this.getJsonPath(index).controls.forEach(jsonPath => {
if (result) { if (result) {
@ -448,7 +453,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
indicatorPath.get('result').setValue(null); indicatorPath.get('result').setValue(null);
} }
}, 500); }, 500);
}); }));
} }
public getJsonPath(index: number): FormArray { public getJsonPath(index: number): FormArray {
@ -746,7 +751,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id, this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id,
this.section._id this.section._id
]; ];
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.indicator, path).subscribe(indicator => { this.subscriptions.push(this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, this.indicator, path).subscribe(indicator => {
if (this.index !== -1) { if (this.index !== -1) {
this.section.indicators[this.index] = indicator; this.section.indicators[this.index] = indicator;
} else { } else {
@ -773,7 +778,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
pos: 'top-left' pos: 'top-left'
}); });
this.editing = false; this.editing = false;
}); }));
} }
reorderIndicators(sectionId: string, type: IndicatorType, indicatorIds: string[]) { reorderIndicators(sectionId: string, type: IndicatorType, indicatorIds: string[]) {
@ -785,7 +790,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id, this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id,
sectionId sectionId
]; ];
this.stakeholderService.reorderIndicators(this.properties.monitorServiceAPIURL, path, indicatorIds, type).subscribe(indicators => { this.subscriptions.push(this.stakeholderService.reorderIndicators(this.properties.monitorServiceAPIURL, path, indicatorIds, type).subscribe(indicators => {
if (type === 'chart') { if (type === 'chart') {
this.charts.find(section => section._id === sectionId).indicators = indicators; this.charts.find(section => section._id === sectionId).indicators = indicators;
this.filterCharts(); this.filterCharts();
@ -794,7 +799,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.filterNumbers(); this.filterNumbers();
} }
this.editing = false; this.editing = false;
}); }));
} }
hasDifference(index: number): boolean { hasDifference(index: number): boolean {
@ -851,7 +856,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.section._id, this.section._id,
this.indicator._id this.indicator._id
]; ];
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.indicatorChildrenActionOnDelete).subscribe(() => { this.subscriptions.push(this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.indicatorChildrenActionOnDelete).subscribe(() => {
if (this.indicator.type === 'chart') { if (this.indicator.type === 'chart') {
this.charts.find(section => section._id === this.section._id).indicators.splice(this.index, 1); this.charts.find(section => section._id === this.section._id).indicators.splice(this.index, 1);
this.filterCharts(); this.filterCharts();
@ -872,7 +877,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
pos: 'top-left' pos: 'top-left'
}); });
this.editing = false; this.editing = false;
}); }));
} }
changeIndicatorStatus(sectionId: string, indicator: Indicator, visibility: Visibility) { changeIndicatorStatus(sectionId: string, indicator: Indicator, visibility: Visibility) {
@ -885,7 +890,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
sectionId, sectionId,
indicator._id indicator._id
]; ];
this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => { this.subscriptions.push(this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
indicator.visibility = visibility; indicator.visibility = visibility;
UIkit.notification('Indicator has been successfully changed to ' + indicator.visibility.toLowerCase(), { UIkit.notification('Indicator has been successfully changed to ' + indicator.visibility.toLowerCase(), {
status: 'success', status: 'success',
@ -900,7 +905,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
pos: 'top-left' pos: 'top-left'
}); });
this.editing = false; this.editing = false;
}); }));
} }
/*toggleIndicatorAccess(sectionId: string, indicator: Indicator) { /*toggleIndicatorAccess(sectionId: string, indicator: Indicator) {
@ -939,7 +944,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id, this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id
]; ];
this.stakeholderService.saveSection(this.properties.monitorServiceAPIURL, section, path, index).subscribe(section => { this.subscriptions.push(this.stakeholderService.saveSection(this.properties.monitorServiceAPIURL, section, path, index).subscribe(section => {
if (type === 'chart') { if (type === 'chart') {
this.charts[index] = section; this.charts[index] = section;
this.filterCharts(); this.filterCharts();
@ -961,7 +966,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
pos: 'top-left' pos: 'top-left'
}); });
this.editing = false; this.editing = false;
}); }));
} }
createSection(index = -1, type: IndicatorType = 'chart') { createSection(index = -1, type: IndicatorType = 'chart') {
@ -973,7 +978,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id, this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex]._id,
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id
]; ];
this.stakeholderService.saveSection(this.properties.monitorServiceAPIURL, this.section, path, index).subscribe(section => { this.subscriptions.push(this.stakeholderService.saveSection(this.properties.monitorServiceAPIURL, this.section, path, index).subscribe(section => {
if (type === 'chart') { if (type === 'chart') {
if (index !== -1) { if (index !== -1) {
this.charts.splice(index, 0, section); this.charts.splice(index, 0, section);
@ -1003,7 +1008,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
pos: 'top-left' pos: 'top-left'
}); });
this.editing = false; this.editing = false;
}); }));
} }
// deleteNumberSectionOpen(section: Section, index: number) { // deleteNumberSectionOpen(section: Section, index: number) {
@ -1052,7 +1057,7 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id, this.stakeholder.topics[this.topicIndex].categories[this.categoryIndex].subCategories[this.subcategoryIndex]._id,
this.section._id this.section._id
]; ];
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.sectionChildrenActionOnDelete).subscribe(() => { this.subscriptions.push(this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.sectionChildrenActionOnDelete).subscribe(() => {
if (this.sectionTypeToDelete === "chart") { if (this.sectionTypeToDelete === "chart") {
this.charts.splice(this.index, 1); this.charts.splice(this.index, 1);
this.filterCharts(); this.filterCharts();
@ -1074,6 +1079,6 @@ export class IndicatorsComponent implements OnInit, OnDestroy, OnChanges, AfterV
pos: 'top-left' pos: 'top-left'
}); });
this.editing = false; this.editing = false;
}); }));
} }
} }

View File

@ -1,10 +1,9 @@
import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core'; import {Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {DomSanitizer, Title} from '@angular/platform-browser'; import {Title} from '@angular/platform-browser';
import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import { import {
Category, Category,
Section,
Stakeholder, Stakeholder,
SubCategory, SubCategory,
Topic, Topic,
@ -20,6 +19,7 @@ import {StringUtils} from "../openaireLibrary/utils/string-utils.class";
import {IDeactivateComponent} from "../openaireLibrary/utils/can-exit.guard"; import {IDeactivateComponent} from "../openaireLibrary/utils/can-exit.guard";
import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service"; import {LayoutService} from "../openaireLibrary/dashboard/sharedComponents/sidebar/layout.service";
import {Option} from "../openaireLibrary/sharedComponents/input/input.component"; import {Option} from "../openaireLibrary/sharedComponents/input/input.component";
import {properties} from "../../environments/environment";
declare var UIkit; declare var UIkit;
@ -31,7 +31,6 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
public subscriptions: any[] = []; public subscriptions: any[] = [];
public properties: EnvProperties; public properties: EnvProperties;
public stakeholderUtils: StakeholderUtils = new StakeholderUtils(); public stakeholderUtils: StakeholderUtils = new StakeholderUtils();
public indicatorUtils: IndicatorUtils = new IndicatorUtils();
public loading: boolean = true; public loading: boolean = true;
public stakeholder: Stakeholder; public stakeholder: Stakeholder;
/** /**
@ -78,11 +77,9 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
} }
public ngOnInit() { public ngOnInit() {
this.route.data this.properties = properties;
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
let subscription: Subscription; let subscription: Subscription;
this.route.params.subscribe(params => { this.subscriptions.push(this.route.params.subscribe(params => {
if (subscription) { if (subscription) {
subscription.unsubscribe(); subscription.unsubscribe();
} }
@ -110,11 +107,16 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
} }
}); });
this.subscriptions.push(subscription); this.subscriptions.push(subscription);
}); }));
});
} }
public ngOnDestroy() { public ngOnDestroy() {
this.subscriptions.forEach(value => {
if (value instanceof Subscriber) {
value.unsubscribe();
}
});
} }
canExit():boolean { canExit():boolean {
@ -463,7 +465,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
} }
private save(message: string, path: string[], saveElement: any, callback: Function, redirect = false) { private save(message: string, path: string[], saveElement: any, callback: Function, redirect = false) {
this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, saveElement, path).subscribe(saveElement => { this.subscriptions.push(this.stakeholderService.saveElement(this.properties.monitorServiceAPIURL, saveElement, path).subscribe(saveElement => {
callback(saveElement); callback(saveElement);
this.stakeholderService.setStakeholder(this.stakeholder); this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(message, { UIkit.notification(message, {
@ -482,11 +484,11 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
timeout: 3000, timeout: 3000,
pos: 'top-left' pos: 'top-left'
}); });
}); }));
} }
private delete(message: string, path: string[], callback: Function, redirect = false) { private delete(message: string, path: string[], callback: Function, redirect = false) {
this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.elementChildrenActionOnDelete).subscribe(() => { this.subscriptions.push(this.stakeholderService.deleteElement(this.properties.monitorServiceAPIURL, path, this.elementChildrenActionOnDelete).subscribe(() => {
callback(); callback();
this.stakeholderService.setStakeholder(this.stakeholder); this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(message, { UIkit.notification(message, {
@ -503,7 +505,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
timeout: 3000, timeout: 3000,
pos: 'top-left' pos: 'top-left'
}); });
}); }));
} }
public toggleStatusByIndex(index: number, visibility:Visibility, type) { public toggleStatusByIndex(index: number, visibility:Visibility, type) {
@ -518,7 +520,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
} }
private changeStatus(element: Topic | Category | SubCategory, path: string[], visibility:Visibility) { private changeStatus(element: Topic | Category | SubCategory, path: string[], visibility:Visibility) {
this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => { this.subscriptions.push(this.stakeholderService.changeVisibility(this.properties.monitorServiceAPIURL, path, visibility).subscribe(visibility => {
element.visibility = visibility; element.visibility = visibility;
this.stakeholderService.setStakeholder(this.stakeholder); this.stakeholderService.setStakeholder(this.stakeholder);
UIkit.notification(StringUtils.capitalize(this.type) + ' has been successfully changed to ' + element.visibility.toLowerCase(), { UIkit.notification(StringUtils.capitalize(this.type) + ' has been successfully changed to ' + element.visibility.toLowerCase(), {
@ -532,7 +534,7 @@ export class TopicComponent implements OnInit, OnDestroy, IDeactivateComponent {
timeout: 3000, timeout: 3000,
pos: 'top-left' pos: 'top-left'
}); });
}); }));
} }
back() { back() {

View File

@ -1,7 +1,6 @@
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common'; import {CommonModule} from '@angular/common';
import {FreeGuard} from '../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard'; import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service'; import {PiwikService} from '../openaireLibrary/utils/piwik/piwik.service';

View File

@ -1,6 +1,7 @@
import {Component, OnInit} from "@angular/core"; import {Component, OnInit} from "@angular/core";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {properties} from "../../environments/environment"; import {properties} from "../../environments/environment";
import {Subscriber} from "rxjs";
@Component({ @Component({
selector: 'users', selector: 'users',
@ -16,10 +17,15 @@ export class UsersComponent implements OnInit{
constructor(private stakeholderService: StakeholderService) { constructor(private stakeholderService: StakeholderService) {
} }
subscription;
ngOnDestroy() {
if (this.subscription instanceof Subscriber) {
this.subscription.unsubscribe();
}
}
ngOnInit() { ngOnInit() {
this.loading = true; this.loading = true;
this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { this.subscription = this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => {
if(stakeholder) { if(stakeholder) {
this.alias = stakeholder.alias; this.alias = stakeholder.alias;
this.name = stakeholder.name; this.name = stakeholder.name;

View File

@ -1,14 +1,14 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, CanActivate, CanLoad, Route, Router, RouterStateSnapshot} from '@angular/router'; import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/Observable'; import {Observable} from 'rxjs/Observable';
import {filter, map, mergeMap} from "rxjs/operators"; import {map, take, tap} from "rxjs/operators";
import {UserManagementService} from "../openaireLibrary/services/user-management.service"; import {UserManagementService} from "../openaireLibrary/services/user-management.service";
import {LoginErrorCodes} from "../openaireLibrary/login/utils/guardHelper.class"; import {LoginErrorCodes} from "../openaireLibrary/login/utils/guardHelper.class";
import {Session} from "../openaireLibrary/login/utils/helper.class"; import {Session} from "../openaireLibrary/login/utils/helper.class";
import {properties} from "../../environments/environment";
import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service"; import {StakeholderService} from "../openaireLibrary/monitor/services/stakeholder.service";
import {of} from "rxjs"; import {zip} from "rxjs";
@Injectable() @Injectable()
export class AdminDashboardGuard implements CanActivate { export class AdminDashboardGuard implements CanActivate {
@ -20,26 +20,18 @@ export class AdminDashboardGuard implements CanActivate {
check(path: string, alias: string): Observable<boolean> | boolean { check(path: string, alias: string): Observable<boolean> | boolean {
if (Session.isLoggedIn()) { if (Session.isLoggedIn()) {
const obs = this.userManagementService.getUserInfo(false).pipe(map(user => { return zip(
if(user) { this.userManagementService.getUserInfo(false)
return this.stakeholderService.getStakeholder(alias).pipe(map(stakeholder => { ,this.stakeholderService.getStakeholder(alias)
if(stakeholder) { ).pipe(take(1),map(res =>{
return (Session.isPortalAdministrator(user) || return res[0] && res[1] && (Session.isPortalAdministrator(res[0]) ||
Session.isCurator(stakeholder.type, user) || Session.isManager(stakeholder.type, stakeholder.alias, user)); Session.isCurator(res[1].type, res[0]) || Session.isManager(res[1].type, res[1].alias, res[0]));
} else { }),tap(authorized => {
return false; if(!authorized){
}
}));
} else {
return of(false);
}
}), mergeMap( authorized => {
return authorized;
}));
obs.pipe(filter(isManager => !isManager)).subscribe(() => {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_ADMIN, 'redirectUrl':path}}); this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_ADMIN, 'redirectUrl':path}});
}); }
return obs; }));
} else { } else {
this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, 'redirectUrl':path}}); this.router.navigate(['/user-info'], {queryParams: {'errorCode': LoginErrorCodes.NOT_LOGIN, 'redirectUrl':path}});
return false; return false;

View File

@ -1,41 +0,0 @@
export class PiwikHelper{
public static siteIDs={
"connect": 80,
"dh-ch":81,
"ee":82,
"egi":83,
"elixir-gr":84,
"fam":85,
"instruct":86,
"mes":87,
"ni":88,
"oa-pg":89,
"rda":90,
"aginfra":93,
"clarin":100,
"dariah":103
};
public static siteIDsProduction={
"connect": 112,
"dh-ch":198,
"ee":200,
"egi":'',
"elixir-gr":'',
"fam":197,
"instruct":'',
"mes":196,
"ni":199,
"oa-pg":'',
"rda":'',
"aginfra":'',
"clarin":'',
"dariah":''
};
public static getSiteId(communityId:string, environment:string){
if(environment == 'production'){
return this.siteIDsProduction[communityId];
}
return this.siteIDs[communityId];
}
}

View File

@ -1,9 +1,8 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http"; import {HttpClient} from "@angular/common/http";
import {EnvironmentSpecificService} from "../../openaireLibrary/utils/properties/environment-specific.service";
import {Observable} from "rxjs"; import {Observable} from "rxjs";
import {SourceType} from "../../openaireLibrary/monitor/entities/stakeholder"; import {SourceType} from "../../openaireLibrary/monitor/entities/stakeholder";
import {el} from "@angular/platform-browser/testing/src/browser_util"; import {properties} from "../../../environments/environment";
@Injectable({ @Injectable({
@ -14,8 +13,7 @@ export class StatisticsService {
numberSources: Map<SourceType, string[]> = new Map<SourceType, string[]>(); numberSources: Map<SourceType, string[]> = new Map<SourceType, string[]>();
chartSources: Map<SourceType, string[]> = new Map<SourceType, string[]>(); chartSources: Map<SourceType, string[]> = new Map<SourceType, string[]>();
constructor(private http:HttpClient, private environmentSpecificService: EnvironmentSpecificService) { constructor(private http:HttpClient) {
this.environmentSpecificService.subscribeEnvironment().subscribe(properties => {
this.numberSources.set('statistics', [properties.statisticsAPIURL]); this.numberSources.set('statistics', [properties.statisticsAPIURL]);
this.numberSources.set('search', [properties.searchAPIURLLAst]); this.numberSources.set('search', [properties.searchAPIURLLAst]);
this.numberSources.set('metrics', [properties.metricsAPIURL]); this.numberSources.set('metrics', [properties.metricsAPIURL]);
@ -24,7 +22,6 @@ export class StatisticsService {
this.chartSources.set('old', [properties.statisticsFrameAPIURL]); this.chartSources.set('old', [properties.statisticsFrameAPIURL]);
this.chartSources.set('metrics', [properties.metricsAPIURL]); this.chartSources.set('metrics', [properties.metricsAPIURL]);
this.chartSources.set('image', [""]); this.chartSources.set('image', [""]);
})
} }
getSourceType(source:string):SourceType{ getSourceType(source:string):SourceType{
let sourceType: SourceType = 'search'; let sourceType: SourceType = 'search';

View File

@ -1,242 +0,0 @@
import {Component, EventEmitter, Input, Output, ViewChild} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {AlertModal} from '../../openaireLibrary/utils/modal/alert';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {SubscribeService} from '../../openaireLibrary/utils/subscribe/subscribe.service';
import {EmailService} from "../../openaireLibrary/utils/email/email.service";
import {Session, User} from '../../openaireLibrary/login/utils/helper.class';
import {Email} from "../../openaireLibrary/utils/email/email";
import {Composer} from "../../openaireLibrary/utils/email/composer";
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
import {UserManagementService} from "../../openaireLibrary/services/user-management.service";
declare var UIkit: any;
@Component({
selector: 'subscribe',
template: `
<span *ngIf="subscribed != null && !showNumbers && showTemplate">
<div *ngIf="!subscribed && showLoginAlert" class="uk-alert-warning uk-animation-slide-bottom" uk-alert="">
<a class="uk-alert-close" uk-close></a>
<p>Please login first to subscribe</p>
</div>
<button *ngIf="!subscribed" [class]="'uk-button uk-button-primary' + (loading ? ' uk-disabled' : '')"
(click)="subscribe()"> Subscribe</button>
<button *ngIf="subscribed" [class]="'uk-button uk-button-primary' + (loading ? ' uk-disabled' : '')"
(click)="confirmOpen()"> Unsubscribe</button>
</span>
<span *ngIf="showNumbers && subscribers !=null && subscribers > 0 && showTemplate">
<span class="lowOpacityColor"> Members</span> {{subscribers}}
</span>
<modal-alert (alertOutput)="confirmClose($event)">
</modal-alert>
`
})
export class SubscribeComponent {
// @Input() showSubscribe:boolean = true;
@Input() showNumbers: boolean;
@Input() communityId: string;
@Input() showTemplate: boolean = true;
@Output() subscribeEvent = new EventEmitter();
public community = null;
public emailToInformManagers: Email;
loading: boolean = false;
subscribed: boolean = null;
properties: EnvProperties;
subscribers: number = null;
showLoginAlert: Boolean = false;
@ViewChild(AlertModal) alert;
private user: User;
constructor(private route: ActivatedRoute,
private _subscribeService: SubscribeService,
private _emailService: EmailService,
private _communityService: CommunityService,
private router: Router,
private userManagementService: UserManagementService
) {
}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;
if (!this.showNumbers) {
let email = (this.user)?this.user.email:null;
if (email == null) {
this.subscribed = false;
} else {
if (this.communityId) {
this._subscribeService.isSubscribedToCommunity(this.properties, this.communityId).subscribe(
res => {
this.subscribed = res;
if (this.subscribed) {
this.subscribeEvent.emit({
value: "ok"
});
}
},
error => {
this.handleError("Error getting response if email: " + email + " is subscribed to community with id: " + this.communityId, error);
});
}
}
} else {
if (this.communityId) {
this._subscribeService.getCommunitySubscribers(this.properties, this.communityId).subscribe(
res => {
this.subscribers = (res && res.subscribers && res.subscribers.length) ? res.subscribers.length : 0;
},
error => {
this.handleError("Error getting community subscribers for community with id: " + this.communityId, error);
});
}
}
if (this.communityId) {
this.emailToInformManagers = {body: "", subject: "", recipients: []};
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe(
community => {
this.community = community;
},
error => {
//console.log('System error retrieving community profile', error)
this.handleError("Error getting community with id: " + this.communityId, error);
}
);
}
});
});
}
subscribe() {
var email = (this.user)?this.user.email:null;
if (email == null) {
this.subscribed = false;
// this.showLoginAlert = true;
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.ACTION_REQUIRES_LOGIN,
"redirectUrl": this.properties.baseLink + this.router.url
}
});
} else {
this.loading = true;
this.showLoginAlert = false;
this._subscribeService.subscribeToCommunity(this.properties, this.communityId).subscribe(
res => {
this.loading = false;
if (res.status && res.status != 200) {
this.subscribeEvent.emit({
value: "error"
});
UIkit.notification({
message: '<strong>An error occured. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
} else {
if (!this.subscribed) {
this.subscribed = true;
this.subscribeEvent.emit({
value: "ok"
});
this._emailService.sendEmail(this.properties,
Composer.composeEmailToInformManagers(this.community.title, this.communityId, this.community.managers, email, this.properties.adminPortalURL)).subscribe(
res => {
//console.log("The email has been sent successfully!")
},
error => {
//console.log(error)
this.handleError("Error notifying managers about new subscribers for community with id: " + this.communityId, error);
}
);
}
}
},
error => {
this.loading = false;
this.subscribeEvent.emit({
value: "error"
});
UIkit.notification({
message: '<strong>An error occured. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
//console.log(error)
this.handleError("Error subscribing email: " + email + " to community with id: " + this.communityId, error);
});
}
}
unsubscribe() {
var email = (this.user)?this.user.email:null;
if (email == null) {
this.subscribed = false;
} else {
this.loading = true;
//this.properties.adminToolsAPIURL
this._subscribeService.unSubscribeToCommunity(this.properties, this.communityId).subscribe(
res => {
this.loading = false;
if (res.status && res.status != 200) {
UIkit.notification({
message: '<strong>An error occured. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
} else {
//console.log(res);
if (this.subscribed) {
console.log('here')
this.subscribed = false;
}
}
},
error => {
this.loading = false;
UIkit.notification({
message: '<strong>An error occured. Please try again!<strong>',
status: 'warning',
timeout: 3000,
pos: 'top-center'
});
//console.log(error)
this.handleError("Error unsubscribing email: " + email + " from community with id: " + this.communityId, error);
});
}
}
confirmOpen() {
this.alert.cancelButton = true;
this.alert.okButton = true;
this.alert.alertTitle = "Unsubscribe community ";
this.alert.message = "Do you want to proceed? ";
this.alert.okButtonText = "Yes";
this.alert.cancelButtonText = "No";
this.alert.open();
}
confirmClose(data) {
this.unsubscribe();
}
private handleError(message: string, error) {
console.error("Subscribe (component): " + message, error);
}
}

View File

@ -1,32 +0,0 @@
import {ModuleWithProviders, NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {RouterModule} from '@angular/router';
import {SubscribeService} from '../../openaireLibrary/utils/subscribe/subscribe.service';
import {CommunityService} from "../../openaireLibrary/connect/community/community.service";
import {EmailService} from "../../openaireLibrary/utils/email/email.service";
import {SubscribeComponent} from './subscribe.component';
import {AlertModalModule} from '../../openaireLibrary/utils/modal/alertModal.module';
@NgModule({
imports: [
CommonModule, RouterModule, AlertModalModule
],
declarations: [
SubscribeComponent
],
exports: [
SubscribeComponent
]
})
export class SubscribeModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: SubscribeModule,
providers: [
SubscribeService, EmailService, CommunityService
]
}
}
}

View File

@ -1,4 +1,3 @@
User-Agent: * User-Agent: *
Disallow: /cache Disallow: /admin
Disallow: /upload Crawl-delay: 30
Disallow: /