diff --git a/.angular-cli.json b/.angular-cli.json deleted file mode 100644 index f12fe8b..0000000 --- a/.angular-cli.json +++ /dev/null @@ -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": {} - } -} diff --git a/angular.json b/angular.json new file mode 100644 index 0000000..0d4443d --- /dev/null +++ b/angular.json @@ -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" + } + } +} \ No newline at end of file diff --git a/interactivemining.sh b/interactivemining.sh new file mode 100755 index 0000000..f98b99a --- /dev/null +++ b/interactivemining.sh @@ -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 diff --git a/interactiveminingv3.tgz b/interactiveminingv3.tgz index b233449..c312123 100644 Binary files a/interactiveminingv3.tgz and b/interactiveminingv3.tgz differ diff --git a/karma.conf.js b/karma.conf.js index af139fa..0840f6c 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -4,24 +4,22 @@ module.exports = function (config) { config.set({ basePath: '', - frameworks: ['jasmine', '@angular/cli'], + frameworks: ['jasmine', '@angular-devkit/build-angular'], plugins: [ require('karma-jasmine'), require('karma-chrome-launcher'), require('karma-jasmine-html-reporter'), require('karma-coverage-istanbul-reporter'), - require('@angular/cli/plugins/karma') + require('@angular-devkit/build-angular/plugins/karma') ], client:{ clearContext: false // leave Jasmine Spec Runner output visible in browser }, coverageIstanbulReporter: { - reports: [ 'html', 'lcovonly' ], + dir: require('path').join(__dirname, 'coverage'), reports: [ 'html', 'lcovonly' ], fixWebpackSourcePaths: true }, - angularCli: { - environment: 'dev' - }, + reporters: ['progress', 'kjhtml'], port: 9876, colors: true, diff --git a/package.json b/package.json index 982503c..a14e365 100644 --- a/package.json +++ b/package.json @@ -12,53 +12,61 @@ }, "private": true, "dependencies": { - "@angular/animations": "^4.2.4", - "@angular/common": "^4.2.4", - "@angular/compiler": "^4.2.4", - "@angular/core": "^4.2.4", - "@angular/forms": "^4.2.4", - "@angular/http": "^4.2.4", - "@angular/platform-browser": "^4.2.4", - "@angular/platform-browser-dynamic": "^4.2.4", - "@angular/router": "^4.2.4", + "@angular/animations": "7.2.14", + "@angular/cdk": "^7.3.7", + "@angular/common": "7.2.14", + "@angular/compiler": "7.2.14", + "@angular/core": "7.2.14", + "@angular/forms": "7.2.14", + "@angular/http": "7.2.14", + "@angular/material": "^7.3.7", + "@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", - "angular-datatables": "^4.4.0", + "angular-datatables": "^4.4.1", "citation-js": "^0.3.4", "clipboard": "^1.5.16", - "core-js": "^2.4.1", - "datatables.net": "^1.10.16", - "datatables.net-dt": "^1.10.16", + "core-js": "2.6.8", + "datatables.net": "^1.10.19", + "datatables.net-dt": "^1.10.19", "interactiveminingv3": "file:./interactiveminingv3.tgz", - "jquery": "^3.2.1", + "jquery": "^3.4.1", "ng2-ckeditor": "1.1.9", "ngx-bootstrap": "^1.6.6", "ngx-color-picker": "^4.5.3", "ngx-json-ld": "0.1.6", - "rxjs": "^5.4.2", "ts-md5": "^1.2.0", - "zone.js": "^0.8.14" + "tslib": "^1.9.0", + "zone.js": "0.8.29" }, "devDependencies": { - "@angular/cli": "1.3.0", - "@angular/compiler-cli": "^4.2.4", - "@angular/language-service": "^4.2.4", - "@types/datatables.net": "^1.10.8", - "@types/jquery": "^3.2.17", - "@types/jasmine": "~2.5.53", - "@types/jasminewd2": "~2.0.2", - "@types/node": "~6.0.60", - "codelyzer": "~3.1.1", - "jasmine-core": "~2.6.2", - "jasmine-spec-reporter": "~4.1.0", - "karma": "~1.7.0", + "@angular-devkit/build-angular": "~0.13.0", + "@angular/cli": "7.3.9", + "@angular/compiler-cli": "7.2.14", + "@angular/language-service": "7.2.14", + "@types/datatables.net": "^1.10.17", + "@types/jasmine": "~2.8.8", + "@types/jasminewd2": "~2.0.3", + "@types/jquery": "^3.3.29", + "@types/node": "~6.14.6", + "codelyzer": "~4.5.0", + "jasmine-core": "~2.99.1", + "jasmine-spec-reporter": "~4.2.1", + "karma": "~3.0.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", - "karma-coverage-istanbul-reporter": "^1.2.1", - "karma-jasmine": "~1.1.0", + "karma-coverage-istanbul-reporter": "~2.0.1", + "karma-jasmine": "~1.1.2", "karma-jasmine-html-reporter": "^0.2.2", - "protractor": "~5.1.2", - "ts-node": "~3.2.0", - "tslint": "~5.3.2", - "typescript": "~2.3.3" + "protractor": "~5.4.0", + "ts-node": "~7.0.0", + "tslint": "^5.7.0", + "typescript": "3.2.4", + "rxjs": "6.5.1", + "rxjs-compat": "^6.5.1", + "rxjs-tslint": "^0.1.7" } } diff --git a/src/app/app.module.ts b/src/app/app.module.ts index fc4bbdd..c108cbc 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,16 +1,9 @@ import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; -import { HttpModule, JsonpModule } from '@angular/http'; +import { HttpClientModule } from '@angular/common/http'; import { AppComponent } from './app.component'; 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 { 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'; @@ -35,7 +28,6 @@ import {SafeHtmlPipeModule} from './openaireLibrary/utils/pipes/safeHTMLPipe.mod import {InteractiveMiningModule} from 'interactiveminingv3'; import {CommunityService} from './openaireLibrary/connect/community/community.service'; import {SubscribeService} from './openaireLibrary/utils/subscribe/subscribe.service'; -import { FAQService } from './services/faq.service'; import {ConnectRIGuard} from './openaireLibrary/connect/communityGuard/connectRIGuard.guard'; import {SideBarModule} from "./openaireLibrary/sharedComponents/sidebar/sideBar.module"; @@ -43,9 +35,7 @@ import {SideBarModule} from "./openaireLibrary/sharedComponents/sidebar/sideBar. imports: [ AppRoutingModule, BrowserModule, - HttpModule, - JsonpModule, - ModalModule.forRoot(), + HttpClientModule, FormsModule, ReactiveFormsModule, BottomModule, NavigationBarModule, CookieLawModule, @@ -56,17 +46,10 @@ import {SideBarModule} from "./openaireLibrary/sharedComponents/sidebar/sideBar. ], declarations: [ AppComponent, - TopicsComponent, - QuestionsComponent, - TopicsFormComponent, - ModalFormComponent, - QuestionsFormComponent, - DeleteConfirmationDialogComponent, CommunityErrorPageComponent, AdminErrorPageComponent ], providers: [ - FAQService, HelpContentService, CommunityService, SubscribeService, ConnectAdminLoginGuard, EnvironmentSpecificResolver, EnvironmentSpecificService, diff --git a/src/app/pages/community/content-providers/communityContentProviders.module.ts b/src/app/pages/community/content-providers/communityContentProviders.module.ts index 36b4008..a432dbf 100644 --- a/src/app/pages/community/content-providers/communityContentProviders.module.ts +++ b/src/app/pages/community/content-providers/communityContentProviders.module.ts @@ -1,5 +1,5 @@ import { NgModule } from '@angular/core'; -import { HttpModule, JsonpModule } from '@angular/http'; +import { HttpClientModule } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; @@ -26,8 +26,8 @@ import {CommunityContentProvidersRoutingModule} from './communityContentProvider @NgModule({ imports: [ CommonModule, - HttpModule, - JsonpModule, + HttpClientModule, + FormsModule, FormsModule, ReactiveFormsModule, RouterModule, diff --git a/src/app/pages/community/content-providers/remove-content-providers.component.ts b/src/app/pages/community/content-providers/remove-content-providers.component.ts index eff900c..6a1dff2 100644 --- a/src/app/pages/community/content-providers/remove-content-providers.component.ts +++ b/src/app/pages/community/content-providers/remove-content-providers.component.ts @@ -1,6 +1,6 @@ import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; import { ActivatedRoute, Router } from "@angular/router"; -import { Subject } from 'rxjs/Subject'; +import { Subject } from 'rxjs'; import { DataTableDirective } from 'angular-datatables'; import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; diff --git a/src/app/pages/community/projects/communityProjects.module.ts b/src/app/pages/community/projects/communityProjects.module.ts index 353e9d3..6a679fa 100644 --- a/src/app/pages/community/projects/communityProjects.module.ts +++ b/src/app/pages/community/projects/communityProjects.module.ts @@ -1,5 +1,5 @@ import { NgModule } from '@angular/core'; -import { HttpModule, JsonpModule } from '@angular/http'; +import { HttpClientModule } from '@angular/common/http'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { RouterModule } from '@angular/router'; @@ -27,8 +27,7 @@ import {CommunityProjectsRoutingModule} from './communityProjects-routing.module @NgModule({ imports: [ CommonModule, - HttpModule, - JsonpModule, + HttpClientModule, FormsModule, ReactiveFormsModule, RouterModule, diff --git a/src/app/pages/community/projects/remove-projects.component.ts b/src/app/pages/community/projects/remove-projects.component.ts index 0f41612..acc670e 100644 --- a/src/app/pages/community/projects/remove-projects.component.ts +++ b/src/app/pages/community/projects/remove-projects.component.ts @@ -1,6 +1,6 @@ import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core'; import { ActivatedRoute, Router } from "@angular/router"; -import { Subject } from 'rxjs/Subject'; +import { Subject } from 'rxjs'; import { DataTableDirective } from 'angular-datatables'; import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes'; diff --git a/src/app/pages/delete-confirmation-dialog.component.html b/src/app/pages/delete-confirmation-dialog.component.html deleted file mode 100644 index 38d3d42..0000000 --- a/src/app/pages/delete-confirmation-dialog.component.html +++ /dev/null @@ -1,21 +0,0 @@ - diff --git a/src/app/pages/delete-confirmation-dialog.component.ts b/src/app/pages/delete-confirmation-dialog.component.ts deleted file mode 100644 index 3ae8f22..0000000 --- a/src/app/pages/delete-confirmation-dialog.component.ts +++ /dev/null @@ -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 = 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( obj).subscribe( - // data => this.emmitObject.emit(data), - // error => this.emmitError.emit(error) - // ); - // } else if (this.type == 'question') { - // return; - // } - // this.hideModal(); - // } -} \ No newline at end of file diff --git a/src/app/pages/divId/divIds.component.ts b/src/app/pages/divId/divIds.component.ts index 0938f7b..6f95a0d 100644 --- a/src/app/pages/divId/divIds.component.ts +++ b/src/app/pages/divId/divIds.component.ts @@ -2,8 +2,6 @@ import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; import { ActivatedRoute, Router } from "@angular/router"; import { HelpContentService } from "../../services/help-content.service"; 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 { CheckDivId, DivId } from "../../domain/divId"; //import { Community } from "../../domain/community"; diff --git a/src/app/pages/divhelpcontent/div-help-contents.component.ts b/src/app/pages/divhelpcontent/div-help-contents.component.ts index 6f6d020..e7677c2 100644 --- a/src/app/pages/divhelpcontent/div-help-contents.component.ts +++ b/src/app/pages/divhelpcontent/div-help-contents.component.ts @@ -1,7 +1,6 @@ import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; import { Router, ActivatedRoute } from "@angular/router"; import { FormGroup } from "@angular/forms"; -import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component"; import { HelpContentService } from "../../services/help-content.service"; import { DivHelpContent, CheckDivHelpContent, DivHelpContentFilterOptions } from "../../domain/div-help-content"; import { Page } from "../../domain/page"; diff --git a/src/app/pages/divhelpcontent/edit-div-help-content.component.ts b/src/app/pages/divhelpcontent/edit-div-help-content.component.ts index d1ee6a3..b838a4a 100644 --- a/src/app/pages/divhelpcontent/edit-div-help-content.component.ts +++ b/src/app/pages/divhelpcontent/edit-div-help-content.component.ts @@ -1,6 +1,6 @@ import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core'; 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 { DivHelpContent } from "../../domain/div-help-content"; import { ActivatedRoute, Router } from "@angular/router"; diff --git a/src/app/pages/faq/questions-form.component.html b/src/app/pages/faq/questions-form.component.html deleted file mode 100644 index d7c08c5..0000000 --- a/src/app/pages/faq/questions-form.component.html +++ /dev/null @@ -1,35 +0,0 @@ -
-
- - -
-
- - -
-
- - -
-
- - -
- -
- - - Press ctrl + click to select more than one -
- -
- - - - \ No newline at end of file diff --git a/src/app/pages/faq/questions-form.component.ts b/src/app/pages/faq/questions-form.component.ts deleted file mode 100644 index 357845e..0000000 --- a/src/app/pages/faq/questions-form.component.ts +++ /dev/null @@ -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(); - } - -} \ No newline at end of file diff --git a/src/app/pages/faq/questions.component.html b/src/app/pages/faq/questions.component.html deleted file mode 100644 index f690006..0000000 --- a/src/app/pages/faq/questions.component.html +++ /dev/null @@ -1,153 +0,0 @@ -
-
- - -
-
-
- - - -
-
- -
- -
-
-
-
-
- - - -
-
-
-
-
{{check.question.date | date:'yyyy-MM-dd'}}
-
-
-
{{check.question.question}}
-
-
-
{{check.question.answer}} -
-
-
- {{getNames(check.question).join(', ')}} - - -
-
-
{{check.question.weight}}
-
-
-
{{check.question.hitCount}}
-
-
-
- -
-
- -
-
- - - - - - - -
-
- - -
-
-
-
-
-
No questions found
-
-
-
-
-
-
-
-
-
-
- - - - - - - - - - Are you sure you want to delete the selected question(s)? - diff --git a/src/app/pages/faq/questions.component.ts b/src/app/pages/faq/questions.component.ts deleted file mode 100644 index b05df90..0000000 --- a/src/app/pages/faq/questions.component.ts +++ /dev/null @@ -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 = 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({question : _, checked : false}); - }); - self.countQuestions(); - }, - error => this.errorMessage = 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 = Object.create(this.questionsCheckboxes[i].question.topics); - let topics : string[] = []; - for(let topic of 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(error) - ); - } - - public saveQuestion(data : any):void { - this._faqService.saveQuestion(data).subscribe( - question => this.questionSavedSuccessfully(question), - error => this.handleError(error) - ); - } - - public questionSavedSuccessfully(question: Question) { - this.questionsCheckboxes.push({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 == '' || (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({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 (question.topics).map(_ => _.name); - } - - handleError(error) { - if(error == null) { - this.formComponent.reset(); - }else { - this.errorMessage = 'System error saving topic (Server responded: ' + error + ')'; - } - } -} diff --git a/src/app/pages/faq/topics-form.component.html b/src/app/pages/faq/topics-form.component.html deleted file mode 100644 index 52591ca..0000000 --- a/src/app/pages/faq/topics-form.component.html +++ /dev/null @@ -1,26 +0,0 @@ -
-
- - -
-
- - -
-
- - -
-
- - -
- - -
- - - \ No newline at end of file diff --git a/src/app/pages/faq/topics-form.component.ts b/src/app/pages/faq/topics-form.component.ts deleted file mode 100644 index 79e1b70..0000000 --- a/src/app/pages/faq/topics-form.component.ts +++ /dev/null @@ -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(); - } - -} \ No newline at end of file diff --git a/src/app/pages/faq/topics.component.html b/src/app/pages/faq/topics.component.html deleted file mode 100644 index 106c534..0000000 --- a/src/app/pages/faq/topics.component.html +++ /dev/null @@ -1,111 +0,0 @@ -
-
- - -
-
-
- - - - -
-
-
-
- - - -
-
-
-
-
{{check.topic.date | date:'yyyy-MM-dd'}}
-
-
-
{{check.topic.name}}
-
-
-
{{check.topic.description}} -
-
-
-
{{check.topic.weight}}
-
-
-
{{check.topic.questionOrder}}
-
-
-
- - -
-
-
-
-
-
No topics found
-
-
-
-
-
-
-
-
-
-
- - - - - - - - - - Are you sure you want to delete the selected topic(s)? - diff --git a/src/app/pages/faq/topics.components.ts b/src/app/pages/faq/topics.components.ts deleted file mode 100644 index aebf06f..0000000 --- a/src/app/pages/faq/topics.components.ts +++ /dev/null @@ -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({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', error) - ); - this.applyCheck(false); - } - - public topicSavedSuccessfully(topic: Topic) { - this.topicsCheckboxes.push({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({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 + ')'; - } - } -} \ No newline at end of file diff --git a/src/app/pages/helpcontent/edit-page-help-content.component.ts b/src/app/pages/helpcontent/edit-page-help-content.component.ts index e29e604..9559844 100644 --- a/src/app/pages/helpcontent/edit-page-help-content.component.ts +++ b/src/app/pages/helpcontent/edit-page-help-content.component.ts @@ -3,7 +3,7 @@ */ import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core'; 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 { PageHelpContent } from "../../domain/page-help-content"; import { ActivatedRoute, Router } from "@angular/router"; diff --git a/src/app/pages/helpcontent/page-help-contents.component.ts b/src/app/pages/helpcontent/page-help-contents.component.ts index 2b6a028..0c921c9 100644 --- a/src/app/pages/helpcontent/page-help-contents.component.ts +++ b/src/app/pages/helpcontent/page-help-contents.component.ts @@ -4,7 +4,6 @@ import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; import { FormGroup } from "@angular/forms"; import { ActivatedRoute, Router } from "@angular/router"; -import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component"; import { HelpContentService } from "../../services/help-content.service"; import { PageHelpContent, CheckPageHelpContent, PageHelpContentFilterOptions } from "../../domain/page-help-content"; import { Page } from "../../domain/page"; diff --git a/src/app/pages/htmlpagecontent/edit-html-page-content.module.ts b/src/app/pages/htmlpagecontent/edit-html-page-content.module.ts index 43e1101..5e13b53 100644 --- a/src/app/pages/htmlpagecontent/edit-html-page-content.module.ts +++ b/src/app/pages/htmlpagecontent/edit-html-page-content.module.ts @@ -1,6 +1,6 @@ import { NgModule } from '@angular/core'; 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 { RouterModule } from '@angular/router'; @@ -19,8 +19,7 @@ import {CommonModule} from '@angular/common'; @NgModule({ imports: [ CommonModule, - HttpModule, - JsonpModule, + HttpClientModule, FormsModule, ReactiveFormsModule, RouterModule, diff --git a/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts b/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts index 14fbfbe..21cd44f 100644 --- a/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts +++ b/src/app/pages/htmlpagecontent/edit-htmlpage-content.component.ts @@ -8,7 +8,7 @@ import { HtmlPageContent, CheckHtmlPageContent } from "../../domain/html-page-co import { HtmlPageContentFormComponent } from "./html-page-content-form.component"; 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 {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class'; diff --git a/src/app/pages/htmlpagecontent/html-page-content.service.ts b/src/app/pages/htmlpagecontent/html-page-content.service.ts index af88584..caa5919 100644 --- a/src/app/pages/htmlpagecontent/html-page-content.service.ts +++ b/src/app/pages/htmlpagecontent/html-page-content.service.ts @@ -1,14 +1,15 @@ import { Injectable } from '@angular/core'; -import { Http, Response, Headers, RequestOptions } from '@angular/http'; -import { Observable } from 'rxjs/Rx'; +import {HttpClient, HttpErrorResponse} from '@angular/common/http'; +import { Observable } from 'rxjs'; import {COOKIE} from "../../openaireLibrary/login/utils/helper.class" import { HtmlPageContent } from "../../domain/html-page-content"; import { CustomOptions } from '../../openaireLibrary/services/servicesUtils/customOptions.class'; +import {catchError} from "rxjs/operators"; @Injectable() export class HtmlPageContentService { - constructor(private http:Http) { + constructor(private http:HttpClient) { } static removeNulls(obj){ @@ -20,9 +21,9 @@ export class HtmlPageContentService { } getHtmlPageContent(community : string, page: string, adminToolsAPIURL:string) { - return this.http.get(adminToolsAPIURL + 'htmlpagecontent?community=' + community + "&page="+page) - .map(res => res.json()) - .catch(this.handleError); + return this.http.get>(adminToolsAPIURL + 'htmlpagecontent?community=' + community + "&page="+page) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } updateHtmlPageContent(htmlPageContent: HtmlPageContent, adminToolsAPIURL:string) { @@ -31,17 +32,17 @@ export class HtmlPageContentService { HtmlPageContentService.removeNulls(htmlPageContent); - return this.http.post(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), CustomOptions.getAuthOptionsWithBody()) + return this.http.post(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), CustomOptions.getAuthOptionsWithBody()) //return this.http.post(adminToolsAPIURL + 'htmlpagecontent/update', JSON.stringify(htmlPageContent), options) - .map(res => res.json()) - .catch(this.handleError); + //.map(res => res.json()) + .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 // instead of just logging it to the console console.error(error); - return Observable.throw(error.json().error || 'Server error'); + return Observable.throw(error.error || 'Server error'); } } diff --git a/src/app/pages/modal-form.component.html b/src/app/pages/modal-form.component.html deleted file mode 100644 index c2d6fed..0000000 --- a/src/app/pages/modal-form.component.html +++ /dev/null @@ -1,22 +0,0 @@ - diff --git a/src/app/pages/modal-form.component.ts b/src/app/pages/modal-form.component.ts deleted file mode 100644 index a7c47c8..0000000 --- a/src/app/pages/modal-form.component.ts +++ /dev/null @@ -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 = new EventEmitter(); - - @Output() emmitError: EventEmitter = 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( obj).subscribe( - data => this.emmitObject.emit(data), - error => this.emmitError.emit(error) - ); - } else if (this.type == 'question') { - this._faqService.saveQuestion( obj).subscribe( - data => this.emmitObject.emit(data), - error => this.emmitError.emit(error) - ); - } else if (this.type == 'community') { - if(this.saveText == 'Update') { - this._helpService.updateCommunity( obj, this.properties.adminToolsAPIURL).subscribe( - data => this.emmitObject.emit(data), - error => this.emmitError.emit(error) - ); - - } else if(this.saveText == 'Save') { - this._helpService.saveCommunity( 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( obj, this.properties.adminToolsAPIURL).subscribe( - data => this.emmitObject.emit(data), - error => this.emmitError.emit(error) - ); - } else if(this.saveText == 'Save') { - this._helpService.savePage( 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( obj, this.properties.adminToolsAPIURL).subscribe( - data => this.emmitObject.emit(data), - error => this.emmitError.emit(error) - ); - } else if(this.saveText == 'Save') { - this._helpService.saveEntity( 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( obj, this.properties.adminToolsAPIURL).subscribe( - data => this.emmitObject.emit(data), - error => this.emmitError.emit(error) - ); - } else if(this.saveText == 'Save') { - this._helpService.saveDivId( obj, this.properties.adminToolsAPIURL).subscribe( - data => this.emmitObject.emit(data), - error => this.emmitError.emit(error) - ); - } - } - this.hideModal(); - } - } -} diff --git a/src/app/pages/page/pages.component.ts b/src/app/pages/page/pages.component.ts index bba9464..6c993e9 100644 --- a/src/app/pages/page/pages.component.ts +++ b/src/app/pages/page/pages.component.ts @@ -5,8 +5,6 @@ import { Component, ViewChild, OnInit, ElementRef } from '@angular/core'; import { ActivatedRoute, Router } from "@angular/router"; import { HelpContentService } from "../../services/help-content.service"; 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 { CheckPage, Page } from "../../domain/page"; import { Community } from "../../domain/community"; @@ -23,15 +21,6 @@ import {HelperFunctions} from "../../openaireLibrary/utils/HelperFunctions.class 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('AlertModalUpdatePage') alertModalUpdatePage; @ViewChild('AlertModalDeletePages') alertModalDeletePages; @@ -155,9 +144,6 @@ export class PagesComponent implements OnInit { error => this.handleError('System error retrieving communities', error)); } */ - public showModal():void { - this.modal.showModal(); - } public toggleCheckBoxes(event) { this.checkboxes.forEach(_ => _.checked = event.target.checked); diff --git a/src/app/pages/subjects/subjects.service.ts b/src/app/pages/subjects/subjects.service.ts index b593feb..2950cb6 100644 --- a/src/app/pages/subjects/subjects.service.ts +++ b/src/app/pages/subjects/subjects.service.ts @@ -1,41 +1,42 @@ import { Injectable } from '@angular/core'; -import { Http, Response, Headers, RequestOptions } from '@angular/http'; -import { Observable } from 'rxjs/Rx'; +import {HttpClient, HttpHeaders} from "@angular/common/http"; +import {map} from "rxjs/operators"; @Injectable() export class SubjectsService { - constructor(private http: Http) { + constructor(private http: HttpClient) { } addSubjects(url: string, subjects: any) { - const headers = new Headers({'Content-Type': 'application/json'}); - const options = new RequestOptions({headers: headers}); + let headers = new HttpHeaders({'Content-Type': 'application/json'}); - 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)) - .map(res => res.json()) - .map(res => { + //.map(res => res.json()) + .pipe(map(res => { res['method'] = 'post'; return res; - }); + })); } 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 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)) - .map(res => res.json()) - .map(res => { + //.map(res => res.json()) + .pipe(map(res => { res['method'] = 'delete'; return res; - }); + })); } } diff --git a/src/app/pages/subscribers/manage-subscribers.component.ts b/src/app/pages/subscribers/manage-subscribers.component.ts index 654ce5f..19b0d6d 100644 --- a/src/app/pages/subscribers/manage-subscribers.component.ts +++ b/src/app/pages/subscribers/manage-subscribers.component.ts @@ -3,7 +3,7 @@ import {ViewEncapsulation, EventEmitter} from '@angular/core'; import {SimpleChanges, OnChanges} from '@angular/core'; import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; -import {Subject} from 'rxjs/Subject'; +import {Subject} from 'rxjs'; import {DataTableDirective} from 'angular-datatables'; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; diff --git a/src/app/pages/usernotifications/manage-user-notifications.service.ts b/src/app/pages/usernotifications/manage-user-notifications.service.ts index a7d241b..3d1c12b 100644 --- a/src/app/pages/usernotifications/manage-user-notifications.service.ts +++ b/src/app/pages/usernotifications/manage-user-notifications.service.ts @@ -1,20 +1,20 @@ -import {Injectable} from '@angular/core'; -import {Http, Response, Headers, RequestOptions} from '@angular/http'; - +import {Injectable} from "@angular/core"; +import {HttpClient} from "@angular/common/http"; import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties'; import {UserNotificationsRights} from './userNotificationsRights'; import {CustomOptions} from '../../openaireLibrary/services/servicesUtils/customOptions.class'; +import {map} from "rxjs/operators"; @Injectable() export class ManageUserNotificationsService { - constructor(private http: Http) { + constructor(private http: HttpClient) { } getUserNotifications(url: string, email: string) { - return this.http.get(url).map(res => res.json()) - .map(res => this.parseUserNotifications(res, email)); + return this.http.get(url)//.map(res => res.json()) + .pipe(map(res => this.parseUserNotifications(res, email))); } updateUserNotifications(url: string, userNotificationsRights: any) { diff --git a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts index 45e414e..5afe4d5 100644 --- a/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts +++ b/src/app/pages/zenodo-communities/manage-zenodo-communities.component.ts @@ -2,7 +2,7 @@ import {Component, OnInit, Input, ViewChild, ViewEncapsulation} import {SimpleChanges, OnChanges} from '@angular/core'; import {FormGroup, FormArray, FormBuilder, Validators} from '@angular/forms'; import {ActivatedRoute, Router} from '@angular/router'; -import { Subject } from 'rxjs/Subject'; +import { Subject } from 'rxjs'; import { DataTableDirective } from 'angular-datatables'; diff --git a/src/app/services/faq.service.ts b/src/app/services/faq.service.ts deleted file mode 100644 index a7fb488..0000000 --- a/src/app/services/faq.service.ts +++ /dev/null @@ -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 => > 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 => 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 => 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 => res.json()) - .catch(this.handleError); - } - - getQuestions() { - return this.http.get(this._faqsUrl + 'question') - .map(res => > 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 => 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 => 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'); - } - - -} diff --git a/src/app/services/help-content.service.ts b/src/app/services/help-content.service.ts index d0b3483..186a622 100644 --- a/src/app/services/help-content.service.ts +++ b/src/app/services/help-content.service.ts @@ -2,8 +2,8 @@ * Created by stefania on 7/13/17. */ import { Injectable } from '@angular/core'; -import { Http, Response, Headers, RequestOptions } from '@angular/http'; -import { Observable } from 'rxjs/Rx'; +import {HttpClient, HttpErrorResponse, HttpHeaders} from "@angular/common/http"; +import { Observable } from 'rxjs'; import { Page } from "../domain/page"; import { PageHelpContent } from "../domain/page-help-content"; import { Community } from "../domain/community"; @@ -12,12 +12,14 @@ import { DivId } from "../domain/divId"; import { DivHelpContent } from "../domain/div-help-content"; import {StatisticsDisplay, StatisticsSummary} from '../openaireLibrary/connect/statistics/statisticsEntities'; import { CustomOptions } from '../openaireLibrary/services/servicesUtils/customOptions.class'; +import {catchError, map} from "rxjs/operators"; +import {COOKIE} from "../openaireLibrary/login/utils/helper.class"; @Injectable() export class HelpContentService { - constructor(private http:Http) { + constructor(private http:HttpClient) { } static removeNulls(obj){ @@ -30,42 +32,42 @@ export class HelpContentService { getDivIdsFull(page_id: string, helpContentUrl:string) { if(page_id) { - return this.http.get(helpContentUrl + 'divFull?&page='+page_id) - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'divFull?&page='+page_id) + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } else { - return this.http.get(helpContentUrl + 'divFull') - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'divFull') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } } updateDivId(divId: DivId, helpContentUrl:string) { HelpContentService.removeNulls(divId); - return this.http.post(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } getDivId(divId: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'div/'+divId) - .map(res => res.json()) - .catch(this.handleError); + return this.http.get(helpContentUrl + 'div/'+divId) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } getDivIdFull(divId: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'divFull/'+divId) - .map(res => res.json()) - .catch(this.handleError); + return this.http.get(helpContentUrl + 'divFull/'+divId) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } saveDivId(divId: DivId, helpContentUrl:string) { HelpContentService.removeNulls(divId); - return this.http.post(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } /* getCommunitiesWithDivId(helpContentUrl:string) { @@ -75,88 +77,88 @@ export class HelpContentService { } */ getCommunityPagesWithDivId(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'community/'+community_pid+'/pages?div=true') - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'community/'+community_pid+'/pages?div=true') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getCommunityDivHelpContents(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'divhelpcontent?community='+community_pid) - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'divhelpcontent?community='+community_pid) + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getDivHelpContent(id : string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'divhelpcontent/' + id) - .map(res => res.json()) - .catch(this.handleError); + return this.http.get(helpContentUrl + 'divhelpcontent/' + id) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string) { HelpContentService.removeNulls(divHelpContent); - return this.http.post(helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'divhelpcontent', JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } deleteDivIds(ids : string[], helpContentUrl:string) { return this.http.post(helpContentUrl + 'div/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) - .catch(this.handleError); + .pipe(catchError(this.handleError)); } deleteDivHelpContents(ids : string[], helpContentUrl:string) { 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) { return this.http.post(helpContentUrl + 'divhelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) //.map( res => res.json()) - .catch(this.handleError); + .pipe(catchError(this.handleError)); } getPagesWithDivIds(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'div/pages') - .map(res => >> res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'div/pages') + //.map(res => >> res.json()) + .pipe(catchError(this.handleError)); } getPages(helpContentUrl:string,pid:string) { - return this.http.get(helpContentUrl + 'page'+(pid?("?pid="+pid):"")) - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'page'+(pid?("?pid="+pid):"")) + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getPage(pageId:string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'page/'+pageId) - .map(res => res.json()) - .catch(this.handleError); + return this.http.get(helpContentUrl + 'page/'+pageId) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } getCommunities( helpContentUrl:string) { - return this.http.get(helpContentUrl + 'community') - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'community') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getCommunity(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'community/'+community_pid) - .map(res => res.json()) - .catch(this.handleError); + return this.http.get(helpContentUrl + 'community/'+community_pid) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } getCommunitiesFull( helpContentUrl:string) { - return this.http.get(helpContentUrl + 'communityFull') - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'communityFull') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getCommunityFull(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'communityFull/'+community_pid) - .map(res => res.json()) - .catch(this.handleError); + return this.http.get(helpContentUrl + 'communityFull/'+community_pid) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } saveCommunity(community: Community, helpContentUrl:string) { @@ -165,9 +167,9 @@ export class HelpContentService { HelpContentService.removeNulls(community); - return this.http.post(helpContentUrl + 'community/save', JSON.stringify(community),CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'community/save', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } updateCommunity(community: Community, helpContentUrl:string) { @@ -176,9 +178,9 @@ export class HelpContentService { HelpContentService.removeNulls(community); - return this.http.post(helpContentUrl + 'community/update', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'community/update', JSON.stringify(community), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } deleteCommunities(ids : string[], helpContentUrl:string) { @@ -186,42 +188,42 @@ export class HelpContentService { // let options = new RequestOptions({headers: headers}); 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) { - return this.http.get(helpContentUrl + 'community/'+community_pid+'/pages'+params) - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'community/'+community_pid+'/pages'+params) + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getEntities(helpContentUrl:string) { - return this.http.get(helpContentUrl + 'entity') - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'entity') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getCommunityEntities(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'community/'+community_pid+'/entities') - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'community/'+community_pid+'/entities') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } saveEntity(entity: Entity, helpContentUrl:string) { HelpContentService.removeNulls(entity); - return this.http.post(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } updateEntity(entity: Entity, helpContentUrl:string) { HelpContentService.removeNulls(entity); - return this.http.post(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } // 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()) //.map( res => res.json()) - .catch(this.handleError); + .pipe(catchError(this.handleError)); } deleteEntities(ids : string[], helpContentUrl:string) { 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) { 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) { HelpContentService.removeNulls(page); - return this.http.post(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } updatePage(page: Page, helpContentUrl:string) { HelpContentService.removeNulls(page); - return this.http.post(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } 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()) - .catch(this.handleError); + .pipe(catchError(this.handleError)); } deletePages(ids : string[], helpContentUrl:string) { return this.http.post(helpContentUrl + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) - .catch(this.handleError); + .pipe(catchError(this.handleError)); } getPageHelpContents(helpContentUrl:string) { - return this.http.get(helpContentUrl + 'pagehelpcontent') - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'pagehelpcontent') + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getCommunityPageHelpContents(community_pid: string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'pagehelpcontent?community='+community_pid) - .map(res => > res.json()) - .catch(this.handleError); + return this.http.get>(helpContentUrl + 'pagehelpcontent?community='+community_pid) + //.map(res => > res.json()) + .pipe(catchError(this.handleError)); } getPageHelpContent(id : string, helpContentUrl:string) { - return this.http.get(helpContentUrl + 'pagehelpcontent/' + id) - .map(res => res.json()) - .catch(this.handleError); + return this.http.get(helpContentUrl + 'pagehelpcontent/' + id) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } savePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) { HelpContentService.removeNulls(pageHelpContent); - return this.http.post(helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'pagehelpcontent/save', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string) { HelpContentService.removeNulls(pageHelpContent); - return this.http.post(helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) - .map(res => res.json()) - .catch(this.handleError); + return this.http.post(helpContentUrl + 'pagehelpcontent/update', JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody()) + //.map(res => res.json()) + .pipe(catchError(this.handleError)); } deletePageHelpContents(ids : string[], helpContentUrl:string) { 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) { return this.http.post(helpContentUrl + 'pagehelpcontent/toggle?status='+ status.toString(), JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody()) //.map( res => 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 // instead of just logging it to the console console.error(error); - return Observable.throw(error.json().error || 'Server error'); + return Observable.throw(error.error || 'Server error'); } // getDataProviders() { @@ -339,16 +341,16 @@ export class HelpContentService { const url = `${apiUrl}communities/${communityId}`; //console.log(`getting statistics summary from: ${url}`); return this.http.get(url) - .map(res => res.json()) - .map(res => res.statistics); + //.map(res => res.json()) + .pipe(map(res => res['statistics'])); } getCommunityAdminStatisticsChoices(apiUrl: string, communityId: string): Observable { const url = `${apiUrl}statistics/${communityId}`; //console.log(`getting admin choices for statistics from: ${url}`); - return this.http.get(url) - .map(stats => stats.json()) - .catch(this.handleError); + return this.http.get(url) + //.map(stats => stats.json()) + .pipe(catchError(this.handleError)); } postCommunityAdminStatisticsChoices(apiUrl: string, @@ -362,7 +364,7 @@ export class HelpContentService { //console.log(`getting admin choices for statistics from: ${url}`); return this.http.post(url, title, CustomOptions.getAuthOptionsWithBody()) - .map(stats => stats.json()) - .catch(this.handleError); + //.map(stats => stats.json()) + .pipe(catchError(this.handleError)); } } diff --git a/src/app/services/manageContentProviders.service.ts b/src/app/services/manageContentProviders.service.ts index b5685eb..adc95ed 100644 --- a/src/app/services/manageContentProviders.service.ts +++ b/src/app/services/manageContentProviders.service.ts @@ -1,34 +1,35 @@ import {Injectable} from '@angular/core'; -import {Http, Response, Headers, RequestOptions} from '@angular/http'; -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() export class ManageCommunityContentProvidersService { - constructor(private http: Http ) {} + constructor(private http: HttpClient ) {} removeContentProvider (properties:EnvProperties, communityId: string, id: string):any { - let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); - let options = new RequestOptions({headers: headers, body: id}); + //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); + //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"; - 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) { - let headers = new Headers({'Content-Type': 'application/json'}); - let options = new RequestOptions({headers: headers}); + //let headers = new Headers({'Content-Type': 'application/json'}); + //let options = new RequestOptions({headers: headers}); - let url = properties.communityAPI+communityId+"/contentproviders"; + let headers = new HttpHeaders({'Content-Type': 'application/json'}); + + let url = properties.communityAPI+communityId+"/contentproviders"; let communityContentProvider = this.convertSearchContentProviderToCommunityContentProvider(contentProvider, communityId); - return this.http.post(url, JSON.stringify(communityContentProvider), options) - .map(res => res.json()) + return this.http.post(url, JSON.stringify(communityContentProvider), {headers: headers}); + //return this.http.post(url, JSON.stringify(communityContentProvider), options) + //.map(res => res.json()) } convertSearchContentProviderToCommunityContentProvider(contentProvider: any, community: string) : any { diff --git a/src/app/services/manageProjects.service.ts b/src/app/services/manageProjects.service.ts index 9751a97..e4d504e 100644 --- a/src/app/services/manageProjects.service.ts +++ b/src/app/services/manageProjects.service.ts @@ -1,29 +1,29 @@ import {Injectable} from '@angular/core'; -import {Http, Response, Headers, RequestOptions} from '@angular/http'; -import {Observable} from 'rxjs/Observable'; -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'; +import {EnvProperties} from '../openaireLibrary/utils/properties/env-properties'; +import {HttpClient, HttpHeaders} from '@angular/common/http'; @Injectable() export class ManageCommunityProjectsService { - constructor(private http: Http ) {} + constructor(private http: HttpClient ) {} removeProject (properties:EnvProperties, communityId: string, id: string):any { - let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); - let options = new RequestOptions({headers: headers, body: id}); + //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); + //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"; - 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) { - let headers = new Headers({'Content-Type': 'application/json'}); - let options = new RequestOptions({headers: headers}); + //let headers = new Headers({'Content-Type': 'application/json'}); + //let options = new RequestOptions({headers: headers}); - let url = properties.communityAPI+communityId+"/projects"; + let headers = new HttpHeaders({'Content-Type': 'application/json'}); + + let url = properties.communityAPI+communityId+"/projects"; let communityProject = this.convertSearchProjectToCommunityProject(project, communityId); let testProject: any = { @@ -35,8 +35,9 @@ export class ManageCommunityProjectsService { "openaireId": "test" }; - return this.http.post(url, JSON.stringify(communityProject), options) - .map(res => res.json()) + return this.http.post(url, JSON.stringify(communityProject), {headers: headers}); + //return this.http.post(url, JSON.stringify(communityProject), options) + //.map(res => res.json()) } convertSearchProjectToCommunityProject(project: any, community: string) : any { diff --git a/src/app/services/manageZenodoCommunities.service.ts b/src/app/services/manageZenodoCommunities.service.ts index 1e740a7..3257313 100644 --- a/src/app/services/manageZenodoCommunities.service.ts +++ b/src/app/services/manageZenodoCommunities.service.ts @@ -1,28 +1,27 @@ import {Injectable} from '@angular/core'; -import {Http, Response, Headers, RequestOptions} from '@angular/http'; -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() export class ManageZenodoCommunitiesService { - constructor(private http: Http ) {} + constructor(private http: HttpClient ) {} removeZCommunity (properties: EnvProperties, communityId: string,id: string):any { - let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); - let options = new RequestOptions({headers: headers, body: id}); + //let headers = new Headers({'Content-Type': 'application/json', 'accept': 'application/json'}); + //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"; - 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) { - let headers = new Headers({'Content-Type': 'application/json'}); - let options = new RequestOptions({headers: headers}); + //let headers = new Headers({'Content-Type': 'application/json'}); + //let options = new RequestOptions({headers: headers}); + + let headers = new HttpHeaders({'Content-Type': 'application/json'}); let url = properties.communityAPI+communityId+"/zenodocommunities"; var zCommunity: any = { @@ -30,8 +29,8 @@ export class ManageZenodoCommunitiesService { "zenodoid": zenodoid }; - return this.http.post(url, JSON.stringify(zCommunity), options) - .map(res => res.json()) + return this.http.post(url, JSON.stringify(zCommunity), {headers: headers}); + //.map(res => res.json()) } diff --git a/src/polyfills.ts b/src/polyfills.ts index 98fd841..4e77c07 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -39,7 +39,6 @@ import 'core-js/es6/set'; /** Evergreen browsers require these. **/ import 'core-js/es6/reflect'; -import 'core-js/es7/reflect'; /** diff --git a/src/tsconfig.app.json b/src/tsconfig.app.json index 2ac34b0..c300528 100644 --- a/src/tsconfig.app.json +++ b/src/tsconfig.app.json @@ -1,6 +1,16 @@ { "extends": "../tsconfig.json", "compilerOptions": { + "paths": { + "*": [ + "types/*" + ] + }, + "paths": { + "*": [ + "types/*" + ] + }, "outDir": "../out-tsc/app", "baseUrl": "./", "module": "es2015", diff --git a/src/tsconfig.spec.json b/src/tsconfig.spec.json index 63d89ff..18bad40 100644 --- a/src/tsconfig.spec.json +++ b/src/tsconfig.spec.json @@ -11,7 +11,8 @@ ] }, "files": [ - "test.ts" + "test.ts", + "polyfills.ts" ], "include": [ "**/*.spec.ts", diff --git a/tsconfig.json b/tsconfig.json index a6c016b..8cd9a30 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "compileOnSave": false, "compilerOptions": { + "importHelpers": true, "outDir": "./dist/out-tsc", "sourceMap": true, "declaration": false, @@ -14,6 +15,8 @@ "lib": [ "es2017", "dom" - ] + ], + "module": "es2015", + "baseUrl": "./" } -} +} \ No newline at end of file diff --git a/tslint.json b/tslint.json index 0db5751..7223e1a 100644 --- a/tslint.json +++ b/tslint.json @@ -14,8 +14,7 @@ "eofline": true, "forin": true, "import-blacklist": [ - true, - "rxjs" + true ], "import-spacing": true, "indent": [