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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,4 @@
import {Component, ElementRef} from '@angular/core'; import {Component} from '@angular/core';
import {Observable} from 'rxjs/Observable';
@Component({ @Component({
selector: 'openaire-user', 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. * 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 {ActivatedRoute} from '@angular/router';
import {CommunityService} from "./openaireLibrary/connect/community/community.service"; import {CommunityService} from '../../openaireLibrary/connect/community/community.service';
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'dashboard', selector: 'dashboard',
templateUrl: 'dashboard.component.html', templateUrl: 'dashboard.component.html',
}) })
export class DashboardComponent implements OnInit {
export class DashboardComponent { communityId: string = null;
communityId:string= null;
communityType = 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() { ngOnInit() {
this.route.data.subscribe((data: { envSpecific: EnvProperties }) => { this.route.data.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific; this.properties = data.envSpecific;
this.route.queryParams.subscribe(data => { this.route.queryParams.subscribe(data => {
this.scroll(); this.scroll();
this.communityId = ((data['communityId']) ? data['communityId'] : data['community']);
this.communityId = ((data['communityId'])?data['communityId']:data['community']); this._communityService.getCommunity(this.properties, this.properties.communityAPI + this.communityId).subscribe (
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
community => { community => {
this.communityType = community.type; 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"> <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-primary" (click)="updateUserNotifications()">Save</button>
<button *ngIf="!hasChanged && !mailPrefsChanged()" class="uk-button uk-button-default" disabled>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> </div>

View File

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

View File

@ -5,21 +5,22 @@ import {FormsModule} from '@angular/forms';
import {ManageUserNotificationsComponent} from './manage-user-notifications.component'; import {ManageUserNotificationsComponent} from './manage-user-notifications.component';
import {ManageUserNotificationsService} from './manage-user-notifications.service'; 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({ @NgModule({
imports: [ imports: [
RouterModule, CommonModule, FormsModule, MailPrefsModule ManageUserNotificationsRoutingModule, RouterModule, CommonModule, FormsModule, MailPrefsModule
], ],
declarations: [ declarations: [
ManageUserNotificationsComponent ManageUserNotificationsComponent
], ],
providers: [ providers: [
ManageUserNotificationsService ManageUserNotificationsService
], ],
exports: [ exports: [
ManageUserNotificationsComponent ManageUserNotificationsComponent
] ]
}) })
export class ManageUserNotificationsModule { export class ManageUserNotificationsModule {

View File

@ -1,5 +1,5 @@
export class UserNotificationsRights { export class UserNotificationsRights {
notifyForNewManagers:boolean; notifyForNewManagers: boolean;
notifyForNewSubscribers:boolean; notifyForNewSubscribers: boolean;
managerEmail:string; 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 { NgModule} from '@angular/core';
import { CommonModule } from '@angular/common'; 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{ReloadModule} from '../openaireLibrary/reload/reload.module'; import { ReloadModule } from '../openaireLibrary/reload/reload.module';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, FormsModule, RouterModule, ReloadModule CommonModule, FormsModule, RouterModule, ReloadModule
], ]
declarations: [
],
providers:[
],
exports: [
]
}) })
export class LibReloadModule { } export class LibReloadModule { }