1. Create /about and /organizations pages with html content from admin API.

2. htmlPage.component: helper component that queries admin API and displays html content according to current route. 


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@52402 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
konstantina.galouni 2018-06-08 11:25:35 +00:00
parent bde2f196d6
commit 18a2caa6e4
10 changed files with 281 additions and 0 deletions

View File

@ -11,6 +11,8 @@ const routes: Routes = [
{ path: '', loadChildren: './communitywrapper/communityWrapper.module#CommunityWrapperModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
// { path: 'communities', loadChildren: './communities/communities.module#CommunitiesModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'my-communities', loadChildren: './my-communities/communities.module#MyCommunitiesModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'about', loadChildren: './htmlPages/about/aboutPage.module#AboutPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'organizations', loadChildren: './htmlPages/organizations/organizationsPage.module#OrganizationsPageModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'monitor', loadChildren: './statistics/statistics.module#StatisticsModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/publication', loadChildren: './landingPages/publication/libPublication.module#LibPublicationModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'search/dataset', loadChildren: './landingPages/dataset/libDataset.module#LibDatasetModule', resolve: { envSpecific: EnvironmentSpecificResolver }},

View File

@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {AboutPageComponent} from './aboutPage.component';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: AboutPageComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] }
])
]
})
export class AboutPageRoutingModule { }

View File

@ -0,0 +1,45 @@
import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import{EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
@Component({
selector: 'about',
template: `
<div class=" uk-section uk-margin-small-top tm-middle uk-container" id="tm-main">
<div class="uk-container uk-margin-bottom">
<html-page></html-page>
</div>
</div>
`
})
export class AboutPageComponent {
properties:EnvProperties;
constructor ( private route: ActivatedRoute, private _router: Router,
private _meta: Meta, private _title: Title) {}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.updateUrl(data.envSpecific.baseLink+this._router.url);
this.updateTitle("About");
this.updateDescription("About, open access");
});
}
private updateDescription(description:string){
this._meta.updateTag({content:description},"name='description'");
this._meta.updateTag({content:description},"property='og:description'");
}
private updateTitle(title:string){
var _prefix ="OpenAIRE | ";
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
this._title.setTitle(_title);
this._meta.updateTag({content:_title},"property='og:title'");
}
private updateUrl(url:string){
this._meta.updateTag({content:url},"property='og:url'");
}
}

View File

@ -0,0 +1,26 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
import {AboutPageComponent} from './aboutPage.component';
import {AboutPageRoutingModule} from './aboutPage-routing.module';
import {HtmlPagesModule} from '../htmlPages.module';
@NgModule({
imports: [
AboutPageRoutingModule, HtmlPagesModule
],
declarations: [
AboutPageComponent
],
providers:[FreeGuard,PreviousRouteRecorder, IsRouteEnabled],
exports: [
AboutPageComponent
]
})
export class AboutPageModule{}

View File

@ -0,0 +1,59 @@
import { Component, Input } from '@angular/core';
import {ActivatedRoute} from '@angular/router';
import 'rxjs/Rx';
import {HtmlPageService} from './htmlPage.service';
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {ConnectHelper} from '../openaireLibrary/connect/connectHelper';
import {SafeHtmlPipe} from '../openaireLibrary/utils/pipes/safeHTML.pipe';
@Component({
selector: 'html-page',
template: `
<div [innerHTML]="content | safeHtml"></div>
`
})
export class HtmlPageComponent {
public content:string="";
sub:any;
properties:EnvProperties;
private communityId: string = null;
constructor (private _service: HtmlPageService, private route: ActivatedRoute,) {}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(
params => {
this.communityId = params['communityId'];
if(!this.communityId){
this.communityId = ConnectHelper.getCommunityFromDomain(document.location.hostname);
}
if(!this.communityId){
this.communityId = this.properties.adminToolsCommunity;
}
if(location){
this.sub = this._service.getHtmlContent(location.pathname, this.properties, this.communityId).subscribe(
data => {
if(data.length > 0) {
this.content = data[0].content;
}
},
err => {
console.log(err);
}
);
}
});
});
}
ngOnDestroy() {
if(this.sub){
this.sub.unsubscribe();
}
}
}

View File

@ -0,0 +1,25 @@
import {Injectable, Inject} from '@angular/core';
import {Http, Response} from '@angular/http';
import {Observable} from 'rxjs/Observable';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/do';
import 'rxjs/add/operator/share';
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
@Injectable()
export class HtmlPageService {
constructor(private http: Http) {}
getHtmlContent (router: string, properties:EnvProperties, communityId:string ):any {
console.info("get router html content for : "+router);
let url = properties.adminToolsAPIURL + '/htmlpagecontent?community='+communityId+'&page='+router;
return this.http.get((properties.useCache)? (properties.cacheUrl+encodeURIComponent(url)): url)
.map(res => <Array<any>> res.json());
}
}

View File

@ -0,0 +1,21 @@
import { NgModule } from '@angular/core';
import {HtmlPageComponent} from './htmlPage.component';
import {HtmlPageService} from './htmlPage.service';
import {SafeHtmlPipeModule} from '../openaireLibrary/utils/pipes/safeHTMLPipe.module';
@NgModule({
imports: [
SafeHtmlPipeModule
],
declarations: [
HtmlPageComponent
],
providers:[HtmlPageService],
exports: [
HtmlPageComponent
]
})
export class HtmlPagesModule{}

View File

@ -0,0 +1,16 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {OrganizationsPageComponent} from './organizationsPage.component';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: OrganizationsPageComponent, canActivate: [FreeGuard], canDeactivate: [PreviousRouteRecorder] }
])
]
})
export class OrganizationsPageRoutingModule { }

View File

@ -0,0 +1,45 @@
import {Component, Input, Output, EventEmitter, ViewChild, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ActivatedRoute, Router} from '@angular/router';
import {Title, Meta} from '@angular/platform-browser';
import{EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
@Component({
selector: 'organizations',
template: `
<div class=" uk-section uk-margin-small-top tm-middle uk-container" id="tm-main">
<div class="uk-container uk-margin-bottom">
<html-page></html-page>
</div>
</div>
`
})
export class OrganizationsPageComponent {
properties:EnvProperties;
constructor ( private route: ActivatedRoute, private _router: Router,
private _meta: Meta, private _title: Title) {}
public ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.updateUrl(data.envSpecific.baseLink+this._router.url);
this.updateTitle("Organizations");
this.updateDescription("Organizations, open access");
});
}
private updateDescription(description:string){
this._meta.updateTag({content:description},"name='description'");
this._meta.updateTag({content:description},"property='og:description'");
}
private updateTitle(title:string){
var _prefix ="OpenAIRE | ";
var _title = _prefix + ((title.length> 50 ) ?title.substring(0,50):title);
this._title.setTitle(_title);
this._meta.updateTag({content:_title},"property='og:title'");
}
private updateUrl(url:string){
this._meta.updateTag({content:url},"property='og:url'");
}
}

View File

@ -0,0 +1,26 @@
import { NgModule, ModuleWithProviders } from '@angular/core';
import {FreeGuard} from '../../openaireLibrary/login/freeGuard.guard';
import {PreviousRouteRecorder} from '../../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
import {IsRouteEnabled} from '../../openaireLibrary/error/isRouteEnabled.guard'
import {OrganizationsPageComponent} from './organizationsPage.component';
import {OrganizationsPageRoutingModule} from './organizationsPage-routing.module';
import {HtmlPagesModule} from '../htmlPages.module';
@NgModule({
imports: [
OrganizationsPageRoutingModule, HtmlPagesModule
],
declarations: [
OrganizationsPageComponent
],
providers:[FreeGuard,PreviousRouteRecorder, IsRouteEnabled],
exports: [
OrganizationsPageComponent
]
})
export class OrganizationsPageModule{}