[Library | Trunk]: admin tools pages add title

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60678 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2021-03-19 16:51:02 +00:00
parent 6b90c17e62
commit 8b23de0974
7 changed files with 358 additions and 529 deletions

View File

@ -509,7 +509,9 @@ export class DisplayClaimsComponent {
_prefix = "OpenAIRE | ";
}
var _title = _prefix + ((title.length > 50) ? title.substring(0, 50) : title);
this._title.setTitle(_title);
if(this.myClaims) {
this._title.setTitle(_title);
}
this._meta.updateTag({content: _title}, "property='og:title'");
}

View File

@ -30,9 +30,9 @@ import {Subscriber} from "rxjs";
</div>
</div>
</div>
`,
})
export class ClaimsAdminComponent {
@Input() fetchBy: string;
@ -43,15 +43,20 @@ export class ClaimsAdminComponent {
@Input() userInfoURL: string;
public user: User = null;
sub;
constructor(private _meta: Meta, private _title: Title,
private userManagementService: UserManagementService, private _router: Router) {
this._title.setTitle(this.isConnect?"OpenAIRE Connect | Manage links ":"OpenAIRE | Manage links ");
if (!this.isConnect) {
this._title.setTitle("OpenAIRE | Manage links ");
}
}
ngOnDestroy() {
if (this.sub instanceof Subscriber) {
this.sub.unsubscribe();
}
}
ngOnInit() {
this.sub = this.userManagementService.getUserInfo().subscribe(user => {
this.user = user;

View File

@ -5,9 +5,6 @@ import {FormArray, FormBuilder, FormGroup, Validators} from "@angular/forms";
import {CheckDivId, DivId} from "../../utils/entities/adminTool/divId";
import {Page} from "../../utils/entities/adminTool/page";
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";
@ -15,6 +12,7 @@ import {PortalUtils} from "../portal/portalHelper";
import {AlertModal} from "../../utils/modal/alert";
import {Option} from "../../sharedComponents/input/input.component";
import {SearchInputComponent} from "../../sharedComponents/search-input/search-input.component";
import {Title} from "@angular/platform-browser";
declare var UIkit;
@ -31,7 +29,7 @@ export class DivIdsComponent implements OnInit {
public divIds: DivId[] = [];
public classForm: FormGroup;
public pagesCtrl: FormArray;
private searchText: RegExp = new RegExp('');
public keyword: string = "";
public properties: EnvProperties = properties;
@ -42,15 +40,22 @@ export class DivIdsComponent implements OnInit {
public allPages: Option[] = [];
@ViewChild('PageInput') pageInput: ElementRef<HTMLInputElement>;
selectedCommunityPid = null;
public portalUtils:PortalUtils = new PortalUtils();
public portalUtils: PortalUtils = new PortalUtils();
private index: number;
public selectedKeyword: string;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router,
private title: Title,
private _helpContentService: HelpContentService, private _fb: FormBuilder) {
}
ngOnInit() {
this.filterForm = this._fb.group({
this.title.setTitle('Administrator Dashboard | Classes');
this.filterForm = this._fb.group({
keyword: [''],
type: ['all', Validators.required]});
type: ['all', Validators.required]
});
this.subscriptions.push(this.filterForm.get('keyword').valueChanges.subscribe(value => {
this.searchText = new RegExp(value, 'i');
this.applyFilters();
@ -64,12 +69,9 @@ export class DivIdsComponent implements OnInit {
this.selectedCommunityPid = params['communityId'];
this.getPages();
}));
}
constructor(private element: ElementRef, private route: ActivatedRoute, private _router: Router, private _helpContentService: HelpContentService, private _fb: FormBuilder) {
}
ngOnDestroy(): void {
this.subscriptions.forEach(value => {
if (value instanceof Subscriber) {
@ -79,49 +81,40 @@ export class DivIdsComponent implements OnInit {
}
});
}
getDivIds() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.showLoading = true;
this.subscriptions.push(this._helpContentService.getAllDivIdsFull( this.properties.adminToolsAPIURL).subscribe(
divIds => {
this.divIds = divIds;
this.checkboxes = [];
let self = this;
divIds.forEach(_ => {
self.checkboxes.push(<CheckDivId>{divId: _, checked: false});
});
this.showLoading = false;
},
error => this.handleError('System error retrieving classes', error)));
}
this.showLoading = true;
this.subscriptions.push(this._helpContentService.getAllDivIdsFull(this.properties.adminToolsAPIURL).subscribe(
divIds => {
this.divIds = divIds;
this.checkboxes = [];
let self = this;
divIds.forEach(_ => {
self.checkboxes.push(<CheckDivId>{divId: _, checked: false});
});
this.showLoading = false;
},
error => this.handleError('System error retrieving classes', error)));
}
// public showModal():void {
// this.modal.showModal();
// }
public toggleCheckBoxes(event) {
this.checkboxes.forEach(_ => _.checked = event.target.checked);
}
public applyCheck(flag: boolean) {
this.checkboxes.forEach(_ => _.checked = flag);
}
public getSelectedDivIds(): string[] {
return this.checkboxes.filter(divId => divId.checked == true).map(checkedDivId => checkedDivId.divId).map(res => res._id);
}
private deleteDivIdsFromArray(ids: string[]): void {
for (let id of ids) {
let i = this.divIds.findIndex(_ => _._id == id);
@ -129,60 +122,42 @@ export class DivIdsComponent implements OnInit {
}
this.applyFilters();
}
public confirmDeleteDivId(id: string) {
this.selectedDivIds = [id];
this.confirmModalOpen();
}
public confirmDeleteSelectedDivIds() {
this.selectedDivIds = this.getSelectedDivIds();
this.confirmModalOpen();
}
private confirmModalOpen() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.deleteModal.cancelButton = true;
this.deleteModal.okButton = true;
this.deleteModal.alertTitle = "Delete Confirmation";
this.deleteModal.message = "Are you sure you want to delete the selected class(es)?";
this.deleteModal.okButtonText = "Yes";
this.deleteModal.open();
}
this.deleteModal.cancelButton = true;
this.deleteModal.okButton = true;
this.deleteModal.alertTitle = "Delete Confirmation";
this.deleteModal.message = "Are you sure you want to delete the selected class(es)?";
this.deleteModal.okButtonText = "Yes";
this.deleteModal.open();
}
public confirmedDeleteDivIds(data: any) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.showLoading = true;
this.subscriptions.push(this._helpContentService.deleteDivIds(this.selectedDivIds, this.properties.adminToolsAPIURL).subscribe(
_ => {
this.deleteDivIdsFromArray(this.selectedDivIds);
UIkit.notification('Classes have been <b>successfully deleted</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected classes', error)
));
}
this.showLoading = true;
this.subscriptions.push(this._helpContentService.deleteDivIds(this.selectedDivIds, this.properties.adminToolsAPIURL).subscribe(
_ => {
this.deleteDivIdsFromArray(this.selectedDivIds);
UIkit.notification('Classes have been <b>successfully deleted</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected classes', error)
));
}
public editDivId(i: number) {
let divId: DivId = this.checkboxes[i].divId;
this.index = this.divIds.findIndex(value => value._id === divId._id);
@ -195,15 +170,15 @@ export class DivIdsComponent implements OnInit {
portalType: this._fb.control(divId.portalType, Validators.required)
});
this.classForm.get('portalType').disable();
for(let i = 0; i < divId.pages.length; i++) {
for (let i = 0; i < divId.pages.length; i++) {
this.pagesCtrl.push(this._fb.control(divId.pages[i]));
}
this.divIdsModalOpen("Edit class", "Save Changes");
}
public newDivId() {
this.pagesCtrl = this._fb.array([], Validators.required);
if(this.classForm) {
if (this.classForm) {
this.classForm.get('portalType').enable();
}
this.classForm = this._fb.group({
@ -214,79 +189,61 @@ export class DivIdsComponent implements OnInit {
});
this.divIdsModalOpen("Create class", "Create");
}
private divIdsModalOpen(title: string, yesBtn: string) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.editModal.cancelButton = true;
this.editModal.okButton = true;
this.editModal.okButtonLeft = false;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
this.editModal.cancelButton = true;
this.editModal.okButton = true;
this.editModal.okButtonLeft = false;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
public divIdSaveConfirmed(data: any) {
this.showLoading = true;
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
if (!this.classForm.value._id) {
this.subscriptions.push(this._helpContentService.saveDivId(<DivId>this.classForm.value, this.properties.adminToolsAPIURL).subscribe(
divId => {
this.divIdSavedSuccessfully(divId);
UIkit.notification('Class <b>' + divId.name + '</b> has been <b>successfully created</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError("System error creating class", error)
));
} else {
if (!this.classForm.value._id) {
this.subscriptions.push(this._helpContentService.saveDivId(<DivId>this.classForm.value, this.properties.adminToolsAPIURL).subscribe(
divId => {
this.divIdSavedSuccessfully(divId);
UIkit.notification('Class <b>' + divId.name + '</b> has been <b>successfully created</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError("System error creating class", error)
));
} else {
this.classForm.get('portalType').enable();
this.subscriptions.push(this._helpContentService.updateDivId(<DivId>this.classForm.value, this.properties.adminToolsAPIURL).subscribe(
divId => {
this.divIdUpdatedSuccessfully(divId);
UIkit.notification('Class <b>' + divId.name + '</b> has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError("System error updating class", error)
));
}
this.classForm.get('portalType').enable();
this.subscriptions.push(this._helpContentService.updateDivId(<DivId>this.classForm.value, this.properties.adminToolsAPIURL).subscribe(
divId => {
this.divIdUpdatedSuccessfully(divId);
UIkit.notification('Class <b>' + divId.name + '</b> has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError("System error updating class", error)
));
}
}
public divIdSavedSuccessfully(divId: DivId) {
this.divIds.push(divId);
this.applyFilters();
this.applyCheck(false);
this.showLoading = false;
}
public divIdUpdatedSuccessfully(divId: DivId) {
this.divIds[this.index] = divId;
this.applyFilters();
this.applyCheck(false);
this.showLoading = false;
}
public applyFilters() {
this.checkboxes = [];
this.divIds.filter(item => this.filterByType(item)).forEach(
@ -294,16 +251,17 @@ export class DivIdsComponent implements OnInit {
);
this.checkboxes = this.checkboxes.filter(item => this.filterDivIds(item.divId));
}
public filterByType(divId: DivId): boolean {
let type = this.filterForm.get("type").value;
return type == "all" || (type == divId.portalType);
return type == "all" || (type == divId.portalType);
}
public filterDivIds(divId: DivId): boolean {
let textFlag = this.searchText.toString() == '' || (divId.name + ' ' + divId.portalType).match(this.searchText) != null;
return textFlag;
}
handleUpdateError(message: string, error) {
if (error == null) {
// this.formComponent.reset();
@ -317,7 +275,7 @@ export class DivIdsComponent implements OnInit {
}
this.showLoading = false;
}
handleError(message: string, error) {
UIkit.notification(message, {
status: 'danger',
@ -327,7 +285,7 @@ export class DivIdsComponent implements OnInit {
console.log('Server responded: ' + error);
this.showLoading = false;
}
getPages() {
this.showLoading = true;
this.subscriptions.push(this._helpContentService.getAllPages(this.properties.adminToolsAPIURL).subscribe(

View File

@ -13,6 +13,8 @@ import {properties} from "../../../../environments/environment";
import {ConnectHelper} from "../../connect/connectHelper";
import {AlertModal} from "../../utils/modal/alert";
import {SearchInputComponent} from "../../sharedComponents/search-input/search-input.component";
import {StringUtils} from "../../utils/string-utils.class";
import {Title} from "@angular/platform-browser";
declare var UIkit;
@ -52,7 +54,7 @@ export class EntitiesComponent implements OnInit {
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
constructor(private element: ElementRef, private route: ActivatedRoute,
private _router: Router,
private _router: Router, private title: Title,
private _helpContentService: HelpContentService,
private userManagementService: UserManagementService, private _fb: FormBuilder) {
}
@ -72,6 +74,13 @@ export class EntitiesComponent implements OnInit {
this.userManagementService.getUserInfo().subscribe(user => {
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);
if (this.route.snapshot.data.portal) {
this.title.setTitle(StringUtils.capitalize(this.portal) + ' | Entities');
} else if (this.route.snapshot.params[this.route.snapshot.data.param]) {
this.title.setTitle(this.portal.toUpperCase() + ' | Entities');
} else {
this.title.setTitle('Administrator Dashboard | Entities');
}
this.applyPortalFilter(this.portal);
this.isPortalAdministrator = Session.isPortalAdministrator(user) && !this.portal;
});
@ -90,39 +99,34 @@ export class EntitiesComponent implements OnInit {
}
getEntities(portal: string) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
this.showLoading = true;
if (portal) {
this._helpContentService.getCommunityEntities(portal, this.properties.adminToolsAPIURL).subscribe(
entities => {
this.entities = entities;
this.checkboxes = [];
let self = this;
entities.forEach(_ => {
self.checkboxes.push(<CheckEntity>{entity: _, checked: false});
});
this.showLoading = false;
},
error => this.handleError('System error retrieving entities', error));
} else {
this.showLoading = true;
if (portal) {
this._helpContentService.getCommunityEntities(portal, this.properties.adminToolsAPIURL).subscribe(
entities => {
this.entities = entities;
this.checkboxes = [];
let self = this;
entities.forEach(_ => {
self.checkboxes.push(<CheckEntity>{entity: _, checked: false});
});
this.showLoading = false;
},
error => this.handleError('System error retrieving entities', error));
} else {
this._helpContentService.getEntities(this.properties.adminToolsAPIURL).subscribe(
entities => {
this.entities = entities;
this.checkboxes = [];
let self = this;
entities.forEach(_ => {
self.checkboxes.push(<CheckEntity>{entity: _, checked: false});
});
this.showLoading = false;
},
error => this.handleError('System error retrieving entities', error));
}
this._helpContentService.getEntities(this.properties.adminToolsAPIURL).subscribe(
entities => {
this.entities = entities;
this.checkboxes = [];
let self = this;
entities.forEach(_ => {
self.checkboxes.push(<CheckEntity>{entity: _, checked: false});
});
this.showLoading = false;
},
error => this.handleError('System error retrieving entities', error));
}
}
@ -161,38 +165,28 @@ export class EntitiesComponent implements OnInit {
}
private confirmDeleteEntitiesModalOpen() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
this.deleteModal.cancelButton = true;
this.deleteModal.okButton = true;
this.deleteModal.alertTitle = 'Delete Confirmation';
this.deleteModal.message = 'Are you sure you want to delete the selected entity(-ies)?';
this.deleteModal.okButtonText = 'Yes';
this.deleteModal.open();
}
this.deleteModal.cancelButton = true;
this.deleteModal.okButton = true;
this.deleteModal.alertTitle = 'Delete Confirmation';
this.deleteModal.message = 'Are you sure you want to delete the selected entity(-ies)?';
this.deleteModal.okButtonText = 'Yes';
this.deleteModal.open();
}
public confirmedDeleteEntities(data: any) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
this.showLoading = true;
this._helpContentService.deleteEntities(this.selectedEntities, this.properties.adminToolsAPIURL).subscribe(
_ => {
this.deleteEntitiesFromArray(this.selectedEntities);
UIkit.notification('Entities have been <b>successfully deleted</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected entities', error)
);
}
this.showLoading = true;
this._helpContentService.deleteEntities(this.selectedEntities, this.properties.adminToolsAPIURL).subscribe(
_ => {
this.deleteEntitiesFromArray(this.selectedEntities);
UIkit.notification('Entities have been <b>successfully deleted</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected entities', error)
);
}
public editEntity(i: number) {
@ -216,51 +210,41 @@ export class EntitiesComponent implements OnInit {
}
private entitiesModalOpen(title: string, yesBtn: string) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
this.editModal.cancelButton = true;
this.editModal.okButton = true;
this.editModal.okButtonLeft = false;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
this.editModal.cancelButton = true;
this.editModal.okButton = true;
this.editModal.okButtonLeft = false;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
public entitySaveConfirmed(data: any) {
this.showLoading = true;
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
if (this.entityForm.value._id) {
this._helpContentService.updateEntity(
<Entity>this.entityForm.value, this.properties.adminToolsAPIURL).subscribe(
entity => {
this.entityUpdatedSuccessfully(entity);
UIkit.notification('Entity <b>' + entity.name + '</b> has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error updating entity', error)
);
} else {
if (this.entityForm.value._id) {
this._helpContentService.updateEntity(
<Entity>this.entityForm.value, this.properties.adminToolsAPIURL).subscribe(
entity => {
this.entityUpdatedSuccessfully(entity);
UIkit.notification('Entity <b>' + entity.name + '</b> has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error updating entity', error)
);
} else {
this._helpContentService.saveEntity(<Entity>this.entityForm.value, this.properties.adminToolsAPIURL).subscribe(
entity => {
this.entitySavedSuccessfully(entity);
UIkit.notification('Entity <b>' + entity.name + '</b> has been <b>successfully created</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error creating entity', error)
);
}
this._helpContentService.saveEntity(<Entity>this.entityForm.value, this.properties.adminToolsAPIURL).subscribe(
entity => {
this.entitySavedSuccessfully(entity);
UIkit.notification('Entity <b>' + entity.name + '</b> has been <b>successfully created</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error creating entity', error)
);
}
}
@ -338,36 +322,26 @@ export class EntitiesComponent implements OnInit {
}
private confirmRelatedPagesModalOpen() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
this.relatedPages.cancelButton = true;
this.relatedPages.okButton = true;
this.relatedPages.alertTitle = 'Warning';
this.relatedPages.message = "This action will affect all search pages related to this entity! Pages' status will change to entity's status! Do you want to continue?";
this.relatedPages.okButtonText = 'Yes';
this.relatedPages.open();
}
this.relatedPages.cancelButton = true;
this.relatedPages.okButton = true;
this.relatedPages.alertTitle = 'Warning';
this.relatedPages.message = "This action will affect all search pages related to this entity! Pages' status will change to entity's status! Do you want to continue?";
this.relatedPages.okButtonText = 'Yes';
this.relatedPages.open();
}
public continueToggling(event: any) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'],
{queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}});
} else {
this._helpContentService.toggleEntities(
this.portal, this.toggleIds, this.toggleStatus, this.properties.adminToolsAPIURL).subscribe(
() => {
for (let id of this.toggleIds) {
const i = this.checkboxes.findIndex(_ => _.entity._id === id);
this.checkboxes[i].entity.isEnabled = this.toggleStatus;
}
this.applyCheck(false);
},
error => this.handleUpdateError('System error changing the status of the selected entity(-ies)', error)
);
}
this._helpContentService.toggleEntities(
this.portal, this.toggleIds, this.toggleStatus, this.properties.adminToolsAPIURL).subscribe(
() => {
for (let id of this.toggleIds) {
const i = this.checkboxes.findIndex(_ => _.entity._id === id);
this.checkboxes[i].entity.isEnabled = this.toggleStatus;
}
this.applyCheck(false);
},
error => this.handleUpdateError('System error changing the status of the selected entity(-ies)', error)
);
}
public onSearchClose() {
@ -378,9 +352,9 @@ export class EntitiesComponent implements OnInit {
this.selectedKeyword = null;
this.searchInputComponent.reset()
}
selectAll(){
let checked = !!(this.getSelectedEntities().length != this.checkboxes.length);
selectAll() {
let checked = (this.getSelectedEntities().length != this.checkboxes.length);
for (let check of this.checkboxes) {
check.checked = checked;
}

View File

@ -1,14 +1,11 @@
import {Component, Input, OnInit} from '@angular/core';
import {Component, 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 {from, Observable, Subscriber, Subscription} from 'rxjs';
import {Observable, Subscriber, Subscription} from 'rxjs';
import {HelperFunctions} from '../../utils/HelperFunctions.class';
import {PageHelpContent} from '../../utils/entities/adminTool/page-help-content';
import {ConnectHelper} from "../../connect/connectHelper";
@ -28,10 +25,7 @@ export class PageContentFormComponent implements OnInit {
page: Page;
placementsOptions = [];
orderOptions = [];
private availablePages: Page[] = [];
private ckeditorContent: string;
public properties: EnvProperties = null;
public properties: EnvProperties = properties;
public showLoading: boolean = true;
private subs: Subscription[] = [];
public pageHelpContent: PageHelpContent;
@ -40,8 +34,6 @@ export class PageContentFormComponent implements OnInit {
}
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);
@ -53,24 +45,7 @@ export class PageContentFormComponent implements OnInit {
if (!this.pageId) {
this._router.navigate(['../'], {relativeTo: this.route});
}
/* this.getPage(this.pageId);
if (this.pageContentId) {
this.getPageHelpContent(this.pageContentId);
}else{
this.myForm = this.form;
}*/
this.getInfo(this.pageId);
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
}
}));
}));
}
@ -150,18 +125,14 @@ export class PageContentFormComponent implements OnInit {
));
}
private getPageHelpContent(pageContentId: string) {
if(!Session.isLoggedIn()){
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
} else {
this.showLoading = true;
this.showLoading = true;
this.subs.push(this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
pageHelpContent => {
this.updateForm(pageHelpContent);
this.showLoading = false;
},
error => this.handleError('System error retrieving page help content', error)));
}
this.subs.push(this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL, this.communityPid).subscribe(
pageHelpContent => {
this.updateForm(pageHelpContent);
this.showLoading = false;
},
error => this.handleError('System error retrieving page help content', error)));
}*/
private updateForm(pageHelpContent: PageHelpContent) {
this.pageHelpContent = pageHelpContent;
@ -250,34 +221,25 @@ export class PageContentFormComponent implements OnInit {
}
public saveCustom() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
if (this.myForm.valid) {
this.showLoading = true;
this.myForm.get('order').enable();
this.myForm.get('placement').enable();
let pageHelpContent: PageHelpContent = this.myForm.value;
this.subs.push(this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.portal).subscribe(
_ => {
UIkit.notification('Page content has been <b>successfully ' + (this.pageContentId ? 'updated' : 'created') + '</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this._router.navigate(['../'], {queryParams: {"pageId": this.pageId}, relativeTo: this.route});
this.showLoading = false;
},
err => this.handleUpdateError('System error saving page content', err)
));
} else {
if (this.myForm.valid) {
this.showLoading = true;
this.myForm.get('order').enable();
this.myForm.get('placement').enable();
let pageHelpContent: PageHelpContent = this.myForm.value;
this.subs.push(this._helpContentService.savePageHelpContent(pageHelpContent, this.properties.adminToolsAPIURL, this.portal).subscribe(
_ => {
UIkit.notification('Page content has been <b>successfully ' + (this.pageContentId?'updated':'created') + '</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this._router.navigate(['../'], {queryParams: {"pageId": this.pageId}, relativeTo: this.route});
this.showLoading = false;
},
err => this.handleUpdateError('System error saving page content', err)
));
} else {
this.showLoading = false;
}
this.showLoading = false;
}
}

View File

@ -16,6 +16,8 @@ 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";
declare var UIkit;
@ -64,7 +66,9 @@ export class PagesComponent implements OnInit {
public selectedKeyword: string;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
pageHelpContents = {};
constructor(private element: ElementRef, private route: ActivatedRoute,
private title: Title,
private _router: Router, private _helpContentService: HelpContentService,
private userManagementService: UserManagementService, private _fb: FormBuilder) {
}
@ -89,6 +93,13 @@ export class PagesComponent implements OnInit {
}
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);
if (this.route.snapshot.data.portal) {
this.title.setTitle(StringUtils.capitalize(this.portal) + ' | Pages');
} else if (this.route.snapshot.params[this.route.snapshot.data.param]) {
this.title.setTitle(this.portal.toUpperCase() + ' | Pages');
} else {
this.title.setTitle('Administrator Dashboard | Pages');
}
this.keyword = '';
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
this.applyPortalFilter(this.portal);
@ -99,14 +110,14 @@ export class PagesComponent implements OnInit {
entities => {
this.allEntities = [];
entities.forEach(entity => {
this.allEntities.push({
label: entity.name,
value: entity
});
this.allEntities.push({
label: entity.name,
value: entity
});
});
},
error => this.handleError('System error retrieving pages', error)));
if(this.portal) {
if (this.portal) {
this.getPageHelpContents(this.portal);
}
@ -123,60 +134,42 @@ export class PagesComponent implements OnInit {
}
getPages(portal: string) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_VALID,
'redirectUrl': this._router.url
}
});
this.showLoading = true;
this.pageWithDivIds = [];
let parameters = '';
if (this.pagesType) {
parameters = '?page_type=' + this.pagesType;
}
if (portal) {
this.subscriptions.push(this._helpContentService.getCommunityPagesByType(portal, parameters, this.properties.adminToolsAPIURL).subscribe(
pages => {
this.pagesReturned(pages);
//if(!this.pagesType || this.pagesType == "link") {
this.getPagesWithDivIds(portal);
//} else {
//this.showLoading = false;
//}
},
error => this.handleError('System error retrieving pages', error)
));
} else {
this.showLoading = true;
this.pageWithDivIds = [];
let parameters = '';
if (this.pagesType) {
parameters = '?page_type=' + this.pagesType;
}
if (portal) {
this.subscriptions.push(this._helpContentService.getCommunityPagesByType(portal, parameters, this.properties.adminToolsAPIURL).subscribe(
pages => {
this.pagesReturned(pages);
//if(!this.pagesType || this.pagesType == "link") {
this.getPagesWithDivIds(portal);
//} else {
//this.showLoading = false;
//}
},
error => this.handleError('System error retrieving pages', error)
));
} else {
this.subscriptions.push(this._helpContentService.getAllPagesFull(this.properties.adminToolsAPIURL).subscribe(
pages => {
this.pagesReturned(pages);
this.showLoading = false;
},
error => this.handleError('System error retrieving pages', error)
));
}
this.subscriptions.push(this._helpContentService.getAllPagesFull(this.properties.adminToolsAPIURL).subscribe(
pages => {
this.pagesReturned(pages);
this.showLoading = false;
},
error => this.handleError('System error retrieving pages', error)
));
}
}
getPagesWithDivIds(portal: string) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_VALID,
'redirectUrl': this._router.url
}
});
} else {
this.subscriptions.push(this._helpContentService.getPageIdsFromDivIds(portal, this.properties.adminToolsAPIURL).subscribe(
pages => {
this.pageWithDivIds = pages;
this.showLoading = false;
},
error => this.handleError('System error retrieving information about pages\' classes', error)));
}
this.subscriptions.push(this._helpContentService.getPageIdsFromDivIds(portal, this.properties.adminToolsAPIURL).subscribe(
pages => {
this.pageWithDivIds = pages;
this.showLoading = false;
},
error => this.handleError('System error retrieving information about pages\' classes', error)));
}
pagesReturned(pages: Page[]) {
@ -190,19 +183,6 @@ export class PagesComponent implements OnInit {
}
}
/*
getPortals() {
this._helpContentService.getCommunities(this.properties.adminToolsAPIURL).subscribe(
communities => {
this.communities = communities;
this.portal = this.communities[0].pid;
this.getPages(this.portal);
this.getPagesWithDivIds(this.portal);
},
error => this.handleError('System error retrieving communities', error));
}
*/
public toggleCheckBoxes(event) {
this.checkboxes.forEach(_ => _.checked = event.target.checked);
}
@ -224,60 +204,38 @@ export class PagesComponent implements OnInit {
}
public confirmDeletePage(id: string) {
//this.deleteConfirmationModal.ids = [id];
//this.deleteConfirmationModal.showModal();
this.selectedPages = [id];
this.confirmModalOpen();
}
public confirmDeleteSelectedPages() {
//this.deleteConfirmationModal.ids = this.getSelectedPages();
//this.deleteConfirmationModal.showModal();
this.selectedPages = this.getSelectedPages();
this.confirmModalOpen();
}
private confirmModalOpen() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_VALID,
'redirectUrl': this._router.url
}
});
} else {
this.deleteModal.cancelButton = true;
this.deleteModal.okButton = true;
this.deleteModal.alertTitle = 'Delete Confirmation';
this.deleteModal.message = 'Are you sure you want to delete the selected page(s)?';
this.deleteModal.okButtonText = 'Yes';
this.deleteModal.open();
}
this.deleteModal.cancelButton = true;
this.deleteModal.okButton = true;
this.deleteModal.alertTitle = 'Delete Confirmation';
this.deleteModal.message = 'Are you sure you want to delete the selected page(s)?';
this.deleteModal.okButtonText = 'Yes';
this.deleteModal.open();
}
public confirmedDeletePages(data: any) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_VALID,
'redirectUrl': this._router.url
}
});
} else {
this.showLoading = true;
this.subscriptions.push(this._helpContentService.deletePages(this.selectedPages, this.properties.adminToolsAPIURL).subscribe(
_ => {
this.deletePagesFromArray(this.selectedPages);
UIkit.notification('Pages have been <b>successfully deleted</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected pages', error)
));
}
this.showLoading = true;
this.subscriptions.push(this._helpContentService.deletePages(this.selectedPages, this.properties.adminToolsAPIURL).subscribe(
_ => {
this.deletePagesFromArray(this.selectedPages);
UIkit.notification('Pages have been <b>successfully deleted</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
this.showLoading = false;
},
error => this.handleUpdateError('System error deleting the selected pages', error)
));
}
public editPage(i: number) {
@ -305,7 +263,7 @@ export class PagesComponent implements OnInit {
}
public newPage() {
if(this.pageForm) {
if (this.pageForm) {
this.pageForm.get('portalType').enable();
}
this.entitiesCtrl = this._fb.array([]);
@ -326,60 +284,41 @@ export class PagesComponent implements OnInit {
}
private pagesModalOpen(title: string, yesBtn: string) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_VALID,
'redirectUrl': this._router.url
}
});
} else {
this.editModal.cancelButton = true;
this.editModal.okButton = true;
this.editModal.okButtonLeft = false;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
this.editModal.cancelButton = true;
this.editModal.okButton = true;
this.editModal.okButtonLeft = false;
this.editModal.alertTitle = title;
this.editModal.okButtonText = yesBtn;
this.editModal.open();
}
public pageSaveConfirmed(data: any) {
this.showLoading = true;
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
'errorCode': LoginErrorCodes.NOT_VALID,
'redirectUrl': this._router.url
}
});
if (!this.pageForm.value._id) {
this.subscriptions.push(this._helpContentService.savePage(<Page>this.pageForm.value, this.properties.adminToolsAPIURL).subscribe(
page => {
this.pageSavedSuccessfully(page, true);
UIkit.notification('Page <b>' + page.name + '</b> has been <b>successfully created</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error creating page', error)
));
} else {
if (!this.pageForm.value._id) {
this.subscriptions.push(this._helpContentService.savePage(<Page>this.pageForm.value, this.properties.adminToolsAPIURL).subscribe(
page => {
this.pageSavedSuccessfully(page, true);
UIkit.notification('Page <b>' + page.name + '</b> has been <b>successfully created</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error creating page', error)
));
} else {
this.pageForm.get('portalType').enable();
this.subscriptions.push(this._helpContentService.updatePage(<Page>this.pageForm.value, this.properties.adminToolsAPIURL).subscribe(
page => {
this.pageSavedSuccessfully(page, false);
UIkit.notification('Page <b>' + page.name + '</b> has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error updating page', error)
));
}
this.pageForm.get('portalType').enable();
this.subscriptions.push(this._helpContentService.updatePage(<Page>this.pageForm.value, this.properties.adminToolsAPIURL).subscribe(
page => {
this.pageSavedSuccessfully(page, false);
UIkit.notification('Page <b>' + page.name + '</b> has been <b>successfully updated</b>', {
status: 'success',
timeout: 6000,
pos: 'bottom-right'
});
},
error => this.handleUpdateError('System error updating page', error)
));
}
}
@ -449,8 +388,8 @@ export class PagesComponent implements OnInit {
}
public getEntitiesAsString(page: Page): string {
if(page.entities) {
return (<any[]> page.entities).map((page: Entity) => page.name).join(',');
if (page.entities) {
return (<any[]>page.entities).map((page: Entity) => page.name).join(',');
}
return '';
}
@ -498,16 +437,18 @@ export class PagesComponent implements OnInit {
this.selectedKeyword = null;
this.searchInputComponent.reset()
}
selectAll(){
selectAll() {
let checked = !!(this.getSelectedPages().length != this.checkboxes.length);
for (let check of this.checkboxes) {
check.checked = checked;
}
}
getPageHelpContents(community_pid: string) {
this.subscriptions.push(this._helpContentService.countCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe(
pageHelpContentsCount => {
this.pageHelpContents = pageHelpContentsCount;
this.pageHelpContents = pageHelpContentsCount;
},
error => this.handleError('System error retrieving page contents', error)));
}

View File

@ -13,6 +13,7 @@ import {PortalUtils} from "./portalHelper";
import {properties} from "../../../../environments/environment";
import {AlertModal} from "../../utils/modal/alert";
import {SearchInputComponent} from "../../sharedComponents/search-input/search-input.component";
import {Title} from "@angular/platform-browser";
declare var UIkit;
@ -45,7 +46,13 @@ export class PortalsComponent implements OnInit {
public selectedKeyword: string;
@ViewChild('searchInputComponent') searchInputComponent: SearchInputComponent;
constructor(private element: ElementRef, private route: ActivatedRoute,
private title: Title,
private _router: Router, private _helpContentService: HelpContentService, private _fb: FormBuilder) {
}
ngOnInit() {
this.title.setTitle('Administrator Dashboard | Portals');
this.filterForm = this._fb.group({
keyword: [''],
type: ['all', Validators.required]
@ -64,11 +71,6 @@ export class PortalsComponent implements OnInit {
}
constructor(private element: ElementRef, private route: ActivatedRoute,
private _router: Router, private _helpContentService: HelpContentService, private _fb: FormBuilder) {
}
ngOnDestroy(): void {
this.subscriptions.forEach(value => {
if (value instanceof Subscriber) {
@ -133,29 +135,15 @@ export class PortalsComponent implements OnInit {
}
private confirmModalOpen() {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {
"errorCode": LoginErrorCodes.NOT_VALID,
"redirectUrl": this._router.url
}
});
} else {
this.deleteModal.cancelButton = true;
this.deleteModal.okButton = true;
this.deleteModal.alertTitle = 'Delete Confirmation';
this.deleteModal.message = 'Are you sure you want to delete the selected portal(-ies)?';
this.deleteModal.okButtonText = 'Yes';
this.deleteModal.open();
}
}
public confirmedDeletePortals(data: any) {
if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], {
queryParams: {'errorCode': LoginErrorCodes.NOT_VALID, 'redirectUrl': this._router.url}
});
} else {
this.showLoading = true;
this.subscriptions.push(this._helpContentService.deleteCommunities(this.selectedPortals, this.properties.adminToolsAPIURL).subscribe(
_ => {
@ -169,7 +157,6 @@ export class PortalsComponent implements OnInit {
},
error => this.handleUpdateError('System error deleting the selected communities', error)
));
}
}
public editPortal(i: number) {