add login components, create admin connect Guard, use env.properties

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@51057 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2018-03-06 15:36:33 +00:00
parent 0943d68297
commit ead4fc6e33
23 changed files with 410 additions and 234 deletions

View File

@ -48,6 +48,7 @@ import {BottomModule} from './openaireLibrary/sharedComponents/bottom.module';
import {FeedbackModule} from './openaireLibrary/sharedComponents/feedback/feedback.module'; import {FeedbackModule} from './openaireLibrary/sharedComponents/feedback/feedback.module';
import {FreeGuard} from './openaireLibrary/login/freeGuard.guard'; import {FreeGuard} from './openaireLibrary/login/freeGuard.guard';
import { AdminLoginGuard} from './openaireLibrary/login/adminLoginGuard.guard'; import { AdminLoginGuard} from './openaireLibrary/login/adminLoginGuard.guard';
import { ConnectAdminLoginGuard} from './openaireLibrary/login/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';
@ -102,7 +103,8 @@ import {StatsComponent} from "./pages/stats/stats.component";
FAQService, FAQService,
HelpContentService, HelpContentService,
appRoutingProviders, appRoutingProviders,
FreeGuard, AdminLoginGuard, EnvironmentSpecificResolver,EnvironmentSpecificService, Meta FreeGuard, AdminLoginGuard,ConnectAdminLoginGuard,
EnvironmentSpecificResolver,EnvironmentSpecificService, Meta
], ],
bootstrap: [ AppComponent ] bootstrap: [ AppComponent ]
}) })

View File

@ -20,12 +20,15 @@ import {ClaimsComponent} from './pages/claims/claims.component';
import {FreeGuard} from './openaireLibrary/login/freeGuard.guard'; import {FreeGuard} from './openaireLibrary/login/freeGuard.guard';
import { AdminLoginGuard} from './openaireLibrary/login/adminLoginGuard.guard'; import { AdminLoginGuard} from './openaireLibrary/login/adminLoginGuard.guard';
import { ConnectAdminLoginGuard} from './openaireLibrary/login/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{ClaimsAdminComponent} from './openaireLibrary/claims/claimsAdmin/claimsAdmin.component'; import{ClaimsAdminComponent} from './openaireLibrary/claims/claimsAdmin/claimsAdmin.component';
import {StatsComponent} from "./pages/stats/stats.component"; import {StatsComponent} from "./pages/stats/stats.component";
//TODO replace FreeGuard with ConnectAdminLoginGuard
const appRoutes: Routes = [ const appRoutes: Routes = [
{ {
@ -96,6 +99,9 @@ const appRoutes: Routes = [
path: 'claims', path: 'claims',
component: ClaimsComponent,canActivate: [FreeGuard],resolve: { envSpecific: EnvironmentSpecificResolver } component: ClaimsComponent,canActivate: [FreeGuard],resolve: { envSpecific: EnvironmentSpecificResolver }
}, },
{ path: 'reload', loadChildren: './reload/libReload.module#LibReloadModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ path: 'user-info', loadChildren: './login/libUser.module#LibUserModule', resolve: { envSpecific: EnvironmentSpecificResolver }},
{ {
path: 'stats', path: 'stats',
component: StatsComponent,canActivate: [FreeGuard],resolve: { envSpecific: EnvironmentSpecificResolver } component: StatsComponent,canActivate: [FreeGuard],resolve: { envSpecific: EnvironmentSpecificResolver }

View File

@ -0,0 +1,20 @@
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';
import { UserModule} from '../openaireLibrary/login/user.module';
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
@NgModule({
imports: [
CommonModule, FormsModule,
UserRoutingModule, UserModule
],
providers:[PreviousRouteRecorder],
declarations: [ConnectUserComponent]
})
export class LibUserModule { }

View File

@ -0,0 +1,15 @@
import { NgModule } from '@angular/core';
import { RouterModule } from '@angular/router';
import {ConnectUserComponent } from './user.component';
import {PreviousRouteRecorder} from '../openaireLibrary/utils/piwik/previousRouteRecorder.guard';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: ConnectUserComponent, canDeactivate: [PreviousRouteRecorder]},
])
]
})
export class UserRoutingModule { }

View File

@ -0,0 +1,11 @@
import {Component, ElementRef} from '@angular/core';
import {Observable} from 'rxjs/Observable';
@Component({
selector: 'openaire-user',
template: `<user></user>`
})
export class ConnectUserComponent {
}

View File

@ -9,6 +9,7 @@ import { ModalFormComponent } from "../modal-form.component";
import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component"; import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
import { CommunityFormComponent } from "./community-form.component"; import { CommunityFormComponent } from "./community-form.component";
import { CheckCommunity, Community } from "../../domain/community"; import { CheckCommunity, Community } from "../../domain/community";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'communities', selector: 'communities',
@ -39,23 +40,28 @@ export class CommunitiesComponent implements OnInit {
public formGroup : FormGroup; public formGroup : FormGroup;
private searchText : RegExp = new RegExp(''); private searchText : RegExp = new RegExp('');
public properties:EnvProperties = null;
ngOnInit() { ngOnInit() {
this.formGroup = this.formComponent.form; this.formGroup = this.formComponent.form;
this.route.queryParams.subscribe(params => {
if(params['community']) { this.route.data
this.getCommunity(params['community']); .subscribe((data: { envSpecific: EnvProperties }) => {
} else { this.properties = data.envSpecific;
this.getCommunities(); this.route.queryParams.subscribe(params => {
} if(params['community']) {
}); this.getCommunity(params['community']);
} else {
this.getCommunities();
}
});
});
} }
constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {} constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
getCommunity(community_pid: string) { getCommunity(community_pid: string) {
let self = this; let self = this;
this._helpContentService.getCommunityFull(community_pid).subscribe( this._helpContentService.getCommunityFull(community_pid, this.properties.adminToolsAPIURL).subscribe(
community => { community => {
self.communities = [community]; self.communities = [community];
this.checkboxes.push(<CheckCommunity>{community : community, checked : false}); this.checkboxes.push(<CheckCommunity>{community : community, checked : false});
@ -65,7 +71,7 @@ export class CommunitiesComponent implements OnInit {
getCommunities() { getCommunities() {
let self = this; let self = this;
this._helpContentService.getCommunitiesFull().subscribe( this._helpContentService.getCommunitiesFull(this.properties.adminToolsAPIURL).subscribe(
communities => { communities => {
self.communities = communities; self.communities = communities;
@ -111,7 +117,7 @@ export class CommunitiesComponent implements OnInit {
} }
public confirmedDeleteCommunities(ids : string[]) { public confirmedDeleteCommunities(ids : string[]) {
this._helpContentService.deleteCommunities(ids).subscribe( this._helpContentService.deleteCommunities(ids, this.properties.adminToolsAPIURL).subscribe(
_ => this.deleteCommunitiesFromArray(ids), _ => this.deleteCommunitiesFromArray(ids),
error => this.handleError('System error deleting the selected communities', error) error => this.handleError('System error deleting the selected communities', error)
); );

View File

@ -8,6 +8,7 @@ import { DivIdFormComponent } from "./divId-form.component";
import { CheckDivId, DivId } from "../../domain/divId"; import { CheckDivId, DivId } from "../../domain/divId";
import { Community } from "../../domain/community"; import { Community } from "../../domain/community";
import { Page } from "../../domain/page"; import { Page } from "../../domain/page";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'divIds', selector: 'divIds',
@ -42,17 +43,22 @@ export class DivIdsComponent implements OnInit {
public selectedCommunityPid: string; public selectedCommunityPid: string;
public communities: Community[] = []; public communities: Community[] = [];
public pages: Page[] = []; public pages: Page[] = [];
public properties:EnvProperties = null;
public formPages: Page[] = []; public formPages: Page[] = [];
ngOnInit() { ngOnInit() {
this.formGroup = this.formComponent.form; this.route.data
this.route.queryParams.subscribe(params => { .subscribe((data: { envSpecific: EnvProperties }) => {
// if(params['community']) { this.properties = data.envSpecific;
// this.getCommunity(params['community']); this.formGroup = this.formComponent.form;
// } else { this.route.queryParams.subscribe(params => {
this.getCommunities(); // if(params['community']) {
//} // this.getCommunity(params['community']);
}); // } else {
this.getCommunities();
//}
});
});
} }
constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {} constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
@ -69,7 +75,7 @@ export class DivIdsComponent implements OnInit {
*/ */
getCommunities() { getCommunities() {
let self = this; let self = this;
this._helpContentService.getCommunities().subscribe( this._helpContentService.getCommunities(this.properties.adminToolsAPIURL).subscribe(
communities => { communities => {
self.communities = communities; self.communities = communities;
self.selectedCommunityPid = self.communities[0].pid; self.selectedCommunityPid = self.communities[0].pid;
@ -83,14 +89,14 @@ export class DivIdsComponent implements OnInit {
} }
getPages(community_pid: string) { getPages(community_pid: string) {
this._helpContentService.getCommunityPages(community_pid).subscribe( this._helpContentService.getCommunityPages(community_pid, this.properties.adminToolsAPIURL).subscribe(
pages => this.pages = pages, pages => this.pages = pages,
error => this.handleError('System error retrieving pages', error)); error => this.handleError('System error retrieving pages', error));
} }
getDivIds(community_pid: string) { getDivIds(community_pid: string) {
let self = this; let self = this;
this._helpContentService.getDivIdsFull(community_pid, null).subscribe( this._helpContentService.getDivIdsFull(community_pid, null, this.properties.adminToolsAPIURL).subscribe(
divIds => { divIds => {
self.divIds = divIds; self.divIds = divIds;
@ -137,7 +143,7 @@ export class DivIdsComponent implements OnInit {
} }
public confirmedDeleteDivIds(ids : string[]) { public confirmedDeleteDivIds(ids : string[]) {
this._helpContentService.deleteDivIds(ids).subscribe( this._helpContentService.deleteDivIds(ids, this.properties.adminToolsAPIURL).subscribe(
_ => this.deleteDivIdsFromArray(ids), _ => this.deleteDivIdsFromArray(ids),
error => this.handleError('System error deleting the selected classes', error) error => this.handleError('System error deleting the selected classes', error)
); );

View File

@ -1,8 +1,10 @@
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute } from "@angular/router";
import { FormGroup, FormBuilder, Validators } from "@angular/forms"; import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { Page } from "../../domain/page"; import { Page } from "../../domain/page";
import { DivId } from "../../domain/divId"; import { DivId } from "../../domain/divId";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
@ -28,19 +30,25 @@ export class DivContentFormComponent implements OnInit{
private ckeditorContent : string; private ckeditorContent : string;
constructor(private _fb: FormBuilder, private _helpContentService: HelpContentService){} constructor(private route: ActivatedRoute, private _fb: FormBuilder, private _helpContentService: HelpContentService){}
public properties:EnvProperties = null;
ngOnInit() { ngOnInit() {
this.myForm = this.form; this.myForm = this.form;
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
if(this.pageId) {
this.showPageSelect = false;
this.getDivs(this.pageId);
} else {
this._helpContentService.getCommunityPagesWithDivId(this.communityPid, this.properties.adminToolsAPIURL).subscribe(
pages => this.availablePages = pages,
error => this.handleError('System error retrieving pages', error));
}
});
if(this.pageId) {
this.showPageSelect = false;
this.getDivs(this.pageId);
} else {
this._helpContentService.getCommunityPagesWithDivId(this.communityPid).subscribe(
pages => this.availablePages = pages,
error => this.handleError('System error retrieving pages', error));
}
} }
public pageSelected(event) { public pageSelected(event) {
@ -49,7 +57,7 @@ export class DivContentFormComponent implements OnInit{
public getDivs(pageId: string) { public getDivs(pageId: string) {
console.info(pageId); console.info(pageId);
this._helpContentService.getDivIdsFull(this.communityPid, pageId).subscribe( this._helpContentService.getDivIdsFull(this.communityPid, pageId, this.properties.adminToolsAPIURL).subscribe(
divs => { divs => {
this.availableDivs = divs; this.availableDivs = divs;
this.pageId = pageId; this.pageId = pageId;

View File

@ -1,13 +1,13 @@
import { Component, ViewChild, OnInit } from '@angular/core'; import { Component, ViewChild, OnInit } from '@angular/core';
import { Router } from "@angular/router"; import { Router, ActivatedRoute } from "@angular/router";
import { FormGroup } from "@angular/forms"; import { FormGroup } from "@angular/forms";
import { ActivatedRoute } from "@angular/router";
import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component"; import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { DivHelpContent, CheckDivHelpContent, DivHelpContentFilterOptions } from "../../domain/div-help-content"; import { DivHelpContent, CheckDivHelpContent, DivHelpContentFilterOptions } from "../../domain/div-help-content";
import { Page } from "../../domain/page"; import { Page } from "../../domain/page";
import { Community } from "../../domain/community"; import { Community } from "../../domain/community";
import { DivId } from "../../domain/divId"; import { DivId } from "../../domain/divId";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'div-help-contents', selector: 'div-help-contents',
@ -54,22 +54,28 @@ export class DivHelpContentsComponent implements OnInit {
public community: Community; public community: Community;
public page: Page; public page: Page;
public properties:EnvProperties = null;
ngOnInit() { ngOnInit() {
this.route.queryParams.subscribe(params => { this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.selectedCommunityPid = params['community']; this.route.queryParams.subscribe(params => {
this.selectedPageId = params['page'];
if(this.selectedCommunityPid && this.selectedPageId) { this.selectedCommunityPid = params['community'];
this.getDivHelpContents(this.selectedCommunityPid); this.selectedPageId = params['page'];
this.getPage(this.selectedPageId);
this.getCommunity(this.selectedCommunityPid); if(this.selectedCommunityPid && this.selectedPageId) {
} else { this.getDivHelpContents(this.selectedCommunityPid);
this.selectedPageId = ""; this.getPage(this.selectedPageId);
this.getCommunities(); this.getCommunity(this.selectedCommunityPid);
} } else {
}); this.selectedPageId = "";
this.getCommunities();
}
});
});
// this.formGroup = this.formComponent.form; // this.formGroup = this.formComponent.form;
} }
@ -77,7 +83,7 @@ export class DivHelpContentsComponent implements OnInit {
getPage(pageId: string) { getPage(pageId: string) {
let self = this; let self = this;
this._helpService.getPage(pageId).subscribe( this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
page => { page => {
self.page = page; self.page = page;
} }
@ -86,7 +92,7 @@ export class DivHelpContentsComponent implements OnInit {
getCommunity(communityPid: string) { getCommunity(communityPid: string) {
let self = this; let self = this;
this._helpService.getCommunity(communityPid).subscribe( this._helpService.getCommunity(communityPid, this.properties.adminToolsAPIURL).subscribe(
community => { community => {
self.community = community; self.community = community;
} }
@ -95,7 +101,7 @@ export class DivHelpContentsComponent implements OnInit {
getCommunities() { getCommunities() {
let self = this; let self = this;
this._helpService.getCommunitiesWithDivId().subscribe( this._helpService.getCommunitiesWithDivId(this.properties.adminToolsAPIURL).subscribe(
communities => { communities => {
self.communities = communities; self.communities = communities;
self.selectedCommunityPid = self.communities[0].pid; self.selectedCommunityPid = self.communities[0].pid;
@ -106,7 +112,7 @@ export class DivHelpContentsComponent implements OnInit {
} }
getPages(community_pid: string) { getPages(community_pid: string) {
this._helpService.getCommunityPagesWithDivId(community_pid).subscribe( this._helpService.getCommunityPagesWithDivId(community_pid, this.properties.adminToolsAPIURL).subscribe(
pages => this.pages = pages, pages => this.pages = pages,
error => this.handleError('System error retrieving pages', error)); error => this.handleError('System error retrieving pages', error));
} }
@ -126,7 +132,7 @@ export class DivHelpContentsComponent implements OnInit {
getDivHelpContents(community_pid: string) { getDivHelpContents(community_pid: string) {
let self = this; let self = this;
this._helpService.getCommunityDivHelpContents(community_pid).subscribe( this._helpService.getCommunityDivHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe(
divHelpContents => { divHelpContents => {
self.divHelpContents = divHelpContents as Array<DivHelpContent>; self.divHelpContents = divHelpContents as Array<DivHelpContent>;
self.counter.all = self.divHelpContents.length; self.counter.all = self.divHelpContents.length;
@ -184,7 +190,7 @@ export class DivHelpContentsComponent implements OnInit {
} }
public confirmedDeleteDivHelpContents(ids : string[]) { public confirmedDeleteDivHelpContents(ids : string[]) {
this._helpService.deleteDivHelpContents(ids).subscribe( this._helpService.deleteDivHelpContents(ids, this.properties.adminToolsAPIURL).subscribe(
_ => this.deleteDivHelpContentsFromArray(ids), _ => this.deleteDivHelpContentsFromArray(ids),
error => this.handleError('System error deleting the selected class content(s)', error) error => this.handleError('System error deleting the selected class content(s)', error)
); );
@ -210,7 +216,7 @@ export class DivHelpContentsComponent implements OnInit {
} }
public toggleDivHelpContents(status : boolean, ids : string[]) { public toggleDivHelpContents(status : boolean, ids : string[]) {
this._helpService.toggleDivHelpContents(ids,status).subscribe( this._helpService.toggleDivHelpContents(ids,status, this.properties.adminToolsAPIURL).subscribe(
() => { () => {
for(let id of ids) { for(let id of ids) {
let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id); let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
@ -224,7 +230,7 @@ export class DivHelpContentsComponent implements OnInit {
} }
public saveDivHelpContent(data : any):void { public saveDivHelpContent(data : any):void {
this._helpService.insertOrUpdateDivHelpContent(data).subscribe( this._helpService.insertOrUpdateDivHelpContent(data, this.properties.adminToolsAPIURL).subscribe(
divHelpContent => this.divHelpContentSavedSuccessfully(divHelpContent), divHelpContent => this.divHelpContentSavedSuccessfully(divHelpContent),
error => this.handleError('System error saving the specified help content', error) error => this.handleError('System error saving the specified help content', error)
); );

View File

@ -4,6 +4,7 @@ import { Subscription } from "rxjs/Subscription";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { DivHelpContent } from "../../domain/div-help-content"; import { DivHelpContent } from "../../domain/div-help-content";
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'edit-div-help-content', selector: 'edit-div-help-content',
@ -24,6 +25,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
private divHelpContent: DivHelpContent; private divHelpContent: DivHelpContent;
private errorMessage : string = null; private errorMessage : string = null;
public properties:EnvProperties = null;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -31,16 +33,19 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
private _helpContentService: HelpContentService) {} private _helpContentService: HelpContentService) {}
ngOnInit() { ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.sub = this.route.queryParams.subscribe(params => { this.sub = this.route.queryParams.subscribe(params => {
//let id = params['id']; //let id = params['id'];
let divContentId = params['classContentId']; let divContentId = params['classContentId'];
this.communityPid = params['community']; this.communityPid = params['community'];
this.pageId = params['pageId']; this.pageId = params['pageId'];
this._helpContentService.getDivHelpContent(divContentId as string).subscribe( this._helpContentService.getDivHelpContent(divContentId as string, this.properties.adminToolsAPIURL).subscribe(
divHelpContent => this.updateForm(divHelpContent), divHelpContent => this.updateForm(divHelpContent),
error => this.handleError('System error retrieving class help content', error)); error => this.handleError('System error retrieving class help content', error));
}); });
});
} }
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
@ -51,7 +56,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
} }
getDivId(divId: string) { getDivId(divId: string) {
this._helpContentService.getDivId(divId).subscribe( this._helpContentService.getDivId(divId, this.properties.adminToolsAPIURL).subscribe(
divId => { divId => {
this.formComponent.pageId = divId.page; this.formComponent.pageId = divId.page;
this.formComponent.getDivs(this.formComponent.pageId); this.formComponent.getDivs(this.formComponent.pageId);
@ -74,7 +79,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
private saveCustom() { private saveCustom() {
if(this.formComponent.myForm.valid) { if(this.formComponent.myForm.valid) {
let divHelpContent : DivHelpContent = this.formComponent.myForm.value; let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent).subscribe( this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL).subscribe(
_ => { _ => {
if(this.pageId) { if(this.pageId) {
this.router.navigate( ['/classContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } ); this.router.navigate( ['/classContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } );

View File

@ -3,6 +3,7 @@ import { ActivatedRoute, Router } from "@angular/router";
import { DivContentFormComponent } from "./div-help-content-form.component"; import { DivContentFormComponent } from "./div-help-content-form.component";
import { DivHelpContent } from "../../domain/div-help-content"; import { DivHelpContent } from "../../domain/div-help-content";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'new-div-help-content', selector: 'new-div-help-content',
@ -19,6 +20,7 @@ export class NewDivHelpContentComponent {
private communityPid: string; private communityPid: string;
private pageId: string; private pageId: string;
public properties:EnvProperties = null;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -26,10 +28,14 @@ export class NewDivHelpContentComponent {
private _helpContentService: HelpContentService) {} private _helpContentService: HelpContentService) {}
ngOnInit() { ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
this.communityPid = params['community']; this.communityPid = params['community'];
this.pageId = params['pageId']; this.pageId = params['pageId'];
}); });
});
} }
private saveCustom() { private saveCustom() {
@ -39,7 +45,7 @@ export class NewDivHelpContentComponent {
if(this.formComponent.myForm.valid) { if(this.formComponent.myForm.valid) {
let divHelpContent : DivHelpContent = this.formComponent.myForm.value; let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent).subscribe( this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL).subscribe(
_ => { _ => {
if(this.pageId) { if(this.pageId) {
this.router.navigate( ['/classContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } ); this.router.navigate( ['/classContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } );

View File

@ -1,4 +1,5 @@
import { Component, ViewChild, OnInit } from '@angular/core'; import { Component, ViewChild, OnInit } from '@angular/core';
import { ActivatedRoute } from "@angular/router";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { FormGroup } from "@angular/forms"; import { FormGroup } from "@angular/forms";
import { ModalFormComponent } from "../modal-form.component"; import { ModalFormComponent } from "../modal-form.component";
@ -6,6 +7,7 @@ import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog
import { EntityFormComponent } from "./entity-form.component"; import { EntityFormComponent } from "./entity-form.component";
import { CheckEntity, Entity } from "../../domain/entity"; import { CheckEntity, Entity } from "../../domain/entity";
import { Community } from "../../domain/community"; import { Community } from "../../domain/community";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'entities', selector: 'entities',
@ -44,18 +46,23 @@ export class EntitiesComponent implements OnInit {
public okModal:ModalFormComponent; public okModal:ModalFormComponent;
public toggleIds: string[]; public toggleIds: string[];
public toggleStatus: boolean; public toggleStatus: boolean;
public properties:EnvProperties = null;
ngOnInit() { ngOnInit() {
this.getCommunities(); this.formGroup = this.formComponent.form;
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.getCommunities();
});
this.formGroup = this.formComponent.form;
} }
constructor(private _helpContentService: HelpContentService) {} constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
getCommunities() { getCommunities() {
let self = this; let self = this;
this._helpContentService.getCommunities().subscribe( this._helpContentService.getCommunities(this.properties.adminToolsAPIURL).subscribe(
communities => { communities => {
self.communities = communities; self.communities = communities;
self.selectedCommunityPid = self.communities[0].pid; self.selectedCommunityPid = self.communities[0].pid;
@ -66,7 +73,7 @@ public toggleStatus: boolean;
getEntities(community_pid: string) { getEntities(community_pid: string) {
let self = this; let self = this;
this._helpContentService.getCommunityEntities(community_pid).subscribe( this._helpContentService.getCommunityEntities(community_pid, this.properties.adminToolsAPIURL).subscribe(
entities => { entities => {
self.entities = entities; self.entities = entities;
self.checkboxes = []; self.checkboxes = [];
@ -113,7 +120,7 @@ public toggleStatus: boolean;
} }
public confirmedDeleteEntities(ids : string[]) { public confirmedDeleteEntities(ids : string[]) {
this._helpContentService.deleteEntities(ids).subscribe( this._helpContentService.deleteEntities(ids, this.properties.adminToolsAPIURL).subscribe(
_ => this.deleteEntitiesFromArray(ids), _ => this.deleteEntitiesFromArray(ids),
error => this.handleError('System error deleting the selected entities', error) error => this.handleError('System error deleting the selected entities', error)
); );
@ -177,7 +184,7 @@ public toggleStatus: boolean;
} }
public continueToggling(event: any) { public continueToggling(event: any) {
this._helpContentService.toggleEntities(this.selectedCommunityPid,this.toggleIds,this.toggleStatus).subscribe( this._helpContentService.toggleEntities(this.selectedCommunityPid,this.toggleIds,this.toggleStatus, this.properties.adminToolsAPIURL).subscribe(
() => { () => {
for(let id of this.toggleIds) { for(let id of this.toggleIds) {
let i = this.checkboxes.findIndex(_ => _.entity._id == id); let i = this.checkboxes.findIndex(_ => _.entity._id == id);

View File

@ -7,6 +7,7 @@ import { Subscription } from "rxjs/Subscription";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { PageHelpContent } from "../../domain/page-help-content"; import { PageHelpContent } from "../../domain/page-help-content";
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'edit-page-help-content', selector: 'edit-page-help-content',
@ -27,6 +28,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
private pageHelpContent: PageHelpContent; private pageHelpContent: PageHelpContent;
private errorMessage : string = null; private errorMessage : string = null;
public properties:EnvProperties = null;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -34,16 +36,19 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
private _helpContentService: HelpContentService) {} private _helpContentService: HelpContentService) {}
ngOnInit() { ngOnInit() {
this.route.data
this.sub = this.route.queryParams.subscribe(params => { .subscribe((data: { envSpecific: EnvProperties }) => {
//let id = params['id']; this.properties = data.envSpecific;
let pageContentId = params['pageContentId']; this.sub = this.route.queryParams.subscribe(params => {
this.communityPid = params['community']; //let id = params['id'];
this.pageId = params['pageId']; let pageContentId = params['pageContentId'];
this._helpContentService.getPageHelpContent(pageContentId as string).subscribe( this.communityPid = params['community'];
pageHelpContent => this.updateForm(pageHelpContent), this.pageId = params['pageId'];
error => this.handleError('System error retrieving page help content', error)); this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL).subscribe(
}); pageHelpContent => this.updateForm(pageHelpContent),
error => this.handleError('System error retrieving page help content', error));
});
});
} }
ngOnDestroy() { ngOnDestroy() {
this.sub.unsubscribe(); this.sub.unsubscribe();
@ -64,7 +69,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
if(this.formComponent.myForm.valid) { if(this.formComponent.myForm.valid) {
let pageHelpContent : PageHelpContent = this.formComponent.myForm.value; let pageHelpContent : PageHelpContent = this.formComponent.myForm.value;
console.info(pageHelpContent.community); console.info(pageHelpContent.community);
this._helpContentService.updatePageHelpContent(pageHelpContent).subscribe( this._helpContentService.updatePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL).subscribe(
_ => { _ => {
if(this.pageId) { if(this.pageId) {
this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } ); this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } );

View File

@ -6,6 +6,7 @@ import { ActivatedRoute, Router } from "@angular/router";
import { PageContentFormComponent } from "./page-help-content-form.component"; import { PageContentFormComponent } from "./page-help-content-form.component";
import { PageHelpContent } from "../../domain/page-help-content"; import { PageHelpContent } from "../../domain/page-help-content";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'new-page-help-content', selector: 'new-page-help-content',
@ -22,6 +23,7 @@ export class NewPageHelpContentComponent {
private communityPid: string; private communityPid: string;
private pageId: string; private pageId: string;
public properties:EnvProperties = null;
constructor( constructor(
private route: ActivatedRoute, private route: ActivatedRoute,
@ -29,10 +31,14 @@ export class NewPageHelpContentComponent {
private _helpContentService: HelpContentService) {} private _helpContentService: HelpContentService) {}
ngOnInit() { ngOnInit() {
this.route.queryParams.subscribe(params => { this.route.data
this.communityPid = params['community']; .subscribe((data: { envSpecific: EnvProperties }) => {
this.pageId = params['pageId']; this.properties = data.envSpecific;
}); this.route.queryParams.subscribe(params => {
this.communityPid = params['community'];
this.pageId = params['pageId'];
});
});
} }
private saveCustom() { private saveCustom() {
@ -42,7 +48,7 @@ export class NewPageHelpContentComponent {
if(this.formComponent.myForm.valid) { if(this.formComponent.myForm.valid) {
let pageHelpContent : PageHelpContent = this.formComponent.myForm.value; let pageHelpContent : PageHelpContent = this.formComponent.myForm.value;
this._helpContentService.savePageHelpContent(pageHelpContent).subscribe( this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL).subscribe(
_ => { _ => {
if(this.pageId) { if(this.pageId) {
this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } ); this.router.navigate( ['/pageContents/'], { queryParams: { "community": this.communityPid, "page": this.pageId } } );

View File

@ -2,9 +2,11 @@
* Created by stefania on 7/14/17. * Created by stefania on 7/14/17.
*/ */
import { Component, OnInit, Input } from '@angular/core'; import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute } from "@angular/router";
import { FormGroup, FormBuilder, Validators } from "@angular/forms"; import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { Page } from "../../domain/page"; import { Page } from "../../domain/page";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
@ -25,14 +27,19 @@ export class PageContentFormComponent implements OnInit{
private errorMessage: string; private errorMessage: string;
private ckeditorContent : string; private ckeditorContent : string;
public properties:EnvProperties = null;
constructor(private _fb: FormBuilder, private _helpContentService: HelpContentService){} constructor(private route: ActivatedRoute,private _fb: FormBuilder, private _helpContentService: HelpContentService){}
ngOnInit() { ngOnInit() {
this.myForm = this.form; this.myForm = this.form;
this._helpContentService.getCommunityPages(this.communityPid).subscribe( this.route.data
pages => this.availablePages = pages, .subscribe((data: { envSpecific: EnvProperties }) => {
error => this.handleError('System error retrieving pages', error)); this.properties = data.envSpecific;
this._helpContentService.getCommunityPages(this.communityPid, this.properties.adminToolsAPIURL).subscribe(
pages => this.availablePages = pages,
error => this.handleError('System error retrieving pages', error));
});
} }
public get form() { public get form() {

View File

@ -10,6 +10,7 @@ import { PageHelpContent, CheckPageHelpContent, PageHelpContentFilterOptions } f
import { Page } from "../../domain/page"; import { Page } from "../../domain/page";
import {Router} from "@angular/router"; import {Router} from "@angular/router";
import { Community } from "../../domain/community"; import { Community } from "../../domain/community";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'page-help-contents', selector: 'page-help-contents',
@ -56,21 +57,26 @@ export class PageHelpContentsComponent implements OnInit {
public community: Community; public community: Community;
public page: Page; public page: Page;
public properties:EnvProperties = null;
ngOnInit() { ngOnInit() {
this.route.queryParams.subscribe(params => { this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => {
this.selectedCommunityPid = params['community']; this.selectedCommunityPid = params['community'];
this.selectedPageId = params['page']; this.selectedPageId = params['page'];
if(this.selectedCommunityPid && this.selectedPageId) { if(this.selectedCommunityPid && this.selectedPageId) {
this.getPageHelpContents(this.selectedCommunityPid); this.getPageHelpContents(this.selectedCommunityPid);
this.getPage(this.selectedPageId); this.getPage(this.selectedPageId);
this.getCommunity(this.selectedCommunityPid); this.getCommunity(this.selectedCommunityPid);
} else { } else {
this.selectedPageId = ""; this.selectedPageId = "";
this.getCommunities(); this.getCommunities();
} }
});
}); });
// this.formGroup = this.formComponent.form; // this.formGroup = this.formComponent.form;
} }
@ -79,7 +85,7 @@ export class PageHelpContentsComponent implements OnInit {
getPage(pageId: string) { getPage(pageId: string) {
let self = this; let self = this;
this._helpService.getPage(pageId).subscribe( this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
page => { page => {
self.page = page; self.page = page;
} }
@ -88,7 +94,7 @@ export class PageHelpContentsComponent implements OnInit {
getCommunity(communityPid: string) { getCommunity(communityPid: string) {
let self = this; let self = this;
this._helpService.getCommunity(communityPid).subscribe( this._helpService.getCommunity(communityPid, this.properties.adminToolsAPIURL).subscribe(
community => { community => {
self.community = community; self.community = community;
} }
@ -97,7 +103,7 @@ export class PageHelpContentsComponent implements OnInit {
getCommunities() { getCommunities() {
let self = this; let self = this;
this._helpService.getCommunities().subscribe( this._helpService.getCommunities(this.properties.adminToolsAPIURL).subscribe(
communities => { communities => {
self.communities = communities; self.communities = communities;
self.selectedCommunityPid = self.communities[0].pid; self.selectedCommunityPid = self.communities[0].pid;
@ -108,7 +114,7 @@ export class PageHelpContentsComponent implements OnInit {
} }
getPages(community_pid: string) { getPages(community_pid: string) {
this._helpService.getCommunityPages(community_pid).subscribe( this._helpService.getCommunityPages(community_pid, this.properties.adminToolsAPIURL).subscribe(
pages => this.pages = pages, pages => this.pages = pages,
error => this.handleError('System error retrieving pages', error)); error => this.handleError('System error retrieving pages', error));
} }
@ -128,7 +134,7 @@ export class PageHelpContentsComponent implements OnInit {
getPageHelpContents(community_pid: string) { getPageHelpContents(community_pid: string) {
let self = this; let self = this;
this._helpService.getCommunityPageHelpContents(community_pid).subscribe( this._helpService.getCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe(
pageHelpContents => { pageHelpContents => {
self.pageHelpContents = pageHelpContents as Array<PageHelpContent>; self.pageHelpContents = pageHelpContents as Array<PageHelpContent>;
self.counter.all = self.pageHelpContents.length; self.counter.all = self.pageHelpContents.length;
@ -183,7 +189,7 @@ export class PageHelpContentsComponent implements OnInit {
} }
public confirmedDeletePageHelpContents(ids : string[]) { public confirmedDeletePageHelpContents(ids : string[]) {
this._helpService.deletePageHelpContents(ids).subscribe( this._helpService.deletePageHelpContents(ids, this.properties.adminToolsAPIURL).subscribe(
_ => this.deletePageHelpContentsFromArray(ids), _ => this.deletePageHelpContentsFromArray(ids),
error => this.handleError('System error deleting the selected page content(s)', error) error => this.handleError('System error deleting the selected page content(s)', error)
); );
@ -209,7 +215,7 @@ export class PageHelpContentsComponent implements OnInit {
} }
public togglePageHelpContents(status : boolean, ids : string[]) { public togglePageHelpContents(status : boolean, ids : string[]) {
this._helpService.togglePageHelpContents(ids,status).subscribe( this._helpService.togglePageHelpContents(ids,status, this.properties.adminToolsAPIURL).subscribe(
() => { () => {
for(let id of ids) { for(let id of ids) {
let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id); let i = this.checkboxes.findIndex(_ => _.pageHelpContent._id == id);
@ -225,7 +231,7 @@ export class PageHelpContentsComponent implements OnInit {
public savePageHelpContent(data : any):void { public savePageHelpContent(data : any):void {
console.log(data); console.log(data);
this._helpService.savePageHelpContent(data).subscribe( this._helpService.savePageHelpContent(data, this.properties.adminToolsAPIURL).subscribe(
pageHelpContent => this.pageHelpContentSavedSuccessfully(pageHelpContent), pageHelpContent => this.pageHelpContentSavedSuccessfully(pageHelpContent),
error => this.handleError('System error saving the specified help content', error) error => this.handleError('System error saving the specified help content', error)
); );

View File

@ -3,6 +3,7 @@
*/ */
import { Component, ViewChild, Input, Output, EventEmitter, OnInit } from '@angular/core'; import { Component, ViewChild, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { ModalDirective } from 'ngx-bootstrap/modal'; import { ModalDirective } from 'ngx-bootstrap/modal';
import { ActivatedRoute } from "@angular/router";
import { FormGroup } from "@angular/forms"; import { FormGroup } from "@angular/forms";
import { FAQService } from "../services/faq.service"; import { FAQService } from "../services/faq.service";
import { Topic } from "../domain/topic"; import { Topic } from "../domain/topic";
@ -12,6 +13,7 @@ import { Page } from "../domain/page";
import { Entity } from "../domain/entity"; import { Entity } from "../domain/entity";
import { Community } from "../domain/community"; import { Community } from "../domain/community";
import { DivId } from "../domain/divId"; import { DivId } from "../domain/divId";
import { EnvProperties } from '../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'modal-form', selector: 'modal-form',
@ -19,7 +21,7 @@ import { DivId } from "../domain/divId";
}) })
export class ModalFormComponent { export class ModalFormComponent {
constructor(private _faqService : FAQService, private _helpService: HelpContentService){ constructor(private route: ActivatedRoute, private _faqService : FAQService, private _helpService: HelpContentService){
} }
@ViewChild('autoShownModal') @ViewChild('autoShownModal')
@ -45,6 +47,15 @@ export class ModalFormComponent {
@Output() emmitObject: EventEmitter<any> = new EventEmitter(); @Output() emmitObject: EventEmitter<any> = new EventEmitter();
@Output() emmitError: EventEmitter<any> = new EventEmitter(); @Output() emmitError: EventEmitter<any> = new EventEmitter();
public properties:EnvProperties = null;
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
});
}
public showModal():void { public showModal():void {
this.isModalShown = true; this.isModalShown = true;
@ -81,14 +92,14 @@ export class ModalFormComponent {
); );
} else if (this.type == 'community') { } else if (this.type == 'community') {
if(this.saveText == 'Update') { if(this.saveText == 'Update') {
this._helpService.updateCommunity(<Community> obj).subscribe( this._helpService.updateCommunity(<Community> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data), data => this.emmitObject.emit(data),
error => this.emmitError.emit(error) error => this.emmitError.emit(error)
); );
console.info(<Community> obj); console.info(<Community> obj);
} else if(this.saveText == 'Save') { } else if(this.saveText == 'Save') {
this._helpService.saveCommunity(<Community> obj).subscribe( this._helpService.saveCommunity(<Community> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data), data => this.emmitObject.emit(data),
error => this.emmitError.emit(error) error => this.emmitError.emit(error)
); );
@ -96,37 +107,36 @@ export class ModalFormComponent {
} }
} else if (this.type == 'page') { } else if (this.type == 'page') {
if(this.saveText == 'Update') { if(this.saveText == 'Update') {
this._helpService.updatePage(<Page> obj).subscribe( this._helpService.updatePage(<Page> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data), data => this.emmitObject.emit(data),
error => this.emmitError.emit(error) error => this.emmitError.emit(error)
); );
} else if(this.saveText == 'Save') { } else if(this.saveText == 'Save') {
this._helpService.savePage(<Page> obj).subscribe( this._helpService.savePage(<Page> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data), data => this.emmitObject.emit(data),
error => this.emmitError.emit(error) error => this.emmitError.emit(error)
); );
} }
} else if (this.type == 'entity') { } else if (this.type == 'entity') {
if(this.saveText == 'Update') { if(this.saveText == 'Update') {
this._helpService.updateEntity(<Entity> obj).subscribe( this._helpService.updateEntity(<Entity> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data), data => this.emmitObject.emit(data),
error => this.emmitError.emit(error) error => this.emmitError.emit(error)
); );
} else if(this.saveText == 'Save') { } else if(this.saveText == 'Save') {
this._helpService.saveEntity(<Entity> obj).subscribe( this._helpService.saveEntity(<Entity> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data), data => this.emmitObject.emit(data),
error => this.emmitError.emit(error) error => this.emmitError.emit(error)
); );
} }
} else if (this.type == 'divId') { } else if (this.type == 'divId') {
if(this.saveText == 'Update') { if(this.saveText == 'Update') {
this._helpService.updateDivId(<DivId> obj).subscribe( this._helpService.updateDivId(<DivId> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data), data => this.emmitObject.emit(data),
error => this.emmitError.emit(error) error => this.emmitError.emit(error)
); );
} else if(this.saveText == 'Save') { } else if(this.saveText == 'Save') {
//console.info(<DivId> obj); this._helpService.saveDivId(<DivId> obj, this.properties.adminToolsAPIURL).subscribe(
this._helpService.saveDivId(<DivId> obj).subscribe(
data => this.emmitObject.emit(data), data => this.emmitObject.emit(data),
error => this.emmitError.emit(error) error => this.emmitError.emit(error)
); );

View File

@ -2,9 +2,11 @@
* Created by stefania on 7/13/17. * Created by stefania on 7/13/17.
*/ */
import {Component, OnInit, Input} from '@angular/core'; import {Component, OnInit, Input} from '@angular/core';
import { ActivatedRoute } from "@angular/router";
import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms"; import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms";
import {Entity} from '../../domain/entity'; import {Entity} from '../../domain/entity';
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'page-form', selector: 'page-form',
@ -22,10 +24,16 @@ export class PageFormComponent implements OnInit{
public allEntities: Map<Entity, boolean> = new Map<Entity, boolean>(); public allEntities: Map<Entity, boolean> = new Map<Entity, boolean>();
private gotEntities: boolean = false; private gotEntities: boolean = false;
public properties:EnvProperties = null;
constructor(public _fb: FormBuilder, private _helpContentService: HelpContentService){} constructor(private route: ActivatedRoute,public _fb: FormBuilder, private _helpContentService: HelpContentService){}
ngOnInit(): void {} ngOnInit(): void {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
});
}
public toggle() { public toggle() {
this.myForm.value.isCollapsed = !this.myForm.value.isCollapsed; this.myForm.value.isCollapsed = !this.myForm.value.isCollapsed;
@ -57,7 +65,7 @@ export class PageFormComponent implements OnInit{
public getEntities(includedEntities: Set<String>) { public getEntities(includedEntities: Set<String>) {
let self = this; let self = this;
this._helpContentService.getEntities().subscribe( this._helpContentService.getEntities(this.properties.adminToolsAPIURL).subscribe(
entities => { entities => {
for(let entity of entities) { for(let entity of entities) {
if(includedEntities.has(entity._id)) { if(includedEntities.has(entity._id)) {

View File

@ -11,6 +11,7 @@ import { PageFormComponent } from "./page-form.component";
import { CheckPage, Page } from "../../domain/page"; import { CheckPage, Page } from "../../domain/page";
import { Community } from "../../domain/community"; import { Community } from "../../domain/community";
import { Entity } from "../../domain/entity"; import { Entity } from "../../domain/entity";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
@Component({ @Component({
selector: 'pages', selector: 'pages',
@ -48,17 +49,22 @@ export class PagesComponent implements OnInit {
public selectedCommunityPid: string; public selectedCommunityPid: string;
public pagesType: string; public pagesType: string;
public properties:EnvProperties = null;
ngOnInit() { ngOnInit() {
this.formGroup = this.formComponent.form; this.formGroup = this.formComponent.form;
// this.getCommunities(); this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
// this.getCommunities();
this.route.queryParams.subscribe(params => { this.route.queryParams.subscribe(params => {
this.pagesType = ""; this.pagesType = "";
if(params['type']) { if(params['type']) {
this.pagesType = params['type']; this.pagesType = params['type'];
} }
this.getCommunities(); this.getCommunities();
});
}); });
} }
@ -68,13 +74,13 @@ export class PagesComponent implements OnInit {
let self = this; let self = this;
if(this.pagesType) { if(this.pagesType) {
this._helpContentService.getCommunityPagesByType(community_pid, "?page_type="+this.pagesType).subscribe( this._helpContentService.getCommunityPagesByType(community_pid, "?page_type="+this.pagesType, this.properties.adminToolsAPIURL).subscribe(
pages => { pages => {
self.pagesReturned(pages); self.pagesReturned(pages);
}, },
error => this.handleError('System error retrieving pages', error)); error => this.handleError('System error retrieving pages', error));
} else { } else {
this._helpContentService.getCommunityPages(community_pid).subscribe( this._helpContentService.getCommunityPages(community_pid, this.properties.adminToolsAPIURL).subscribe(
pages => { pages => {
self.pagesReturned(pages); self.pagesReturned(pages);
}, },
@ -84,7 +90,7 @@ export class PagesComponent implements OnInit {
getPagesWithDivIds(community_pid: string) { getPagesWithDivIds(community_pid: string) {
let self = this; let self = this;
this._helpContentService.getPagesWithDivIds(community_pid).subscribe( this._helpContentService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe(
pages => { pages => {
self.pageWithDivIds = pages[community_pid]; self.pageWithDivIds = pages[community_pid];
}, },
@ -102,7 +108,7 @@ export class PagesComponent implements OnInit {
getCommunities() { getCommunities() {
let self = this; let self = this;
this._helpContentService.getCommunities().subscribe( this._helpContentService.getCommunities(this.properties.adminToolsAPIURL).subscribe(
communities => { communities => {
self.communities = communities; self.communities = communities;
self.selectedCommunityPid = self.communities[0].pid; self.selectedCommunityPid = self.communities[0].pid;
@ -147,7 +153,7 @@ export class PagesComponent implements OnInit {
} }
public confirmedDeletePages(ids : string[]) { public confirmedDeletePages(ids : string[]) {
this._helpContentService.deletePages(ids).subscribe( this._helpContentService.deletePages(ids, this.properties.adminToolsAPIURL).subscribe(
_ => this.deletePagesFromArray(ids), _ => this.deletePagesFromArray(ids),
error => this.handleError('System error deleting the selected pages', error) error => this.handleError('System error deleting the selected pages', error)
); );
@ -214,7 +220,7 @@ export class PagesComponent implements OnInit {
} }
public togglePages(status : boolean, ids : string[]) { public togglePages(status : boolean, ids : string[]) {
this._helpContentService.togglePages(this.selectedCommunityPid,ids,status).subscribe( this._helpContentService.togglePages(this.selectedCommunityPid,ids,status, this.properties.adminToolsAPIURL).subscribe(
() => { () => {
for(let id of ids) { for(let id of ids) {
// let i = this.checkboxes.findIndex(_ => _.page._id == id); // let i = this.checkboxes.findIndex(_ => _.page._id == id);

View File

@ -19,7 +19,7 @@ export class StatsComponent implements OnInit {
} }
getStatistics() { getStatistics() {
this.contentService.getStatistics('egi').subscribe( this.contentService.getStatistics('egi',"").subscribe(
stats => this.stats = stats, stats => this.stats = stats,
error => console.log(error), error => console.log(error),
() => { () => {
@ -32,4 +32,4 @@ export class StatsComponent implements OnInit {
} }
); );
} }
} }

View File

@ -0,0 +1,23 @@
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';
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule, ReloadModule
],
declarations: [
],
providers:[
],
exports: [
]
})
export class LibReloadModule { }

View File

@ -10,6 +10,8 @@ import { Community } from "../domain/community";
import { Entity } from "../domain/entity"; import { Entity } from "../domain/entity";
import { DivId } from "../domain/divId"; import { DivId } from "../domain/divId";
import { DivHelpContent } from "../domain/div-help-content"; import { DivHelpContent } from "../domain/div-help-content";
import {COOKIE} from "../openaireLibrary/login/utils/helper.class"
import {CommunityStatistics} from "../domain/statistics-classes"; import {CommunityStatistics} from "../domain/statistics-classes";
@Injectable() @Injectable()
@ -18,8 +20,6 @@ export class HelpContentService {
constructor(private http:Http) { constructor(private http:Http) {
} }
private _helpContentUrl = process.env.API_ENDPOINT;
static removeNulls(obj){ static removeNulls(obj){
var isArray = obj instanceof Array; var isArray = obj instanceof Array;
for (var k in obj){ for (var k in obj){
@ -28,222 +28,222 @@ export class HelpContentService {
} }
} }
getDivIdsFull(community_pid: string, page_id: string) { getDivIdsFull(community_pid: string, page_id: string, helpContentUrl:string) {
if(page_id) { if(page_id) {
return this.http.get(this._helpContentUrl + 'divFull?community='+community_pid+'&page='+page_id) return this.http.get(helpContentUrl + 'divFull?community='+community_pid+'&page='+page_id)
.map(res => <Array<DivId>> res.json()) .map(res => <Array<DivId>> res.json())
.catch(this.handleError); .catch(this.handleError);
} else { } else {
return this.http.get(this._helpContentUrl + 'divFull?community='+community_pid) return this.http.get(helpContentUrl + 'divFull?community='+community_pid)
.map(res => <Array<DivId>> res.json()) .map(res => <Array<DivId>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
} }
updateDivId(divId: DivId) { updateDivId(divId: DivId, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(divId); HelpContentService.removeNulls(divId);
return this.http.post(this._helpContentUrl + 'div/update', JSON.stringify(divId), options) return this.http.post(helpContentUrl + 'div/update', JSON.stringify(divId), options)
.map(res => <DivId> res.json()) .map(res => <DivId> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getDivId(divId: string) { getDivId(divId: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'div/'+divId) return this.http.get(helpContentUrl + 'div/'+divId)
.map(res => <DivId> res.json()) .map(res => <DivId> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
saveDivId(divId: DivId) { saveDivId(divId: DivId, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(divId); HelpContentService.removeNulls(divId);
return this.http.post(this._helpContentUrl + 'div/save', JSON.stringify(divId), options) return this.http.post(helpContentUrl + 'div/save', JSON.stringify(divId), options)
.map(res => <DivId> res.json()) .map(res => <DivId> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunitiesWithDivId() { getCommunitiesWithDivId(helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'community?div=true') return this.http.get(helpContentUrl + 'community?div=true')
.map(res => <Array<Community>> res.json()) .map(res => <Array<Community>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunityPagesWithDivId(community_pid: string) { getCommunityPagesWithDivId(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'community/'+community_pid+'/pages?div=true') return this.http.get(helpContentUrl + 'community/'+community_pid+'/pages?div=true')
.map(res => <Array<Page>> res.json()) .map(res => <Array<Page>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunityDivHelpContents(community_pid: string) { getCommunityDivHelpContents(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'divhelpcontent?community='+community_pid) return this.http.get(helpContentUrl + 'divhelpcontent?community='+community_pid)
.map(res => <Array<DivHelpContent>> res.json()) .map(res => <Array<DivHelpContent>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getDivHelpContent(id : string) { getDivHelpContent(id : string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'divhelpcontent/' + id) return this.http.get(helpContentUrl + 'divhelpcontent/' + id)
.map(res => <DivHelpContent> res.json()) .map(res => <DivHelpContent> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent) { insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(divHelpContent); HelpContentService.removeNulls(divHelpContent);
return this.http.post(this._helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), options) return this.http.post(helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), options)
.map(res => <DivHelpContent> res.json()) .map(res => <DivHelpContent> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
deleteDivIds(ids : string[]) { deleteDivIds(ids : string[], helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'div/delete',JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'div/delete',JSON.stringify(ids), options)
.catch(this.handleError); .catch(this.handleError);
} }
deleteDivHelpContents(ids : string[]) { deleteDivHelpContents(ids : string[], helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'divhelpcontent/delete',JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'divhelpcontent/delete',JSON.stringify(ids), options)
.catch(this.handleError); .catch(this.handleError);
} }
toggleDivHelpContents(ids : string[],status : boolean) { toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), options)
//.map( res => <string[]> res.json()) //.map( res => <string[]> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getPagesWithDivIds(community_pid: string) { getPagesWithDivIds(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'div/pages?communtity='+community_pid) return this.http.get(helpContentUrl + 'div/pages?communtity='+community_pid)
.map(res => <Map<string, Set<string>>> res.json()) .map(res => <Map<string, Set<string>>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getPages() { getPages(helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'page') return this.http.get(helpContentUrl + 'page')
.map(res => <Array<Page>> res.json()) .map(res => <Array<Page>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getPage(pageId:string) { getPage(pageId:string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'page/'+pageId) return this.http.get(helpContentUrl + 'page/'+pageId)
.map(res => <Page> res.json()) .map(res => <Page> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunities() { getCommunities( helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'community') return this.http.get(helpContentUrl + 'community')
.map(res => <Array<Community>> res.json()) .map(res => <Array<Community>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunity(community_pid: string) { getCommunity(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'community/'+community_pid) return this.http.get(helpContentUrl + 'community/'+community_pid)
.map(res => <Community> res.json()) .map(res => <Community> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunitiesFull() { getCommunitiesFull( helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'communityFull') return this.http.get(helpContentUrl + 'communityFull')
.map(res => <Array<Community>> res.json()) .map(res => <Array<Community>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunityFull(community_pid: string) { getCommunityFull(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'communityFull/'+community_pid) return this.http.get(helpContentUrl + 'communityFull/'+community_pid)
.map(res => <Community> res.json()) .map(res => <Community> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
saveCommunity(community: Community) { saveCommunity(community: Community, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); // let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); // let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(community); HelpContentService.removeNulls(community);
return this.http.post(this._helpContentUrl + 'community/save', JSON.stringify(community), options) return this.http.post(helpContentUrl + 'community/save', JSON.stringify(community), this.getAuthOptionsWithBody())
.map(res => <Community> res.json()) .map(res => <Community> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
updateCommunity(community: Community) { updateCommunity(community: Community, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); // let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); // let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(community); HelpContentService.removeNulls(community);
return this.http.post(this._helpContentUrl + 'community/update', JSON.stringify(community), options) return this.http.post(helpContentUrl + 'community/update', JSON.stringify(community), this.getAuthOptionsWithBody())
.map(res => <Community> res.json()) .map(res => <Community> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
deleteCommunities(ids : string[]) { deleteCommunities(ids : string[], helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); // let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); // let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'community/delete',JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'community/delete',JSON.stringify(ids), this.getAuthOptionsWithBody())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunityPages(community_pid: string) { getCommunityPages(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'community/'+community_pid+'/pages') return this.http.get(helpContentUrl + 'community/'+community_pid+'/pages')
.map(res => <Array<Page>> res.json()) .map(res => <Array<Page>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunityPagesByType(community_pid: string, params: string) { getCommunityPagesByType(community_pid: string, params: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'community/'+community_pid+'/pages'+params) return this.http.get(helpContentUrl + 'community/'+community_pid+'/pages'+params)
.map(res => <Array<Page>> res.json()) .map(res => <Array<Page>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getEntities() { getEntities(helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'entity') return this.http.get(helpContentUrl + 'entity')
.map(res => <Array<Entity>> res.json()) .map(res => <Array<Entity>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunityEntities(community_pid: string) { getCommunityEntities(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'community/'+community_pid+'/entities') return this.http.get(helpContentUrl + 'community/'+community_pid+'/entities')
.map(res => <Array<Entity>> res.json()) .map(res => <Array<Entity>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
saveEntity(entity: Entity) { saveEntity(entity: Entity, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(entity); HelpContentService.removeNulls(entity);
return this.http.post(this._helpContentUrl + 'entity/save', JSON.stringify(entity), options) return this.http.post(helpContentUrl + 'entity/save', JSON.stringify(entity), options)
.map(res => <Entity> res.json()) .map(res => <Entity> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
updateEntity(entity: Entity) { updateEntity(entity: Entity, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(entity); HelpContentService.removeNulls(entity);
return this.http.post(this._helpContentUrl + 'entity/update', JSON.stringify(entity), options) return this.http.post(helpContentUrl + 'entity/update', JSON.stringify(entity), options)
.map(res => <Entity> res.json()) .map(res => <Entity> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
@ -252,128 +252,128 @@ export class HelpContentService {
// let headers = new Headers({'Content-Type': 'application/json'}); // let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers}); // let options = new RequestOptions({headers: headers});
// //
// return this.http.post(this._helpContentUrl + 'community/'+selectedCommunityId+'/entity/toggle?status='+ status.toString()+'&entityId='+id.toString(), options) // return this.http.post(helpContentUrl + 'community/'+selectedCommunityId+'/entity/toggle?status='+ status.toString()+'&entityId='+id.toString(), options)
// .catch(this.handleError); // .catch(this.handleError);
// } // }
toggleEntities(selectedCommunityPid: string, ids : string[],status : boolean) { toggleEntities(selectedCommunityPid: string, ids : string[],status : boolean, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl +'community/'+selectedCommunityPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), options) return this.http.post(helpContentUrl +'community/'+selectedCommunityPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), options)
//.map( res => <string[]> res.json()) //.map( res => <string[]> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
deleteEntities(ids : string[]) { deleteEntities(ids : string[], helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'entity/delete',JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'entity/delete',JSON.stringify(ids), options)
.catch(this.handleError); .catch(this.handleError);
} }
toggleEntityOfPage(pageId: string, entityId : string,status : boolean) { toggleEntityOfPage(pageId: string, entityId : string,status : boolean, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(), options) return this.http.post(helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(), options)
.catch(this.handleError); .catch(this.handleError);
} }
savePage(page: Page) { savePage(page: Page, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(page); HelpContentService.removeNulls(page);
return this.http.post(this._helpContentUrl + 'page/save', JSON.stringify(page), options) return this.http.post(helpContentUrl + 'page/save', JSON.stringify(page), options)
.map(res => <Page> res.json()) .map(res => <Page> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
updatePage(page: Page) { updatePage(page: Page, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(page); HelpContentService.removeNulls(page);
return this.http.post(this._helpContentUrl + 'page/update', JSON.stringify(page), options) return this.http.post(helpContentUrl + 'page/update', JSON.stringify(page), options)
.map(res => <Page> res.json()) .map(res => <Page> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
togglePages(selectedCommunityPid: string, ids : string[],status : boolean) { togglePages(selectedCommunityPid: string, ids : string[],status : boolean, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'community/'+selectedCommunityPid+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'community/'+selectedCommunityPid+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), options)
.catch(this.handleError); .catch(this.handleError);
} }
deletePages(ids : string[]) { deletePages(ids : string[], helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'page/delete',JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), options)
.catch(this.handleError); .catch(this.handleError);
} }
getPageHelpContents() { getPageHelpContents(helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'pagehelpcontent') return this.http.get(helpContentUrl + 'pagehelpcontent')
.map(res => <Array<PageHelpContent>> res.json()) .map(res => <Array<PageHelpContent>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getCommunityPageHelpContents(community_pid: string) { getCommunityPageHelpContents(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'pagehelpcontent?community='+community_pid) return this.http.get(helpContentUrl + 'pagehelpcontent?community='+community_pid)
.map(res => <Array<PageHelpContent>> res.json()) .map(res => <Array<PageHelpContent>> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
getPageHelpContent(id : string) { getPageHelpContent(id : string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'pagehelpcontent/' + id) return this.http.get(helpContentUrl + 'pagehelpcontent/' + id)
.map(res => <PageHelpContent> res.json()) .map(res => <PageHelpContent> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
savePageHelpContent(pageHelpContent: PageHelpContent) { savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(pageHelpContent); HelpContentService.removeNulls(pageHelpContent);
return this.http.post(this._helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), options) return this.http.post(helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), options)
.map(res => <PageHelpContent> res.json()) .map(res => <PageHelpContent> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
updatePageHelpContent(pageHelpContent: PageHelpContent) { updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(pageHelpContent); HelpContentService.removeNulls(pageHelpContent);
return this.http.post(this._helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), options) return this.http.post(helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), options)
.map(res => <PageHelpContent> res.json()) .map(res => <PageHelpContent> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
deletePageHelpContents(ids : string[]) { deletePageHelpContents(ids : string[], helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'pagehelpcontent/delete',JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'pagehelpcontent/delete',JSON.stringify(ids), options)
.catch(this.handleError); .catch(this.handleError);
} }
togglePageHelpContents(ids : string[],status : boolean) { togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
let headers = new Headers({'Content-Type': 'application/json'}); let headers = new Headers({'Content-Type': 'application/json'});
let options = new RequestOptions({headers: headers}); let options = new RequestOptions({headers: headers});
return this.http.post(this._helpContentUrl + 'pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), options) return this.http.post(helpContentUrl + 'pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), options)
//.map( res => <string[]> res.json()) //.map( res => <string[]> res.json())
.catch(this.handleError); .catch(this.handleError);
} }
@ -384,13 +384,20 @@ export class HelpContentService {
console.error(error); console.error(error);
return Observable.throw(error.json().error || 'Server error'); return Observable.throw(error.json().error || 'Server error');
} }
public getAuthOptionsWithBody():RequestOptions{
let headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('X-XSRF-TOKEN', COOKIE.getCookie(COOKIE.cookieName_id));
let options = new RequestOptions({ headers: headers, withCredentials:true });
return options;
}
getDataProviders() { getDataProviders() {
return this.http.get('https://beta.services.openaire.eu/search/v2/api/datasources?format=json').map(res => <any> res.json()).map(res => res.results).do(res => {console.log(res)}).catch(this.handleError); return this.http.get('https://beta.services.openaire.eu/search/v2/api/datasources?format=json').map(res => <any> res.json()).map(res => res.results).do(res => {console.log(res)}).catch(this.handleError);
} }
getStatistics(community_pid: string) { getStatistics(community_pid: string, helpContentUrl:string) {
return this.http.get(this._helpContentUrl + 'statistics/'+community_pid) return this.http.get(helpContentUrl + 'statistics/'+community_pid)
.map(res => <CommunityStatistics> res.json()) .map(res => <CommunityStatistics> res.json())
.catch(this.handleError); .catch(this.handleError);
} }

View File

@ -54,7 +54,7 @@
"cacheUrl" :"http://scoobydoo.di.uoa.gr:3000/get?url=", "cacheUrl" :"http://scoobydoo.di.uoa.gr:3000/get?url=",
"adminToolsAPIURL" :"http://duffy.di.uoa.gr:8080/uoa-admin-tools", "adminToolsAPIURL" :"http://scoobydoo.di.uoa.gr:8080/uoa-admin-tools/",
"adminToolsCommunity" :"openaire", "adminToolsCommunity" :"openaire",