[Admin|Trunk]

Merge into trunk branch angular7 rev 55968





git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@55972 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2019-06-03 14:52:33 +00:00
parent 47534b7970
commit 5a0ffefd54
46 changed files with 441 additions and 1540 deletions

View File

@ -1,69 +0,0 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"name": "admin-portal"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"robots.txt"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css",
"../node_modules/datatables.net-dt/css/jquery.dataTables.css",
"../node_modules/interactiveminingv3/assets/css/interactive-mining.css",
"../node_modules/interactiveminingv3/assets/css/animations.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.js",
"../node_modules/datatables.net/js/jquery.dataTables.js",
"../node_modules/interactiveminingv3/assets/js/ResizeSensor.js",
"../node_modules/interactiveminingv3/assets/js/jquery.sticky-sidebar.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}

148
angular.json Normal file
View File

@ -0,0 +1,148 @@
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"admin-portal": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist",
"index": "src/index.html",
"main": "src/main.ts",
"tsConfig": "src/tsconfig.app.json",
"polyfills": "src/polyfills.ts",
"assets": [
"src/assets",
"src/robots.txt"
],
"styles": [
"src/styles.css",
"node_modules/datatables.net-dt/css/jquery.dataTables.css",
"node_modules/interactiveminingv3/assets/css/interactive-mining.css",
"node_modules/interactiveminingv3/assets/css/animations.css"
],
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js",
"node_modules/interactiveminingv3/assets/js/ResizeSensor.js",
"node_modules/interactiveminingv3/assets/js/jquery.sticky-sidebar.js"
]
},
"configurations": {
"production": {
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
]
}
}
},
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "admin-portal:build"
},
"configurations": {
"production": {
"browserTarget": "admin-portal:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "admin-portal:build"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "src/test.ts",
"karmaConfig": "./karma.conf.js",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.spec.json",
"scripts": [
"node_modules/jquery/dist/jquery.js",
"node_modules/datatables.net/js/jquery.dataTables.js",
"node_modules/interactiveminingv3/assets/js/ResizeSensor.js",
"node_modules/interactiveminingv3/assets/js/jquery.sticky-sidebar.js"
],
"styles": [
"src/styles.css",
"node_modules/datatables.net-dt/css/jquery.dataTables.css",
"node_modules/interactiveminingv3/assets/css/interactive-mining.css",
"node_modules/interactiveminingv3/assets/css/animations.css"
],
"assets": [
"src/assets",
"src/robots.txt"
]
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"src/tsconfig.app.json",
"src/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"admin-portal-e2e": {
"root": "e2e",
"sourceRoot": "e2e",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "./protractor.conf.js",
"devServerTarget": "admin-portal:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"e2e/tsconfig.e2e.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "admin-portal",
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"styleext": "css"
},
"@schematics/angular:directive": {
"prefix": "app"
}
}
}

14
interactivemining.sh Executable file
View File

@ -0,0 +1,14 @@
rm -f interactiveminingv3.tgz
git clone https://github.com/tasosgig/interactive-mining.git
cd interactive-mining/
git checkout angular7
cd interactive-mining-angular-frontend/
npm install
npm run packagr
cp -r ./src/assets/ ./dist
cd dist/
npm pack
mv interactiveminingv3-1.0.0.tgz ../../../interactiveminingv3.tgz
cd ../../../
rm -rf interactive-mining/
npm install --no-save ./interactiveminingv3.tgz

Binary file not shown.

View File

@ -4,24 +4,22 @@
module.exports = function (config) { module.exports = function (config) {
config.set({ config.set({
basePath: '', basePath: '',
frameworks: ['jasmine', '@angular/cli'], frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [ plugins: [
require('karma-jasmine'), require('karma-jasmine'),
require('karma-chrome-launcher'), require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'), require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'), require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma') require('@angular-devkit/build-angular/plugins/karma')
], ],
client:{ client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser clearContext: false // leave Jasmine Spec Runner output visible in browser
}, },
coverageIstanbulReporter: { coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ], dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true fixWebpackSourcePaths: true
}, },
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'], reporters: ['progress', 'kjhtml'],
port: 9876, port: 9876,
colors: true, colors: true,

View File

@ -12,53 +12,61 @@
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/animations": "^4.2.4", "@angular/animations": "7.2.14",
"@angular/common": "^4.2.4", "@angular/cdk": "^7.3.7",
"@angular/compiler": "^4.2.4", "@angular/common": "7.2.14",
"@angular/core": "^4.2.4", "@angular/compiler": "7.2.14",
"@angular/forms": "^4.2.4", "@angular/core": "7.2.14",
"@angular/http": "^4.2.4", "@angular/forms": "7.2.14",
"@angular/platform-browser": "^4.2.4", "@angular/http": "7.2.14",
"@angular/platform-browser-dynamic": "^4.2.4", "@angular/material": "^7.3.7",
"@angular/router": "^4.2.4", "@angular/platform-browser": "7.2.14",
"@angular/platform-browser-dynamic": "7.2.14",
"@angular/router": "7.2.14",
"@nguniversal/express-engine": "^6.0.0",
"@types/express": "^4.16.1",
"@types/node": "^6.0.101", "@types/node": "^6.0.101",
"angular-datatables": "^4.4.0", "angular-datatables": "^4.4.1",
"citation-js": "^0.3.4", "citation-js": "^0.3.4",
"clipboard": "^1.5.16", "clipboard": "^1.5.16",
"core-js": "^2.4.1", "core-js": "2.6.8",
"datatables.net": "^1.10.16", "datatables.net": "^1.10.19",
"datatables.net-dt": "^1.10.16", "datatables.net-dt": "^1.10.19",
"interactiveminingv3": "file:./interactiveminingv3.tgz", "interactiveminingv3": "file:./interactiveminingv3.tgz",
"jquery": "^3.2.1", "jquery": "^3.4.1",
"ng2-ckeditor": "1.1.9", "ng2-ckeditor": "1.1.9",
"ngx-bootstrap": "^1.6.6", "ngx-bootstrap": "^1.6.6",
"ngx-color-picker": "^4.5.3", "ngx-color-picker": "^4.5.3",
"ngx-json-ld": "0.1.6", "ngx-json-ld": "0.1.6",
"rxjs": "^5.4.2",
"ts-md5": "^1.2.0", "ts-md5": "^1.2.0",
"zone.js": "^0.8.14" "tslib": "^1.9.0",
"zone.js": "0.8.29"
}, },
"devDependencies": { "devDependencies": {
"@angular/cli": "1.3.0", "@angular-devkit/build-angular": "~0.13.0",
"@angular/compiler-cli": "^4.2.4", "@angular/cli": "7.3.9",
"@angular/language-service": "^4.2.4", "@angular/compiler-cli": "7.2.14",
"@types/datatables.net": "^1.10.8", "@angular/language-service": "7.2.14",
"@types/jquery": "^3.2.17", "@types/datatables.net": "^1.10.17",
"@types/jasmine": "~2.5.53", "@types/jasmine": "~2.8.8",
"@types/jasminewd2": "~2.0.2", "@types/jasminewd2": "~2.0.3",
"@types/node": "~6.0.60", "@types/jquery": "^3.3.29",
"codelyzer": "~3.1.1", "@types/node": "~6.14.6",
"jasmine-core": "~2.6.2", "codelyzer": "~4.5.0",
"jasmine-spec-reporter": "~4.1.0", "jasmine-core": "~2.99.1",
"karma": "~1.7.0", "jasmine-spec-reporter": "~4.2.1",
"karma": "~3.0.0",
"karma-chrome-launcher": "~2.1.1", "karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1", "karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1", "karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~1.1.0", "karma-jasmine": "~1.1.2",
"karma-jasmine-html-reporter": "^0.2.2", "karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2", "protractor": "~5.4.0",
"ts-node": "~3.2.0", "ts-node": "~7.0.0",
"tslint": "~5.3.2", "tslint": "^5.7.0",
"typescript": "~2.3.3" "typescript": "3.2.4",
"rxjs": "6.5.1",
"rxjs-compat": "^6.5.1",
"rxjs-tslint": "^0.1.7"
} }
} }

View File

@ -1,16 +1,9 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { HttpModule, JsonpModule } from '@angular/http'; import { HttpClientModule } from '@angular/common/http';
import { AppComponent } from './app.component'; import { AppComponent } from './app.component';
import { AppRoutingModule} from './app.routing'; import { AppRoutingModule} from './app.routing';
import { TopicsComponent } from './pages/faq/topics.components';
import { QuestionsComponent } from './pages/faq/questions.component';
import { ModalModule } from 'ngx-bootstrap';
import { TopicsFormComponent } from './pages/faq/topics-form.component';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { ModalFormComponent } from './pages/modal-form.component';
import { QuestionsFormComponent } from './pages/faq/questions-form.component';
import { DeleteConfirmationDialogComponent } from './pages/delete-confirmation-dialog.component';
import { HelpContentService } from './services/help-content.service'; import { HelpContentService } from './services/help-content.service';
@ -35,7 +28,6 @@ import {SafeHtmlPipeModule} from './openaireLibrary/utils/pipes/safeHTMLPipe.mod
import {InteractiveMiningModule} from 'interactiveminingv3'; import {InteractiveMiningModule} from 'interactiveminingv3';
import {CommunityService} from './openaireLibrary/connect/community/community.service'; import {CommunityService} from './openaireLibrary/connect/community/community.service';
import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service'; import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service';
import { FAQService } from './services/faq.service';
import {ConnectRIGuard} from './openaireLibrary/connect/communityGuard/connectRIGuard.guard'; import {ConnectRIGuard} from './openaireLibrary/connect/communityGuard/connectRIGuard.guard';
import {SideBarModule} from "./openaireLibrary/sharedComponents/sidebar/sideBar.module"; import {SideBarModule} from "./openaireLibrary/sharedComponents/sidebar/sideBar.module";
@ -43,9 +35,7 @@ import {SideBarModule} from "./openaireLibrary/sharedComponents/sidebar/sideBar.
imports: [ imports: [
AppRoutingModule, AppRoutingModule,
BrowserModule, BrowserModule,
HttpModule, HttpClientModule,
JsonpModule,
ModalModule.forRoot(),
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
BottomModule, NavigationBarModule, CookieLawModule, BottomModule, NavigationBarModule, CookieLawModule,
@ -56,17 +46,10 @@ import {SideBarModule} from "./openaireLibrary/sharedComponents/sidebar/sideBar.
], ],
declarations: [ declarations: [
AppComponent, AppComponent,
TopicsComponent,
QuestionsComponent,
TopicsFormComponent,
ModalFormComponent,
QuestionsFormComponent,
DeleteConfirmationDialogComponent,
CommunityErrorPageComponent, CommunityErrorPageComponent,
AdminErrorPageComponent AdminErrorPageComponent
], ],
providers: [ providers: [
FAQService,
HelpContentService, CommunityService, SubscribeService, HelpContentService, CommunityService, SubscribeService,
ConnectAdminLoginGuard, ConnectAdminLoginGuard,
EnvironmentSpecificResolver, EnvironmentSpecificService, EnvironmentSpecificResolver, EnvironmentSpecificService,

View File

@ -1,5 +1,5 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { HttpModule, JsonpModule } from '@angular/http'; import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
@ -26,8 +26,8 @@ import {CommunityContentProvidersRoutingModule} from './communityContentProvider
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
HttpModule, HttpClientModule,
JsonpModule, FormsModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
RouterModule, RouterModule,

View File

@ -1,6 +1,6 @@
import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { Subject } from 'rxjs/Subject'; import { Subject } from 'rxjs';
import { DataTableDirective } from 'angular-datatables'; import { DataTableDirective } from 'angular-datatables';
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';

View File

@ -1,5 +1,5 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { HttpModule, JsonpModule } from '@angular/http'; import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
@ -27,8 +27,7 @@ import {CommunityProjectsRoutingModule} from './communityProjects-routing.module
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
HttpModule, HttpClientModule,
JsonpModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
RouterModule, RouterModule,

View File

@ -1,6 +1,6 @@
import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { Subject } from 'rxjs/Subject'; import { Subject } from 'rxjs';
import { DataTableDirective } from 'angular-datatables'; import { DataTableDirective } from 'angular-datatables';
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';

View File

@ -1,21 +0,0 @@
<div *ngIf="isModalShown" [config]="{ show: true }" (onHidden)="onHidden()" bsModal #autoShownModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true">&times;</span>
</button>
<div class="uk-text-large"> Delete Confirmation </div>
</div>
<div class="modal-body">
<ng-content></ng-content>
</div>
<div class="modal-footer">
<div class="confirmationModalButtons">
<a (click)="hideModal()" class="btn"><i></i> Cancel </a>
<a (click)="confirmedAction()" class="btn btn-danger"><i></i> Yes, delete them </a>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,55 +0,0 @@
/**
* Created by stefania on 5/2/17.
*/
import { Component, ViewChild, Input, Output, EventEmitter } from '@angular/core';
import { ModalDirective } from 'ngx-bootstrap/modal';
@Component({
selector: 'delete-confirmation-dialog',
templateUrl: './delete-confirmation-dialog.component.html'
})
export class DeleteConfirmationDialogComponent {
@ViewChild('autoShownModal')
public autoShownModal:ModalDirective;
@Input()
public isModalShown:boolean = false;
@Output() emmitObject: EventEmitter<any> = new EventEmitter();
private _ids: string[] = [];
public set ids(ids: string[]) {
this._ids = ids;
}
public showModal():void {
this.isModalShown = true;
}
public hideModal():void {
this.autoShownModal.hide();
}
public onHidden():void {
this.isModalShown = false;
}
public confirmedAction() {
this.emmitObject.emit(this._ids);
this.hideModal();
}
// public saveCustom(obj : any) {
// if (this.type == 'topic') {
// this._faqService.saveTopic(<Topic> obj).subscribe(
// data => this.emmitObject.emit(data),
// error => this.emmitError.emit(error)
// );
// } else if (this.type == 'question') {
// return;
// }
// this.hideModal();
// }
}

View File

@ -2,8 +2,6 @@ import { Component, ViewChild, OnInit, ElementRef } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } 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 { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
import { DivIdFormComponent } from "./divId-form.component"; 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";

View File

@ -1,7 +1,6 @@
import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; import { Component, ViewChild, OnInit, ElementRef } from '@angular/core';
import { Router, ActivatedRoute } from "@angular/router"; import { Router, ActivatedRoute } from "@angular/router";
import { FormGroup } from "@angular/forms"; import { FormGroup } from "@angular/forms";
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";

View File

@ -1,6 +1,6 @@
import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core'; import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core';
import { DivContentFormComponent } from "./div-help-content-form.component"; import { DivContentFormComponent } from "./div-help-content-form.component";
import { Subscription } from "rxjs/Subscription"; import { Subscription } from "rxjs";
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";

View File

@ -1,35 +0,0 @@
<form [formGroup]="myForm">
<div class="form-group required" [ngClass]="{'has-error':!myForm.controls.question.valid && myForm.controls.question.dirty}">
<label for="questionTag">Question</label>
<textarea class="form-control" formControlName="question" id="questionTag" placeholder="Question" rows="2"></textarea>
</div>
<div class="form-group required" [ngClass]="{'has-error':!myForm.controls.answer.valid && myForm.controls.answer.dirty}">
<label for="answerTag">Answer</label>
<textarea class="form-control" formControlName="answer" id="answerTag" placeholder="Answer" rows="3"></textarea>
</div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.weight.valid && myForm.controls.weight.dirty}">
<label for="topicWeightTag">Weight</label>
<input type="number" step="0.1" class="form-control" formControlName="weight" id="topicWeightTag" placeholder="Topic Weight (e.g. 3.5)">
</div>
<div class="form-group">
<label>Select Status</label>
<label class="checkbox">
<span style="font-weight: normal;">Active</span>
<input tabindex="0" type="checkbox" formControlName="isActive">
</label>
</div>
<div class="form-group required" [ngClass]="{'has-error':!myForm.controls.weight.valid && myForm.controls.weight.dirty}">
<label for="topicTag">Select Topic(s)</label>
<select multiple formControlName="topics" id="topicTag" class="form-control">
<option *ngFor="let topic of availableTopics" [value]="topic._id">{{topic.name}}</option>
</select>
<small class="form-text text-muted">Press <kbd>ctrl</kbd> + <kbd>click</kbd> to select more than one</small>
</div>
<input type="hidden" formControlName="_id">
</form>
<!--<pre>-->
<!--{{myForm.value | json}} |-->
<!--{{myForm.valid}}-->
<!--</pre>-->

View File

@ -1,51 +0,0 @@
/**
* Created by stefania on 5/2/17.
*/
import {Component, OnInit, Input} from '@angular/core';
import {FormGroup, FormBuilder, Validators} from "@angular/forms";
import {Topic} from "../../domain/topic";
@Component({
selector: 'questions-form',
templateUrl: './questions-form.component.html',
})
export class QuestionsFormComponent implements OnInit{
@Input('group')
myForm: FormGroup;
@Input() availableTopics : Topic[] = [];
constructor(private _fb: FormBuilder){}
ngOnInit(): void {
}
public get form() {
return this._fb.group({
question : ['', Validators.required],
answer : ['', Validators.required],
topics : [[],Validators.required],
weight : ['0.0', Validators.required],
isActive : true,
_id : '',
// date : ''
});
}
public reset() {
this.myForm.patchValue({
question : '',
answer : '',
topics : [],
weight : '0.0',
// date : '',
isActive : true,
_id : ''
});
this.myForm.markAsPristine();
}
}

View File

@ -1,153 +0,0 @@
<div id="faqQuestions">
<div id="content">
<div class="menubar fixed">
<div class="sidebar-toggler visible-xs">
<i class="ion-navicon"></i>
</div>
<div class="page-title">FAQ Questions</div>
<form class="search">
<!--<input class="gwt-TextBox" placeholder="Search questions (question, answer)..." type="text">-->
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Search questions (question, answer)..." type="text"/>
<input class="btn" type="submit">
</form>
<a (click)="showModal()" class="btn btn-success pull-right"><i></i> New Question </a>
</div>
<div class="content-wrapper" id="contentWrapper">
<div>
<div class="contentPanel">
<div [hidden]="!errorMessage" class="alert alert-danger" aria-hidden="true">
{{errorMessage}}
</div>
<div [hidden]="!successMessage" class="alert alert-success" aria-hidden="true">
{{successMessage}}
</div>
<div class="alert" style="display: none;" aria-hidden="true"><span></span><span></span><span></span></div>
<div class="page-controls"> <!--"row" class removed"-->
<div class="col-md-12 filters marginBottom20">
<div class="links form-group form-inline">
<div class="gwt-Label filterLabel">Filter by topic:</div>
<select class="input-xxlarge form-control" (change)="filterByTopic($event)">
<option value="">-- none selected --</option>
<option *ngFor="let topic of topics" value="{{topic._id}}">{{topic.name}}</option>
</select>
</div>
</div>
<div class="col-md-12 filters">
<div class="links">
<div class="gwt-Label filterLabel">Filter questions:</div>
<a [ngClass]="{'active' : filters.active==null}" (click)="displayAllQuestions()">
All Questions ({{counter.all}})
</a>
<a [ngClass]="{'active' : filters.active==true}" (click)="displayActiveQuestions()">
Active ({{counter.active}})
</a>
<a [ngClass]="{'active' : filters.active==false}" (click)="displayInactiveQuestions()">
Inactive ({{counter.inactive}})
</a>
</div>
<div class="show-options">
<div class="btn-group"><a href="javascript:;" class="btn dropdown-toggle"
data-toggle="dropdown"><i></i> Bulk Actions <span
class="caret"></span></a>
<ul class="dropdown-menu">
<li><a (click)="toggleQuestion(true,getSelectedQuestions())"><i></i> Activate </a></li>
<li><a (click)="toggleQuestion(false,getSelectedQuestions())"><i></i> Deactivate </a></li>
<li><a (click)="confirmDeleteSelectedQuestions()"><i></i> Delete </a></li>
</ul>
</div>
</div>
</div>
</div>
<div>
<div class="gwt-HTML">
<div class="users-list"> <!--"row" class removed"-->
<div class="col-md-12">
<div class="headers"> <!--"row" class removed"-->
<div class="col-sm-1 header select-users"><input id="allQuestionsCheckbox" [checked]="checkboxAll" type="checkbox" (change)="toggleCheckBoxes($event)">
</div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Date</a></label></div>
<div class="col-sm-2 header hidden-xs"><label><a href="#">Question</a></label></div>
<div class="col-sm-3 header hidden-xs"><label><a href="#">Answer</a></label></div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Topics</a></label></div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Weight</a></label></div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Hit Count</a></label></div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Active</a></label></div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Actions</a></label></div>
</div>
<ng-template [ngIf]="questionsCheckboxes && questionsCheckboxes.length>0">
<div *ngFor="let check of questionsCheckboxes; let i=index" class="user"> <!--"row" class removed"-->
<div class="col-sm-1 avatar"><input id="{{check.question._id}}" class="checkBox" type="checkbox"
name="questionscb[]" value="{{check.question._id}}" [(ngModel)]="check.checked">
</div>
<div class="col-sm-1">
<div class="date" href="#">{{check.question.date | date:'yyyy-MM-dd'}}</div>
</div>
<div class="col-sm-2">
<div class="name" href="#">{{check.question.question}}</div>
</div>
<div class="col-sm-3">
<div class="description" href="#">{{check.question.answer}}
</div>
</div>
<div class="col-sm-1">
{{getNames(check.question).join(', ')}}
<!--<div class="topics" href="#">{{check.question.topics}}</div>-->
<!--<span *ngFor="let topic of check.question.topics" class="label label-primary">{{topic.name}}</span>-->
</div>
<div class="col-sm-1">
<div class="weight" href="#">{{check.question.weight}}</div>
</div>
<div class="col-sm-1">
<div class="hitCount" href="#">{{check.question.hitCount}}</div>
</div>
<div class="col-sm-1">
<div *ngIf="check.question.isActive" class="activated" >
<input (click)="toggleQuestion(false,[check.question._id])" class="deactivate" src="assets/imgs/check-icon.png" title="Deactivate" width="20" type="image" height="20">
</div>
<div *ngIf="!check.question.isActive" class="activated" >
<input (click)="toggleQuestion(true,[check.question._id])" class="deactivate" src="assets/imgs/x-icon.png" title="Activate" width="20" type="image" height="20">
</div>
</div>
<!--<div class="col-sm-1">-->
<!--<bSwitch [switch-on-text]="'A'" [switch-off-text]="'I'"-->
<!--[switch-label-text]="''" [(ngModel)]="check.question.isActive"-->
<!--[switch-on-color]="'mySuccess'" [switch-off-color]="'default'"-->
<!--[switch-size]="'small'" [switch-handle-width]="22"-->
<!--(onChangeState)="toggleQuestion($event.currentValue,[check.question._id])"></bSwitch>-->
<!--</div>-->
<div class="col-sm-1">
<div class="actions" href="#">
<input title="Edit" src="assets/imgs/icn_edit.png" class="edit" type="image" (click)="editQuestion(i)">
<input title="Delete" src="assets/imgs/icn_trash.png" class="delete" type="image" (click)="confirmDeleteQuestion(check.question._id)">
</div>
</div>
</div>
</ng-template>
<div *ngIf="questionsCheckboxes.length==0" class="col-md-12">
<div class="alert alert-warning">No questions found</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<modal-form #saveModal [saveText]="'Save'" [titleText]="'Add a new Question'" [formGroup]="formGroup" [type]="'question'"
[isModalShown]="isModalShown" (emmitObject)="questionSavedSuccessfully($event)" (emmitError)="handleError($event)">
<questions-form [group]="formGroup" [availableTopics]="topics"></questions-form>
</modal-form>
<modal-form #updateModal [saveText]="'Update'" [titleText]="'Update Question'" [formGroup]="formGroup" [type]="'question'"
[isModalShown]="isModalShown" (emmitObject)="questionUpdatedSuccessfully($event)" (emmitError)="handleError($event)">
<questions-form [group]="formGroup" [availableTopics]="topics"></questions-form>
</modal-form>
<delete-confirmation-dialog #deleteConfirmationModal [isModalShown]="isModalShown" (emmitObject)="confirmedDeleteQuestions($event)">
Are you sure you want to delete the selected question(s)?
</delete-confirmation-dialog>

View File

@ -1,241 +0,0 @@
/**
* Created by stefania on 4/26/17.
*/
import { Component, ViewChild, OnInit } from '@angular/core';
import { FAQService } from "../../services/faq.service";
import { FormGroup } from "@angular/forms";
import { ModalFormComponent } from "../modal-form.component";
import { QuestionsFormComponent } from "./questions-form.component";
import { CheckQuestion, Question, QuestionFilterOptions } from "../../domain/question";
import { Topic } from "../../domain/topic";
import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
@Component({
selector: 'questions',
templateUrl: './questions.component.html',
})
export class QuestionsComponent implements OnInit {
// @ViewChild(ModalFormComponent)
@ViewChild('saveModal')
public modal:ModalFormComponent;
@ViewChild('updateModal')
public updateModal:ModalFormComponent;
@ViewChild(QuestionsFormComponent)
public formComponent : QuestionsFormComponent;
@ViewChild('deleteConfirmationModal')
public deleteConfirmationModal : DeleteConfirmationDialogComponent;
public questionsCheckboxes : CheckQuestion[] = [];
public questions : Question[] = [];
public errorMessage: string = null;
public successMessage: string = null;
public formGroup : FormGroup;
public topics: Topic[];
public checkboxAll : boolean = false;
public filters : QuestionFilterOptions = {id : '', active : null, text : new RegExp('')};
public counter = {all : 0, active : 0, inactive : 0};
ngOnInit() {
this.getTopics();
this.getQuestions();
this.formGroup = this.formComponent.form;
}
constructor(private _faqService: FAQService) {}
getTopics() {
this._faqService.getTopics().subscribe(
topics => this.topics = topics,
error => this.errorMessage = <any>error);
}
public countQuestions() {
this.counter = {all : 0, active : 0, inactive : 0};
let filter = Object.assign({},this.filters);
filter.active = null;
this.questions.forEach(_ => {
if(this.filterQuestion(_,filter)){
if (_.isActive==true) this.counter.active++;
else this.counter.inactive++
}
});
this.counter.all = this.counter.active + this.counter.inactive;
}
getQuestions() {
let self = this;
this._faqService.getQuestions().subscribe(
questions => {
self.questions = questions;
self.counter.all = questions.length;
questions.forEach(_ => {
self.questionsCheckboxes.push(<CheckQuestion>{question : _, checked : false});
});
self.countQuestions();
},
error => this.errorMessage = <any>error);
}
public showModal():void {
this.modal.showModal();
}
public toggleCheckBoxes(event) {
this.questionsCheckboxes.forEach(_ => _.checked = event.target.checked);
this.checkboxAll = event.target.checked;
}
public applyCheck(flag : boolean) {
this.questionsCheckboxes.forEach(_ => _.checked = flag);
this.checkboxAll = false;
}
public getSelectedQuestions() : string[] {
return this.questionsCheckboxes.filter(question => question.checked == true)
.map(checkedQuestion => checkedQuestion.question).map(res => res._id);
}
public confirmDeleteQuestion(id : string) {
this.deleteConfirmationModal.ids = [id];
this.deleteConfirmationModal.showModal();
}
public confirmDeleteSelectedQuestions() {
this.deleteConfirmationModal.ids = this.getSelectedQuestions();
this.deleteConfirmationModal.showModal();
}
public confirmedDeleteQuestions(ids : string[]) {
this._faqService.deleteQuestions(ids).subscribe(
_ => this.deleteQuestionsFromArray(ids),
error => this.handleError(error)
);
}
private deleteQuestionsFromArray(ids : string[]) : void {
this.successMessage = `Successfully deleted Question(s)`;
for(let id of ids) {
let iqc = this.questionsCheckboxes.findIndex(_ => _.question._id == id);
let iq = this.questions.findIndex(_ => _._id == id);
this.questionsCheckboxes.splice(iqc, 1);
this.questions.splice(iqc, 1);
}
}
public editQuestion(i : number) {
let question : Question = Object.assign({}, this.questionsCheckboxes[i].question);
// question.topics = <Topic[]>Object.create(this.questionsCheckboxes[i].question.topics);
let topics : string[] = [];
for(let topic of <Topic[]>question.topics) {
topics.push(topic._id)
}
question.topics = topics;
this.formGroup.patchValue(question);
this.updateModal.showModal();
}
public toggleQuestion(status : boolean, ids : string[]) {
this._faqService.toggleQuestion(ids,status).subscribe(
ret => {
for(let id of ret) {
let i = this.questionsCheckboxes.findIndex(_ => _.question._id == id);
this.questionsCheckboxes[i].question.isActive=status;
}
this.countQuestions();
this.applyCheck(false);
},
error => this.handleError(<any>error)
);
}
public saveQuestion(data : any):void {
this._faqService.saveQuestion(data).subscribe(
question => this.questionSavedSuccessfully(question),
error => this.handleError(<any>error)
);
}
public questionSavedSuccessfully(question: Question) {
this.questionsCheckboxes.push(<CheckQuestion>{question : question, checked : false});
this.questions.push(question);
this.successMessage = `Question [${question.question}] saved successfully`;
this.applyCheck(false);
this.countQuestions();
}
public questionUpdatedSuccessfully(question : Question) {
this.questionsCheckboxes.find(checkItem => checkItem.question._id==question._id).question = question;
let index = this.questions.findIndex(checkItem => checkItem._id==question._id);
this.successMessage = `Question [${question.question}] updated successfully`;
this.questions[index] = question;
this.applyCheck(false);
this.countQuestions();
}
public filterQuestion(question : Question, filters : QuestionFilterOptions) : boolean {
let idFlag = filters.id == '' || (<Topic[]>question.topics).map(_ => _._id).includes(filters.id);
let activeFlag = filters.active == null || question.isActive == filters.active;
let textFlag = filters.text.toString() == '' || (question.question + ' ' +question.answer).match(filters.text) != null;
return idFlag && activeFlag && textFlag;
}
public applyFilter() {
this.questionsCheckboxes = [];
this.questions.filter(item => this.filterQuestion(item,this.filters)).forEach(
_ => this.questionsCheckboxes.push(<CheckQuestion>{question: _, checked: false})
);
this.countQuestions();
}
public filterByTopic(event: any) {
this.filters.id = event.target.value;
this.applyFilter();
}
public displayAllQuestions() {
this.filters.active = null;
this.applyFilter();
}
public displayActiveQuestions() {
this.filters.active = true;
this.applyFilter();
}
public filterBySearch(text : string) {
this.filters.text = new RegExp(text, "i");
this.applyFilter();
}
public displayInactiveQuestions() {
this.filters.active = false;
this.applyFilter();
}
public getNames(question : Question) : string[]{
return (<Topic[]>question.topics).map(_ => _.name);
}
handleError(error) {
if(error == null) {
this.formComponent.reset();
}else {
this.errorMessage = 'System error saving topic (Server responded: ' + error + ')';
}
}
}

View File

@ -1,26 +0,0 @@
<form [formGroup]="myForm">
<div class="form-group required" [ngClass]="{'has-error':!myForm.controls.name.valid && myForm.controls.name.dirty}">
<label for="topicNameTag">Topic Name</label>
<input type="text" class="form-control" formControlName="name" id="topicNameTag" placeholder="Topic Name">
</div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.description.valid && myForm.controls.description.dirty}">
<label for="topicDescTag">Topic Description</label>
<textarea class="form-control" formControlName="description" id="topicDescTag" placeholder="Topic Description" rows="3"></textarea>
</div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.weight.valid && myForm.controls.weight.dirty}">
<label for="topicWeightTag">Weight</label>
<input type="number" step="0.1" class="form-control" formControlName="weight" id="topicWeightTag" placeholder="Topic Weight (e.g. 3.5)">
</div>
<div class="form-group">
<label for="topicQuestionOrder">Order questions by</label>
<select class="form-control" id="topicQuestionOrder" formControlName="questionOrder">
<option value="hits">Hit Count</option>
<option value="weight">Weight</option>
</select>
</div>
<input type="hidden" formControlName="_id">
<!--<input type="hidden" formControlName="date">-->
</form>
<!--<pre>-->
<!--{{myForm.value | json}}-->
<!--</pre>-->

View File

@ -1,46 +0,0 @@
/**
* Created by stefanos on 28/4/2017.
*/
import {Component, OnInit, Input} from '@angular/core';
import {FormGroup, FormBuilder, Validators} from "@angular/forms";
@Component({
selector: 'topics-form',
templateUrl: './topics-form.component.html',
})
export class TopicsFormComponent implements OnInit{
@Input('group')
myForm: FormGroup;
constructor(private _fb: FormBuilder){}
ngOnInit(): void {
}
public get form() {
return this._fb.group({
name : ['', Validators.required],
description : '',
weight : ['0.0', Validators.required],
questionOrder : 'hits',
_id : ''
// date : '',
});
}
public reset() {
this.myForm.patchValue({
name : '',
description : '',
weight : '0.0',
questionOrder : 'hits',
_id : ''
});
this.myForm.markAsPristine();
}
}

View File

@ -1,111 +0,0 @@
<div id="faqTopics">
<div id="content">
<div class="menubar fixed">
<div class="sidebar-toggler visible-xs">
<i class="ion-navicon"></i>
</div>
<div class="page-title">FAQ Topics</div>
<form target="BSFormPanel_Admin_1" class="search">
<!--<input class="gwt-TextBox" placeholder="Search topics (name, description)..." type="text">-->
<input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Search topics (name, description)..." type="text"/>
<input class="btn" type="submit">
</form>
<a (click)="showModal()" class="btn btn-success pull-right"><i></i> New Topic </a>
</div>
<div class="content-wrapper" id="contentWrapper">
<div>
<div class="contentPanel">
<div [hidden]="!errorMessage" class="alert alert-danger" aria-hidden="true">
{{errorMessage}}
</div>
<div [hidden]="!successMessage" class="alert alert-success" aria-hidden="true">
{{successMessage}}
</div>
<div class="alert" style="display: none;" aria-hidden="true"><span></span><span></span><span></span></div>
<div class="page-controls"> <!--"row" class removed"-->
<div class="col-md-12 filters">
<div class="show-options">
<div class="btn-group"><a href="javascript:;" class="btn dropdown-toggle"
data-toggle="dropdown"><i></i> Bulk Actions <span
class="caret"></span></a>
<ul class="dropdown-menu">
<li><a (click)="confirmDeleteSelectedTopics()"><i></i> Delete </a></li>
<li><a (click)="toggleTopic('weight',getSelectedTopics())"><i></i> Order Questions By Weight </a></li>
<li><a (click)="toggleTopic('hits',getSelectedTopics())"><i></i> Order Questions By Hit Count </a></li>
</ul>
</div>
</div>
</div>
</div>
<div>
<div class="gwt-HTML">
<div class="users-list"> <!--"row" class removed"-->
<div class="col-md-12">
<div class="headers"> <!--"row" class removed"-->
<div class="col-sm-1 header select-users"><input id="allTopicsCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)">
</div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Date</a></label></div>
<div class="col-sm-2 header hidden-xs"><label><a href="#">Name</a></label></div>
<div class="col-sm-4 header hidden-xs"><label><a href="#">Description</a></label></div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Weight</a></label></div>
<div class="col-sm-2 header hidden-xs"><label><a href="#">Questions Order</a></label>
</div>
<div class="col-sm-1 header hidden-xs"><label><a href="#">Actions</a></label></div>
</div>
<ng-template [ngIf]="topicsCheckboxes && topicsCheckboxes.length>0">
<div *ngFor="let check of topicsCheckboxes; let i=index" class="user"> <!--"row" class removed"-->
<div class="col-sm-1 avatar"><input id="{{check.topic._id}}" class="checkBox" type="checkbox"
name="topicscb[]" value="{{check.topic._id}}" [(ngModel)]="check.checked">
</div>
<div class="col-sm-1">
<div class="date" href="#">{{check.topic.date | date:'yyyy-MM-dd'}}</div>
</div>
<div class="col-sm-2">
<div class="name" href="#">{{check.topic.name}}</div>
</div>
<div class="col-sm-4">
<div class="description" href="#">{{check.topic.description}}
</div>
</div>
<div class="col-sm-1">
<div class="weight" href="#">{{check.topic.weight}}</div>
</div>
<div class="col-sm-2">
<div class="questionsOrder" href="#">{{check.topic.questionOrder}}</div>
</div>
<div class="col-sm-1">
<div class="actions" href="#">
<input title="Edit" src="assets/imgs/icn_edit.png" class="edit" type="image" (click)="editTopic(i)">
<input title="Delete" src="assets/imgs/icn_trash.png" class="delete" type="image" (click)="confirmDeleteTopic(check.topic._id)">
</div>
</div>
</div>
</ng-template>
<div *ngIf="topicsCheckboxes.length==0" class="col-md-12">
<div class="alert alert-warning">No topics found</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<modal-form #saveModal [saveText]="'Save'" [titleText]="'Add a new Topic'" [formGroup]="formGroup"
[isModalShown]="isModalShown" (emmitObject)="topicSavedSuccessfully($event)" (emmitError)="handleError($event)">
<topics-form [group]="formGroup"></topics-form>
</modal-form>
<modal-form #updateModal [saveText]="'Update'" [titleText]="'Update Topic'" [formGroup]="formGroup"
[isModalShown]="isModalShown" (emmitObject)="topicUpdatedSuccessfully($event)" (emmitError)="handleError($event)">
<topics-form [group]="formGroup"></topics-form>
</modal-form>
<delete-confirmation-dialog #deleteConfirmationModal [isModalShown]="isModalShown" (emmitObject)="confirmedDeleteTopic($event)">
Are you sure you want to delete the selected topic(s)?
</delete-confirmation-dialog>

View File

@ -1,169 +0,0 @@
/**
* Created by stefania on 4/26/17.
*/
import { Component, ViewChild, OnInit } from '@angular/core';
import { Topic, CheckTopic } from "../../domain/topic";
import { FAQService } from "../../services/faq.service";
import { FormGroup } from "@angular/forms";
import { ModalFormComponent } from "../modal-form.component";
import { TopicsFormComponent } from "./topics-form.component";
import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
@Component({
selector: 'topics',
templateUrl: './topics.component.html',
})
export class TopicsComponent implements OnInit {
// @ViewChild(ModalFormComponent)
@ViewChild('saveModal')
public modal:ModalFormComponent;
@ViewChild('updateModal')
public updateModal:ModalFormComponent;
@ViewChild('deleteConfirmationModal')
public deleteConfirmationModal : DeleteConfirmationDialogComponent;
@ViewChild(TopicsFormComponent)
public formComponent : TopicsFormComponent;
public topicsCheckboxes : CheckTopic[] = [];
public topics : Topic[] = [];
public errorMessage: string = null;
public successMessage: string = null;
public formGroup : FormGroup;
private searchText : RegExp = new RegExp('');
ngOnInit() {
this.getTopics();
this.formGroup = this.formComponent.form;
}
constructor(private _faqService: FAQService) {}
getTopics() {
let self = this;
this._faqService.getTopics().subscribe(
topics => {
self.topics = topics;
topics.forEach(_ => {
self.topicsCheckboxes.push(<CheckTopic>{topic : _, checked : false});
});
},
error => this.handleError('System error retrieving topics topics', error));
}
public showModal():void {
this.modal.showModal();
}
public toggleCheckBoxes(event) {
this.topicsCheckboxes.forEach(_ => _.checked = event.target.checked);
}
public applyCheck(flag : boolean) {
this.topicsCheckboxes.forEach(_ => _.checked = flag);
}
public getSelectedTopics() : string[] {
return this.topicsCheckboxes.filter(topic => topic.checked == true).map(checkedTopic => checkedTopic.topic).map(res => res._id);
}
private deleteTopicsFromArray(ids : string[]) : void {
this.successMessage = `Successfully deleted Topic(s)`;
for(let id of ids) {
let i = this.topicsCheckboxes.findIndex(_ => _.topic._id == id);
this.topicsCheckboxes.splice(i, 1);
}
}
public confirmDeleteTopic(id : string) {
this.deleteConfirmationModal.ids = [id];
this.deleteConfirmationModal.showModal();
}
public confirmDeleteSelectedTopics() {
this.deleteConfirmationModal.ids = this.getSelectedTopics();
this.deleteConfirmationModal.showModal();
}
public confirmedDeleteTopic(ids : string[]) {
this._faqService.deleteTopics(ids).subscribe(
_ => this.deleteTopicsFromArray(ids),
error => this.handleError('System error deleting the selected topics', error)
);
}
public sort(type : string) {
if(type=='weight') {
this.topicsCheckboxes.sort(function(a, b) {
return a.topic.weight - b.topic.weight;
});
} else if (type == 'hits') {
}
}
public editTopic(i : number) {
let topic : Topic = this.topicsCheckboxes[i].topic;
this.formGroup.patchValue(topic);
this.updateModal.showModal();
}
public toggleTopic(order : string, ids : string[]) {
this._faqService.orderTopic(ids,order).subscribe(
ret => {
for(let id of ret) {
let i = this.topicsCheckboxes.findIndex(_ => _.topic._id == id);
this.topicsCheckboxes[i].topic.questionOrder=order;
}
},
error => this.handleError('System error ordering topics', <any>error)
);
this.applyCheck(false);
}
public topicSavedSuccessfully(topic: Topic) {
this.topicsCheckboxes.push(<CheckTopic>{topic : topic, checked : false});
this.successMessage = `Topic [${topic.name}] saved successfully`;
this.applyCheck(false);
}
public topicUpdatedSuccessfully(topic : Topic) {
this.topicsCheckboxes.find(checkItem => checkItem.topic._id==topic._id).topic = topic;
this.successMessage = `Topic [${topic.name}] updated successfully`;
this.applyCheck(false);
}
public filterBySearch(text : string) {
this.searchText = new RegExp(text,'i');
this.applyFilter();
}
public applyFilter() {
this.topicsCheckboxes = [];
this.topics.filter(item => this.filterQuestion(item)).forEach(
_ => this.topicsCheckboxes.push(<CheckTopic>{topic: _, checked: false})
);
}
public filterQuestion(topic : Topic) : boolean {
let textFlag = this.searchText.toString() == '' || (topic.name + ' ' +topic.description).match(this.searchText) != null;
return textFlag;
}
handleError(message: string, error) {
if(error == null) {
this.formComponent.reset();
} else {
this.errorMessage = message + ' (Server responded: ' + error + ')';
}
}
}

View File

@ -3,7 +3,7 @@
*/ */
import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core'; import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core';
import { PageContentFormComponent } from "./page-help-content-form.component"; import { PageContentFormComponent } from "./page-help-content-form.component";
import { Subscription } from "rxjs/Subscription"; import { Subscription } from "rxjs";
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";

View File

@ -4,7 +4,6 @@
import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; import { Component, ViewChild, OnInit, ElementRef } from '@angular/core';
import { FormGroup } from "@angular/forms"; import { FormGroup } from "@angular/forms";
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } from "@angular/router";
import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
import { HelpContentService } from "../../services/help-content.service"; import { HelpContentService } from "../../services/help-content.service";
import { PageHelpContent, CheckPageHelpContent, PageHelpContentFilterOptions } from "../../domain/page-help-content"; import { PageHelpContent, CheckPageHelpContent, PageHelpContentFilterOptions } from "../../domain/page-help-content";
import { Page } from "../../domain/page"; import { Page } from "../../domain/page";

View File

@ -1,6 +1,6 @@
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser'; import { BrowserModule } from '@angular/platform-browser';
import { HttpModule, JsonpModule } from '@angular/http'; import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router'; import { RouterModule } from '@angular/router';
@ -19,8 +19,7 @@ import {CommonModule} from '@angular/common';
@NgModule({ @NgModule({
imports: [ imports: [
CommonModule, CommonModule,
HttpModule, HttpClientModule,
JsonpModule,
FormsModule, FormsModule,
ReactiveFormsModule, ReactiveFormsModule,
RouterModule, RouterModule,

View File

@ -8,7 +8,7 @@ import { HtmlPageContent, CheckHtmlPageContent } from "../../domain/html-page-co
import { HtmlPageContentFormComponent } from "./html-page-content-form.component"; import { HtmlPageContentFormComponent } from "./html-page-content-form.component";
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties'; import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
import { Subscription } from "rxjs/Subscription"; import { Subscription } from "rxjs";
import {Session} from '../../openaireLibrary/login/utils/helper.class'; import {Session} from '../../openaireLibrary/login/utils/helper.class';
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';

View File

@ -1,14 +1,15 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http'; import {HttpClient, HttpErrorResponse} from '@angular/common/http';
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs';
import {COOKIE} from "../../openaireLibrary/login/utils/helper.class" import {COOKIE} from "../../openaireLibrary/login/utils/helper.class"
import { HtmlPageContent } from "../../domain/html-page-content"; import { HtmlPageContent } from "../../domain/html-page-content";
import { CustomOptions } from '../../openaireLibrary/services/servicesUtils/customOptions.class'; import { CustomOptions } from '../../openaireLibrary/services/servicesUtils/customOptions.class';
import {catchError} from "rxjs/operators";
@Injectable() @Injectable()
export class HtmlPageContentService { export class HtmlPageContentService {
constructor(private http:Http) { constructor(private http:HttpClient) {
} }
static removeNulls(obj){ static removeNulls(obj){
@ -20,9 +21,9 @@ export class HtmlPageContentService {
} }
getHtmlPageContent(community : string, page: string, adminToolsAPIURL:string) { getHtmlPageContent(community : string, page: string, adminToolsAPIURL:string) {
return this.http.get(adminToolsAPIURL + 'htmlpagecontent?community=' + community + "&page="+page) return this.http.get<Array<HtmlPageContent>>(adminToolsAPIURL + 'htmlpagecontent?community=' + community + "&page="+page)
.map(res => <HtmlPageContent> res.json()) //.map(res => <HtmlPageContent> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
updateHtmlPageContent(htmlPageContent: HtmlPageContent, adminToolsAPIURL:string) { updateHtmlPageContent(htmlPageContent: HtmlPageContent, adminToolsAPIURL:string) {
@ -31,17 +32,17 @@ export class HtmlPageContentService {
HtmlPageContentService.removeNulls(htmlPageContent); HtmlPageContentService.removeNulls(htmlPageContent);
return this.http.post(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), CustomOptions.getAuthOptionsWithBody()) return this.http.post<HtmlPageContent>(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), CustomOptions.getAuthOptionsWithBody())
//return this.http.post(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), options) //return this.http.post(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), options)
.map(res => <HtmlPageContent> res.json()) //.map(res => <HtmlPageContent> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
private handleError(error: Response) { private handleError(error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.error(error);
return Observable.throw(error.json().error || 'Server error'); return Observable.throw(error.error || 'Server error');
} }
} }

View File

@ -1,22 +0,0 @@
<div *ngIf="isModalShown" [config]="{ show: true }" (onHidden)="onHidden()" bsModal #autoShownModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close pull-right" aria-label="Close" (click)="hideModal()">
<span aria-hidden="true">&times;</span>
</button>
<div class="uk-text-large"> {{titleText}} </div>
</div>
<div class="modal-body">
<div *ngIf="errorMessage" class="uk-alert-danger" uk-alert aria-hidden="true">{{ errorMessage }}</div>
<ng-content></ng-content>
</div>
<div class="modal-footer">
<div class="confirmationModalButtons">
<a *ngIf="formGroup" (click)="saveCustom(formGroup.value)" class="btn btn-success"><i></i> {{saveText}} </a>
<a (click)="hideModal()" class="btn"><i></i> Cancel </a>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,142 +0,0 @@
/**
* Created by stefanos on 28/4/2017.
*/
import { Component, ViewChild, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { ModalDirective } from 'ngx-bootstrap/modal';
import { ActivatedRoute } from "@angular/router";
import { FormGroup } from "@angular/forms";
import { FAQService } from "../services/faq.service";
import { Topic } from "../domain/topic";
import { Question } from "../domain/question";
import { HelpContentService } from "../services/help-content.service";
import { Page } from "../domain/page";
import { Entity } from "../domain/entity";
import { Community } from "../domain/community";
import { DivId } from "../domain/divId";
import { EnvProperties } from '../openaireLibrary/utils/properties/env-properties';
@Component({
selector: 'modal-form',
templateUrl: './modal-form.component.html'
})
export class ModalFormComponent {
constructor(private route: ActivatedRoute, private _faqService : FAQService, private _helpService: HelpContentService){
}
@ViewChild('autoShownModal')
public autoShownModal:ModalDirective;
@Input()
public isModalShown:boolean = false;
@Input()
public saveText : string;
@Input()
public titleText : string;
@Input()
public formGroup : FormGroup;
@Input()
public type : string = 'topic';
public errorMessage : string = null;
@Output() emmitObject: 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 {
this.isModalShown = true;
}
public hideModal():void {
this.autoShownModal.hide();
}
public onHidden():void {
this.isModalShown = false;
this.emmitError.emit(null);
this.errorMessage = null;
}
public saveCustom(obj : any) {
if(!this.formGroup.valid) {
this.errorMessage = "Please fill in all required fields marked with *"
} else {
if (this.type == 'topic') {
this._faqService.saveTopic(<Topic> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if (this.type == 'question') {
this._faqService.saveQuestion(<Question> obj).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if (this.type == 'community') {
if(this.saveText == 'Update') {
this._helpService.updateCommunity(<Community> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.saveCommunity(<Community> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
} else if (this.type == 'page') {
if(this.saveText == 'Update') {
this._helpService.updatePage(<Page> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.savePage(<Page> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
} else if (this.type == 'entity') {
if(this.saveText == 'Update') {
this._helpService.updateEntity(<Entity> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.saveEntity(<Entity> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
} else if (this.type == 'divId') {
if(this.saveText == 'Update') {
this._helpService.updateDivId(<DivId> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
} else if(this.saveText == 'Save') {
this._helpService.saveDivId(<DivId> obj, this.properties.adminToolsAPIURL).subscribe(
data => this.emmitObject.emit(data),
error => this.emmitError.emit(error)
);
}
}
this.hideModal();
}
}
}

View File

@ -5,8 +5,6 @@ import { Component, ViewChild, OnInit, ElementRef } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router"; import { ActivatedRoute, Router } 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 { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
import { PageFormComponent } from "./page-form.component"; 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";
@ -23,15 +21,6 @@ import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class
export class PagesComponent implements OnInit { export class PagesComponent implements OnInit {
// @ViewChild(ModalFormComponent)
@ViewChild('saveModal')
public modal:ModalFormComponent;
//
// @ViewChild('updateModal')
// public updateModal:ModalFormComponent;
// @ViewChild('deleteConfirmationModal')
// public deleteConfirmationModal : DeleteConfirmationDialogComponent;
@ViewChild('AlertModalSavePage') alertModalSavePage; @ViewChild('AlertModalSavePage') alertModalSavePage;
@ViewChild('AlertModalUpdatePage') alertModalUpdatePage; @ViewChild('AlertModalUpdatePage') alertModalUpdatePage;
@ViewChild('AlertModalDeletePages') alertModalDeletePages; @ViewChild('AlertModalDeletePages') alertModalDeletePages;
@ -155,9 +144,6 @@ export class PagesComponent implements OnInit {
error => this.handleError('System error retrieving communities', error)); error => this.handleError('System error retrieving communities', error));
} }
*/ */
public showModal():void {
this.modal.showModal();
}
public toggleCheckBoxes(event) { public toggleCheckBoxes(event) {
this.checkboxes.forEach(_ => _.checked = event.target.checked); this.checkboxes.forEach(_ => _.checked = event.target.checked);

View File

@ -1,41 +1,42 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http'; import {HttpClient, HttpHeaders} from "@angular/common/http";
import { Observable } from 'rxjs/Rx'; import {map} from "rxjs/operators";
@Injectable() @Injectable()
export class SubjectsService { export class SubjectsService {
constructor(private http: Http) { constructor(private http: HttpClient) {
} }
addSubjects(url: string, subjects: any) { addSubjects(url: string, subjects: any) {
const headers = new Headers({'Content-Type': 'application/json'}); let headers = new HttpHeaders({'Content-Type': 'application/json'});
const options = new RequestOptions({headers: headers});
const body = JSON.stringify(subjects); const body = JSON.stringify(subjects);
return this.http.post(url, body, options) return this.http.post(url, body, {headers: headers})
// .do(request => console.log("Insert Response:"+request.status)) // .do(request => console.log("Insert Response:"+request.status))
.map(res => res.json()) //.map(res => res.json())
.map(res => { .pipe(map(res => {
res['method'] = 'post'; res['method'] = 'post';
return res; return res;
}); }));
} }
removeSubjects(url: string, subjects: any) { removeSubjects(url: string, subjects: any) {
const headers = new Headers({'Content-Type': 'application/json'}); //const headers = new Headers({'Content-Type': 'application/json'});
let headers = new HttpHeaders({'Content-Type': 'application/json'});
const body = JSON.stringify(subjects); const body = JSON.stringify(subjects);
const options = new RequestOptions({headers: headers, body: body}); //const options = new RequestOptions({headers: headers, body: body});
return this.http.delete(url, options) //return this.http.delete(url, options)
return this.http.request('delete', url, { body: body, headers: headers})
// .do(request => console.log("Delete Response:"+request.status)) // .do(request => console.log("Delete Response:"+request.status))
.map(res => res.json()) //.map(res => res.json())
.map(res => { .pipe(map(res => {
res['method'] = 'delete'; res['method'] = 'delete';
return res; return res;
}); }));
} }
} }

View File

@ -3,7 +3,7 @@ import {ViewEncapsulation, EventEmitter} from '@angular/core';
import {SimpleChanges, OnChanges} from '@angular/core'; import {SimpleChanges, OnChanges} from '@angular/core';
import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms'; import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import {Subject} from 'rxjs/Subject'; import {Subject} from 'rxjs';
import {DataTableDirective} from 'angular-datatables'; import {DataTableDirective} from 'angular-datatables';
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';

View File

@ -1,20 +1,20 @@
import {Injectable} from '@angular/core'; import {Injectable} from "@angular/core";
import {Http, Response, Headers, RequestOptions} from '@angular/http'; import {HttpClient} from "@angular/common/http";
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
import {UserNotificationsRights} from './userNotificationsRights'; import {UserNotificationsRights} from './userNotificationsRights';
import {CustomOptions} from '../../openaireLibrary/services/servicesUtils/customOptions.class'; import {CustomOptions} from '../../openaireLibrary/services/servicesUtils/customOptions.class';
import {map} from "rxjs/operators";
@Injectable() @Injectable()
export class ManageUserNotificationsService { export class ManageUserNotificationsService {
constructor(private http: Http) { constructor(private http: HttpClient) {
} }
getUserNotifications(url: string, email: string) { getUserNotifications(url: string, email: string) {
return this.http.get(url).map(res => <any> res.json()) return this.http.get(url)//.map(res => <any> res.json())
.map(res => this.parseUserNotifications(res, email)); .pipe(map(res => this.parseUserNotifications(res, email)));
} }
updateUserNotifications(url: string, userNotificationsRights: any) { updateUserNotifications(url: string, userNotificationsRights: any) {

View File

@ -2,7 +2,7 @@ import {Component, OnInit, Input, ViewChild, ViewEncapsulation}
import {SimpleChanges, OnChanges} from '@angular/core'; import {SimpleChanges, OnChanges} from '@angular/core';
import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms'; import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms';
import {ActivatedRoute, Router} from '@angular/router'; import {ActivatedRoute, Router} from '@angular/router';
import { Subject } from 'rxjs/Subject'; import { Subject } from 'rxjs';
import { DataTableDirective } from 'angular-datatables'; import { DataTableDirective } from 'angular-datatables';

View File

@ -1,106 +0,0 @@
/**
* Created by stefania on 4/26/17.
*/
import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http';
import { Observable } from 'rxjs/Rx';
import { Topic } from './../domain/topic';
import { Question } from './../domain/question';
import { ActiveTopicQuestions } from './../domain/active-topic-questions';
import { CustomOptions } from '../openaireLibrary/services/servicesUtils/customOptions.class';
@Injectable()
export class FAQService {
constructor (private http: Http) {}
private _faqsUrl = process.env.API_ENDPOINT;
static removeNulls(obj){
var isArray = obj instanceof Array;
for (var k in obj){
if (obj[k]===null || obj[k]==='') isArray ? obj.splice(k,1) : delete obj[k];
else if (typeof obj[k]=="object") FAQService.removeNulls(obj[k]);
}
}
getTopics() {
return this.http.get(this._faqsUrl + 'topic')
.map(res => <Array<Topic>> res.json())
.catch(this.handleError);
}
saveTopic(topic: Topic) {
FAQService.removeNulls(topic);
return this.http.post(this._faqsUrl + 'topic', JSON.stringify(topic), CustomOptions.getAuthOptionsWithBody())
.map(res => <Topic> res.json())
.catch(this.handleError);
}
updateTopic(topic: Topic) {
FAQService.removeNulls(topic);
return this.http.put(this._faqsUrl + 'topic', JSON.stringify(topic), CustomOptions.getAuthOptionsWithBody())
.map(res => <Topic> res.json())
.catch(this.handleError);
}
deleteTopics(ids : string[]) {
return this.http.post(this._faqsUrl + 'topic/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError);
}
orderTopic(ids: string[], order: string) {
return this.http.post(this._faqsUrl + 'topic/toggle?order='+ order, JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.map( res => <string[]> res.json())
.catch(this.handleError);
}
getQuestions() {
return this.http.get(this._faqsUrl + 'question')
.map(res => <Array<Question>> res.json())
.catch(this.handleError);
}
saveQuestion(question: Question) {
FAQService.removeNulls(question);
return this.http.post(this._faqsUrl + 'question', JSON.stringify(question), CustomOptions.getAuthOptionsWithBody())
.map(res => <Question> res.json())
.catch(this.handleError);
}
toggleQuestion(ids : string[],status : boolean) {
return this.http.post(this._faqsUrl + 'question/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.map( res => <string[]> res.json())
.catch(this.handleError);
}
deleteQuestion(id : string) {
return this.http.delete(this._faqsUrl + 'question/' + id)
.catch(this.handleError);
}
deleteQuestions(ids : string[]) {
return this.http.post(this._faqsUrl + 'question/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError);
}
private handleError(error: Response) {
// in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console
console.error(error);
return Observable.throw(error.json().error || 'Server error');
}
}

View File

@ -2,8 +2,8 @@
* Created by stefania on 7/13/17. * Created by stefania on 7/13/17.
*/ */
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Http, Response, Headers, RequestOptions } from '@angular/http'; import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http";
import { Observable } from 'rxjs/Rx'; import { Observable } from 'rxjs';
import { Page } from "../domain/page"; import { Page } from "../domain/page";
import { PageHelpContent } from "../domain/page-help-content"; import { PageHelpContent } from "../domain/page-help-content";
import { Community } from "../domain/community"; import { Community } from "../domain/community";
@ -12,12 +12,14 @@ import { DivId } from "../domain/divId";
import { DivHelpContent } from "../domain/div-help-content"; import { DivHelpContent } from "../domain/div-help-content";
import {StatisticsDisplay, StatisticsSummary} from '../openaireLibrary/connect/statistics/statisticsEntities'; import {StatisticsDisplay, StatisticsSummary} from '../openaireLibrary/connect/statistics/statisticsEntities';
import { CustomOptions } from '../openaireLibrary/services/servicesUtils/customOptions.class'; import { CustomOptions } from '../openaireLibrary/services/servicesUtils/customOptions.class';
import {catchError, map} from "rxjs/operators";
import {COOKIE} from "../openaireLibrary/login/utils/helper.class";
@Injectable() @Injectable()
export class HelpContentService { export class HelpContentService {
constructor(private http:Http) { constructor(private http:HttpClient) {
} }
static removeNulls(obj){ static removeNulls(obj){
@ -30,42 +32,42 @@ export class HelpContentService {
getDivIdsFull(page_id: string, helpContentUrl:string) { getDivIdsFull(page_id: string, helpContentUrl:string) {
if(page_id) { if(page_id) {
return this.http.get(helpContentUrl + 'divFull?&page='+page_id) return this.http.get<Array<DivId>>(helpContentUrl + 'divFull?&page='+page_id)
.map(res => <Array<DivId>> res.json()) //.map(res => <Array<DivId>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} else { } else {
return this.http.get(helpContentUrl + 'divFull') return this.http.get<Array<DivId>>(helpContentUrl + 'divFull')
.map(res => <Array<DivId>> res.json()) //.map(res => <Array<DivId>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
} }
updateDivId(divId: DivId, helpContentUrl:string) { updateDivId(divId: DivId, helpContentUrl:string) {
HelpContentService.removeNulls(divId); HelpContentService.removeNulls(divId);
return this.http.post(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) return this.http.post<DivId>(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
.map(res => <DivId> res.json()) //.map(res => <DivId> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getDivId(divId: string, helpContentUrl:string) { getDivId(divId: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'div/'+divId) return this.http.get<DivId>(helpContentUrl + 'div/'+divId)
.map(res => <DivId> res.json()) //.map(res => <DivId> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getDivIdFull(divId: string, helpContentUrl:string) { getDivIdFull(divId: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'divFull/'+divId) return this.http.get<DivId>(helpContentUrl + 'divFull/'+divId)
.map(res => <DivId> res.json()) //.map(res => <DivId> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
saveDivId(divId: DivId, helpContentUrl:string) { saveDivId(divId: DivId, helpContentUrl:string) {
HelpContentService.removeNulls(divId); HelpContentService.removeNulls(divId);
return this.http.post(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) return this.http.post<DivId>(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
.map(res => <DivId> res.json()) //.map(res => <DivId> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
/* /*
getCommunitiesWithDivId(helpContentUrl:string) { getCommunitiesWithDivId(helpContentUrl:string) {
@ -75,88 +77,88 @@ export class HelpContentService {
} }
*/ */
getCommunityPagesWithDivId(community_pid: string, helpContentUrl:string) { getCommunityPagesWithDivId(community_pid: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'community/'+community_pid+'/pages?div=true') return this.http.get<Array<Page>>(helpContentUrl + 'community/'+community_pid+'/pages?div=true')
.map(res => <Array<Page>> res.json()) //.map(res => <Array<Page>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getCommunityDivHelpContents(community_pid: string, helpContentUrl:string) { getCommunityDivHelpContents(community_pid: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'divhelpcontent?community='+community_pid) return this.http.get<Array<DivHelpContent>>(helpContentUrl + 'divhelpcontent?community='+community_pid)
.map(res => <Array<DivHelpContent>> res.json()) //.map(res => <Array<DivHelpContent>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getDivHelpContent(id : string, helpContentUrl:string) { getDivHelpContent(id : string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'divhelpcontent/' + id) return this.http.get<DivHelpContent>(helpContentUrl + 'divhelpcontent/' + id)
.map(res => <DivHelpContent> res.json()) //.map(res => <DivHelpContent> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string) { insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(divHelpContent); HelpContentService.removeNulls(divHelpContent);
return this.http.post(helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody()) return this.http.post<DivHelpContent>(helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
.map(res => <DivHelpContent> res.json()) //.map(res => <DivHelpContent> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
deleteDivIds(ids : string[], helpContentUrl:string) { deleteDivIds(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
deleteDivHelpContents(ids : string[], helpContentUrl:string) { deleteDivHelpContents(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'divhelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'divhelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string) { toggleDivHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + 'divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json()) //.map( res => <string[]> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getPagesWithDivIds(community_pid: string, helpContentUrl:string) { getPagesWithDivIds(community_pid: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'div/pages') return this.http.get<Array<string>>(helpContentUrl + 'div/pages')
.map(res => <Map<string, Set<string>>> res.json()) //.map(res => <Map<string, Set<string>>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getPages(helpContentUrl:string,pid:string) { getPages(helpContentUrl:string,pid:string) {
return this.http.get(helpContentUrl + 'page'+(pid?("?pid="+pid):"")) return this.http.get<Array<Page>>(helpContentUrl + 'page'+(pid?("?pid="+pid):""))
.map(res => <Array<Page>> res.json()) //.map(res => <Array<Page>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getPage(pageId:string, helpContentUrl:string) { getPage(pageId:string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'page/'+pageId) return this.http.get<Page>(helpContentUrl + 'page/'+pageId)
.map(res => <Page> res.json()) //.map(res => <Page> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getCommunities( helpContentUrl:string) { getCommunities( helpContentUrl:string) {
return this.http.get(helpContentUrl + 'community') return this.http.get<Array<Community>>(helpContentUrl + 'community')
.map(res => <Array<Community>> res.json()) //.map(res => <Array<Community>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getCommunity(community_pid: string, helpContentUrl:string) { getCommunity(community_pid: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'community/'+community_pid) return this.http.get<Community>(helpContentUrl + 'community/'+community_pid)
.map(res => <Community> res.json()) //.map(res => <Community> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getCommunitiesFull( helpContentUrl:string) { getCommunitiesFull( helpContentUrl:string) {
return this.http.get(helpContentUrl + 'communityFull') return this.http.get<Array<Community>>(helpContentUrl + 'communityFull')
.map(res => <Array<Community>> res.json()) //.map(res => <Array<Community>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getCommunityFull(community_pid: string, helpContentUrl:string) { getCommunityFull(community_pid: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'communityFull/'+community_pid) return this.http.get<Community>(helpContentUrl + 'communityFull/'+community_pid)
.map(res => <Community> res.json()) //.map(res => <Community> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
saveCommunity(community: Community, helpContentUrl:string) { saveCommunity(community: Community, helpContentUrl:string) {
@ -165,9 +167,9 @@ export class HelpContentService {
HelpContentService.removeNulls(community); HelpContentService.removeNulls(community);
return this.http.post(helpContentUrl + 'community/save', JSON.stringify(community),CustomOptions.getAuthOptionsWithBody()) return this.http.post<Community>(helpContentUrl + 'community/save', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody())
.map(res => <Community> res.json()) //.map(res => <Community> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
updateCommunity(community: Community, helpContentUrl:string) { updateCommunity(community: Community, helpContentUrl:string) {
@ -176,9 +178,9 @@ export class HelpContentService {
HelpContentService.removeNulls(community); HelpContentService.removeNulls(community);
return this.http.post(helpContentUrl + 'community/update', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Community>(helpContentUrl + 'community/update', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody())
.map(res => <Community> res.json()) //.map(res => <Community> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
deleteCommunities(ids : string[], helpContentUrl:string) { deleteCommunities(ids : string[], helpContentUrl:string) {
@ -186,42 +188,42 @@ export class HelpContentService {
// let options = new RequestOptions({headers: headers}); // let options = new RequestOptions({headers: headers});
return this.http.post(helpContentUrl + 'community/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'community/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getCommunityPages(community_pid: string, params: string, helpContentUrl:string) { getCommunityPages(community_pid: string, params: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'community/'+community_pid+'/pages'+params) return this.http.get<Array<Page>>(helpContentUrl + 'community/'+community_pid+'/pages'+params)
.map(res => <Array<Page>> res.json()) //.map(res => <Array<Page>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getEntities(helpContentUrl:string) { getEntities(helpContentUrl:string) {
return this.http.get(helpContentUrl + 'entity') return this.http.get<Array<Entity>>(helpContentUrl + 'entity')
.map(res => <Array<Entity>> res.json()) //.map(res => <Array<Entity>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getCommunityEntities(community_pid: string, helpContentUrl:string) { getCommunityEntities(community_pid: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'community/'+community_pid+'/entities') return this.http.get<Array<Entity>>(helpContentUrl + 'community/'+community_pid+'/entities')
.map(res => <Array<Entity>> res.json()) //.map(res => <Array<Entity>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
saveEntity(entity: Entity, helpContentUrl:string) { saveEntity(entity: Entity, helpContentUrl:string) {
HelpContentService.removeNulls(entity); HelpContentService.removeNulls(entity);
return this.http.post(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Entity>(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
.map(res => <Entity> res.json()) //.map(res => <Entity> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
updateEntity(entity: Entity, helpContentUrl:string) { updateEntity(entity: Entity, helpContentUrl:string) {
HelpContentService.removeNulls(entity); HelpContentService.removeNulls(entity);
return this.http.post(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Entity>(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
.map(res => <Entity> res.json()) //.map(res => <Entity> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
// toggleEntity(selectedCommunityId: string, id : string,status : boolean) { // toggleEntity(selectedCommunityId: string, id : string,status : boolean) {
@ -236,99 +238,99 @@ export class HelpContentService {
return this.http.post(helpContentUrl +'community/'+selectedCommunityPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl +'community/'+selectedCommunityPid+ '/entity/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json()) //.map( res => <string[]> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
deleteEntities(ids : string[], helpContentUrl:string) { deleteEntities(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'entity/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'entity/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
toggleEntityOfPage(pageId: string, entityId : string,status : boolean, helpContentUrl:string) { toggleEntityOfPage(pageId: string, entityId : string,status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'page/'+pageId+'/entity/toggle?status='+ status.toString()+'&entityId='+entityId.toString(), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
savePage(page: Page, helpContentUrl:string) { savePage(page: Page, helpContentUrl:string) {
HelpContentService.removeNulls(page); HelpContentService.removeNulls(page);
return this.http.post(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Page>(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
.map(res => <Page> res.json()) //.map(res => <Page> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
updatePage(page: Page, helpContentUrl:string) { updatePage(page: Page, helpContentUrl:string) {
HelpContentService.removeNulls(page); HelpContentService.removeNulls(page);
return this.http.post(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) return this.http.post<Page>(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
.map(res => <Page> res.json()) //.map(res => <Page> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
togglePages(selectedCommunityPid: string, ids : string[],status : boolean, helpContentUrl:string) { togglePages(selectedCommunityPid: string, ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + 'community/'+selectedCommunityPid+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'community/'+selectedCommunityPid+'/page/toggle?status='+ status.toString(),JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
deletePages(ids : string[], helpContentUrl:string) { deletePages(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getPageHelpContents(helpContentUrl:string) { getPageHelpContents(helpContentUrl:string) {
return this.http.get(helpContentUrl + 'pagehelpcontent') return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent')
.map(res => <Array<PageHelpContent>> res.json()) //.map(res => <Array<PageHelpContent>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getCommunityPageHelpContents(community_pid: string, helpContentUrl:string) { getCommunityPageHelpContents(community_pid: string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'pagehelpcontent?community='+community_pid) return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent?community='+community_pid)
.map(res => <Array<PageHelpContent>> res.json()) //.map(res => <Array<PageHelpContent>> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
getPageHelpContent(id : string, helpContentUrl:string) { getPageHelpContent(id : string, helpContentUrl:string) {
return this.http.get(helpContentUrl + 'pagehelpcontent/' + id) return this.http.get<PageHelpContent>(helpContentUrl + 'pagehelpcontent/' + id)
.map(res => <PageHelpContent> res.json()) //.map(res => <PageHelpContent> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) { savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(pageHelpContent); HelpContentService.removeNulls(pageHelpContent);
return this.http.post(helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) return this.http.post<PageHelpContent>(helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
.map(res => <PageHelpContent> res.json()) //.map(res => <PageHelpContent> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) { updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) {
HelpContentService.removeNulls(pageHelpContent); HelpContentService.removeNulls(pageHelpContent);
return this.http.post(helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) return this.http.post<PageHelpContent>(helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
.map(res => <PageHelpContent> res.json()) //.map(res => <PageHelpContent> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
deletePageHelpContents(ids : string[], helpContentUrl:string) { deletePageHelpContents(ids : string[], helpContentUrl:string) {
return this.http.post(helpContentUrl + 'pagehelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'pagehelpcontent/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string) { togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string) {
return this.http.post(helpContentUrl + 'pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) return this.http.post(helpContentUrl + 'pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json()) //.map( res => <string[]> res.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
private handleError(error: Response) { private handleError(error: HttpErrorResponse) {
// in a real world app, we may send the error to some remote logging infrastructure // in a real world app, we may send the error to some remote logging infrastructure
// instead of just logging it to the console // instead of just logging it to the console
console.error(error); console.error(error);
return Observable.throw(error.json().error || 'Server error'); return Observable.throw(error.error || 'Server error');
} }
// getDataProviders() { // getDataProviders() {
@ -339,16 +341,16 @@ export class HelpContentService {
const url = `${apiUrl}communities/${communityId}`; const url = `${apiUrl}communities/${communityId}`;
//console.log(`getting statistics summary from: ${url}`); //console.log(`getting statistics summary from: ${url}`);
return this.http.get(url) return this.http.get(url)
.map(res => <any>res.json()) //.map(res => <any>res.json())
.map(res => res.statistics); .pipe(map(res => res['statistics']));
} }
getCommunityAdminStatisticsChoices(apiUrl: string, communityId: string): Observable<StatisticsDisplay> { getCommunityAdminStatisticsChoices(apiUrl: string, communityId: string): Observable<StatisticsDisplay> {
const url = `${apiUrl}statistics/${communityId}`; const url = `${apiUrl}statistics/${communityId}`;
//console.log(`getting admin choices for statistics from: ${url}`); //console.log(`getting admin choices for statistics from: ${url}`);
return this.http.get(url) return this.http.get<StatisticsDisplay>(url)
.map(stats => <StatisticsDisplay>stats.json()) //.map(stats => <StatisticsDisplay>stats.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
postCommunityAdminStatisticsChoices(apiUrl: string, postCommunityAdminStatisticsChoices(apiUrl: string,
@ -362,7 +364,7 @@ export class HelpContentService {
//console.log(`getting admin choices for statistics from: ${url}`); //console.log(`getting admin choices for statistics from: ${url}`);
return this.http.post(url, title, CustomOptions.getAuthOptionsWithBody()) return this.http.post(url, title, CustomOptions.getAuthOptionsWithBody())
.map(stats => <any>stats.json()) //.map(stats => <any>stats.json())
.catch(this.handleError); .pipe(catchError(this.handleError));
} }
} }

View File

@ -1,34 +1,35 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions} from '@angular/http'; import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Observable} from 'rxjs/Observable';
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
import { catchError } from 'rxjs/operators';
@Injectable() @Injectable()
export class ManageCommunityContentProvidersService { export class ManageCommunityContentProvidersService {
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
removeContentProvider (properties:EnvProperties, communityId: string, id: string):any { removeContentProvider (properties:EnvProperties, communityId: string, id: string):any {
let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
let options = new RequestOptions({headers: headers, body: id}); //let options = new RequestOptions({headers: headers, body: id});
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
let url = properties.communityAPI+communityId+"/contentproviders"; let url = properties.communityAPI+communityId+"/contentproviders";
return this.http.delete(url, options) //return this.http.delete(url, options)
return this.http.request('delete', url, { body: id, headers: headers})
} }
addContentProvider(properties:EnvProperties, communityId: string, contentProvider: any) { addContentProvider(properties:EnvProperties, communityId: string, contentProvider: any) {
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});
let headers = new HttpHeaders({'Content-Type': 'application/json'});
let url = properties.communityAPI+communityId+"/contentproviders"; let url = properties.communityAPI+communityId+"/contentproviders";
let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, communityId); let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, communityId);
return this.http.post(url, JSON.stringify(communityContentProvider), options) return this.http.post<any>(url, JSON.stringify(communityContentProvider), {headers: headers});
.map(res => <any> res.json()) //return this.http.post(url, JSON.stringify(communityContentProvider), options)
//.map(res => <any> res.json())
} }
convertSearchContentProviderToCommunityContentProvider(contentProvider: any, community: string) : any { convertSearchContentProviderToCommunityContentProvider(contentProvider: any, community: string) : any {

View File

@ -1,27 +1,27 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions} from '@angular/http'; import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import {Observable} from 'rxjs/Observable'; import {HttpClient, HttpHeaders} from '@angular/common/http';
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
import { catchError } from 'rxjs/operators';
@Injectable() @Injectable()
export class ManageCommunityProjectsService { export class ManageCommunityProjectsService {
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
removeProject (properties:EnvProperties, communityId: string, id: string):any { removeProject (properties:EnvProperties, communityId: string, id: string):any {
let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
let options = new RequestOptions({headers: headers, body: id}); //let options = new RequestOptions({headers: headers, body: id});
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
let url = properties.communityAPI+communityId+"/projects"; let url = properties.communityAPI+communityId+"/projects";
return this.http.delete(url, options) //return this.http.delete(url, options)
return this.http.request('delete', url, { body: id, headers: headers})
} }
addProject(properties:EnvProperties, communityId: string, project: any) { addProject(properties:EnvProperties, communityId: string, project: any) {
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});
let headers = new HttpHeaders({'Content-Type': 'application/json'});
let url = properties.communityAPI+communityId+"/projects"; let url = properties.communityAPI+communityId+"/projects";
@ -35,8 +35,9 @@ export class ManageCommunityProjectsService {
"openaireId": "test" "openaireId": "test"
}; };
return this.http.post(url, JSON.stringify(communityProject), options) return this.http.post<any>(url, JSON.stringify(communityProject), {headers: headers});
.map(res => <any> res.json()) //return this.http.post(url, JSON.stringify(communityProject), options)
//.map(res => <any> res.json())
} }
convertSearchProjectToCommunityProject(project: any, community: string) : any { convertSearchProjectToCommunityProject(project: any, community: string) : any {

View File

@ -1,28 +1,27 @@
import {Injectable} from '@angular/core'; import {Injectable} from '@angular/core';
import {Http, Response, Headers, RequestOptions} from '@angular/http'; import {HttpClient, HttpHeaders} from '@angular/common/http';
import {Observable} from 'rxjs/Observable';
import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; import{EnvProperties} from '../openaireLibrary/utils/properties/env-properties';
import { HttpErrorResponse, HttpResponse } from '@angular/common/http';
import { ErrorObservable } from 'rxjs/observable/ErrorObservable';
import { catchError } from 'rxjs/operators';
@Injectable() @Injectable()
export class ManageZenodoCommunitiesService { export class ManageZenodoCommunitiesService {
constructor(private http: Http ) {} constructor(private http: HttpClient ) {}
removeZCommunity (properties: EnvProperties, communityId: string,id: string):any { removeZCommunity (properties: EnvProperties, communityId: string,id: string):any {
let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'});
let options = new RequestOptions({headers: headers, body: id}); //let options = new RequestOptions({headers: headers, body: id});
let headers = new HttpHeaders({'Content-Type': 'application/json', 'accept': 'application/json'});
let url = properties.communityAPI + communityId + "/zenodocommunities"; let url = properties.communityAPI + communityId + "/zenodocommunities";
return this.http.delete(url, options); //return this.http.delete(url, options);
return this.http.request('delete', url, { body: id, headers: headers})
} }
addZCommunity(properties:EnvProperties, communityId: string,zenodoid: string) { addZCommunity(properties:EnvProperties, communityId: string,zenodoid: 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});
let headers = new HttpHeaders({'Content-Type': 'application/json'});
let url = properties.communityAPI+communityId+"/zenodocommunities"; let url = properties.communityAPI+communityId+"/zenodocommunities";
var zCommunity: any = { var zCommunity: any = {
@ -30,8 +29,8 @@ export class ManageZenodoCommunitiesService {
"zenodoid": zenodoid "zenodoid": zenodoid
}; };
return this.http.post(url, JSON.stringify(zCommunity), options) return this.http.post<any>(url, JSON.stringify(zCommunity), {headers: headers});
.map(res => <any> res.json()) //.map(res => <any> res.json())
} }

View File

@ -39,7 +39,6 @@ import 'core-js/es6/set';
/** Evergreen browsers require these. **/ /** Evergreen browsers require these. **/
import 'core-js/es6/reflect'; import 'core-js/es6/reflect';
import 'core-js/es7/reflect';
/** /**

View File

@ -1,6 +1,16 @@
{ {
"extends": "../tsconfig.json", "extends": "../tsconfig.json",
"compilerOptions": { "compilerOptions": {
"paths": {
"*": [
"types/*"
]
},
"paths": {
"*": [
"types/*"
]
},
"outDir": "../out-tsc/app", "outDir": "../out-tsc/app",
"baseUrl": "./", "baseUrl": "./",
"module": "es2015", "module": "es2015",

View File

@ -11,7 +11,8 @@
] ]
}, },
"files": [ "files": [
"test.ts" "test.ts",
"polyfills.ts"
], ],
"include": [ "include": [
"**/*.spec.ts", "**/*.spec.ts",

View File

@ -1,6 +1,7 @@
{ {
"compileOnSave": false, "compileOnSave": false,
"compilerOptions": { "compilerOptions": {
"importHelpers": true,
"outDir": "./dist/out-tsc", "outDir": "./dist/out-tsc",
"sourceMap": true, "sourceMap": true,
"declaration": false, "declaration": false,
@ -14,6 +15,8 @@
"lib": [ "lib": [
"es2017", "es2017",
"dom" "dom"
] ],
"module": "es2015",
"baseUrl": "./"
} }
} }

View File

@ -14,8 +14,7 @@
"eofline": true, "eofline": true,
"forin": true, "forin": true,
"import-blacklist": [ "import-blacklist": [
true, true
"rxjs"
], ],
"import-spacing": true, "import-spacing": true,
"indent": [ "indent": [