[Trunk|Admin]: 1. Cleaning some code. 2. Add Modules for lazy loading(not all). 3. Refactor interactive mining library for lazy loading and guard's protection

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@54961 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2019-03-04 14:32:58 +00:00
parent 9e37115b11
commit fd3fb6f491
29 changed files with 247 additions and 252 deletions

Binary file not shown.

View File

@ -1,23 +1,18 @@
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { HttpModule, JsonpModule } from '@angular/http';
import { AppComponent } from "./app.component";
import { routing, appRoutingProviders } from "./app.routing";
import { DashboardComponent } from "./dashboard.component";
import { AppComponent } from './app.component';
import { routing, appRoutingProviders } from './app.routing';
import { TopicsComponent } from "./pages/faq/topics.components";
import { QuestionsComponent } from "./pages/faq/questions.component";
import { FAQService } from "./services/faq.service";
import { ModalModule } from 'ngx-bootstrap';
//import { CollapseModule } from 'ngx-bootstrap';
//import { AccordionModule } from 'ngx-bootstrap';
import { TopicsFormComponent } from "./pages/faq/topics-form.component";
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ModalFormComponent } from "./pages/modal-form.component";
import { QuestionsFormComponent } from "./pages/faq/questions-form.component";
import { DeleteConfirmationDialogComponent } from "./pages/delete-confirmation-dialog.component";
//import { DeleteConfirmationDialogModule } from "./pages/delete-confirmation-dialog.module";
// import { JWBootstrapSwitchModule } from 'jw-bootstrap-switch-ng2';
import { PagesComponent } from "./pages/page/pages.component";
import { HelpContentService } from "./services/help-content.service";
import { PageFormComponent } from "./pages/page/page-form.component";
@ -32,12 +27,10 @@ import { EntitiesComponent } from "./pages/entity/entities.component";
import { EntityFormComponent } from "./pages/entity/entity-form.component";
import { DivIdsComponent } from "./pages/divId/divIds.component";
import { DivIdFormComponent } from "./pages/divId/divId-form.component";
//import { DivIdModule } from './pages/divId/divId.module';
import { DivHelpContentsComponent } from "./pages/divhelpcontent/div-help-contents.component";
import { NewDivHelpContentComponent } from "./pages/divhelpcontent/new-div-help-content.component";
import { DivContentFormComponent } from "./pages/divhelpcontent/div-help-content-form.component";
import { EditDivHelpContentComponent } from "./pages/divhelpcontent/edit-div-help-content.component";
//import { DivHelpContentsModule } from './pages/divhelpcontent/divhelpcontent.module';
import { HtmlPageContentModule } from "./pages/htmlpagecontent/htmlpagecontent.module";
@ -59,29 +52,24 @@ import { AdminLoginGuard} from './openaireLibrary/login/adminLoginGuard.guard';
import { ConnectAdminLoginGuard} from './openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard';
import { EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver';
import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
import{ClaimsAdminModule} from './openaireLibrary/claims/claimsAdmin/claimsAdmin.module';
import {StatsComponent} from "./pages/stats/stats.component";
//, , ErrorModule CookieLawModule
import {ClaimsAdminModule} from './openaireLibrary/claims/claimsAdmin/claimsAdmin.module';
import {StatsComponent} from './pages/stats/stats.component';
import { DataTablesModule } from 'angular-datatables';
import { CommunityProjectsModule } from './pages/community/projects/communityProjects.module';
import { CommunityContentProvidersModule } from './pages/community/content-providers/communityContentProviders.module';
import {InteractiveMiningModule} from 'interactiveminingv3';
import {MiningComponent} from './pages/mining/mining.component';
import {CommunitiesService} from "./openaireLibrary/connect/communities/communities.service";
import{CommunityErrorPageComponent} from './openaireLibrary/connect/communityGuard/communityErrorPage.component';
import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service';
import {CommunityErrorPageComponent} from './openaireLibrary/connect/communityGuard/communityErrorPage.component';
import {IsCommunity} from './openaireLibrary/connect/communityGuard/isCommunity.guard';
import {AdminErrorPageComponent} from './pages/error/errorPage.component';
import {ErrorModule} from './openaireLibrary/error/error.module';
import {CommonModule, TitleCasePipe} from '@angular/common';
import {WellcomeComponent} from './pages/wellcome/wellcome.component';
import {TitleCasePipe} from '@angular/common';
import {AlertModalModule} from './openaireLibrary/utils/modal/alertModal.module';
import {FABModule} from './utils/fabModule.module';
import {SafeHtmlPipeModule} from './openaireLibrary/utils/pipes/safeHTMLPipe.module';
import {ManageUserNotificationsModule} from './pages/usernotifications/manage-user-notifications.module';
import {InteractiveMiningModule} from 'interactiveminingv3';
@NgModule({
imports: [
@ -90,11 +78,8 @@ import {ManageUserNotificationsModule} from './pages/usernotifications/manage-us
HttpModule,
JsonpModule,
ModalModule.forRoot(),
//CollapseModule.forRoot(),
//AccordionModule.forRoot(),
FormsModule,
ReactiveFormsModule,
// JWBootstrapSwitchModule,
CKEditorModule,
BottomModule, FeedbackModule, NavigationBarModule, CookieLawModule, ClaimsAdminModule,
CommunityProjectsModule,
@ -104,20 +89,13 @@ import {ManageUserNotificationsModule} from './pages/usernotifications/manage-us
ManageSubscribersModule,
SubjectsEditFormModule,
DataTablesModule,
InteractiveMiningModule,
ErrorModule,
AlertModalModule, SafeHtmlPipeModule, FABModule,
HtmlPageContentModule,
// DivIdModule,
// DivHelpContentsModule
//DeleteConfirmationDialogModule
// , CookieLawModule, ErrorModule
ManageUserNotificationsModule
InteractiveMiningModule,
],
declarations: [
AppComponent,
DashboardComponent,
TopicsComponent,
QuestionsComponent,
TopicsFormComponent,
@ -142,17 +120,15 @@ import {ManageUserNotificationsModule} from './pages/usernotifications/manage-us
DivContentFormComponent,
ClaimsComponent,
StatsComponent,
MiningComponent,
CommunityErrorPageComponent,
AdminErrorPageComponent,
WellcomeComponent
AdminErrorPageComponent
],
providers: [
FAQService,
HelpContentService,
appRoutingProviders,
FreeGuard, AdminLoginGuard,ConnectAdminLoginGuard,LoginGuard,
EnvironmentSpecificResolver,EnvironmentSpecificService,
FreeGuard, AdminLoginGuard, ConnectAdminLoginGuard, LoginGuard,
EnvironmentSpecificResolver, EnvironmentSpecificService,
IsCommunity, CommunitiesService, TitleCasePipe
],

View File

@ -1,10 +1,8 @@
/**
* Created by stefania on 9/16/16.
*/
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { DashboardComponent } from "./dashboard.component";
import { ModuleWithProviders } from '@angular/core';
import { Routes, RouterModule} from '@angular/router';
import { CommunitiesComponent } from './pages/community/communities.component';
import { ZenodoCommunitiesComponent } from "./pages/zenodo-communities/zenodo-communities.component";
import { ManageSubscribersComponent } from "./pages/subscribers/manage-subscribers.component";
@ -24,43 +22,32 @@ import {ClaimsComponent} from './pages/claims/claims.component';
import {FreeGuard} from './openaireLibrary/login/freeGuard.guard';
import {IsCommunity} from './openaireLibrary/connect/communityGuard/isCommunity.guard';
import { AdminLoginGuard} from './openaireLibrary/login/adminLoginGuard.guard';
import { LoginGuard} from './openaireLibrary/login/loginGuard.guard';
import { ConnectAdminLoginGuard} from './openaireLibrary/connect/communityGuard/connectAdminLoginGuard.guard';
import { EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver';
import { EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
import{ClaimsAdminComponent} from './openaireLibrary/claims/claimsAdmin/claimsAdmin.component';
import {StatsComponent} from "./pages/stats/stats.component";
import {MiningComponent} from './pages/mining/mining.component';
import {StatsComponent} from './pages/stats/stats.component';
import{CommunityErrorPageComponent} from './openaireLibrary/connect/communityGuard/communityErrorPage.component';
import {AdminErrorPageComponent} from './pages/error/errorPage.component';
import { ManageProjectsComponent } from './pages/community/projects/manage-projects.component';
import { ManageContentProvidersComponent } from './pages/community/content-providers/manage-content-providers.component';
import {WellcomeComponent} from './pages/wellcome/wellcome.component';
import {ManageUserNotificationsComponent} from './pages/usernotifications/manage-user-notifications.component';
//TODO replace IsCommunity with ConnectAdminLoginGuard
//, IsCommunity
const appRoutes: Routes = [
{
path: '',
component: WellcomeComponent,
canActivate: [FreeGuard],resolve: { envSpecific: EnvironmentSpecificResolver }
// redirectTo: 'dashboard',
// pathMatch: 'full'
path: '', loadChildren: './pages/wellcome/wellcome.module#WellcomeModule', resolve: { envSpecific: EnvironmentSpecificResolver }
},
{
path: 'dashboard',
component: DashboardComponent,
canActivate: [IsCommunity, ConnectAdminLoginGuard],resolve: { envSpecific: EnvironmentSpecificResolver }
loadChildren: './pages/dashboard/dashboard.module#DashboardModule',
canLoad: [IsCommunity, ConnectAdminLoginGuard],
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'manage-user-notifications',
component: ManageUserNotificationsComponent,
canActivate: [IsCommunity, ConnectAdminLoginGuard], resolve: {envSpecific: EnvironmentSpecificResolver}
loadChildren: './pages/usernotifications/manage-user-notifications.module#ManageUserNotificationsModule',
canLoad: [IsCommunity, ConnectAdminLoginGuard],
resolve: {envSpecific: EnvironmentSpecificResolver}
},
{
path: 'communities',
@ -159,13 +146,13 @@ const appRoutes: Routes = [
},
{
path: 'mining',
component: MiningComponent,canActivate: [IsCommunity,ConnectAdminLoginGuard]
loadChildren: './pages/mining/mining.module#MiningModule'
},
{
path: 'errorcommunity',
component: CommunityErrorPageComponent,canActivate: [FreeGuard]
},
{ path: '**',pathMatch: 'full',component: AdminErrorPageComponent }
{ path: '**', pathMatch: 'full', component: AdminErrorPageComponent }
];
// @NgModule({

View File

@ -1,10 +1,10 @@
/**
* Created by stefania on 4/26/17.
*/
import { Topic } from "./topic";
import { Question } from "./question";
import { Topic } from './topic';
import { Question } from './question';
export interface ActiveTopicQuestions {
topic: Topic;
questionList: Question[];
}
}

View File

@ -10,6 +10,6 @@ export interface Community {
}
export interface CheckCommunity {
community : Community;
checked : boolean;
community: Community;
checked: boolean;
}

View File

@ -1,4 +1,4 @@
import { DivId } from "./divId";
import { DivId } from './divId';
import {Community} from './community';
export interface DivHelpContent {

View File

@ -7,6 +7,6 @@ export interface DivId {
}
export interface CheckDivId {
divId : DivId;
checked : boolean;
divId: DivId;
checked: boolean;
}

View File

@ -2,10 +2,10 @@ export class Entity {
_id: string;
pid: string;
name: string;
isEnabled :boolean;
isEnabled: boolean;
}
export interface CheckEntity {
entity : Entity;
checked : boolean;
entity: Entity;
checked: boolean;
}

View File

@ -9,6 +9,6 @@ export interface HtmlPageContent {
}
export interface CheckHtmlPageContent {
pageHelpContent : HtmlPageContent;
checked : boolean;
pageHelpContent: HtmlPageContent;
checked: boolean;
}

View File

@ -1,14 +1,14 @@
/**
* Created by stefania on 7/13/17.
*/
import { Page } from "./page";
import { Community } from "./community";
import { Page } from './page';
import { Community } from './community';
export interface PageHelpContent {
_id: string;
page: Page | string;
community: Community | string;
placement : string;
placement: string;
order: number;
content: string;
isActive: boolean;
@ -16,12 +16,12 @@ export interface PageHelpContent {
}
export interface CheckPageHelpContent {
pageHelpContent : PageHelpContent;
checked : boolean;
pageHelpContent: PageHelpContent;
checked: boolean;
}
export interface PageHelpContentFilterOptions {
id : string;
active : Boolean;
text : RegExp;
id: string;
active: Boolean;
text: RegExp;
}

View File

@ -5,13 +5,13 @@ export interface Page {
route: string;
name: string;
type: string;
isEnabled :boolean;
connect :boolean;
openaire :boolean;
isEnabled: boolean;
connect: boolean;
openaire: boolean;
entities: Entity[] | string[];
}
export interface CheckPage {
page : Page;
checked : boolean;
page: Page;
checked: boolean;
}

View File

@ -1,13 +1,13 @@
/**
* Created by stefania on 4/26/17.
*/
import { Topic } from "./topic";
import { Topic } from './topic';
export interface Question {
_id: string;
question: string;
answer: string;
date : Date;
date: Date;
isActive: boolean;
weight: number;
hitCount: number;
@ -15,12 +15,12 @@ export interface Question {
}
export interface CheckQuestion {
question : Question;
checked : boolean;
question: Question;
checked: boolean;
}
export interface QuestionFilterOptions {
id : string;
active : Boolean;
text : RegExp;
}
id: string;
active: Boolean;
text: RegExp;
}

View File

@ -5,12 +5,12 @@ export interface Topic {
_id: string;
name: string;
description: string;
date : Date;
date: Date;
weight: number;
questionOrder: string;
}
export interface CheckTopic {
topic : Topic;
checked : boolean;
}
topic: Topic;
checked: boolean;
}

View File

@ -1,6 +1,6 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import {ConnectUserComponent } from './user.component';
import { UserRoutingModule } from './user-routing.module';
@ -12,9 +12,8 @@ import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRout
imports: [
CommonModule, FormsModule,
UserRoutingModule, UserModule
],
providers:[PreviousRouteRecorder],
providers: [PreviousRouteRecorder],
declarations: [ConnectUserComponent]
})
export class LibUserModule { }

View File

@ -1,5 +1,4 @@
import {Component, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {Component} from '@angular/core';
@Component({
selector: 'openaire-user',

View File

@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import {RouterModule} from '@angular/router';
import {DashboardComponent} from './dashboard.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: DashboardComponent}
])
]
})
export class DashboardRoutingModule { }

View File

@ -2,31 +2,29 @@
* Created by stefania on 3/21/16.
*/
import { Component, ElementRef } from '@angular/core';
import {Component, ElementRef, OnInit} from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import {CommunityService} from "./openaireLibrary/connect/community/community.service";
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
@Component({
selector: 'dashboard',
templateUrl: 'dashboard.component.html',
})
export class DashboardComponent {
communityId:string= null;
export class DashboardComponent implements OnInit {
communityId: string = null;
communityType = null;
properties:EnvProperties;
properties: EnvProperties;
constructor( private element: ElementRef, private route: ActivatedRoute, private _communityService:CommunityService) {}
constructor( private element: ElementRef, private route: ActivatedRoute, private _communityService: CommunityService) {}
ngOnInit() {
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(data => {
this.scroll();
this.communityId = ((data['communityId'])?data['communityId']:data['community']);
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
this.communityId = ((data['communityId']) ? data['communityId'] : data['community']);
this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe (
community => {
this.communityType = community.type;
},

View File

@ -0,0 +1,14 @@
import { NgModule } from '@angular/core';
import {DashboardRoutingModule} from './dashboard-routing.module';
import {RouterModule} from '@angular/router';
import {DashboardComponent} from './dashboard.component';
import {CommonModule} from '@angular/common';
@NgModule({
imports: [
CommonModule, DashboardRoutingModule, RouterModule
],
declarations: [DashboardComponent],
exports: [DashboardComponent]
})
export class DashboardModule { }

View File

@ -1,12 +0,0 @@
import {Component, OnInit} from "@angular/core";
@Component({
selector: 'mining',
template: `
<p> import mining here </p>
<!--app-interactivemining [userid]="'user5649231'" [backendserveraddress]="'https://beta.services.openaire.eu/interactive-mining'"></app-interactivemining-->`
})
export class MiningComponent {
}

View File

@ -0,0 +1,9 @@
import { NgModule } from '@angular/core';
import { InteractiveMiningModule, InteractiveMiningRoutingModule} from 'interactiveminingv3';
@NgModule({
imports: [
InteractiveMiningModule,
InteractiveMiningRoutingModule
]
})
export class MiningModule { }

View File

@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import {RouterModule} from '@angular/router';
import {ManageUserNotificationsComponent} from './manage-user-notifications.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: ManageUserNotificationsComponent}
])
]
})
export class ManageUserNotificationsRoutingModule { }

View File

@ -92,5 +92,5 @@
<div class = "uk-first-column uk-align-center uk-width-1-3">
<button *ngIf="hasChanged || mailPrefsChanged()" class="uk-button uk-button-primary" (click)="updateUserNotifications()">Save</button>
<button *ngIf="!hasChanged && !mailPrefsChanged()" class="uk-button uk-button-default" disabled>Save</button>
<button class="uk-button" (click)="resetForm(communityId)">Reset</button>
<button class="uk-button" (click)="resetForm()">Reset</button>
</div>

View File

@ -1,7 +1,6 @@
import {Component, OnInit, Input, ViewChild, ElementRef} from '@angular/core';
import {FormGroup, FormBuilder} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router';
import {CommonModule} from "@angular/common";
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
@ -30,16 +29,16 @@ export class ManageUserNotificationsComponent implements OnInit {
public initialUserNotifications = null;
public userEmail = null;
public showLoading: boolean = true;
public errorMessage: string = '';
public updateErrorMessage: string = '';
public showLoading = true;
public errorMessage = '';
public updateErrorMessage = '';
public successfulSaveMessage: string = '';
public successfulResetMessage: string = '';
public successfulSaveMessage = '';
public successfulResetMessage = '';
public hasChanged: boolean = false;
public hasChanged = false;
@ViewChild (MailPrefsComponent) mailPrefs : MailPrefsComponent;
@ViewChild (MailPrefsComponent) mailPrefs: MailPrefsComponent;
constructor (private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder,
private _manageUserNotificationsService: ManageUserNotificationsService, private element: ElementRef) {
@ -53,34 +52,35 @@ export class ManageUserNotificationsComponent implements OnInit {
this.scroll();
this.communityId = communityId['communityId'];
if (this.communityId != null && this.communityId != '') {
if (this.communityId != null && this.communityId !== '') {
this.showLoading = true;
this.updateErrorMessage = "";
this.errorMessage = "";
this.successfulSaveMessage = "";
this.updateErrorMessage = '';
this.errorMessage = '';
this.successfulSaveMessage = '';
if (Session.getUser()) {
this.userEmail = Session.getUserEmail();
this._manageUserNotificationsService.getUserNotifications(this.properties.adminToolsAPIURL + "community/" + this.communityId + "/notifications", this.userEmail).subscribe(
this._manageUserNotificationsService.getUserNotifications(
this.properties.adminToolsAPIURL + 'community/' + this.communityId + '/notifications', this.userEmail).
subscribe(
userNotifications => {
this.initialUserNotifications = userNotifications;
if (this.initialUserNotifications['notifyForNewManagers'] == null || this.initialUserNotifications['notifyForNewSubscribers'] == null) {
if (this.initialUserNotifications['notifyForNewManagers'] == null ||
this.initialUserNotifications['notifyForNewSubscribers'] == null) {
this.initialUserNotifications = this.initiateUserNotifications();
}
this.userNotifications = JSON.parse(JSON.stringify( this.initialUserNotifications ));
//TODO remove after final testing
// TODO remove after final testing
this.showLoading = false;
},
error => {
if (error.status == '404') {
if (error.status === '404') {
this.initialUserNotifications = this.initiateUserNotifications();
this.userNotifications = JSON.parse(JSON.stringify( this.initialUserNotifications ));
} else {
this.handleError('System error retrieving user notifications', error)
this.handleError('System error retrieving user notifications', error);
}
this.showLoading = false;
}
@ -92,8 +92,8 @@ export class ManageUserNotificationsComponent implements OnInit {
});
}
public initiateUserNotifications() : UserNotificationsRights {
var notificationRights: UserNotificationsRights = new UserNotificationsRights();
public initiateUserNotifications(): UserNotificationsRights {
const notificationRights: UserNotificationsRights = new UserNotificationsRights();
notificationRights['notifyForNewManagers'] = true;
notificationRights['notifyForNewSubscribers'] = true;
@ -103,97 +103,80 @@ export class ManageUserNotificationsComponent implements OnInit {
}
public updateUserNotifications() {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{ queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} });
} else {
if (this.communityId != null && this.communityId != '') {
this.mailPrefs.saveNotification(0);
if (this.communityId != null && this.communityId !== '') {
this.mailPrefs.saveNotification(0);
this.successfulSaveMessage = "";
this.showLoading = true;
var userNotifications = this.parseUpdatedUserNotifications();
this._manageUserNotificationsService.updateUserNotifications(this.properties.adminToolsAPIURL + "community/" + this.communityId + "/notifications", userNotifications).subscribe(
userNotifications => {
this.initialUserNotifications = JSON.parse(JSON.stringify( this.userNotifications ));
this.handleSuccessfulSave('Notification settings saved!')
},
error => this.handleUpdateError('System error updating user notifications', error)
);
}
this.resetChange();
this.successfulSaveMessage = '';
this.showLoading = true;
const userNotifications = this.parseUpdatedUserNotifications();
this._manageUserNotificationsService.updateUserNotifications(
this.properties.adminToolsAPIURL + 'community/' + this.communityId + '/notifications',
userNotifications).subscribe(
userNotifications => {
this.initialUserNotifications = JSON.parse(JSON.stringify( this.userNotifications ));
this.handleSuccessfulSave('Notification settings saved!');
},
error => this.handleUpdateError('System error updating user notifications', error)
);
}
this.resetChange();
}
}
private parseUpdatedUserNotifications() : {} {
var userNotifications = {};
private parseUpdatedUserNotifications(): {} {
const userNotifications = {};
userNotifications["notifyForNewManagers"] = this.userNotifications.notifyForNewManagers;
userNotifications["notifyForNewSubscribers"] = this.userNotifications.notifyForNewSubscribers;
userNotifications['notifyForNewManagers'] = this.userNotifications.notifyForNewManagers;
userNotifications['notifyForNewSubscribers'] = this.userNotifications.notifyForNewSubscribers;
if (this.userNotifications.managerEmail) {
userNotifications["managerEmail"] = this.userNotifications.managerEmail;
userNotifications['managerEmail'] = this.userNotifications.managerEmail;
} else {
if (Session.getUser()) {
userNotifications["managerEmail"] = Session.getUserEmail();
userNotifications['managerEmail'] = Session.getUserEmail();
}
}
return userNotifications;
}
public resetForm(communityId:string) {
/*
if (communityId != null && communityId != '') {
this.showLoading = true;
this.updateErrorMessage = "";
this.errorMessage = "";
this.mailPrefs.restoreNotification(0);
this._manageUserNotificationsService.getUserNotifications(this.properties.adminToolsAPIURL + "community/" + this.communityId + "/notifications", this.userEmail).subscribe(
userNotifications => {
this.userNotifications = userNotifications;
this.showLoading = false;
console.log(userNotifications);
},
error => this.handleError('System error retrieving user notifications', error)
);
}
*/
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
public resetForm() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} });
} else {
this.mailPrefs.restoreNotification(0);
if(this.userNotifications && this.initialUserNotifications) {
this.successfulSaveMessage = "";
this.showLoading = true;
this.userNotifications = JSON.parse(JSON.stringify( this.initialUserNotifications ));
this.showLoading = false;
}
this.resetChange();
this.mailPrefs.restoreNotification(0);
if (this.userNotifications && this.initialUserNotifications) {
this.successfulSaveMessage = '';
this.showLoading = true;
this.userNotifications = JSON.parse(JSON.stringify( this.initialUserNotifications ));
this.showLoading = false;
}
this.resetChange();
}
}
public changeValueForNewManagers(notifyForManagers : any) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
this.userNotifications.notifyForNewManagers = !notifyForManagers;
this.change();
}
public changeValueForNewManagers(notifyForManagers: any) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {' "errorCode"': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} });
} else {
this.userNotifications.notifyForNewManagers = !notifyForManagers;
this.change();
}
}
public changeValueForNewSubscribers(notifyForSubscribers : any) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
this.userNotifications.notifyForNewSubscribers = !notifyForSubscribers;
this.change();
}
public changeValueForNewSubscribers(notifyForSubscribers: any) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} });
} else {
this.userNotifications.notifyForNewSubscribers = !notifyForSubscribers;
this.change();
}
}
private change() {
@ -207,16 +190,17 @@ export class ManageUserNotificationsComponent implements OnInit {
}
public mailPrefsChanged(): boolean {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
return this.mailPrefs.prefsChanged["0"];//(0);
}
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: { 'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url} });
} else {
return this.mailPrefs.prefsChanged['0'];
}
}
handleUpdateError(message: string, error) {
this.updateErrorMessage = message;
console.log('Server responded: ' +error);
console.log('Server responded: ' + error);
this.showLoading = false;
}
@ -239,8 +223,8 @@ export class ManageUserNotificationsComponent implements OnInit {
}
public scroll() {
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
if (typeof document !== 'undefined') {
this.element.nativeElement.scrollIntoView();
}
}
}

View File

@ -5,21 +5,22 @@ import {FormsModule} from '@angular/forms';
import {ManageUserNotificationsComponent} from './manage-user-notifications.component';
import {ManageUserNotificationsService} from './manage-user-notifications.service';
import { MailPrefsModule } from '../../openaireLibrary/connect/userEmailPreferences/mailsPrefs.module';
import {MailPrefsModule} from '../../openaireLibrary/connect/userEmailPreferences/mailsPrefs.module';
import {ManageUserNotificationsRoutingModule} from './manage-user-notifications-routing.module';
@NgModule({
imports: [
RouterModule, CommonModule, FormsModule, MailPrefsModule
ManageUserNotificationsRoutingModule, RouterModule, CommonModule, FormsModule, MailPrefsModule
],
declarations: [
ManageUserNotificationsComponent
],
],
providers: [
ManageUserNotificationsService
],
],
exports: [
ManageUserNotificationsComponent
]
]
})
export class ManageUserNotificationsModule {

View File

@ -1,5 +1,5 @@
export class UserNotificationsRights {
notifyForNewManagers:boolean;
notifyForNewSubscribers:boolean;
managerEmail:string;
notifyForNewManagers: boolean;
notifyForNewSubscribers: boolean;
managerEmail: string;
}

View File

@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import {RouterModule} from '@angular/router';
import {WellcomeComponent} from './wellcome.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: WellcomeComponent}
])
]
})
export class WellcomeRoutingModule { }

View File

@ -0,0 +1,13 @@
import { NgModule } from '@angular/core';
import {WellcomeComponent} from './wellcome.component';
import {WellcomeRoutingModule} from './wellcome-routing.module';
import {RouterModule} from '@angular/router';
@NgModule({
imports: [
WellcomeRoutingModule, RouterModule
],
declarations: [WellcomeComponent],
exports: [WellcomeComponent]
})
export class WellcomeModule { }

View File

@ -1,23 +1,14 @@
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import{ReloadModule} from '../openaireLibrary/reload/reload.module';
import { ReloadModule } from '../openaireLibrary/reload/reload.module';
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule, ReloadModule
],
declarations: [
],
providers:[
],
exports: [
]
]
})
export class LibReloadModule { }