[Admin|Trunk]
parent
47534b7970
commit
5a0ffefd54
@ -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": {}
|
||||
}
|
||||
}
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
@ -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.
@ -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">×</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>
|
@ -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();
|
||||
// }
|
||||
}
|
@ -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>-->
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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>
|
@ -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 + ')';
|
||||
}
|
||||
}
|
||||
}
|
@ -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>-->
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
@ -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>
|
@ -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 + ')';
|
||||
}
|
||||
}
|
||||
}
|
@ -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">×</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>
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -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');
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue