From 5fa7e7ce2ab67c86217376dad84d291052015b3a Mon Sep 17 00:00:00 2001 From: Argiro Kokogiannaki Date: Fri, 20 Dec 2019 11:48:35 +0000 Subject: [PATCH] [Monitor_Dashboard|Trunk] add routes for manage Admin tool common entities(pages, communities, helptexts, entities) Stakeholder ddefault profile: update colors in charts Input component: add type checkbox git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-monitor-portal/trunk/monitor_dashboard@57929 d315682c-612b-4755-9ff5-7f18f6832af3 --- server.ts | 2 +- src/app/app-routing.module.ts | 79 ++++++++ src/app/app.component.html | 2 + src/app/app.component.ts | 176 +++++++++--------- src/app/app.module.ts | 17 +- src/app/home/home-routing.module.ts | 2 +- src/app/home/home.component.ts | 5 +- .../sharedComponents/input/input.component.ts | 4 +- .../sharedComponents/input/input.module.ts | 3 +- src/app/monitor/monitor.component.html | 2 +- src/app/monitor/monitor.component.ts | 69 +++++++ src/app/utils/entities/stakeholderCreator.ts | 69 +++---- src/index.html | 6 +- 13 files changed, 303 insertions(+), 133 deletions(-) diff --git a/server.ts b/server.ts index 5794d7e..6c61534 100644 --- a/server.ts +++ b/server.ts @@ -13,7 +13,7 @@ enableProdMode(); // Express server const app = express(); -const PORT = process.env.PORT || 5000; +const PORT = 5000; const DIST_FOLDER = join(process.cwd(), 'dist'); // Our index.html we'll use as our template diff --git a/src/app/app-routing.module.ts b/src/app/app-routing.module.ts index 4042922..0ab3d02 100644 --- a/src/app/app-routing.module.ts +++ b/src/app/app-routing.module.ts @@ -38,6 +38,85 @@ const routes: Routes = [ loadChildren: './topic/topic.module#TopicModule', resolve: {envSpecific: EnvironmentSpecificResolver} }, + + /* Library paths*/ + { + path: 'portals', + loadChildren: './openaireLibrary/dashboard/portal/communities.module#CommunitiesModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'entities', + loadChildren: './openaireLibrary/dashboard/entity/entities.module#EntitiesModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'classes', + loadChildren: './openaireLibrary/dashboard/divId/divIds.module#DivIdsModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'classContents', + loadChildren: './openaireLibrary/dashboard/divhelpcontent/div-help-contents.module#DivHelpContentsModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'classContents/new', + loadChildren: './openaireLibrary/dashboard/divhelpcontent/new-div-help-content.module#NewDivHelpContentModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'classContents/edit', + loadChildren: './openaireLibrary/dashboard/divhelpcontent/edit-div-help-content.module#EditDivHelpContentModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'helptexts', + loadChildren: './openaireLibrary/dashboard/helpTexts/page-help-contents.module#PageHelpContentsModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'helptexts/new', + loadChildren: './openaireLibrary/dashboard/helpTexts/new-page-help-content.module#NewPageHelpContentModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'helptexts/edit', + loadChildren: './openaireLibrary/dashboard/helpTexts/edit-page-help-content.module#EditPageHelpContentModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'pages', + loadChildren: './openaireLibrary/dashboard/page/pages.module#PagesModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + /*{ + path: 'pages', + loadChildren: './openaireLibrary/dashboard/page/pages.module#PagesModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'pageContents', + loadChildren: './openaireLibrary/dashboard/helpcontent/page-help-contents.module#PageHelpContentsModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'pageContents/new', + loadChildren: './pages/helpcontent/new-page-help-content.module#NewPageHelpContentModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + { + path: 'pageContents/edit', + loadChildren: './pages/helpcontent/edit-page-help-content.module#EditPageHelpContentModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + }, + + + { + path: 'htmlPageContent/edit', + loadChildren: './pages/htmlpagecontent/edit-html-page-content.module#EditHtmlPageContentModule', + resolve: { envSpecific: EnvironmentSpecificResolver } + },*/ { path: '', loadChildren: './monitor/monitor.module#MonitorModule', diff --git a/src/app/app.component.html b/src/app/app.component.html index 0c41548..c0aa5f7 100644 --- a/src/app/app.component.html +++ b/src/app/app.component.html @@ -22,5 +22,7 @@ + diff --git a/src/app/app.component.ts b/src/app/app.component.ts index dbe67b0..57f1222 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -8,100 +8,110 @@ import {StakeholderService} from "./services/stakeholder.service"; import {Subscriber} from "rxjs"; import {LayoutService} from "./library/sharedComponents/sidebar/layout.service"; import {MenuItem} from "./openaireLibrary/sharedComponents/menu"; +import {Item} from "./utils/entities/sidebar"; @Component({ - selector: 'app-root', - templateUrl: './app.component.html' + selector: 'app-root', + templateUrl: './app.component.html' }) export class AppComponent implements OnInit, OnDestroy { - properties: EnvProperties; - user: User; - hasSidebar: boolean = false; - hasHeader: boolean = false; - userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})]; - private subscriptions: any[] = []; + properties: EnvProperties; + user: User; + hasSidebar: boolean = false; + hasHeader: boolean = false; + userMenuItems: MenuItem[] = [new MenuItem("", "My profile", "", "", false, [], [], {})]; + private subscriptions: any[] = []; + adminMenuItems: Item[] = []; - constructor(private route: ActivatedRoute, - private propertiesService: EnvironmentSpecificService, - private router: Router, - private userManagementService: UserManagementService, - private layoutService: LayoutService, - private stakeholderService: StakeholderService, - private cdr: ChangeDetectorRef) { - } + constructor(private route: ActivatedRoute, + private propertiesService: EnvironmentSpecificService, + private router: Router, + private userManagementService: UserManagementService, + private layoutService: LayoutService, + private stakeholderService: StakeholderService, + private cdr: ChangeDetectorRef) { + } - ngOnInit() { - this.subscriptions.push(this.layoutService.hasSidebar.subscribe(hasSidebar => { - this.hasSidebar = hasSidebar; - this.cdr.detectChanges(); - })); - this.subscriptions.push(this.layoutService.hasHeader.subscribe(hasHeader => { - this.hasHeader = hasHeader; - this.cdr.detectChanges(); - })); - this.propertiesService.loadEnvironment() - .then(properties => { - this.properties = properties; - this.subscriptions.push(this.router.events.subscribe(() => { - let r = this.route; - while (r.firstChild) { - r = r.firstChild; - } - this.subscriptions.push(r.params.subscribe(params => { - if (params['stakeholder']) { - if (!this.stakeholderService.stakeholder || - this.stakeholderService.stakeholder.alias !== params['stakeholder']) { - this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => { - this.stakeholderService.setStakeholder(stakeholder); - this.layoutService.setOpen(true); - }); - } - } else { - this.stakeholderService.setStakeholder(null); - } - })); - })); - this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => { - this.user = user; - this.buildMenu(); - }, error => { - console.log("App couldn't fetch properties"); - console.log(error); - })); - }); - } - - public ngOnDestroy() { - this.subscriptions.forEach(value => { - if (value instanceof Subscriber) { - value.unsubscribe(); + ngOnInit() { + this.subscriptions.push(this.layoutService.hasSidebar.subscribe(hasSidebar => { + this.hasSidebar = hasSidebar; + this.cdr.detectChanges(); + })); + this.subscriptions.push(this.layoutService.hasHeader.subscribe(hasHeader => { + this.hasHeader = hasHeader; + this.cdr.detectChanges(); + })); + this.propertiesService.loadEnvironment() + .then(properties => { + this.properties = properties; + this.subscriptions.push(this.router.events.subscribe(() => { + let r = this.route; + while (r.firstChild) { + r = r.firstChild; + } + this.subscriptions.push(r.params.subscribe(params => { + if (params['stakeholder']) { + if (!this.stakeholderService.stakeholder || + this.stakeholderService.stakeholder.alias !== params['stakeholder']) { + this.stakeholderService.getStakeholder(this.properties.monitorServiceAPIURL, params['stakeholder']).subscribe(stakeholder => { + this.stakeholderService.setStakeholder(stakeholder); + this.layoutService.setOpen(true); + }); + } + } else { + this.stakeholderService.setStakeholder(null); } - }); + })); + })); + this.subscriptions.push(this.userManagementService.getUserInfo(this.properties.userInfoUrl).subscribe(user => { + this.user = user; + this.buildMenu(); + }, error => { + console.log("App couldn't fetch properties"); + console.log(error); + })); + }); + } + + public ngOnDestroy() { + this.subscriptions.forEach(value => { + if (value instanceof Subscriber) { + value.unsubscribe(); + } + }); + } + + public get open() { + return this.layoutService.open; + } + + public toggleOpen(event = null) { + if (!event) { + this.layoutService.setOpen(!this.open); + } else if (event && event['value'] === true) { + this.layoutService.setOpen(false); } + } + + + buildMenu() { + this.userMenuItems = []; + if (Session.isPortalAdministrator(this.user)) { + this.userMenuItems.push(new MenuItem("", "Manage helptexts", + ((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {})) - public get open() { - return this.layoutService.open; } - - public toggleOpen(event = null) { - if (!event) { - this.layoutService.setOpen(!this.open); - } else if (event && event['value'] === true) { - this.layoutService.setOpen(false); - } + if (this.user) { + this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); } - - - buildMenu() { - this.userMenuItems = []; - if (Session.isPortalAdministrator(this.user)) { - this.userMenuItems.push(new MenuItem("", "Manage helptexts", - ((this.properties.environment == "beta") ? "https://beta.admin.connect.openaire.eu" : "https://admin.explore.openaire.eu") + "/dashboard?communityId=openaire", "", true, [], [], {})) - - } - if (this.user) { - this.userMenuItems.push(new MenuItem("", "User information", "", "/user-info", false, [], [], {})); - } + if (this.adminMenuItems.length == 0) { + //nstructor(id: string, name: string, route: string, items: Item[], icon, open: boolean) { + this.adminMenuItems.push(new Item("stakeholders", "Manage Stakeholders", "/admin", [], null, false)); + this.adminMenuItems.push(new Item("pages", "Pages", "/pages", [], null, false)); + this.adminMenuItems.push(new Item("monitor", "Monitor", "/portals", [], null, false)); + this.adminMenuItems.push(new Item("entities", "Entities", "/entities", [], null, false)); + this.adminMenuItems.push(new Item("helptexts", "Help texts", "/helptexts?communityId=openaire", [], null, false)); } + } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 17b1624..5919377 100755 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -15,12 +15,9 @@ import {ErrorModule} from './openaireLibrary/error/error.module'; import {NavigationBarModule} from './openaireLibrary/sharedComponents/navigationBar.module'; import {EnvironmentSpecificResolver} from './openaireLibrary/utils/properties/environmentSpecificResolver'; - -import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service'; -import {LayoutService} from "./openaireLibrary/services/layout.service"; import {SubscribeModule} from './utils/subscribe/subscribe.module'; -import {StakeholderService} from "./services/stakeholder.service"; import {UserMiniModule} from "./openaireLibrary/login/userMiniModule.module"; +import {SideBarModule} from "./library/sharedComponents/sidebar/sideBar.module"; @NgModule({ @@ -37,12 +34,14 @@ import {UserMiniModule} from "./openaireLibrary/login/userMiniModule.module"; SubscribeModule.forRoot(), BrowserModule.withServerTransition({appId: 'my-app'}), AppRoutingModule, - UserMiniModule + UserMiniModule, SideBarModule + ], - declarations: [ AppComponent, OpenaireErrorPageComponent], - exports: [ AppComponent ], - providers:[EnvironmentSpecificResolver], + declarations: [AppComponent, OpenaireErrorPageComponent], + exports: [AppComponent], + providers: [EnvironmentSpecificResolver], bootstrap: [AppComponent] }) // -export class AppModule {} +export class AppModule { +} diff --git a/src/app/home/home-routing.module.ts b/src/app/home/home-routing.module.ts index dacc8c9..3b13521 100644 --- a/src/app/home/home-routing.module.ts +++ b/src/app/home/home-routing.module.ts @@ -12,7 +12,7 @@ import {HomeComponent} from "./home.component"; component: HomeComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder], - data: {hasSidebar: false} + data: {hasSidebar: true} } ]) ] diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index 2dfa493..1a8fdf0 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -8,6 +8,7 @@ import {Option, StakeholderUtils} from "../utils/indicator-utils"; import {FormBuilder, FormGroup, Validators} from "@angular/forms"; import {AlertModal} from "../openaireLibrary/utils/modal/alert"; import {StakeholderCreator} from "../utils/entities/stakeholderCreator"; +import {LayoutService} from "../library/sharedComponents/sidebar/layout.service"; @Component({ selector: 'home', @@ -50,7 +51,7 @@ export class HomeComponent implements OnInit, OnDestroy { constructor(private stakeholderService: StakeholderService, private propertiesService: EnvironmentSpecificService, - private fb: FormBuilder) { + private fb: FormBuilder, private layoutService: LayoutService) { } ngOnInit(): void { @@ -70,6 +71,8 @@ export class HomeComponent implements OnInit, OnDestroy { this.loading = false; }); }); + this.layoutService.setHasHeader(true); + this.layoutService.setOpen(true); } ngOnDestroy(): void { diff --git a/src/app/library/sharedComponents/input/input.component.ts b/src/app/library/sharedComponents/input/input.component.ts index e5a4651..30f7934 100644 --- a/src/app/library/sharedComponents/input/input.component.ts +++ b/src/app/library/sharedComponents/input/input.component.ts @@ -6,7 +6,7 @@ import {HelperFunctions} from "../../../openaireLibrary/utils/HelperFunctions.cl @Component({ selector: '[dashboard-input]', template: ` - +