[Library|Trunk]

Dashboard: 
- DivIds: clean up components, new UI
- pages: add count for divIds


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60756 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2021-03-31 11:23:24 +00:00
parent f4456bc305
commit 3302e2c238
28 changed files with 947 additions and 1431 deletions

View File

@ -114,14 +114,14 @@ export class CustomizationOptions {
constructor() {
this.mainColor = '#4C9CD5';
this.secondaryColor = '#24857F';
this.mainColor = '#4687E6';
this.secondaryColor = '#2D72D6';
this.panel = {
onDarkBackground: true,
background: {
color: '#4C9CD5',
color: '#4687E6',
borderStyle: 'solid',
borderColor: "#4C9CD5",
borderColor: "#4687E6",
borderWidth: 0
}, fonts: {
color: '#ffffff',
@ -160,9 +160,9 @@ export class CustomizationOptions {
},
},
lightBackground: {
color: '#4C9CD5',
color: '#4687E6',
onHover: {
color: '#24857F'
color: '#2D72D6'
},
}
};
@ -170,28 +170,28 @@ export class CustomizationOptions {
this.buttons = {
darkBackground: {
backgroundColor: "#ffffff",
color:"#4C9CD5",
color:"#000000",
borderStyle:"solid",
borderColor: "#ffffff",
borderWidth: 1,
borderRadius: 4,
borderRadius: 500,
onHover: {
backgroundColor: "#eeeeee",
color: "#4C9CD5",
color: "#000000",
borderColor: "#eeeeee",
}
},
lightBackground: {
backgroundColor: '#003052',
backgroundColor: '#4687E6',
color: '#ffffff',
borderStyle: "solid",
borderColor: "#003052",
borderColor: "#4687E6",
borderWidth: 1,
borderRadius: 4,
borderRadius: 500,
onHover: {
backgroundColor: '#154B71',
backgroundColor: '#2D72D6',
color: '#ffffff',
borderColor: "#154B71",
borderColor: "#2D72D6",
}
}

View File

@ -0,0 +1,13 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {ClassContentFormComponent} from './class-help-content-form.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: ClassContentFormComponent}
])
]
})
export class ClassHelpContentFormRoutingModule { }

View File

@ -0,0 +1,85 @@
<div page-content>
<div header>
<div class="uk-margin-top">
<a routerLink="../" [queryParams]=" { 'pageId': pageId }"
class="uk-text-secondary uk-text-uppercase uk-text-bold uk-text-small">
<span class="uk-icon-button uk-icon small uk-button-secondary">
<icon name="arrow_left"></icon>
</span>
<span class="space">
Go back to class contents list
</span>
</a>
</div>
</div>
<div inner>
<div class="uk-card-header">
<div class="uk-flex uk-flex-middle uk-child-width-1-1 uk-child-width-1-2@m uk-grid" uk-grid>
<div>
<div class="uk-text-small uk-text-muted"> {{pageHelpContent ? 'Update ' : 'Add new '}} class content</div>
<div>
<span *ngIf="page" class="uk-text-bold">{{page.name}}</span>
<span *ngIf="myForm.dirty"> (unsaved changes)</span>
</div>
</div>
<div class=" uk-flex uk-flex-right">
<button (click)="resetCustom()" [disabled]="showLoading || !myForm.dirty"
class="uk-button uk-button-secondary outlined uk-margin-small-right">Reset
</button>
<button (click)="saveCustom()" class="uk-button uk-button-secondary uk-margin-small-right"
[disabled]="showLoading || !myForm.dirty || !myForm.valid ">Save
</button>
</div>
</div>
</div>
<div class="uk-card uk-card-default uk-position-relative " style="min-height: 60vh">
<div style="max-height: 60vh" class="uk-padding-large uk-overflow-auto">
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
<div class="uk-animation-fade uk-width-1-1" role="alert">
<div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div>
<div *ngIf="showLoading" class="uk-position-center">
<loading *ngIf="showLoading"></loading>
</div>
<form [formGroup]="myForm" [class.hidden]="showLoading">
<div class="uk-grid uk-child-width-1-2 ">
<div *ngIf="classOptions.length > 0" dashboard-input
[formInput]="myForm.get('divId')"
type="select" placeholder="Select Class"
label="Select Class" [options]="classOptions"
>
</div>
</div>
<div class="form-group uk-margin-top">
<span class="uk-text-bold uk-margin-small-right">Select Status (Enable/ disable)</span>
<mat-slide-toggle [checked]="myForm.get('isActive').value"
(change)="changeStatus()"
uk-tooltip="title:<div class='uk-padding-small uk-width-large'><div class='uk-text-bold '> Enable or disable help text to show or hide it from the dashboard</div></div>"
></mat-slide-toggle>
</div>
<div class="form-group uk-margin-large-top"
[ngClass]="{'has-error':!myForm.controls.content.valid &&
myForm.controls.content.dirty}" >
<label class="uk-text-bold">Content</label>
<div class="uk-margin-top">
<ckeditor (change)="contentChanged()"
[readonly]="false"
debounce="500"
[formControl]="myForm.get('content')"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', removeButtons: 'Save,NewPage,DocProps,Preview,Print',
extraPlugins: 'divarea'}">
</ckeditor>
</div>
</div>
<input type="hidden" formControlName="_id">
</form>
</div>
</div>
</div>
</div>
</div>

View File

@ -0,0 +1,220 @@
import {Component, Input, OnInit} from '@angular/core';
import {ActivatedRoute, Router} from '@angular/router';
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
import {Page} from '../../utils/entities/adminTool/page';
import {HelpContentService} from '../../services/help-content.service';
import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {properties} from '../../../../environments/environment';
import {Observable, Subscriber, Subscription} from 'rxjs';
import {HelperFunctions} from '../../utils/HelperFunctions.class';
import {ConnectHelper} from '../../connect/connectHelper';
import {DivHelpContent} from '../../utils/entities/adminTool/div-help-content';
declare var UIkit;
@Component({
selector: 'class-content-form',
templateUrl: './class-help-content-form.component.html',
})
export class ClassContentFormComponent implements OnInit {
myForm: FormGroup;
portal: string;
pageId: string;
pageContentId: string;
page: Page;
classOptions = [];
public properties: EnvProperties = null;
public showLoading: boolean = true;
public errorMessage: string = '';
@Input() updateErrorMessage: string = '';
private subs: Subscription[] = [];
public pageHelpContent: DivHelpContent;
constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService) {
}
ngOnInit() {
this.properties = properties;
this.subs.push(this.route.params.subscribe(params => {
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
ConnectHelper.setPortalTypeFromPid(this.portal);
this.subs.push(this.route.queryParams.subscribe(params => {
HelperFunctions.scroll();
this.pageId = params['pageId'];
this.myForm = this.form;
this.pageContentId = params['pageContentId'];
if (!this.pageId) {
this._router.navigate(['../'], {relativeTo: this.route});
}
this.getInfo(this.pageId);
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
}));
}));
}
ngOnDestroy() {
this.subs.forEach(value => {
if (value instanceof Subscriber) {
value.unsubscribe();
}
});
}
getInfo(pageId: string) {
this.showLoading = true;
let obs = Observable.zip(this._helpContentService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.portal),
this._helpContentService.getDivIdsFullByPortal(pageId, this.properties.adminToolsAPIURL, this.portal));
this.subs.push(obs.subscribe(
results => {
this.page = results[0];
if (this.properties.adminToolsPortalType != this.page.portalType) {
this._router.navigate(['../'], {relativeTo: this.route});
}
this.setOptions(results[1]);
if (!this.pageContentId) {
this.updateForm(null);
this.showLoading = false;
} else {
this.subs.push(this._helpContentService.getDivHelpContent( this.pageContentId, this.properties.adminToolsAPIURL, this.portal).subscribe(pageHelpContent=>{
this.pageHelpContent = pageHelpContent;
if (this.properties.adminToolsPortalType != this.page.portalType) {
this._router.navigate(['../'], {relativeTo: this.route});
}
this.updateForm(this.pageHelpContent);
this.showLoading = false;
},
error => {
this.handleError('System error retrieving content by id '+ this.pageContentId, error)
}));
}
}));
}
private updateForm(pageHelpContent: DivHelpContent) {
this.pageHelpContent = pageHelpContent;
this.myForm = this.form;
if (this.pageHelpContent) {
this.myForm.patchValue((pageHelpContent));
this.myForm.get('divId').disable();
}
this.myForm.markAsPristine();
}
public setOptions(divIds) {
this.classOptions = [];
for(let divid of divIds){
this.classOptions.push({label:divid.name, value:divid._id});
}
}
public get form() {
return this._fb.group({
divId: ['', Validators.required],
content: ['', Validators.required],
isActive: true,
portal: this.portal,
_id : '',
});
}
public reset() {
this.myForm.patchValue({
divId: ['', Validators.required],
content: ['', Validators.required],
isActive: true,
portal: '',
_id : '',
});
this.myForm.markAsPristine();
}
handleError(message: string, error) {
this.errorMessage = message;
console.error('Server responded: ' + error);
this.showLoading = false;
}
public saveCustom() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
if (this.myForm.valid) {
this.showLoading = true;
this.updateErrorMessage = "";
this.myForm.get('divId').enable();
let pageHelpContent: DivHelpContent = this.myForm.value;
this.subs.push(this._helpContentService.insertOrUpdateDivHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.portal).subscribe(
_ => {
this._router.navigate(['../'], {queryParams: {"pageId": this.pageId}, relativeTo: this.route});
UIkit.notification('Page content has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.showLoading = false;
},
err => this.handleUpdateError('System error saving page content', err)
));
} else {
this.showLoading = false;
this.errorMessage = "Please fill all required fields";
}
}
}
public resetCustom() {
this.showLoading = true;
this.updateForm(this.pageHelpContent);
this.showLoading = false;
}
handleUpdateError(message: string, error) {
this.updateErrorMessage = message;
console.error('Server responded: ' + error);
this.showLoading = false;
}
changeStatus() {
this.myForm.get('isActive').setValue(!this.myForm.get('isActive').value);
if (this.pageHelpContent && this.myForm.get('isActive').value != this.pageHelpContent.isActive || !this.pageHelpContent && !this.myForm.get('isActive').value) {
this.myForm.get('isActive').markAsDirty();
} else {
this.myForm.get('isActive').markAsPristine()
}
}
contentChanged() {
if (this.pageHelpContent && this.myForm.get('content').value != this.pageHelpContent.content || !this.pageHelpContent && this.myForm.get('content').value != '') {
this.myForm.get('content').markAsDirty();
} else {
this.myForm.get('content').markAsPristine()
}
}
}

View File

@ -0,0 +1,34 @@
import {NgModule} from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {AlertModalModule} from '../../utils/modal/alertModal.module';
import {SafeHtmlPipeModule} from '../../utils/pipes/safeHTMLPipe.module';
import {CKEditorModule} from 'ng2-ckeditor';
import {AdminToolServiceModule} from '../../services/adminToolService.module';
import {InputModule} from '../../sharedComponents/input/input.module';
import {MatSlideToggleModule} from '@angular/material';
import {IconsModule} from '../../utils/icons/icons.module';
import {RouterModule} from '@angular/router';
import {LoadingModule} from '../../utils/loading/loading.module';
import {IconsService} from '../../utils/icons/icons.service';
import {arrow_left} from '../../utils/icons/icons';
import {ClassContentFormComponent} from './class-help-content-form.component';
import {ClassHelpContentFormRoutingModule} from './class-help-content-form-routing.module';
import {PageContentModule} from '../sharedComponents/page-content/page-content.module';
@NgModule({
imports: [
CommonModule, FormsModule, RouterModule,
SafeHtmlPipeModule, CKEditorModule,
AlertModalModule, ReactiveFormsModule, ClassHelpContentFormRoutingModule, AdminToolServiceModule, InputModule, MatSlideToggleModule, IconsModule, LoadingModule, PageContentModule
],
declarations: [
ClassContentFormComponent
],
exports: [ClassContentFormComponent]
})
export class ClassHelpContentFormModule {
constructor(private iconsService: IconsService) {
this.iconsService.registerIcons([arrow_left]);
}
}

View File

@ -0,0 +1,12 @@
import { NgModule } from '@angular/core';
import {RouterModule} from '@angular/router';
import {ClassHelpContentsComponent} from './class-help-contents.component';
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: ClassHelpContentsComponent}
])
]
})
export class ClassHelpContentsRoutingModule { }

View File

@ -0,0 +1,143 @@
<div page-content>
<div header>
<div *ngIf="updateErrorMessage" class="uk-alert-danger" uk-alert>
<a class="uk-alert-close" uk-close></a>
{{updateErrorMessage}}
</div>
<div class="uk-text-bold">
<span *ngIf="selectedPageId && page">{{page.name}}</span>
</div>
<div class="uk-margin-top">
<a routerLink="../pages/" class="uk-text-secondary uk-text-uppercase uk-text-bold uk-text-small">
<span class="uk-icon-button small uk-icon uk-button-secondary">
<icon name="arrow_left"></icon>
</span>
<span class="space">
Back to pages list
</span>
</a>
</div>
<div class="uk-width-1-1 uk-flex uk-flex-right@m uk-flex-center uk-flex-wrap uk-flex-middle uk-grid" uk-grid>
<div #searchInputComponent search-input [control]="filterForm" [showSearch]="false" placeholder="Search helptext"
[selected]="selectedKeyword" (closeEmitter)="onSearchClose()" (resetEmitter)="reset()"
[bordered]="true" colorClass="uk-text-secondary" class="uk-width-1-3@xl uk-width-2-5@l uk-width-1-2@m uk-width-1-1"></div>
<div>
<a (click)="newPageContent()"
class="uk-flex uk-flex-middle uk-text-uppercase">
<button class="large uk-icon-button uk-button-secondary">
<icon name="add"></icon>
</button>
<button class="uk-button uk-button-link uk-margin-small-left uk-text-secondary">Add new class content</button>
</a>
</div>
</div>
<div *ngIf="checkboxes.length > 0"
class="uk-padding uk-padding-remove-bottom uk-padding-remove-top uk-margin-remove-top uk-margin-small-bottom"
[attr.uk-tooltip]="getSelectedPageHelpContents().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
title="Select at least one help text"><input id="checkAll" type="checkbox" (click)="selectAll()"
[ngModel]="getSelectedPageHelpContents().length ==checkboxes.length"/>
<span *ngIf="getSelectedPageHelpContents().length > 0" class="uk-margin-left uk-text-muted">
{{getSelectedPageHelpContents().length}} pages selected </span>
<a class="uk-margin-left ">Actions </a>
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-dropdown-nav"
[attr.uk-tooltip]="getSelectedPageHelpContents().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
title="Select at least one help text">
<li><a [class]="getSelectedPageHelpContents().length == 0 ? 'uk-disabled' : ''"
(click)="togglePageHelpContents(true,getSelectedPageHelpContents())"><i></i> Enable
</a></li>
<li><a [class]="getSelectedPageHelpContents().length == 0 ? 'uk-disabled' : ''"
(click)="togglePageHelpContents(false,getSelectedPageHelpContents())"><i></i> Disable
</a>
</li>
<li><a [class]="getSelectedPageHelpContents().length == 0 ? 'uk-disabled' : ''"
(click)="confirmDeleteSelectedPageHelpContents()"><i></i> Delete </a></li>
</ul>
</div>
</div>
</div>
<div inner>
<div class="content-wrapper" id="contentWrapper">
<div>
<div class="contentPanel">
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger uk-margin-large-top"
role="alert">{{errorMessage}}</div>
<div *ngIf="showLoading" class="uk-position-center">
<loading *ngIf="showLoading"></loading>
</div>
<div *ngIf="!errorMessage && !showLoading">
<div class="md-card uk-margin-medium-bottom" *ngIf="!errorMessage && !showLoading">
<div class="md-card-content">
<div class="uk-overflow-container">
<div class="uk-overflow-container">
<ul class="uk-list pages">
<li *ngFor="let check of checkboxes; let i=index" class="uk-card uk-card-default uk-margin-bottom">
<div class="uk-grid uk-grid-divider uk-padding" uk-grid>
<div class="uk-width-4-5 uk-first-column ">
<div class="uk-grid uk-flex uk-flex-middle">
<div><input id="{{check.divHelpContent._id}}" class="checkBox" type="checkbox"
name="entitiescb[]" value="{{check.divHelpContent._id}}" [(ngModel)]="check.checked">
</div>
<div class="uk-width-expand uk-margin-medium-bottom">
<div class="content multi-line-ellipsis lines-2">
<p>{{check.divHelpContent.content|htmlToString}}</p></div>
</div>
<div class="uk-grid uk-width-1-1 uk-margin-left">
<div class=" ">
<span class="title">Class: </span>{{check.divHelpContent.divId.name?check.divHelpContent.divId.name:check.divHelpContent.divId}}
</div>
<div class=" ">
<span class="title uk-margin-small-right">Enable/disable: </span>
<mat-slide-toggle [checked]="check.divHelpContent.isActive"
(change)="($event.source.checked = check.divHelpContent.isActive);togglePageHelpContents(!check.divHelpContent.isActive,[check.divHelpContent._id])"
uk-tooltip="title:<div class='uk-padding-small uk-width-large'><div class='uk-text-bold '> Enable or disable help text to show or hide it from the dashboard</div></div>"
></mat-slide-toggle>
</div>
</div>
</div>
</div>
<div class="uk-width-1-5 uk-first-column">
<div class=" uk-flex-center uk-flex">
<div class="actions" href="#">
<div class="" (click)="editPageHelpContent(check.divHelpContent._id)" class="uk-button action uk-margin-top uk-flex uk-flex-middle ">
<i class="clickable" uk-icon="pencil"
></i>
<span class="uk-margin-small-left">
Edit
</span>
</div>
<div (click)="confirmDeletePageHelpContent(check.divHelpContent._id)" class="uk-button action uk-margin-top uk-flex uk-flex-middle ">
<i class="clickable " uk-icon="trash"
></i>
<span class="uk-margin-small-left">
Delete
</span>
</div>
</div>
</div>
</div>
</div>
</li>
</ul>
</div>
<div *ngIf="checkboxes.length==0" class="col-md-12">
<div class="uk-alert-warning" uk-alert>No page contents found</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<modal-alert #AlertModalDeletePageHelpContents (alertOutput)="confirmedDeletePageHelpContents($event)"></modal-alert>

View File

@ -0,0 +1,364 @@
import {Component, ViewChild, OnInit, ElementRef} from '@angular/core';
import {FormBuilder, FormControl, FormGroup} from "@angular/forms";
import {ActivatedRoute, Router} from "@angular/router";
import {HelpContentService} from "../../services/help-content.service";
import {PageHelpContentFilterOptions} from '../../utils/entities/adminTool/page-help-content';
import {Page} from "../../utils/entities/adminTool/page";
import {Portal} from "../../utils/entities/adminTool/portal";
import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {Subscriber} from "rxjs";
import {properties} from "../../../../environments/environment";
import {DomSanitizer} from '@angular/platform-browser';
import {SearchInputComponent} from '../../sharedComponents/search-input/search-input.component';
import {ConnectHelper} from '../../connect/connectHelper';
import {CheckDivHelpContent, DivHelpContent} from '../../utils/entities/adminTool/div-help-content';
declare var UIkit;
@Component({
selector: 'class-help-contents',
templateUrl: './class-help-contents.component.html',
})
export class ClassHelpContentsComponent implements OnInit {
@ViewChild('AlertModalDeletePageHelpContents') alertModalDeletePageHelpContents;
private selectedPageContents: string[] = [];
public checkboxes: CheckDivHelpContent[] = [];
public pageHelpContents: DivHelpContent[] = [];
public formGroup: FormGroup;
public pages: Page[];
public checkboxAll: boolean = false;
public filters: PageHelpContentFilterOptions = {id: '', active: null, text: new RegExp('')};
public keyword: string = "";
public counter = {all: 0, active: 0, inactive: 0};
public communities: Portal[] = [];
public portal: string;
public selectedPageId: string;
public community: Portal;
public page: Page;
public properties: EnvProperties = null;
public showLoading: boolean = true;
public errorMessage: string = '';
public updateErrorMessage: string = '';
public filterForm: FormControl;
public selectForm: FormControl;
private subscriptions: any[] = [];
public selectedKeyword: string;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
ngOnInit() {
this.filterForm = this._fb.control('');
this.selectForm = this._fb.control('');
this.subscriptions.push(this.filterForm.valueChanges.subscribe(value => {
this.filterBySearch(value);
}));
this.subscriptions.push(this.selectForm.valueChanges.subscribe(value => {
this.filterByPage(value);
}));
this.properties = properties;
this.subscriptions.push(this.route.params.subscribe(params => {
this.portal = (this.route.snapshot.data.portal) ? this.route.snapshot.data.portal : this.route.snapshot.params[this.route.snapshot.data.param];
ConnectHelper.setPortalTypeFromPid(this.portal);
this.subscriptions.push(this.route.queryParams.subscribe(params => {
HelperFunctions.scroll();
this.selectedPageId = params['pageId'];
if (this.portal && this.selectedPageId) {
this.getPage(this.selectedPageId);
}
if(!this.selectedPageId) {
this.router.navigate(['../pages'], {relativeTo: this.route });
}
}));
}));
}
constructor(private element: ElementRef, private route: ActivatedRoute, private router: Router, private _helpService: HelpContentService, private _fb: FormBuilder, private sanitizer: DomSanitizer) {
}
ngOnDestroy(): void {
this.subscriptions.forEach(value => {
if (value instanceof Subscriber) {
value.unsubscribe();
} else if (value instanceof Function) {
value();
}
});
}
init(){
}
getPage(pageId: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.showLoading = true;
this.updateErrorMessage = "";
this.errorMessage = "";
this.subscriptions.push(this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.portal).subscribe(
page => {
if (this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['./pageContents'], {queryParams: {"communityId": this.portal}});
} else {
this.page = page;
this.getPageHelpContents(this.portal);
}
},
error => this.handleError('System error retrieving page', error)));
}
}
public countPageHelpContents() {
this.counter = {all: 0, active: 0, inactive: 0};
let filter = Object.assign({}, this.filters);
filter.active = null;
this.pageHelpContents.forEach(_ => {
if (this.filterPageHelpContent(_, filter)) {
if (_.isActive == true) this.counter.active++;
else this.counter.inactive++
}
});
this.counter.all = this.counter.active + this.counter.inactive;
}
getPageHelpContents(community_pid: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.subscriptions.push(this._helpService.getCommunityDivHelpContents(community_pid, this.properties.adminToolsAPIURL, this.selectedPageId).subscribe(
pageHelpContents => {
this.pageHelpContents = pageHelpContents as Array<DivHelpContent>;
this.counter.all = this.pageHelpContents.length;
this.checkboxes = [];
for (let i = this.pageHelpContents.length - 1; i >= 0; i -= 1) {
this.checkboxes.unshift(<CheckDivHelpContent>{divHelpContent: this.pageHelpContents[i], checked: false});
}
this.countPageHelpContents();
this.showLoading = false;
},
error => this.handleError('System error retrieving page contents', error)));
}
}
public toggleCheckBoxes(event) {
this.checkboxes.forEach(_ => _.checked = event.target.checked);
this.checkboxAll = event.target.checked;
}
public applyCheck(flag: boolean) {
this.checkboxes.forEach(_ => _.checked = flag);
this.checkboxAll = false;
}
public getSelectedPageHelpContents(): string[] {
return this.checkboxes.filter(pageHelpContent => pageHelpContent.checked == true)
.map(checkedPageHelpContent => checkedPageHelpContent.divHelpContent).map(res => res._id);
}
public confirmDeletePageHelpContent(id: string) {
this.selectedPageContents = [id];
this.confirmModalOpen();
}
public confirmDeleteSelectedPageHelpContents() {
this.selectedPageContents = this.getSelectedPageHelpContents();
this.confirmModalOpen();
}
private confirmModalOpen() {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.alertModalDeletePageHelpContents.cancelButton = true;
this.alertModalDeletePageHelpContents.okButton = true;
this.alertModalDeletePageHelpContents.alertTitle = "Delete Confirmation";
this.alertModalDeletePageHelpContents.message = "Are you sure you want to delete the selected page content(s)?";
this.alertModalDeletePageHelpContents.okButtonText = "Yes";
this.alertModalDeletePageHelpContents.open();
}
}
public confirmedDeletePageHelpContents(data: any) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.showLoading = true;
this.updateErrorMessage = "";
this.subscriptions.push(this._helpService.deleteDivHelpContents(this.selectedPageContents, this.properties.adminToolsAPIURL, this.portal).subscribe(
_ => {
this.deletePageHelpContentsFromArray(this.selectedPageContents);
UIkit.notification('Page content(s) has been <b>successfully deleted</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected page content(s)', error)
));
}
}
private deletePageHelpContentsFromArray(ids: string[]): void {
for (let id of ids) {
let iqc = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
let iq = this.pageHelpContents.findIndex(_ => _._id == id);
this.checkboxes.splice(iqc, 1);
this.pageHelpContents.splice(iqc, 1);
}
this.countPageHelpContents();
}
public editPageHelpContent(id: string) {
if (this.selectedPageId) {
this.router.navigate(['edit/'], {
queryParams: {
"pageContentId": id,
"pageId": this.selectedPageId
}, relativeTo: this.route
});
} else {
this.router.navigate(['edit/'], {
queryParams: {
"pageContentId": id,
}, relativeTo: this.route
});
}
}
public togglePageHelpContents(status: boolean, ids: string[]) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.updateErrorMessage = "";
this.subscriptions.push(this._helpService.toggleDivHelpContents(ids, status, this.properties.adminToolsAPIURL, this.portal).subscribe(
() => {
for (let id of ids) {
let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
this.checkboxes[i].divHelpContent.isActive = status;
}
this.countPageHelpContents();
this.applyCheck(false);
UIkit.notification('Page content(s) has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error changing the status of the selected page content(s)', error)
));
}
}
public filterPageHelpContent(pageHelpContent: DivHelpContent, filters: PageHelpContentFilterOptions): boolean {
let activeFlag = filters.active == null || pageHelpContent.isActive == filters.active;
let textFlag = filters.text.toString() == '' || (pageHelpContent.content).match(filters.text) != null;
return activeFlag && textFlag;
}
public applyFilter() {
this.checkboxes = [];
this.pageHelpContents.filter(item => this.filterPageHelpContent(item, this.filters)).forEach(
_ => {
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent: _, checked: false})
}
);
}
public filterByPage(event: any) {
if(event.target && event.target.value) {
this.filters.id = event.target.value;
this.applyFilter();
}
}
public filterBySearch(text: string) {
this.filters.text = new RegExp(text, "i");
this.applyFilter();
}
handleError(message: string, error) {
this.errorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
handleUpdateError(message: string, error) {
this.updateErrorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
public newPageContent() {
this.router.navigate(['edit'], {
queryParams: {
pageId: this.selectedPageId
}, relativeTo: this.route
});
}
public onSearchClose() {
this.selectedKeyword = this.filterForm.value;
}
public reset() {
this.selectedKeyword = null;
this.searchInputComponent.reset()
}
selectAll(){
let checked = !!(this.getSelectedPageHelpContents().length != this.checkboxes.length);
for (let check of this.checkboxes) {
check.checked = checked;
}
}
}

View File

@ -0,0 +1,38 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {CommonModule} from '@angular/common';
import {IsCommunity} from '../../connect/communityGuard/isCommunity.guard';
import {ConnectAdminLoginGuard} from '../../connect/communityGuard/connectAdminLoginGuard.guard';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {AlertModalModule} from '../../utils/modal/alertModal.module';
import {SafeHtmlPipeModule} from '../../utils/pipes/safeHTMLPipe.module';
import {MatSlideToggleModule} from '@angular/material';
import {AdminToolServiceModule} from '../../services/adminToolService.module';
import {InputModule} from '../../sharedComponents/input/input.module';
import {SearchInputModule} from '../../sharedComponents/search-input/search-input.module';
import {IconsModule} from '../../utils/icons/icons.module';
import {IconsService} from '../../utils/icons/icons.service';
import {add, arrow_left} from '../../utils/icons/icons';
import {LoadingModule} from '../../utils/loading/loading.module';
import {HTMLToStringPipeModule} from '../../utils/pipes/HTMLToStringPipe.module';
import {ClassHelpContentsRoutingModule} from './class-help-contents-routing.module';
import {ClassHelpContentsComponent} from './class-help-contents.component';
import {PageContentModule} from '../sharedComponents/page-content/page-content.module';
@NgModule({
imports: [
CommonModule, RouterModule, FormsModule, SafeHtmlPipeModule,
AlertModalModule, ReactiveFormsModule, MatSlideToggleModule, AdminToolServiceModule, InputModule, ClassHelpContentsRoutingModule,
SearchInputModule, IconsModule, LoadingModule, HTMLToStringPipeModule, PageContentModule
],
declarations: [
ClassHelpContentsComponent
],
providers: [IsCommunity, ConnectAdminLoginGuard],
exports: [ClassHelpContentsComponent]
})
export class ClassHelpContentsModule {
constructor(private iconsService: IconsService) {
this.iconsService.registerIcons([add, arrow_left])
}
}

View File

@ -1,56 +0,0 @@
<div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div>
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-width-1-1" role="alert"><img class="uk-align-center loading-gif"></div>
<div class="uk-alert uk-alert-primary uk-margin-top-large">
<span class="uk-margin-small-right uk-icon" uk-icon="info"></span>
Create or edit help text
<div class="uk-text-small">
Select the class to be displayed, add the content and click active to make it visible to dashboard
</div>
</div>
<form *ngIf="!errorMessage && !showLoading" [formGroup]="myForm">
<div class="form-group">
<div class="uk-margin-bottom" *ngIf="selectedDiv">Class content displayed in page(s): <span *ngFor="let page of selectedDiv.pages let i=index">{{page.name}}<span *ngIf="i<(selectedDiv.pages.length-1)">, </span></span></div>
<div *ngIf="showPageSelect && !editMode" class="form-group">
<label for="pageTag">Select Page</label>
<select id="pageTag" (change)="pageSelected($event)" [value]="pageId ? pageId : ''">
<!-- <option *ngIf="!pageId">No page selected</option>-->
<option *ngFor="let page of availablePages" [value]="page._id">{{page.name}}</option>
</select>
</div>
<div *ngIf="pageId || selectedDiv" class="form-group">
<label for="divTag">Select Class</label>
<select formControlName="divId" id="divTag" class="form-control">
<!-- <option *ngIf="selectedDiv" [value]="selectedDiv._id">{{selectedDiv.name}}</option> -->
<option *ngFor="let div of availableDivs" [value]="div._id" (click)="divIdSelected(div)">{{div.name}}</option>
</select>
</div>
</div>
<div class="form-group" [ngClass]="{'has-error':!myForm.controls.content.valid && myForm.controls.content.dirty}">
<label>Content</label>
<div>
<!-- [config]="{allowedContent: true,extraAllowedContent : '*(*)'}"> -->
<ckeditor
[readonly]="false"
debounce="500"
formControlName="content"
[config]="{ extraAllowedContent: '* [uk-*](*) ; span', disallowedContent: 'script; *[on*]', removeButtons: 'Save,NewPage,DocProps,Preview,Print',
extraPlugins: 'divarea'}">
</ckeditor>
</div>
</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>
<input type="hidden" formControlName="_id">
</form>
<!-- <div *ngIf="selectedDiv"><span *ngFor="let page of selectedDiv.pages">{{page.name}} </span></div> -->

View File

@ -1,161 +0,0 @@
import { Component, OnInit, Input } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router";
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
import { Page } from "../../utils/entities/adminTool/page";
import { DivId } from "../../utils/entities/adminTool/divId";
import { HelpContentService } from "../../services/help-content.service";
import { EnvProperties } from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
@Component({
selector: 'div-content-form',
templateUrl: './div-help-content-form.component.html',
})
export class DivContentFormComponent implements OnInit{
@Input('group')
myForm: FormGroup;
@Input('communityPid')
communityPid: string;
@Input('pageId')
pageId: string;
@Input('editMode')
editMode: boolean = false;
//public divIdName: string = '';
private communityId: string = '';
showPageSelect: boolean = true;
selectedDiv: DivId;
private availablePages : Page[] = [];
private availableDivs : DivId[] = [];
private ckeditorContent : string;
public properties:EnvProperties = null;
public showLoading: boolean = true;
public errorMessage: string = '';
@Input() updateErrorMessage: string = '';
constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService){}
ngOnInit() {
this.myForm = this.form;
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
if(this.pageId) {
this.showPageSelect = false;
this.getDivs(this.pageId);
} else {
if(!this.editMode) {
this._helpContentService.getCommunityPagesWithDivId(this.communityPid, this.properties.adminToolsAPIURL).subscribe(
pages => {
this.availablePages = pages;
this.showLoading = false;
},
error => this.handleError('System error retrieving pages', error));
}
}
this.getCommunity(this.communityPid);
}
});
});
}
public pageSelected(event) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
this.getDivs(event.target.value);
}
}
public divIdSelected(div: DivId) {
this.selectedDiv = div;
}
public getCommunity(communityPid: string) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
this.showLoading = true;
this.errorMessage = '';
this._helpContentService.getCommunity(this.communityPid, this.properties.adminToolsAPIURL).subscribe(
community => {
this.communityId = community._id;
this.myForm.patchValue({
community: this.communityId
});
this.showLoading = false;
},
error => this.handleError('System error retrieving community', error)
);
}
}
public getDivs(pageId: string) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
//this.showLoading = true;
this.errorMessage = '';
this._helpContentService.getDivIdsFullByPortal(pageId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
divs => {
this.availableDivs = divs;
this.pageId = pageId;
this.showLoading = false;
},
error => this.handleError('System error retrieving pages', error));
}
}
// public selectedDiv(event) {
// console.info(event.target.value);
// }
public get form() {
return this._fb.group({
divId: ['', Validators.required],
content: ['', Validators.required],
isActive: true,
portal: '',
_id : '',
});
}
public reset() {
this.myForm.patchValue({
divId: '',
content: '',
isActive: true,
portal: '',
_id : ''
});
this.myForm.markAsPristine();
}
handleError(message: string, error) {
this.errorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
}

View File

@ -1,20 +0,0 @@
import { NgModule } from '@angular/core';
import {CommonModule} from '@angular/common';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {AlertModalModule} from '../../utils/modal/alertModal.module';
import {SafeHtmlPipeModule} from '../../utils/pipes/safeHTMLPipe.module';
import {DivContentFormComponent} from './div-help-content-form.component';
import {CKEditorModule} from 'ng2-ckeditor';
@NgModule({
imports: [
CommonModule, FormsModule,
SafeHtmlPipeModule, CKEditorModule,
AlertModalModule, ReactiveFormsModule
],
declarations: [
DivContentFormComponent
],
exports: [DivContentFormComponent]
})
export class DivHelpContentFormModule { }

View File

@ -1,12 +0,0 @@
import { NgModule } from '@angular/core';
import {RouterModule} from '@angular/router';
import {DivHelpContentsComponent} from "./div-help-contents.component";
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: DivHelpContentsComponent}
])
]
})
export class DivHelpContentsRoutingModule { }

View File

@ -1,152 +0,0 @@
<div id="page_content" click-outside-or-esc targetId="page_content">
<div class="uk-padding-small md-bg-white" uk-grid>
<div *ngIf="!selectedPageId" class="filters marginBottom20">
<div dashboard-input label="Filter by page" [formInput]="selectForm" type="select"
[options]="selectOptions"></div>
</div>
<div class="uk-width-expand@m uk-width-1-1 uk-flex uk-flex-middle uk-flex-right">
<div class="uk-inline uk-width-medium">
<span class="uk-position-center-right"><i class="material-icons">search</i></span>
<div dashboard-input [formInput]="filterForm" label="Find class"></div>
</div>
</div>
</div>
<div id="page_content_inner">
<div class="menubar ">
<div *ngIf="!errorMessage && !showLoading" class="page-controls">
<div class=" filters ">
<div class="show-options uk-float-right">
<button class="uk-button uk-button-primary" type="button">Bulk Actions</button>
<div uk-dropdown="mode: click">
<ul class="uk-nav uk-margin-left"
[attr.uk-tooltip]="getSelectedDivHelpContents().length == 0 ? 'pos:left; cls: uk-active' : 'cls: uk-invisible'"
title="Select at least one help text">
<li><a [class]="getSelectedDivHelpContents().length == 0 ? 'uk-disabled' : ''"
(click)="toggleDivHelpContents(true,getSelectedDivHelpContents())"><i></i> Activate </a></li>
<li><a [class]="getSelectedDivHelpContents().length == 0 ? 'uk-disabled' : ''"
(click)="toggleDivHelpContents(false,getSelectedDivHelpContents())"><i></i> Deactivate </a></li>
<li><a [class]="getSelectedDivHelpContents().length == 0 ? 'uk-disabled' : ''"
(click)="confirmDeleteSelectedDivHelpContents()"><i></i> Delete </a></li>
</ul>
</div>
</div>
</div>
</div>
<h4 class="uk-text-bold">
<span *ngIf="!selectedPageId" >Class help texts</span>
<span *ngIf="selectedPageId && page">Class help texts of page '{{page.name}}'
</span>
</h4>
<div *ngIf="updateErrorMessage" class="uk-alert-danger" uk-alert>
<a class="uk-alert-close" uk-close></a>
{{updateErrorMessage}}
</div>
</div>
<div class="content-wrapper" id="contentWrapper">
<div class="contentPanel">
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger uk-margin-large-top"
role="alert">{{errorMessage}}</div>
<div [style.display]="showLoading ? 'inline' : 'none'"
class="uk-animation-fade uk-margin-large-top uk-width-1-1" role="alert"><img
class="uk-align-center loading-gif"></div>
<div *ngIf="!errorMessage && !showLoading">
<div class="uk-alert uk-alert-primary uk-margin-top-large">
<span class="uk-margin-small-right uk-icon" uk-icon="info"></span>
Enable or disable help text to show or hide it from the dashboard
</div>
<ul uk-tab class="links">
<li [ngClass]="{'uk-active' : filters.active==null}" (click)="displayAllDivHelpContents()">
<a>All class help texts <span class="uk-badge">{{counter.all | number}}</span></a>
</li>
<li [ngClass]="{'uk-active' : filters.active==true}" (click)="displayActiveDivHelpContents()">
<a>Active <span class="uk-badge">{{counter.active | number}}</span></a>
</li>
<li [ngClass]="{'uk-active' : filters.active==false}" (click)="displayInactiveDivHelpContents()">
<a>Inactive <span class="uk-badge">{{counter.inactive | number}}</span></a>
</li>
</ul>
<div class="md-card uk-margin-medium-bottom" *ngIf="!errorMessage && !showLoading">
<div class="md-card-content">
<div class="uk-overflow-container">
<table class="uk-table uk-table-striped">
<thead>
<tr>
<th><input id="allDivHelpContentsCheckbox" type="checkbox"
(change)="toggleCheckBoxes($event)"></th>
<th *ngIf="!selectedPageId">Page</th>
<!--th *ngIf="!selectedPageId">Community</th-->
<th>Class</th>
<th>Content</th>
<th>Change status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let check of checkboxes; let i=index">
<td><input id="{{check.divHelpContent._id}}" class="checkBox" type="checkbox"
name="entitiescb[]" value="{{check.divHelpContent._id}}"
[(ngModel)]="check.checked">
</td>
<td *ngIf="!selectedPageId">
<!-- <div class="page" href="#">{{check.divHelpContent.divId.page.name}}</div> -->
<div class="pages" href="#">
<span *ngFor="let page of check.divHelpContent.divId.pages let i=index">{{page.name}}<span
*ngIf="i<(check.divHelpContent.divId.pages.length-1)">, </span></span>
</div>
</td>
<!--td *ngIf="!selectedPageId">
<div class="community" href="#">{{check.divHelpContent.community.name}}</div>
</td-->
<td>
<div class="divId" href="#">{{check.divHelpContent.divId.name}}</div>
</td>
<td>
<!-- <div class="content" [innerHTML]="check.divHelpContent.content | safeHtml"></div>-->
<div class="content">{{check.divHelpContent.content}}</div>
</td>
<td>
<mat-slide-toggle [checked]="check.divHelpContent.isActive"
(change)="($event.source.checked = check.divHelpContent.isActive);toggleDivHelpContents(!check.divHelpContent.isActive,[check.divHelpContent._id])"></mat-slide-toggle>
</td>
<td>
<div class="actions" href="#">
<i class="clickable" uk-icon="pencil"
(click)="editDivHelpContent(check.divHelpContent._id)"></i>
<i class="clickable uk-text-danger" uk-icon="trash"
(click)="confirmDeleteDivHelpContent(check.divHelpContent._id)"></i>
</div>
</td>
</tr>
</tbody>
</table>
<div class="uk-width-1-1 uk-flex uk-flex-center ">
<div class="uk-width-small uk-flex uk-flex-center uk-button uk-button-default" (click)="newClassContent()">
<i class="" uk-icon="plus"></i>
</div>
</div>
<div *ngIf="checkboxes.length==0" class="col-md-12">
<div class="uk-alert-warning" uk-alert>No class help texts found</div>
</div>
</div>
</div>
</div>
<a *ngIf="selectedPageId && page" [queryParams]="{type: page.type, communityId: selectedCommunityPid}"
routerLink="../../pages">Go back to {{page.type}} pages</a>
</div>
</div>
</div>
</div>
</div>
<modal-alert #AlertModalDeleteDivHelpContents (alertOutput)="confirmedDeleteDivHelpContents($event)"></modal-alert>

View File

@ -1,436 +0,0 @@
import {Component, ViewChild, OnInit, ElementRef} from '@angular/core';
import {Router, ActivatedRoute} from "@angular/router";
import {FormBuilder, FormControl, FormGroup} from "@angular/forms";
import {HelpContentService} from "../../services/help-content.service";
import {
DivHelpContent,
CheckDivHelpContent,
DivHelpContentFilterOptions
} from "../../utils/entities/adminTool/div-help-content";
import {Page} from "../../utils/entities/adminTool/page";
import {Portal} from "../../utils/entities/adminTool/portal";
import {DivId} from "../../utils/entities/adminTool/divId";
import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {Subscriber} from "rxjs";
import {properties} from "../../../../environments/environment";
import {StringUtils} from '../../utils/string-utils.class';
@Component({
selector: 'div-help-contents',
templateUrl: './div-help-contents.component.html',
})
export class DivHelpContentsComponent implements OnInit {
// @ViewChild('deleteConfirmationModal')
// public deleteConfirmationModal : DeleteConfirmationDialogComponent;
@ViewChild('AlertModalDeleteDivHelpContents') alertModalDeleteDivHelpContents;
private selectedDivContents: string[] = [];
public checkboxes: CheckDivHelpContent[] = [];
public divHelpContents: DivHelpContent[] = [];
//public errorMessage: string;
public formGroup: FormGroup;
public pages: Page[];
public checkboxAll: boolean = false;
public filters: DivHelpContentFilterOptions = {id: '', active: null, text: new RegExp('')};
public keyword: string = "";
public counter = {all: 0, active: 0, inactive: 0};
public communities: Portal[] = [];
public selectedCommunityPid: string;
public selectedPageId: string;
public community: Portal;
public page: Page;
public properties: EnvProperties = null;
public showLoading: boolean = true;
public errorMessage: string = '';
public updateErrorMessage: string = '';
public filterForm: FormControl;
public selectForm: FormControl;
public selectOptions = [];
private subscriptions: any[] = [];
ngOnInit() {
this.filterForm = this._fb.control('');
this.selectForm = this._fb.control('');
this.subscriptions.push(this.filterForm.valueChanges.subscribe(value => {
this.filterBySearch(value);
}));
this.subscriptions.push(this.selectForm.valueChanges.subscribe(value => {
this.filterByPage(value);
}));
this.properties = properties;
this.subscriptions.push(this.route.queryParams.subscribe(params => {
HelperFunctions.scroll();
this.selectedCommunityPid = params['communityId'];
this.selectedPageId = params['pageId'];
if (this.selectedCommunityPid && this.selectedPageId) {
this.getPage(this.selectedPageId);
} else if (this.selectedCommunityPid) {
this.selectedPageId = "";
this.getPages(this.selectedCommunityPid);
}
}));
}
constructor(private element: ElementRef, private route: ActivatedRoute, private _helpService: HelpContentService, private router: Router, private _fb: FormBuilder) {
}
ngOnDestroy(): void {
this.subscriptions.forEach(value => {
if (value instanceof Subscriber) {
value.unsubscribe();
} else if (value instanceof Function) {
value();
}
});
}
getPage(pageId: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.showLoading = true;
this.updateErrorMessage = "";
this.errorMessage = "";
this._helpService.getPageByPortal(pageId, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
page => {
if (this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['../../classContents'], {queryParams: {"communityId": this.selectedCommunityPid}});
} else {
this.page = page;
this.getDivHelpContents(this.selectedCommunityPid);
}
},
error => this.handleError('System error retrieving page', error));
}
}
getPages(community_pid: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.showLoading = true;
this.updateErrorMessage = "";
this.errorMessage = "";
this._helpService.getCommunityPagesWithDivId(community_pid, this.properties.adminToolsAPIURL).subscribe(
//this._helpService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe(
pages => {
this.pages = pages;
this.getDivHelpContents(this.selectedCommunityPid);
this.selectOptions = [{label:'All pages', value: ''}];
for (let page of this.pages) {
this.selectOptions.push({label:page.name, value: page._id})
}
},
error => this.handleError('System error retrieving pages', error));
}
}
public countDivHelpContents() {
this.counter = {all: 0, active: 0, inactive: 0};
let filter = Object.assign({}, this.filters);
filter.active = null;
this.divHelpContents.forEach(_ => {
if (this.filterDivHelpContent(_, filter)) {
if (_.isActive == true) this.counter.active++;
else this.counter.inactive++
}
});
this.counter.all = this.counter.active + this.counter.inactive;
}
getDivHelpContents(community_pid: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this._helpService.getCommunityDivHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe(
divHelpContents => {
this.divHelpContents = divHelpContents as Array<DivHelpContent>;
this.counter.all = this.divHelpContents.length;
this.checkboxes = [];
for (let i = this.divHelpContents.length - 1; i >= 0; i -= 1) {
//for (let i = 0; i < this.divHelpContents.length; i++) {
let divId: DivId = this.divHelpContents[i].divId as DivId;
let pages: Page[] = divId.pages as Page[];
const pageIds = pages.map(x => x._id);
if (!this.selectedPageId || pageIds.includes(this.selectedPageId)) {
this.cutContent(this.divHelpContents[i]);
this.checkboxes.unshift(<CheckDivHelpContent>{divHelpContent: this.divHelpContents[i], checked: false});
} else {
this.divHelpContents.splice(i, 1);
}
}
this.countDivHelpContents();
this.showLoading = false;
},
error => this.handleError('System error retrieving page contents', error));
}
}
public toggleCheckBoxes(event) {
this.checkboxes.forEach(_ => _.checked = event.target.checked);
this.checkboxAll = event.target.checked;
}
public applyCheck(flag: boolean) {
this.checkboxes.forEach(_ => _.checked = flag);
this.checkboxAll = false;
}
public getSelectedDivHelpContents(): string[] {
return this.checkboxes.filter(divHelpContent => divHelpContent.checked == true)
.map(checkedDivHelpContent => checkedDivHelpContent.divHelpContent).map(res => res._id);
}
public confirmDeleteDivHelpContent(id: string) {
//this.deleteConfirmationModal.ids = [id];
//this.deleteConfirmationModal.showModal();
this.selectedDivContents = [id];
this.confirmModalOpen();
}
public confirmDeleteSelectedDivHelpContents() {
//this.deleteConfirmationModal.ids = this.getSelectedDivHelpContents();
//this.deleteConfirmationModal.showModal();
this.selectedDivContents = this.getSelectedDivHelpContents();
this.confirmModalOpen();
}
private confirmModalOpen() {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.alertModalDeleteDivHelpContents.cancelButton = true;
this.alertModalDeleteDivHelpContents.okButton = true;
this.alertModalDeleteDivHelpContents.alertTitle = "Delete Confirmation";
this.alertModalDeleteDivHelpContents.message = "Are you sure you want to delete the help text(s)?";
this.alertModalDeleteDivHelpContents.okButtonText = "Yes";
this.alertModalDeleteDivHelpContents.open();
}
}
public confirmedDeleteDivHelpContents(data: any) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.showLoading = true;
this.updateErrorMessage = "";
this._helpService.deleteDivHelpContents(this.selectedDivContents, this.properties.adminToolsAPIURL, this.selectedCommunityPid).subscribe(
_ => {
this.deleteDivHelpContentsFromArray(this.selectedDivContents);
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected class content(s)', error)
);
}
}
private deleteDivHelpContentsFromArray(ids: string[]): void {
for (let id of ids) {
let iqc = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
let iq = this.divHelpContents.findIndex(_ => _._id == id);
this.checkboxes.splice(iqc, 1);
this.divHelpContents.splice(iqc, 1);
}
this.countDivHelpContents();
}
public editDivHelpContent(id: string) {
//this.router.navigate(['/pageContents/edit/', _id]);
if (this.selectedPageId) {
this.router.navigate(['../../classContents/edit/'], {
queryParams: {
"classContentId": id,
"communityId": this.selectedCommunityPid,
"pageId": this.selectedPageId
}
});
} else {
this.router.navigate(['../../classContents/edit/'], {
queryParams: {
"classContentId": id,
"communityId": this.selectedCommunityPid
}
});
}
}
public toggleDivHelpContents(status: boolean, ids: string[]) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.updateErrorMessage = "";
this._helpService.toggleDivHelpContents(ids, status, this.properties.adminToolsAPIURL,this.selectedCommunityPid).subscribe(
() => {
for (let id of ids) {
let i = this.checkboxes.findIndex(_ => _.divHelpContent._id == id);
this.checkboxes[i].divHelpContent.isActive = status;
}
this.countDivHelpContents();
this.applyCheck(false);
},
error => this.handleUpdateError('System error changing the status of the selected page content(s)', error)
);
}
}
public divHelpContentSavedSuccessfully(divHelpContent: DivHelpContent) {
this.cutContent(divHelpContent);
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent: divHelpContent, checked: false});
this.divHelpContents.push(divHelpContent);
this.applyCheck(false);
this.countDivHelpContents();
}
public divHelpContentUpdatedSuccessfully(divHelpContent: DivHelpContent) {
this.checkboxes.find(checkItem => checkItem.divHelpContent._id == divHelpContent._id).divHelpContent = divHelpContent;
let index = this.divHelpContents.findIndex(checkItem => checkItem._id == divHelpContent._id);
this.divHelpContents[index] = divHelpContent;
this.applyCheck(false);
this.countDivHelpContents();
}
public filterDivHelpContent(divHelpContent: DivHelpContent, filters: DivHelpContentFilterOptions): boolean {
let divId: DivId = divHelpContent.divId as DivId;
let pages: Page[] = <Page[]>divId.pages;
let pageIds: string[] = pages.map(x => x._id);
let idFlag = filters.id == '' || /*(<Page[]>divId.pages)._id == filters.id*/ pageIds.includes(filters.id);
let activeFlag = filters.active == null || divHelpContent.isActive == filters.active;
let textFlag = filters.text.toString() == '' || (divHelpContent.content).match(filters.text) != null
|| ((<DivId>divHelpContent.divId).name).match(filters.text) != null;
return idFlag && activeFlag && textFlag;
}
public cutContent(divHelpContent: DivHelpContent) {
divHelpContent.content = StringUtils.HTMLToString(divHelpContent.content);
if (divHelpContent.content.length > 200) {
divHelpContent.content = divHelpContent.content.substr(0, 200) + "...";
}
}
public applyFilter() {
this.checkboxes = [];
this.divHelpContents.filter(item => this.filterDivHelpContent(item, this.filters)).forEach(
_ => {
this.cutContent(_);
this.checkboxes.push(<CheckDivHelpContent>{divHelpContent: _, checked: false})
}
);
this.countDivHelpContents();
}
public filterByPage(value: any) {
this.filters.id = value;
this.applyFilter();
}
public displayAllDivHelpContents() {
this.filters.active = null;
this.applyFilter();
}
public displayActiveDivHelpContents() {
this.filters.active = true;
this.applyFilter();
}
public filterBySearch(text: string) {
this.filters.text = new RegExp(text, "i");
this.applyFilter();
}
public displayInactiveDivHelpContents() {
this.filters.active = false;
this.applyFilter();
}
handleError(message: string, error) {
this.errorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
handleUpdateError(message: string, error) {
this.updateErrorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
public newClassContent() {
console.log("AAA")
if (this.selectedPageId) {
this.router.navigate(['../../classContents/new'], {
queryParams: {
communityId: this.selectedCommunityPid,
pageId: this.selectedPageId
}, relativeTo: this.route
});
} else {
this.router.navigate(['../../classContents/new'], {queryParams: {communityId: this.selectedCommunityPid}, relativeTo: this.route});
}
}
}

View File

@ -1,23 +0,0 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {CommonModule} from '@angular/common';
import {FormsModule, ReactiveFormsModule} from '@angular/forms';
import {AlertModalModule} from '../../utils/modal/alertModal.module';
import {SafeHtmlPipeModule} from '../../utils/pipes/safeHTMLPipe.module';
import {DivHelpContentsComponent} from './div-help-contents.component';
import {MatSlideToggleModule} from '@angular/material';
import {AdminToolServiceModule} from "../../services/adminToolService.module";
import {InputModule} from "../../sharedComponents/input/input.module";
import {DivHelpContentsRoutingModule} from "./div-help-contents-routing.module";
@NgModule({
imports: [
CommonModule, RouterModule, FormsModule, SafeHtmlPipeModule,
AlertModalModule, ReactiveFormsModule, MatSlideToggleModule, AdminToolServiceModule, InputModule, DivHelpContentsRoutingModule
],
declarations: [
DivHelpContentsComponent
],
exports: [DivHelpContentsComponent]
})
export class DivHelpContentsModule { }

View File

@ -1,13 +0,0 @@
import { NgModule } from '@angular/core';
import {RouterModule} from '@angular/router';
import {EditDivHelpContentComponent} from "./edit-div-help-content.component";
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: EditDivHelpContentComponent}
])
]
})
export class EditDivHelpContentRoutingModule { }

View File

@ -1,26 +0,0 @@
<div id="page_content_inner">
<div id="editDivHelpContent" class="uk-card uk-card-default uk-padding">
<div class="menubar fixed">
<div class="sidebar-toggler visible-xs">
<i class="ion-navicon"></i>
</div>
<h4 class="uk-text-bold">
<span>Edit Class help text <span *ngIf="page && page.name">of page "{{page.name}}"</span></span>
</h4>
</div>
<div class="content-wrapper">
<div>
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-width-1-1" role="alert"><img
class="uk-align-center loading-gif"></div>
<div-content-form [communityPid]="communityPid" [pageId]="pageId" [editMode]="true"
[updateErrorMessage]="updateErrorMessage"></div-content-form>
<button (click)="saveCustom()" class="uk-button uk-button-primary">Update class help text</button>
<button (click)="cancelCustom()" class="uk-button">Cancel</button>
</div>
</div>
</div>
</div>

View File

@ -1,180 +0,0 @@
import { Component, ViewChild, OnInit, OnDestroy, ElementRef } from '@angular/core';
import { DivContentFormComponent } from "./div-help-content-form.component";
import { Subscription } from "rxjs";
import { HelpContentService } from "../../services/help-content.service";
import { DivHelpContent } from "../../utils/entities/adminTool/div-help-content";
import { ActivatedRoute, Router } from "@angular/router";
import { EnvProperties } from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {Page} from "../../utils/entities/adminTool/page";
@Component({
selector: 'edit-div-help-content',
templateUrl: 'edit-div-help-content.component.html',
})
export class EditDivHelpContentComponent implements OnInit, OnDestroy{
@ViewChild(DivContentFormComponent)
public formComponent : DivContentFormComponent;
public communityPid: string;
public pageId: string;
public page: Page;
private sub: Subscription;
private divHelpContent: DivHelpContent;
public properties:EnvProperties = null;
public showLoading: boolean = true;
public errorMessage: string = '';
public updateErrorMessage: string = '';
constructor(
private element: ElementRef,
private route: ActivatedRoute,
private router: Router,
private _helpContentService: HelpContentService) {}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.sub = this.route.queryParams.subscribe(params => {
HelperFunctions.scroll();
//let id = params['id'];
let divContentId = params['classContentId'];
this.communityPid = params['communityId'];
this.pageId = params['pageId'];
if(!divContentId) {
this.router.navigate(['../../'], { queryParams: { "communityId": this.communityPid} });
}
this.getDivHelpContent(divContentId);
});
});
}
ngOnDestroy() {
this.sub.unsubscribe();
}
handleError(message: string, error) {
this.errorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
handleUpdateError(message: string, error) {
this.updateErrorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
private getPage(pageId: string) {
this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
page => {
if(this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['../../'], { queryParams: { "communityId": this.communityPid} });
} else {
this.page = page;
this.showLoading = false;
}
},
error => this.handleError('System error retrieving page with id: '+pageId, error)
);
}
private getDivHelpContent(divContentId: string) {
if(!Session.isLoggedIn()){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
} else {
this.showLoading = true;
this.errorMessage = "";
this.updateErrorMessage = "";
this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
divHelpContent => {
if(this.pageId) {
this.getPage(this.pageId);
}
this.updateForm(divHelpContent);
this.showLoading = false;
},
error => this.handleError('System error retrieving class help content', error));
}
}
getDivId(divId: string) {
if(!Session.isLoggedIn()){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
} else {
this.showLoading = true;
this._helpContentService.getDivIdFull(divId, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
div => {
this.formComponent.selectedDiv = div;
if(!this.pageId) {
this.formComponent.getDivs("");
}
this.showLoading = false;
},
error => this.handleError('System error retrieving class', error)
);
}
}
private updateForm(divHelpContent : DivHelpContent) {
this.divHelpContent = divHelpContent;
this.getDivId(divHelpContent.divId as string);
this.formComponent.myForm.patchValue((divHelpContent));
}
public saveCustom() {
if(!Session.isLoggedIn()){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
} else {
if(this.formComponent.myForm.valid) {
this.showLoading = true;
this.updateErrorMessage = "";
let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
_ => {
if(this.pageId) {
this.router.navigate( ['../../'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } );
} else {
this.router.navigate(['../../'], { queryParams: { "communityId": this.communityPid } } );
}
this.showLoading = false;
},
err => this.handleUpdateError('System error updating class content', err)
);
} else {
this.errorMessage = "Please fill all required fields";
}
}
}
public cancelCustom() {
this.errorMessage = "";
this.updateErrorMessage = "";
if(this.pageId) {
this.router.navigate( ['../../'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } } );
} else {
this.router.navigate(['../../'], { queryParams: { "communityId": this.communityPid } } );
}
}
}

View File

@ -1,19 +0,0 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {CommonModule} from '@angular/common';
import {EditDivHelpContentComponent} from './edit-div-help-content.component';
import {DivHelpContentFormModule} from './div-help-content-form.module';
import {AdminToolServiceModule} from "../../services/adminToolService.module";
import {EditDivHelpContentRoutingModule} from "./edit-div-help-content-routing.module";
@NgModule({
imports: [
CommonModule, RouterModule,
DivHelpContentFormModule, AdminToolServiceModule, EditDivHelpContentRoutingModule
],
declarations: [
EditDivHelpContentComponent
],
exports: [EditDivHelpContentComponent]
})
export class EditDivHelpContentModule { }

View File

@ -1,12 +0,0 @@
import { NgModule } from '@angular/core';
import {RouterModule} from '@angular/router';
import {NewDivHelpContentComponent} from "./new-div-help-content.component";
@NgModule({
imports: [
RouterModule.forChild([
{ path: '', component: NewDivHelpContentComponent}
])
]
})
export class NewDivHelpContentRoutingModule { }

View File

@ -1,32 +0,0 @@
<div id="page_content_inner">
<div class="content-wrapper" id="contentWrapper">
<div id="newDivHelpContent" class="uk-card uk-card-default uk-padding">
<div id="content">
<div class="menubar fixed">
<div class="sidebar-toggler visible-xs">
<i class="ion-navicon"></i>
</div>
<h4 class="uk-text-bold">
<span class="uk-text-large">New Class help text <span *ngIf="page && page.name">of page "{{page.name}}"</span></span>
</h4>
</div>
<div class="content-wrapper">
<div>
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
<div [style.display]="showLoading ? 'inline' : 'none'" class="uk-animation-fade uk-width-1-1" role="alert">
<img class="uk-align-center loading-gif"></div>
<div-content-form [communityPid]="communityPid" [pageId]="pageId"
[updateErrorMessage]="updateErrorMessage"></div-content-form>
<button (click)="saveCustom()" class="uk-button uk-button-primary">Save class help text</button>
<button (click)="cancelCustom()" class="uk-button">Cancel</button>
</div>
</div>
</div>
</div>
</div>
</div>

View File

@ -1,123 +0,0 @@
import { Component, ViewChild, ElementRef } from '@angular/core';
import { ActivatedRoute, Router } from "@angular/router";
import { DivContentFormComponent } from "./div-help-content-form.component";
import { DivHelpContent } from "../../utils/entities/adminTool/div-help-content";
import { HelpContentService } from "../../services/help-content.service";
import { EnvProperties } from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {Page} from "../../utils/entities/adminTool/page";
@Component({
selector: 'new-div-help-content',
templateUrl: 'new-div-help-content.component.html',
})
export class NewDivHelpContentComponent {
@ViewChild(DivContentFormComponent)
public formComponent : DivContentFormComponent;
//private errorMessage : string = null;
public communityPid: string;
public pageId: string;
public page: Page;
public properties:EnvProperties = null;
public showLoading: boolean = true;
public errorMessage: string = '';
public updateErrorMessage: string = '';
constructor(
private element: ElementRef,
private route: ActivatedRoute,
private router: Router,
private _helpContentService: HelpContentService) {}
ngOnInit() {
this.route.data
.subscribe((data: { envSpecific: EnvProperties }) => {
this.properties = data.envSpecific;
this.route.queryParams.subscribe(params => {
HelperFunctions.scroll();
this.communityPid = params['communityId'];
this.pageId = params['pageId'];
if(this.pageId) {
this.getPage(this.pageId);
} else {
this.showLoading = false;
}
});
});
}
private getPage(pageId: string) {
this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
page => {
if(this.properties.adminToolsPortalType != page.portalType) {
this.router.navigate(['../../'], { queryParams: { "communityId": this.communityPid}, relativeTo: this.route });
} else {
this.page = page;
this.showLoading = false;
console.info(this.page);
}
},
error => this.handleError('System error retrieving page with id: '+pageId, error)
);
}
public saveCustom() {
if(!Session.isLoggedIn()){
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
} else {
if(this.formComponent.myForm.valid) {
this.showLoading = true;
this.updateErrorMessage = "";
let divHelpContent : DivHelpContent = this.formComponent.myForm.value;
this._helpContentService.insertOrUpdateDivHelpContent(divHelpContent, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
_ => {
if(this.pageId) {
this.router.navigate( ['../../'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId } , relativeTo: this.route} );
} else {
this.router.navigate(['../../'], { queryParams: { "communityId": this.communityPid } , relativeTo: this.route} );
}
this.showLoading = false;
},
err => this.handleUpdateError('System error saving page content', err)
);
} else {
this.errorMessage = "Please fill all required fields";
}
}
}
public cancelCustom() {
if(this.pageId) {
this.router.navigate( ['../../'], { queryParams: { "communityId": this.communityPid, "pageId": this.pageId }, relativeTo: this.route } );
} else {
this.router.navigate(['../../'], { queryParams: { "communityId": this.communityPid }, relativeTo: this.route } );
}
}
handleUpdateError(message: string, error) {
this.errorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
handleError(message: string, error) {
this.errorMessage = message;
console.log('Server responded: ' + error);
this.showLoading = false;
}
}

View File

@ -1,19 +0,0 @@
import {NgModule} from '@angular/core';
import {RouterModule} from '@angular/router';
import {CommonModule} from '@angular/common';
import {NewDivHelpContentComponent} from './new-div-help-content.component';
import {DivHelpContentFormModule} from './div-help-content-form.module';
import {AdminToolServiceModule} from "../../services/adminToolService.module";
import {NewDivHelpContentRoutingModule} from "./new-div-help-content-routing.module";
@NgModule({
imports: [
CommonModule, RouterModule,
DivHelpContentFormModule, AdminToolServiceModule, NewDivHelpContentRoutingModule
],
declarations: [
NewDivHelpContentComponent
],
exports: [NewDivHelpContentComponent]
})
export class NewDivHelpContentModule { }

View File

@ -45,7 +45,6 @@ export class PageHelpContentsComponent implements OnInit {
public showLoading: boolean = true;
public filterForm: FormControl;
public selectForm: FormControl;
public selectOptions = [];
private subscriptions: any[] = [];
public selectedKeyword: string;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
@ -110,31 +109,7 @@ export class PageHelpContentsComponent implements OnInit {
error => this.handleError('System error retrieving page', error)));
}
}
getPages(community_pid: string) {
if (!Session.isLoggedIn()) {
this.router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this.router.url
}
});
} else {
this.showLoading = true;
//this._helpService.getCommunityPages(community_pid, "", this.properties.adminToolsAPIURL).subscribe(
this.subscriptions.push(this._helpService.getCommunityPagesWithPositions(community_pid, this.properties.adminToolsAPIURL).subscribe(
pages => {
this.pages = pages;
this.getPageHelpContents(this.portal);
this.selectOptions = [{label: 'All pages', value: ''}];
for (let page of this.pages) {
this.selectOptions.push({label: page.name, value: page._id})
}
},
error => this.handleError('System error retrieving pages', error)));
}
}
public countPageHelpContents() {
this.counter = {all: 0, active: 0, inactive: 0};
let filter = Object.assign({}, this.filters);
@ -194,15 +169,11 @@ export class PageHelpContentsComponent implements OnInit {
}
public confirmDeletePageHelpContent(id: string) {
//this.deleteConfirmationModal.ids = [id];
//this.deleteConfirmationModal.showModal();
this.selectedPageContents = [id];
this.confirmModalOpen();
}
public confirmDeleteSelectedPageHelpContents() {
//this.deleteConfirmationModal.ids = this.getSelectedPageHelpContents();
//this.deleteConfirmationModal.showModal();
this.selectedPageContents = this.getSelectedPageHelpContents();
this.confirmModalOpen();
}
@ -306,22 +277,7 @@ export class PageHelpContentsComponent implements OnInit {
}
}
public pageHelpContentSavedSuccessfully(pageHelpContent: PageHelpContent) {
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent: pageHelpContent, checked: false});
this.pageHelpContents.push(pageHelpContent);
this.applyCheck(false);
this.countPageHelpContents();
}
public pageHelpContentUpdatedSuccessfully(pageHelpContent: PageHelpContent) {
this.checkboxes.find(checkItem => checkItem.pageHelpContent._id == pageHelpContent._id).pageHelpContent = pageHelpContent;
let index = this.pageHelpContents.findIndex(checkItem => checkItem._id == pageHelpContent._id);
this.pageHelpContents[index] = pageHelpContent;
this.applyCheck(false);
this.countPageHelpContents();
}
public filterPageHelpContent(pageHelpContent: PageHelpContent, filters: PageHelpContentFilterOptions): boolean {
let idFlag = filters.id == '' || (<Page>pageHelpContent.page)._id == filters.id;
let activeFlag = filters.active == null || pageHelpContent.isActive == filters.active;
@ -338,7 +294,6 @@ export class PageHelpContentsComponent implements OnInit {
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent: _, checked: false})
}
);
// this.countPageHelpContents();
}
public filterByPage(event: any) {
@ -347,27 +302,12 @@ export class PageHelpContentsComponent implements OnInit {
this.applyFilter();
}
}
public displayAllPageHelpContents() {
this.filters.active = null;
this.applyFilter();
}
public displayActivePageHelpContents() {
this.filters.active = true;
this.applyFilter();
}
public filterBySearch(text: string) {
this.filters.text = new RegExp(text, "i");
this.applyFilter();
}
public displayInactivePageHelpContents() {
this.filters.active = false;
this.applyFilter();
}
handleError(message: string, error) {
UIkit.notification(message, {
status: 'danger',

View File

@ -97,13 +97,15 @@
[queryParams]="{pageId: check.page._id}"
routerLink="../helptexts">
Manage page contents
<span *ngIf="pageHelpContents[check.page._id]">({{pageHelpContents[check.page._id]}})</span>
<span *ngIf="pageHelpContentsCount[check.page._id]">({{pageHelpContentsCount[check.page._id]}})</span>
</a>
</div>
<div>
<a *ngIf="pageWithDivIds.includes(check.page._id)"
[queryParams]="{ pageId: check.page._id}"
routerLink="../classContents">Manage class contents</a>
routerLink="../classContents">Manage class contents
<span *ngIf="pageClassContentsCount[check.page._id]">({{pageClassContentsCount[check.page._id]}})</span>
</a>
</div>
</div>
<div *ngIf="!isPortalAdministrator" class="uk-width-1-4">

View File

@ -15,7 +15,6 @@ import {ConnectHelper} from "../../connect/connectHelper";
import {Option} from "../../sharedComponents/input/input.component";
import {AlertModal} from "../../utils/modal/alert";
import {SearchInputComponent} from "../../sharedComponents/search-input/search-input.component";
import {CheckPageHelpContent, PageHelpContent} from '../../utils/entities/adminTool/page-help-content';
import {Title} from "@angular/platform-browser";
import {StringUtils} from "../../utils/string-utils.class";
@ -65,7 +64,8 @@ export class PagesComponent implements OnInit {
private index: number;
public selectedKeyword: string;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
pageHelpContents = {};
pageHelpContentsCount = {};
pageClassContentsCount = {};
constructor(private element: ElementRef, private route: ActivatedRoute,
private title: Title,
@ -118,7 +118,7 @@ export class PagesComponent implements OnInit {
},
error => this.handleError('System error retrieving pages', error)));
if (this.portal) {
this.getPageHelpContents(this.portal);
this.getPageHelpContentsCounts(this.portal);
}
}
@ -445,10 +445,15 @@ export class PagesComponent implements OnInit {
}
}
getPageHelpContents(community_pid: string) {
this.subscriptions.push(this._helpContentService.countCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe(
getPageHelpContentsCounts(community_pid: string) {
this.subscriptions.push(this._helpContentService.countCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL, false).subscribe(
pageHelpContentsCount => {
this.pageHelpContents = pageHelpContentsCount;
this.pageHelpContentsCount = pageHelpContentsCount;
},
error => this.handleError('System error retrieving page contents', error)));
this.subscriptions.push(this._helpContentService.countCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL, true).subscribe(
pageClassContentsCount => {
this.pageClassContentsCount = pageClassContentsCount;
},
error => this.handleError('System error retrieving page contents', error)));
}

View File

@ -31,7 +31,6 @@ export class HelpContentService {
getEntities(helpContentUrl:string) {
return this.http.get<Array<Entity>>(helpContentUrl + 'entity')
//.map(res => <Array<Entity>> res.json())
.pipe(catchError(this.handleError));
}
@ -39,7 +38,6 @@ export class HelpContentService {
HelpContentService.removeNulls(entity);
return this.http.post<Entity>(helpContentUrl + 'entity/save', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Entity> res.json())
.pipe(catchError(this.handleError));
}
@ -47,7 +45,6 @@ export class HelpContentService {
HelpContentService.removeNulls(entity);
return this.http.post<Entity>(helpContentUrl + 'entity/update', JSON.stringify(entity), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Entity> res.json())
.pipe(catchError(this.handleError));
}
@ -66,7 +63,6 @@ export class HelpContentService {
getCommunityEntities(pid: string, helpContentUrl:string) {
return this.http.get<Array<Entity>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/entities')
//.map(res => <Array<Entity>> res.json())
.pipe(catchError(this.handleError));
}
@ -74,7 +70,6 @@ export class HelpContentService {
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/'+pid+ '/entity/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
@ -120,13 +115,11 @@ export class HelpContentService {
// unused
getDivId(divId: string, helpContentUrl:string) {
return this.http.get<DivId>(helpContentUrl + 'div/'+divId)
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
getDivIdFull(divId: string, helpContentUrl:string, pid: string) {
return this.http.get<DivId>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/'+divId+"/full")
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
@ -134,7 +127,6 @@ export class HelpContentService {
HelpContentService.removeNulls(divId);
return this.http.post<DivId>(helpContentUrl + 'div/update', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
@ -142,7 +134,6 @@ export class HelpContentService {
HelpContentService.removeNulls(divId);
return this.http.post<DivId>(helpContentUrl + 'div/save', JSON.stringify(divId), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivId> res.json())
.pipe(catchError(this.handleError));
}
@ -152,57 +143,27 @@ export class HelpContentService {
}
getPageIdsFromDivIds(pid: string, helpContentUrl:string) {
//let parameters = (pid ? "?portal="+pid : "");
return this.http.get<Array<string>>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/pages')
//.map(res => <Map<string, Set<string>>> res.json())
.pipe(catchError(this.handleError));
}
/*
getCommunitiesWithDivId(helpContentUrl:string) {
return this.http.get(helpContentUrl + 'community?div=true')
.map(res => <Array<Portal>> res.json())
.catch(this.handleError);
}
*/
getCommunityDivHelpContents(pid: string, helpContentUrl:string) {
return this.http.get<Array<DivHelpContent>>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent')
//.map(res => <Array<DivHelpContent>> res.json())
getCommunityDivHelpContents(pid: string, helpContentUrl:string, pageId:string = null) {
return this.http.get<Array<DivHelpContent>>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + (pageId ? '/' + pageId : '') + '/divhelpcontent')
.pipe(catchError(this.handleError));
}
getDivHelpContent(id : string, helpContentUrl:string, pid: string) {
return this.http.get<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/' + id)
//.map(res => <DivHelpContent> res.json())
.pipe(catchError(this.handleError));
}
// unused
insertOrUpdateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string, pid: string) {
HelpContentService.removeNulls(divHelpContent);
return this.http.post<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent',
JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <DivHelpContent> res.json())
.pipe(catchError(this.handleError));
}
saveDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string, pid: string) {
HelpContentService.removeNulls(divHelpContent);
return this.http.post<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/save',
return this.http.post<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/' + (divHelpContent._id ? 'update' : 'save'),
JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
updateDivHelpContent(divHelpContent: DivHelpContent, helpContentUrl:string, pid: string) {
HelpContentService.removeNulls(divHelpContent);
return this.http.post<DivHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid +'/divhelpcontent/update',
JSON.stringify(divHelpContent), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
deleteDivHelpContents(ids : string[], helpContentUrl:string, pid: string) {
return this.http.post(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/divhelpcontent/delete',
@ -214,26 +175,22 @@ export class HelpContentService {
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
// unused
getPageHelpContents(helpContentUrl:string) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + 'pagehelpcontent')
//.map(res => <Array<PageHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
getCommunityPageHelpContents(pid: string, helpContentUrl:string, pageId:string = null) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + (pageId ? '/' + pageId : '') + '/pagehelpcontent')
//.map(res => <Array<PageHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
//http://duffy.di.uoa.gr:8080/uoa-admin-tools/connect/connect/pagehelpcontent/page/count
countCommunityPageHelpContents(pid: string, helpContentUrl:string ) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/page/count')
//.map(res => <Array<PageHelpContent>> res.json())
countCommunityPageHelpContents(pid: string, helpContentUrl:string ,classContents:boolean=false) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + (classContents?"/divhelpcontent":"/pagehelpcontent")+'/page/count')
.pipe(catchError(this.handleError));
}
getPageHelpContent(id : string, helpContentUrl:string, pid: string) {
@ -247,7 +204,6 @@ export class HelpContentService {
return this.http.post<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + (pageHelpContent._id ? 'update' : 'save'),
JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
@ -256,7 +212,6 @@ export class HelpContentService {
return this.http.post<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid +'/pagehelpcontent/update',
JSON.stringify(pageHelpContent), CustomOptions.getAuthOptionsWithBody())
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
@ -269,13 +224,11 @@ export class HelpContentService {
togglePageHelpContents(ids : string[],status : boolean, helpContentUrl:string, pid: string) {
return this.http.post(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
//.map( res => <string[]> res.json())
.pipe(catchError(this.handleError));
}
getCommunityPagesWithDivId(pid: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?div=true')
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
@ -289,7 +242,6 @@ export class HelpContentService {
getCommunityPagesByType(pid: string, type: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages'
+ (type ? '?page_type='+type : ''))
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
// End of replacing getCommunityPages
@ -297,7 +249,6 @@ export class HelpContentService {
// Replacing part of getPages (now getAllPages)
getCommunityPagesWithPositions(pid: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?with_positions=true')
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
// End of replacing part of getPages (now getAllPages)
@ -326,7 +277,6 @@ export class HelpContentService {
getPageByPortal(pageId:string, helpContentUrl:string, pid: string) {
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
@ -348,7 +298,6 @@ export class HelpContentService {
HelpContentService.removeNulls(page);
return this.http.post<Page>(helpContentUrl + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
@ -368,19 +317,16 @@ export class HelpContentService {
// unused
getCommunities( helpContentUrl:string) {
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType)
//.map(res => <Array<Portal>> res.json())
.pipe(catchError(this.handleError));
}
getCommunity(pid: string, helpContentUrl:string) {
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+pid)
//.map(res => <Portal> res.json())
.pipe(catchError(this.handleError));
}
getCommunitiesFull( helpContentUrl:string) {
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType + '/full')
//.map(res => <Array<Portal>> res.json())
.pipe(catchError(this.handleError));
}
@ -391,7 +337,6 @@ export class HelpContentService {
}
getCommunityFull(portal_pid: string, helpContentUrl:string) {
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/full')
//.map(res => <Portal> res.json())
.pipe(catchError(this.handleError));
}
@ -402,7 +347,6 @@ export class HelpContentService {
HelpContentService.removeNulls(portal);
return this.http.post<Portal>(helpContentUrl + portal.type + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Portal> res.json())
.pipe(catchError(this.handleError));
}