For every page: when Session is expired, redirect to '/user-info' page to show a proper message.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@53735 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
3d64e0ebae
commit
9ddb0b32c9
|
@ -2,7 +2,7 @@
|
|||
* Created by stefania on 7/13/17.
|
||||
*/
|
||||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { ModalFormComponent } from "../modal-form.component";
|
||||
|
@ -11,6 +11,9 @@ import { CommunityFormComponent } from "./community-form.component";
|
|||
import { CheckCommunity, Community } from "../../domain/community";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'communities',
|
||||
templateUrl: './communities.component.html',
|
||||
|
@ -62,10 +65,14 @@ export class CommunitiesComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _helpContentService: HelpContentService) {}
|
||||
|
||||
|
||||
getCommunities() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
@ -80,6 +87,7 @@ export class CommunitiesComponent implements OnInit {
|
|||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving communities', error));
|
||||
}
|
||||
}
|
||||
|
||||
// public showModal():void {
|
||||
|
@ -121,15 +129,24 @@ export class CommunitiesComponent implements OnInit {
|
|||
}
|
||||
|
||||
private confirmModalOpen() {
|
||||
this.alertModalDeleteCommunities.cancelButton = true;
|
||||
this.alertModalDeleteCommunities.okButton = true;
|
||||
this.alertModalDeleteCommunities.alertTitle = "Delete Confirmation";
|
||||
this.alertModalDeleteCommunities.message = "Are you sure you want to delete the selected community(-ies)?";
|
||||
this.alertModalDeleteCommunities.okButtonText = "Yes";
|
||||
this.alertModalDeleteCommunities.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.alertModalDeleteCommunities.cancelButton = true;
|
||||
this.alertModalDeleteCommunities.okButton = true;
|
||||
this.alertModalDeleteCommunities.alertTitle = "Delete Confirmation";
|
||||
this.alertModalDeleteCommunities.message = "Are you sure you want to delete the selected community(-ies)?";
|
||||
this.alertModalDeleteCommunities.okButtonText = "Yes";
|
||||
this.alertModalDeleteCommunities.open();
|
||||
}
|
||||
}
|
||||
|
||||
public confirmedDeleteCommunities(data: any) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -140,6 +157,7 @@ export class CommunitiesComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error deleting the selected communities', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public editCommunity(i : number) {
|
||||
|
@ -157,39 +175,54 @@ export class CommunitiesComponent implements OnInit {
|
|||
}
|
||||
|
||||
private communitiesModalOpen(modal: any, title: string, yesBtn: string) {
|
||||
modal.cancelButton = true;
|
||||
modal.okButton = true;
|
||||
modal.alertTitle = title;
|
||||
modal.okButtonText = yesBtn;
|
||||
modal.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
modal.cancelButton = true;
|
||||
modal.okButton = true;
|
||||
modal.alertTitle = title;
|
||||
modal.okButtonText = yesBtn;
|
||||
modal.open();
|
||||
}
|
||||
}
|
||||
|
||||
public communitySaveConfirmed(data: any) {
|
||||
if(!this.formGroup.valid) {
|
||||
this.communitiesModalOpen(this.alertModalSaveCommunity, "Save", "Add a new Community");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.modalErrorMessage = "";
|
||||
this._helpContentService.saveCommunity(<Community> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
community => {
|
||||
this.communitySavedSuccessfully(community);
|
||||
},
|
||||
error => this.handleUpdateError("System error creating community", error)
|
||||
);
|
||||
if(!this.formGroup.valid) {
|
||||
this.communitiesModalOpen(this.alertModalSaveCommunity, "Save", "Add a new Community");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
} else {
|
||||
this.modalErrorMessage = "";
|
||||
this._helpContentService.saveCommunity(<Community> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
community => {
|
||||
this.communitySavedSuccessfully(community);
|
||||
},
|
||||
error => this.handleUpdateError("System error creating community", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public communityUpdateConfirmed(data: any) {
|
||||
if(!this.formGroup.valid) {
|
||||
this.communitiesModalOpen(this.alertModalUpdateCommunity, "Update", "Update Community");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this._helpContentService.updateCommunity(<Community> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
community => {
|
||||
this.communityUpdatedSuccessfully(community);
|
||||
},
|
||||
error => this.handleUpdateError("System error updating community", error)
|
||||
);
|
||||
if(!this.formGroup.valid) {
|
||||
this.communitiesModalOpen(this.alertModalUpdateCommunity, "Update", "Update Community");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
} else {
|
||||
this._helpContentService.updateCommunity(<Community> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
community => {
|
||||
this.communityUpdatedSuccessfully(community);
|
||||
},
|
||||
error => this.handleUpdateError("System error updating community", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,9 @@ import {EnvProperties} from '../../../openaire
|
|||
|
||||
import {CommunityInfo} from '../../../openaireLibrary/connect/community/communityInfo';
|
||||
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'community-edit-form',
|
||||
templateUrl: './community-edit-form.component.html',
|
||||
|
@ -55,22 +58,27 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
communityId => {
|
||||
this.communityId = communityId['communityId'];
|
||||
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
|
||||
community => {
|
||||
this.community = community;
|
||||
this.params = {community: encodeURIComponent('"'+community.queryId+'"')};
|
||||
this.firstVersionOfManagers = community.managers.slice();
|
||||
console.log("First version of managers " + this.firstVersionOfManagers);
|
||||
console.log(community);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving community profile', error)
|
||||
);
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
|
||||
community => {
|
||||
this.community = community;
|
||||
this.params = {community: encodeURIComponent('"'+community.queryId+'"')};
|
||||
this.firstVersionOfManagers = community.managers.slice();
|
||||
console.log("First version of managers " + this.firstVersionOfManagers);
|
||||
console.log(community);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving community profile', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -93,6 +101,10 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
// }
|
||||
|
||||
public resetForm(communityId: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if (communityId != null && communityId != '') {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
@ -109,10 +121,14 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
);
|
||||
}
|
||||
this.resetChange();
|
||||
}
|
||||
}
|
||||
|
||||
public updateCommunity() {
|
||||
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this.showLoading = true;
|
||||
var community = this.parseUpdatedCommunity();
|
||||
|
@ -155,6 +171,7 @@ export class CommunityEditFormComponent implements OnInit{
|
|||
}
|
||||
}
|
||||
this.resetChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import {SearchResult} from '../../../openaireLibrary/utils/entities/searchResult';
|
||||
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';
|
||||
import {SearchFields, FieldDetails} from '../../../openaireLibrary/utils/properties/searchFields';
|
||||
|
@ -9,6 +9,8 @@ import {SearchDataprovidersService} from '../../../openaireLibrary/services/sear
|
|||
import {RouterHelper} from '../../../openaireLibrary/utils/routerHelper.class';
|
||||
import {DOI, StringUtils} from '../../../openaireLibrary/utils/string-utils.class';
|
||||
import {ManageCommunityContentProvidersService} from '../../../services/manageContentProviders.service';
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'add-content-providers',
|
||||
|
@ -62,7 +64,7 @@ export class AddContentProvidersComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute, private _searchContentProvidersService: SearchDataprovidersService, private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService) {
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _searchContentProvidersService: SearchDataprovidersService, private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.openaireSearchUtils.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
@ -80,39 +82,49 @@ export class AddContentProvidersComponent implements OnInit {
|
|||
}
|
||||
|
||||
public addContentProvider(contenProvider: SearchResult) {
|
||||
console.info("Add: "+ contenProvider.id);
|
||||
this.subAdd = this._manageCommunityContentProvidersService.addContentProvider(this.properties, this.community, contenProvider).subscribe(
|
||||
data => {
|
||||
console.info("data ADD");
|
||||
console.info(data);
|
||||
this.undo[contenProvider.id] = data.id;
|
||||
},
|
||||
err => {
|
||||
console.info("error ADD");
|
||||
console.log(err.status);
|
||||
},
|
||||
() => {
|
||||
console.info("completed ADD");
|
||||
}
|
||||
)
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("Add: "+ contenProvider.id);
|
||||
this.subAdd = this._manageCommunityContentProvidersService.addContentProvider(this.properties, this.community, contenProvider).subscribe(
|
||||
data => {
|
||||
console.info("data ADD");
|
||||
console.info(data);
|
||||
this.undo[contenProvider.id] = data.id;
|
||||
},
|
||||
err => {
|
||||
console.info("error ADD");
|
||||
console.log(err.status);
|
||||
},
|
||||
() => {
|
||||
console.info("completed ADD");
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public removeContentProvider(contentProviderId: string, communityContentProviderId: string) {
|
||||
console.info("REMOVE: "+ contentProviderId);
|
||||
this.subRemove = this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, contentProviderId).subscribe(
|
||||
data => {
|
||||
console.info("data REMOVE");
|
||||
console.info(data);
|
||||
},
|
||||
err => {
|
||||
console.info("error REMOVE");
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
console.info("completed REMOVE");
|
||||
this.undo[communityContentProviderId] = "";
|
||||
}
|
||||
)
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("REMOVE: "+ contentProviderId);
|
||||
this.subRemove = this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, contentProviderId).subscribe(
|
||||
data => {
|
||||
console.info("data REMOVE");
|
||||
console.info(data);
|
||||
},
|
||||
err => {
|
||||
console.info("error REMOVE");
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
console.info("completed REMOVE");
|
||||
this.undo[communityContentProviderId] = "";
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public inCommunity(contentProvider: any): any {
|
||||
|
@ -129,58 +141,63 @@ export class AddContentProvidersComponent implements OnInit {
|
|||
}
|
||||
|
||||
private _getOpenaireContentProviders(parameters:string, page: number, size: number){
|
||||
console.info("_getOpenaireContentProviders");
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("_getOpenaireContentProviders");
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
|
||||
if(this.openaireSearchUtils.status == this.errorCodes.LOADING) {
|
||||
this.openaireSearchUtils.status = this.errorCodes.LOADING;
|
||||
if(this.openaireSearchUtils.status == this.errorCodes.LOADING) {
|
||||
this.openaireSearchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.disableForms = true;
|
||||
this.openaireContentProviders = [];
|
||||
this.openaireSearchUtils.totalResults = 0;
|
||||
this.disableForms = true;
|
||||
this.openaireContentProviders = [];
|
||||
this.openaireSearchUtils.totalResults = 0;
|
||||
|
||||
this.subResults = this._searchContentProvidersService.searchDataproviders(parameters, null, page, size, [], this.properties).subscribe(
|
||||
data => {
|
||||
this.undo = {};
|
||||
console.info("total openaire content providers = "+data[0]);
|
||||
this.openaireSearchUtils.totalResults = data[0];
|
||||
this.openaireContentProviders = data[1];
|
||||
this.subResults = this._searchContentProvidersService.searchDataproviders(parameters, null, page, size, [], this.properties).subscribe(
|
||||
data => {
|
||||
this.undo = {};
|
||||
console.info("total openaire content providers = "+data[0]);
|
||||
this.openaireSearchUtils.totalResults = data[0];
|
||||
this.openaireContentProviders = data[1];
|
||||
|
||||
this.openaireSearchUtils.status = this.errorCodes.DONE;
|
||||
if(this.openaireSearchUtils.totalResults == 0 ){
|
||||
this.openaireSearchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.openaireSearchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.openaireSearchUtils.totalResults/(this.openaireSearchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
this.openaireSearchUtils.status = this.errorCodes.DONE;
|
||||
if(this.openaireSearchUtils.totalResults == 0 ){
|
||||
this.openaireSearchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.openaireSearchUtils.totalResults = 0;
|
||||
this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.openaireSearchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.openaireSearchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.openaireSearchUtils.totalResults/(this.openaireSearchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.openaireSearchUtils.totalResults = 0;
|
||||
this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.openaireSearchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { Component, ViewChild, OnInit, ViewEncapsulation, Input } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
import {RemoveContentProvidersComponent} from './remove-content-providers.component';
|
||||
import {AddContentProvidersComponent} from './add-content-providers.component';
|
||||
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'manage-content-providers',
|
||||
template: `
|
||||
|
@ -47,22 +50,29 @@ export class ManageContentProvidersComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute) {}
|
||||
constructor(private route: ActivatedRoute, private _router: Router) {}
|
||||
|
||||
public ngOnDestroy() {}
|
||||
|
||||
public updateCommunityContentProviders() {
|
||||
this.toggle = !this.toggle;
|
||||
if(this.toggle) {
|
||||
this.pageTitle = "Manage content providers";
|
||||
//this.toggleLinkMessage = "Missing content providers?";
|
||||
|
||||
this.removeContentProvidersComponent._getCommunityContentProviders();
|
||||
this.addContentProvidersComponent.undo = {};
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.updateCommunityContentProvidersOnToggle = false;
|
||||
this.pageTitle = "Search content providers";
|
||||
//this.toggleLinkMessage = "Manage content providers";
|
||||
this.toggle = !this.toggle;
|
||||
if(this.toggle) {
|
||||
this.pageTitle = "Manage content providers";
|
||||
//this.toggleLinkMessage = "Missing content providers?";
|
||||
|
||||
this.removeContentProvidersComponent._getCommunityContentProviders();
|
||||
this.addContentProvidersComponent.undo = {};
|
||||
console.info("In remove");
|
||||
} else {
|
||||
this.updateCommunityContentProvidersOnToggle = false;
|
||||
this.pageTitle = "Search content providers";
|
||||
//this.toggleLinkMessage = "Manage content providers";
|
||||
console.info("In add");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { DataTableDirective } from 'angular-datatables';
|
||||
|
||||
|
@ -11,6 +11,9 @@ import {SearchCommunityDataprovidersService} from '../../../openaireLibrary/conn
|
|||
import {RouterHelper} from '../../../openaireLibrary/utils/routerHelper.class';
|
||||
import {DOI, StringUtils} from '../../../openaireLibrary/utils/string-utils.class';
|
||||
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'remove-content-providers',
|
||||
templateUrl: './remove-content-providers.component.html',
|
||||
|
@ -85,7 +88,7 @@ export class RemoveContentProvidersComponent implements OnInit {
|
|||
this.communitySearchUtils.keyword = "";
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
constructor(private route: ActivatedRoute, private _router: Router,
|
||||
private _manageCommunityContentProvidersService: ManageCommunityContentProvidersService,
|
||||
private _searchCommunityContentProvidersService: SearchCommunityDataprovidersService) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
|
@ -190,111 +193,127 @@ export class RemoveContentProvidersComponent implements OnInit {
|
|||
}
|
||||
|
||||
public confirmedDeleteContentProvider(data : any) {
|
||||
console.info("REMOVE: "+ this.selectedCommunityContentProvider.id);
|
||||
this.subRemove = this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, this.selectedCommunityContentProvider.id).subscribe(
|
||||
data => {
|
||||
console.info("data REMOVE");
|
||||
console.info(data);
|
||||
},
|
||||
err => {
|
||||
console.info("error REMOVE");
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
console.info("completed REMOVE");
|
||||
let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider);
|
||||
this.communityContentProviders.splice(index, 1);
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("REMOVE: "+ this.selectedCommunityContentProvider.id);
|
||||
this.subRemove = this._manageCommunityContentProvidersService.removeContentProvider(this.properties, this.community, this.selectedCommunityContentProvider.id).subscribe(
|
||||
data => {
|
||||
console.info("data REMOVE");
|
||||
console.info(data);
|
||||
},
|
||||
err => {
|
||||
console.info("error REMOVE");
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
console.info("completed REMOVE");
|
||||
let index = this.communityContentProviders.indexOf(this.selectedCommunityContentProvider);
|
||||
this.communityContentProviders.splice(index, 1);
|
||||
|
||||
this.communitySearchUtils.totalResults--;
|
||||
this.communitySearchUtils.page=1;
|
||||
this.communitySearchUtils.totalResults--;
|
||||
this.communitySearchUtils.page=1;
|
||||
|
||||
this.rerender();
|
||||
}
|
||||
)
|
||||
this.rerender();
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public removeContentProvider(communityContentProvider: any) {
|
||||
this.selectedCommunityContentProvider = communityContentProvider;
|
||||
this.alertModalDeleteCommunity.cancelButton = true;
|
||||
this.alertModalDeleteCommunity.okButton = true;
|
||||
this.alertModalDeleteCommunity.alertTitle = "Remove content provider?";
|
||||
let title = "";
|
||||
if(communityContentProvider.name) {
|
||||
title = communityContentProvider.name;
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.selectedCommunityContentProvider = communityContentProvider;
|
||||
this.alertModalDeleteCommunity.cancelButton = true;
|
||||
this.alertModalDeleteCommunity.okButton = true;
|
||||
this.alertModalDeleteCommunity.alertTitle = "Remove content provider?";
|
||||
let title = "";
|
||||
if(communityContentProvider.name) {
|
||||
title = communityContentProvider.name;
|
||||
}
|
||||
if(communityContentProvider.name && communityContentProvider.acronym) {
|
||||
title += " (";
|
||||
}
|
||||
if(communityContentProvider.acronym) {
|
||||
title += communityContentProvider.acronym;
|
||||
}
|
||||
if(communityContentProvider.name && communityContentProvider.acronym) {
|
||||
title += ") ";
|
||||
}
|
||||
this.alertModalDeleteCommunity.message = "Content Provider";
|
||||
if(title) {
|
||||
this.alertModalDeleteCommunity.message += " '"+title+"' ";
|
||||
}
|
||||
this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?";
|
||||
this.alertModalDeleteCommunity.okButtonText = "Yes";
|
||||
this.alertModalDeleteCommunity.open();
|
||||
}
|
||||
if(communityContentProvider.name && communityContentProvider.acronym) {
|
||||
title += " (";
|
||||
}
|
||||
if(communityContentProvider.acronym) {
|
||||
title += communityContentProvider.acronym;
|
||||
}
|
||||
if(communityContentProvider.name && communityContentProvider.acronym) {
|
||||
title += ") ";
|
||||
}
|
||||
this.alertModalDeleteCommunity.message = "Content Provider";
|
||||
if(title) {
|
||||
this.alertModalDeleteCommunity.message += " '"+title+"' ";
|
||||
}
|
||||
this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?";
|
||||
this.alertModalDeleteCommunity.okButtonText = "Yes";
|
||||
this.alertModalDeleteCommunity.open();
|
||||
}
|
||||
|
||||
public _getCommunityContentProviders(){
|
||||
this.communitySearchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.communityContentProviders = [];
|
||||
this.communitySearchUtils.totalResults = 0;
|
||||
this.communitySearchUtils.page=1;
|
||||
this.communitySearchUtils.keyword = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("_getCommunityContentProviders");
|
||||
this.communitySearchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.communityContentProviders = [];
|
||||
this.communitySearchUtils.totalResults = 0;
|
||||
this.communitySearchUtils.page=1;
|
||||
this.communitySearchUtils.keyword = "";
|
||||
|
||||
this.subResults = this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.community).subscribe(
|
||||
data => {
|
||||
console.info(data);
|
||||
console.info("search Content Providers [total communityContentProviders:"+data.length+"]");
|
||||
this.communityContentProviders = data;
|
||||
this.subResults = this._searchCommunityContentProvidersService.searchDataproviders(this.properties, this.community).subscribe(
|
||||
data => {
|
||||
console.info(data);
|
||||
console.info("search Content Providers [total communityContentProviders:"+data.length+"]");
|
||||
this.communityContentProviders = data;
|
||||
|
||||
this.communitySearchUtils.totalResults = data.length;
|
||||
this.communitySearchUtils.status = this.errorCodes.DONE;
|
||||
// if(this.communitySearchUtils.totalResults == 0 ){
|
||||
// this.communitySearchUtils.status = this.errorCodes.NONE;
|
||||
// }
|
||||
this.disableForms = false;
|
||||
if(!this.triggered) {
|
||||
this.triggerInitialLoad();
|
||||
} else {
|
||||
var table = $('#dpTable').DataTable();
|
||||
table.clear();
|
||||
this.communitySearchUtils.totalResults = data.length;
|
||||
this.communitySearchUtils.status = this.errorCodes.DONE;
|
||||
// if(this.communitySearchUtils.totalResults == 0 ){
|
||||
// this.communitySearchUtils.status = this.errorCodes.NONE;
|
||||
// }
|
||||
this.disableForms = false;
|
||||
if(!this.triggered) {
|
||||
this.triggerInitialLoad();
|
||||
} else {
|
||||
var table = $('#dpTable').DataTable();
|
||||
table.clear();
|
||||
|
||||
this.rerender();
|
||||
this.rerender();
|
||||
}
|
||||
|
||||
this.communityContentProvidersChanged.emit({
|
||||
value: this.communityContentProviders,
|
||||
});
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
|
||||
if(err.status == '404') {
|
||||
this.communitySearchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.communitySearchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
if(!this.triggered) {
|
||||
this.triggerInitialLoad();
|
||||
} else {
|
||||
var table = $('#dpTable').DataTable();
|
||||
table.clear();
|
||||
|
||||
this.rerender();
|
||||
}
|
||||
}
|
||||
|
||||
this.communityContentProvidersChanged.emit({
|
||||
value: this.communityContentProviders,
|
||||
});
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
|
||||
if(err.status == '404') {
|
||||
this.communitySearchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.communitySearchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
if(!this.triggered) {
|
||||
this.triggerInitialLoad();
|
||||
} else {
|
||||
var table = $('#dpTable').DataTable();
|
||||
table.clear();
|
||||
|
||||
this.rerender();
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
//import { Subject } from 'rxjs/Subject';
|
||||
import {SearchResult} from '../../../openaireLibrary/utils/entities/searchResult';
|
||||
import {ErrorCodes} from '../../../openaireLibrary/utils/properties/errorCodes';
|
||||
|
@ -11,6 +11,9 @@ import {RouterHelper} from '../../../openaireLibrary/utils/routerHelper.class';
|
|||
import {DOI, StringUtils} from '../../../openaireLibrary/utils/string-utils.class';
|
||||
import {ManageCommunityProjectsService} from '../../../services/manageProjects.service';
|
||||
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'add-projects',
|
||||
templateUrl: './add-projects.component.html',
|
||||
|
@ -69,7 +72,7 @@ export class AddProjectsComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute, private _searchProjectsService: SearchProjectsService, private _manageCommunityProjectsService: ManageCommunityProjectsService) {
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _searchProjectsService: SearchProjectsService, private _manageCommunityProjectsService: ManageCommunityProjectsService) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.openaireSearchUtils.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
@ -90,39 +93,49 @@ export class AddProjectsComponent implements OnInit {
|
|||
}
|
||||
|
||||
public addProject(project: SearchResult) {
|
||||
console.info("Add: "+ project.id);
|
||||
this.subAdd = this._manageCommunityProjectsService.addProject(this.properties, this.community, project).subscribe(
|
||||
data => {
|
||||
console.info("data ADD");
|
||||
console.info(data);
|
||||
this.undo[project.id] = data.id;
|
||||
},
|
||||
err => {
|
||||
console.info("error ADD");
|
||||
console.log(err.status);
|
||||
},
|
||||
() => {
|
||||
console.info("completed ADD");
|
||||
}
|
||||
)
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("Add: "+ project.id);
|
||||
this.subAdd = this._manageCommunityProjectsService.addProject(this.properties, this.community, project).subscribe(
|
||||
data => {
|
||||
console.info("data ADD");
|
||||
console.info(data);
|
||||
this.undo[project.id] = data.id;
|
||||
},
|
||||
err => {
|
||||
console.info("error ADD");
|
||||
console.log(err.status);
|
||||
},
|
||||
() => {
|
||||
console.info("completed ADD");
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public removeProject(projectId: string, communityProjectId: string) {
|
||||
console.info("REMOVE: "+ projectId);
|
||||
this.subRemove = this._manageCommunityProjectsService.removeProject(this.properties, this.community, projectId).subscribe(
|
||||
data => {
|
||||
console.info("data REMOVE");
|
||||
console.info(data);
|
||||
},
|
||||
err => {
|
||||
console.info("error REMOVE");
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
console.info("completed REMOVE");
|
||||
this.undo[communityProjectId] = "";
|
||||
}
|
||||
)
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("REMOVE: "+ projectId);
|
||||
this.subRemove = this._manageCommunityProjectsService.removeProject(this.properties, this.community, projectId).subscribe(
|
||||
data => {
|
||||
console.info("data REMOVE");
|
||||
console.info(data);
|
||||
},
|
||||
err => {
|
||||
console.info("error REMOVE");
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
console.info("completed REMOVE");
|
||||
this.undo[communityProjectId] = "";
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public inCommunity(project: any): any {
|
||||
|
@ -144,70 +157,80 @@ export class AddProjectsComponent implements OnInit {
|
|||
}
|
||||
|
||||
getFunders () {
|
||||
console.info("Getting Funders....");
|
||||
this.subFunders = this._searchProjectsService.getFunders(this.properties).subscribe(
|
||||
data => {
|
||||
this.funders = data[1];
|
||||
},
|
||||
err => console.log(err)
|
||||
);
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("Getting Funders....");
|
||||
this.subFunders = this._searchProjectsService.getFunders(this.properties).subscribe(
|
||||
data => {
|
||||
this.funders = data[1];
|
||||
},
|
||||
err => console.log(err)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private _getOpenaireProjects(parameters:string, page: number, size: number){
|
||||
console.info("_getOpenaireProjects");
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("_getOpenaireProjects");
|
||||
if(page > this.pagingLimit) {
|
||||
size=0;
|
||||
}
|
||||
|
||||
if(this.openaireSearchUtils.status == this.errorCodes.LOADING) {
|
||||
this.openaireSearchUtils.status = this.errorCodes.LOADING;
|
||||
if(this.openaireSearchUtils.status == this.errorCodes.LOADING) {
|
||||
this.openaireSearchUtils.status = this.errorCodes.LOADING;
|
||||
|
||||
this.disableForms = true;
|
||||
this.openaireProjects = [];
|
||||
this.openaireSearchUtils.totalResults = 0;
|
||||
this.disableForms = true;
|
||||
this.openaireProjects = [];
|
||||
this.openaireSearchUtils.totalResults = 0;
|
||||
|
||||
this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], this.properties).subscribe(
|
||||
data => {
|
||||
this.undo = {};
|
||||
console.info("total openaire projects = "+data[0]);
|
||||
this.openaireSearchUtils.totalResults = data[0];
|
||||
this.openaireProjects = data[1];
|
||||
this.subResults = this._searchProjectsService.searchProjects(parameters, null, page, size, [], this.properties).subscribe(
|
||||
data => {
|
||||
this.undo = {};
|
||||
console.info("total openaire projects = "+data[0]);
|
||||
this.openaireSearchUtils.totalResults = data[0];
|
||||
this.openaireProjects = data[1];
|
||||
|
||||
//this.searchPage.checkSelectedFilters(this.filters);
|
||||
//this.searchPage.checkSelectedFilters(this.filters);
|
||||
|
||||
this.openaireSearchUtils.status = this.errorCodes.DONE;
|
||||
if(this.openaireSearchUtils.totalResults == 0 ){
|
||||
this.openaireSearchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.openaireSearchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.openaireSearchUtils.totalResults/(this.openaireSearchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
this.openaireSearchUtils.status = this.errorCodes.DONE;
|
||||
if(this.openaireSearchUtils.totalResults == 0 ){
|
||||
this.openaireSearchUtils.status = this.errorCodes.NONE;
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.openaireSearchUtils.totalResults = 0;
|
||||
this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.openaireSearchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
this.disableForms = false;
|
||||
|
||||
if(this.openaireSearchUtils.status == this.errorCodes.DONE) {
|
||||
// Page out of limit!!!
|
||||
let totalPages:any = this.openaireSearchUtils.totalResults/(this.openaireSearchUtils.size);
|
||||
if(!(Number.isInteger(totalPages))) {
|
||||
totalPages = (parseInt(totalPages, 10) + 1);
|
||||
}
|
||||
if(totalPages < page) {
|
||||
this.openaireSearchUtils.totalResults = 0;
|
||||
this.openaireSearchUtils.status = this.errorCodes.OUT_OF_BOUND;
|
||||
}
|
||||
}
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
if(err.status == '404') {
|
||||
this.openaireSearchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.openaireSearchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.openaireSearchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
import { Component, ViewChild, OnInit, ViewEncapsulation, Input } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
|
||||
import {RemoveProjectsComponent} from './remove-projects.component';
|
||||
import {AddProjectsComponent} from './add-projects.component';
|
||||
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'manage-projects',
|
||||
template: `
|
||||
|
@ -48,24 +51,29 @@ export class ManageProjectsComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute) {}
|
||||
constructor(private route: ActivatedRoute, private _router: Router) {}
|
||||
|
||||
public ngOnDestroy() {}
|
||||
|
||||
public updateCommunityProjects() {
|
||||
this.toggle = !this.toggle;
|
||||
if(this.toggle) {
|
||||
this.pageTitle = "Manage projects";
|
||||
// this.toggleLinkMessage = "Missing projects?";
|
||||
|
||||
//if(this.updateCommunityProjectsOnToggle) {
|
||||
this.removeProjectsComponent._getCommunityProjects();
|
||||
this.addProjectsComponent.undo = {};
|
||||
//}
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.updateCommunityProjectsOnToggle = false;
|
||||
this.pageTitle = "Search projects";
|
||||
//this.toggleLinkMessage = "Manage projects";
|
||||
this.toggle = !this.toggle;
|
||||
if(this.toggle) {
|
||||
this.pageTitle = "Manage projects";
|
||||
// this.toggleLinkMessage = "Missing projects?";
|
||||
|
||||
//if(this.updateCommunityProjectsOnToggle) {
|
||||
this.removeProjectsComponent._getCommunityProjects();
|
||||
this.addProjectsComponent.undo = {};
|
||||
//}
|
||||
} else {
|
||||
this.updateCommunityProjectsOnToggle = false;
|
||||
this.pageTitle = "Search projects";
|
||||
//this.toggleLinkMessage = "Manage projects";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, ViewChild, OnInit, ViewEncapsulation, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { Subject } from 'rxjs/Subject';
|
||||
import { DataTableDirective } from 'angular-datatables';
|
||||
|
||||
|
@ -11,6 +11,9 @@ import {SearchCommunityProjectsService} from '../../../openaireLibrary/connect/p
|
|||
import {RouterHelper} from '../../../openaireLibrary/utils/routerHelper.class';
|
||||
import {DOI, StringUtils} from '../../../openaireLibrary/utils/string-utils.class';
|
||||
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'remove-projects',
|
||||
templateUrl: './remove-projects.component.html',
|
||||
|
@ -95,7 +98,7 @@ export class RemoveProjectsComponent implements OnInit {
|
|||
this.communitySearchUtils.keyword = "";
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute, private _manageCommunityProjectsService: ManageCommunityProjectsService, private _searchCommunityProjectsService: SearchCommunityProjectsService) {
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _manageCommunityProjectsService: ManageCommunityProjectsService, private _searchCommunityProjectsService: SearchCommunityProjectsService) {
|
||||
this.errorCodes = new ErrorCodes();
|
||||
this.communitySearchUtils.status = this.errorCodes.LOADING;
|
||||
}
|
||||
|
@ -215,115 +218,130 @@ export class RemoveProjectsComponent implements OnInit {
|
|||
}
|
||||
|
||||
public confirmedDeleteProject(data : any) {
|
||||
console.info("REMOVE: "+ this.selectedCommunityProject.id);
|
||||
this.subRemove = this._manageCommunityProjectsService.removeProject(this.properties, this.community, this.selectedCommunityProject.id).subscribe(
|
||||
data => {
|
||||
console.info("data REMOVE");
|
||||
console.info(data);
|
||||
},
|
||||
err => {
|
||||
console.info("error REMOVE");
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
console.info("completed REMOVE");
|
||||
let index = this.communityProjects.indexOf(this.selectedCommunityProject);
|
||||
this.communityProjects.splice(index, 1);
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("REMOVE: "+ this.selectedCommunityProject.id);
|
||||
this.subRemove = this._manageCommunityProjectsService.removeProject(this.properties, this.community, this.selectedCommunityProject.id).subscribe(
|
||||
data => {
|
||||
console.info("data REMOVE");
|
||||
console.info(data);
|
||||
},
|
||||
err => {
|
||||
console.info("error REMOVE");
|
||||
console.log(err);
|
||||
},
|
||||
() => {
|
||||
console.info("completed REMOVE");
|
||||
let index = this.communityProjects.indexOf(this.selectedCommunityProject);
|
||||
this.communityProjects.splice(index, 1);
|
||||
|
||||
this.communitySearchUtils.totalResults--;
|
||||
this.communitySearchUtils.page=1;
|
||||
this.communitySearchUtils.totalResults--;
|
||||
this.communitySearchUtils.page=1;
|
||||
|
||||
this.rerender();
|
||||
}
|
||||
)
|
||||
this.rerender();
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public removeProject(communityProject: any) {
|
||||
this.selectedCommunityProject = communityProject;
|
||||
this.alertModalDeleteCommunity.cancelButton = true;
|
||||
this.alertModalDeleteCommunity.okButton = true;
|
||||
this.alertModalDeleteCommunity.alertTitle = "Remove project?";
|
||||
let title = "";
|
||||
if(communityProject.name) {
|
||||
title = communityProject.name;
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.selectedCommunityProject = communityProject;
|
||||
this.alertModalDeleteCommunity.cancelButton = true;
|
||||
this.alertModalDeleteCommunity.okButton = true;
|
||||
this.alertModalDeleteCommunity.alertTitle = "Remove project?";
|
||||
let title = "";
|
||||
if(communityProject.name) {
|
||||
title = communityProject.name;
|
||||
}
|
||||
if(communityProject.name && communityProject.acronym) {
|
||||
title += " (";
|
||||
}
|
||||
if(communityProject.acronym) {
|
||||
title += communityProject.acronym;
|
||||
}
|
||||
if(communityProject.name && communityProject.acronym) {
|
||||
title += ")";
|
||||
}
|
||||
this.alertModalDeleteCommunity.message = "Project";
|
||||
if(title) {
|
||||
this.alertModalDeleteCommunity.message += " '"+title+"' ";
|
||||
}
|
||||
this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?";
|
||||
this.alertModalDeleteCommunity.okButtonText = "Yes";
|
||||
this.alertModalDeleteCommunity.open();
|
||||
}
|
||||
if(communityProject.name && communityProject.acronym) {
|
||||
title += " (";
|
||||
}
|
||||
if(communityProject.acronym) {
|
||||
title += communityProject.acronym;
|
||||
}
|
||||
if(communityProject.name && communityProject.acronym) {
|
||||
title += ")";
|
||||
}
|
||||
this.alertModalDeleteCommunity.message = "Project";
|
||||
if(title) {
|
||||
this.alertModalDeleteCommunity.message += " '"+title+"' ";
|
||||
}
|
||||
this.alertModalDeleteCommunity.message += "will be removed from your community. Are you sure?";
|
||||
this.alertModalDeleteCommunity.okButtonText = "Yes";
|
||||
this.alertModalDeleteCommunity.open();
|
||||
}
|
||||
|
||||
public _getCommunityProjects(){
|
||||
this.communitySearchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.communityProjects = [];
|
||||
this.communitySearchUtils.totalResults = 0;
|
||||
this.communitySearchUtils.page=1;
|
||||
this.communitySearchUtils.keyword = "";
|
||||
this.selectedFunder = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.communitySearchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.communityProjects = [];
|
||||
this.communitySearchUtils.totalResults = 0;
|
||||
this.communitySearchUtils.page=1;
|
||||
this.communitySearchUtils.keyword = "";
|
||||
this.selectedFunder = "";
|
||||
|
||||
this.subResults = this._searchCommunityProjectsService.searchProjects(this.properties, this.community).subscribe(
|
||||
data => {
|
||||
console.info(data);
|
||||
console.info("search Projects [total communityProjects:"+data.length+"]");
|
||||
this.communityProjects = data;
|
||||
this.subResults = this._searchCommunityProjectsService.searchProjects(this.properties, this.community).subscribe(
|
||||
data => {
|
||||
console.info(data);
|
||||
console.info("search Projects [total communityProjects:"+data.length+"]");
|
||||
this.communityProjects = data;
|
||||
|
||||
this.communitySearchUtils.totalResults = data.length;
|
||||
this.communitySearchUtils.status = this.errorCodes.DONE;
|
||||
// if(this.communitySearchUtils.totalResults == 0 ){
|
||||
// this.communitySearchUtils.status = this.errorCodes.NONE;
|
||||
// }
|
||||
this.disableForms = false;
|
||||
if(!this.triggered) {
|
||||
this.triggerInitialLoad();
|
||||
} else {
|
||||
var table = $('#dpTable').DataTable();
|
||||
table.clear();
|
||||
this.communitySearchUtils.totalResults = data.length;
|
||||
this.communitySearchUtils.status = this.errorCodes.DONE;
|
||||
// if(this.communitySearchUtils.totalResults == 0 ){
|
||||
// this.communitySearchUtils.status = this.errorCodes.NONE;
|
||||
// }
|
||||
this.disableForms = false;
|
||||
if(!this.triggered) {
|
||||
this.triggerInitialLoad();
|
||||
} else {
|
||||
var table = $('#dpTable').DataTable();
|
||||
table.clear();
|
||||
|
||||
this.rerender();
|
||||
this.rerender();
|
||||
}
|
||||
|
||||
this.communityProjectsChanged.emit({
|
||||
value: this.communityProjects,
|
||||
});
|
||||
|
||||
this.createFunderFilter();
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
|
||||
if(err.status == '404') {
|
||||
this.communitySearchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.communitySearchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
if(!this.triggered) {
|
||||
this.triggerInitialLoad();
|
||||
} else {
|
||||
var table = $('#dpTable').DataTable();
|
||||
table.clear();
|
||||
|
||||
this.rerender();
|
||||
}
|
||||
}
|
||||
|
||||
this.communityProjectsChanged.emit({
|
||||
value: this.communityProjects,
|
||||
});
|
||||
|
||||
this.createFunderFilter();
|
||||
},
|
||||
err => {
|
||||
console.log(err);
|
||||
//TODO check erros (service not available, bad request)
|
||||
|
||||
if(err.status == '404') {
|
||||
this.communitySearchUtils.status = this.errorCodes.NOT_FOUND;
|
||||
} else if(err.status == '500') {
|
||||
this.communitySearchUtils.status = this.errorCodes.ERROR;
|
||||
} else {
|
||||
this.communitySearchUtils.status = this.errorCodes.NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
this.disableForms = false;
|
||||
if(!this.triggered) {
|
||||
this.triggerInitialLoad();
|
||||
} else {
|
||||
var table = $('#dpTable').DataTable();
|
||||
table.clear();
|
||||
|
||||
this.rerender();
|
||||
}
|
||||
}
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private createFunderFilter(): Set<String> {
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
import {Component, OnInit, Input} from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms";
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { Page } from "../../domain/page";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'divId-form',
|
||||
templateUrl: './divId-form.component.html',
|
||||
|
@ -27,7 +30,7 @@ export class DivIdFormComponent implements OnInit{
|
|||
public showLoading: boolean = false;
|
||||
public errorMessage: string = '';
|
||||
selectedCommunityPid = null;
|
||||
constructor(private route: ActivatedRoute, public _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
||||
constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.data
|
||||
|
@ -44,49 +47,59 @@ export class DivIdFormComponent implements OnInit{
|
|||
}
|
||||
|
||||
getPages(includedPages: Set<String>) {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
|
||||
this._helpContentService.getPages(this.properties.adminToolsAPIURL,this.selectedCommunityPid).subscribe(
|
||||
pages => {
|
||||
//this.allPages = allPages;
|
||||
for(let page of pages) {
|
||||
if(includedPages.has(page._id)) {
|
||||
this.allPages.set(page, true);
|
||||
} else {
|
||||
this.allPages.set(page, false);
|
||||
this._helpContentService.getPages(this.properties.adminToolsAPIURL,this.selectedCommunityPid).subscribe(
|
||||
pages => {
|
||||
//this.allPages = allPages;
|
||||
for(let page of pages) {
|
||||
if(includedPages.has(page._id)) {
|
||||
this.allPages.set(page, true);
|
||||
} else {
|
||||
this.allPages.set(page, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error)
|
||||
);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public toggle() {
|
||||
this.myForm.value.isCollapsed = !this.myForm.value.isCollapsed;
|
||||
///////
|
||||
if(!this.myForm.value.isCollapsed) {
|
||||
let includedPages: Set<String> = new Set<String>();
|
||||
for(let pageName of this.myForm.value.pages) {
|
||||
includedPages.add(pageName._id);
|
||||
}
|
||||
|
||||
let allPages = this.allPages;
|
||||
|
||||
let self = this;
|
||||
allPages.forEach(function (status, page, map) {
|
||||
if(includedPages.has(page._id)) {
|
||||
self.allPages.set(page, true);
|
||||
} else {
|
||||
self.allPages.set(page, false);
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.myForm.value.isCollapsed = !this.myForm.value.isCollapsed;
|
||||
///////
|
||||
if(!this.myForm.value.isCollapsed) {
|
||||
let includedPages: Set<String> = new Set<String>();
|
||||
for(let pageName of this.myForm.value.pages) {
|
||||
includedPages.add(pageName._id);
|
||||
}
|
||||
});
|
||||
|
||||
let allPages = this.allPages;
|
||||
|
||||
let self = this;
|
||||
allPages.forEach(function (status, page, map) {
|
||||
if(includedPages.has(page._id)) {
|
||||
self.allPages.set(page, true);
|
||||
} else {
|
||||
self.allPages.set(page, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if(!this.gotPages) {
|
||||
this.gotPages = true;
|
||||
this.getPages(includedPages);
|
||||
if(!this.gotPages) {
|
||||
this.gotPages = true;
|
||||
this.getPages(includedPages);
|
||||
}
|
||||
}
|
||||
}
|
||||
/////
|
||||
|
@ -149,21 +162,26 @@ export class DivIdFormComponent implements OnInit{
|
|||
}
|
||||
}*/
|
||||
|
||||
let index: number = -1;
|
||||
for(let i=0; i<this.myForm.get('pages').value.length; i++) {
|
||||
if(this.myForm.get('pages').value[i]._id == page._id) {
|
||||
index = i;
|
||||
break;
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
let index: number = -1;
|
||||
for(let i=0; i<this.myForm.get('pages').value.length; i++) {
|
||||
if(this.myForm.get('pages').value[i]._id == page._id) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.allPages.set(page, status);
|
||||
this.allPages.set(page, status);
|
||||
|
||||
if(status && index<0) {
|
||||
this.myForm.value.pages.push(page);
|
||||
} else if(!status){
|
||||
if(index >= 0) {
|
||||
this.myForm.value.pages.splice(index, 1);
|
||||
if(status && index<0) {
|
||||
this.myForm.value.pages.push(page);
|
||||
} else if(!status){
|
||||
if(index >= 0) {
|
||||
this.myForm.value.pages.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { ModalFormComponent } from "../modal-form.component";
|
||||
|
@ -10,6 +10,9 @@ import { CheckDivId, DivId } from "../../domain/divId";
|
|||
import { Page } from "../../domain/page";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'divIds',
|
||||
templateUrl: './divIds.component.html',
|
||||
|
@ -63,9 +66,13 @@ export class DivIdsComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _helpContentService: HelpContentService) {}
|
||||
|
||||
getDivIds() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
@ -83,6 +90,7 @@ export class DivIdsComponent implements OnInit {
|
|||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving classes', error));
|
||||
}
|
||||
}
|
||||
|
||||
// public showModal():void {
|
||||
|
@ -124,15 +132,24 @@ export class DivIdsComponent implements OnInit {
|
|||
}
|
||||
|
||||
private confirmModalOpen() {
|
||||
this.alertModalDeleteDivIds.cancelButton = true;
|
||||
this.alertModalDeleteDivIds.okButton = true;
|
||||
this.alertModalDeleteDivIds.alertTitle = "Delete Confirmation";
|
||||
this.alertModalDeleteDivIds.message = "Are you sure you want to delete the selected class(es)?";
|
||||
this.alertModalDeleteDivIds.okButtonText = "Yes";
|
||||
this.alertModalDeleteDivIds.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.alertModalDeleteDivIds.cancelButton = true;
|
||||
this.alertModalDeleteDivIds.okButton = true;
|
||||
this.alertModalDeleteDivIds.alertTitle = "Delete Confirmation";
|
||||
this.alertModalDeleteDivIds.message = "Are you sure you want to delete the selected class(es)?";
|
||||
this.alertModalDeleteDivIds.okButtonText = "Yes";
|
||||
this.alertModalDeleteDivIds.open();
|
||||
}
|
||||
}
|
||||
|
||||
public confirmedDeleteDivIds(data: any) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -143,6 +160,7 @@ export class DivIdsComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error deleting the selected classes', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public editDivId(i : number) {
|
||||
|
@ -170,39 +188,54 @@ export class DivIdsComponent implements OnInit {
|
|||
}
|
||||
|
||||
private divIdsModalOpen(modal: any, title: string, yesBtn: string) {
|
||||
modal.cancelButton = true;
|
||||
modal.okButton = true;
|
||||
modal.alertTitle = title;
|
||||
modal.okButtonText = yesBtn;
|
||||
modal.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
modal.cancelButton = true;
|
||||
modal.okButton = true;
|
||||
modal.alertTitle = title;
|
||||
modal.okButtonText = yesBtn;
|
||||
modal.open();
|
||||
}
|
||||
}
|
||||
|
||||
public divIdSaveConfirmed(data: any) {
|
||||
if(!this.formGroup.valid) {
|
||||
this.divIdsModalOpen(this.alertModalSaveDivId, "Save", "Add a new Class");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.modalErrorMessage = "";
|
||||
this._helpContentService.saveDivId(<DivId> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
divId => {
|
||||
this.divIdSavedSuccessfully(divId);
|
||||
},
|
||||
error => this.handleUpdateError("System error creating class", error)
|
||||
);
|
||||
if(!this.formGroup.valid) {
|
||||
this.divIdsModalOpen(this.alertModalSaveDivId, "Save", "Add a new Class");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
} else {
|
||||
this.modalErrorMessage = "";
|
||||
this._helpContentService.saveDivId(<DivId> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
divId => {
|
||||
this.divIdSavedSuccessfully(divId);
|
||||
},
|
||||
error => this.handleUpdateError("System error creating class", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public divIdUpdateConfirmed(data: any) {
|
||||
if(!this.formGroup.valid) {
|
||||
this.divIdsModalOpen(this.alertModalUpdateDivId, "Update", "Update Class");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this._helpContentService.updateDivId(<DivId> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
divId => {
|
||||
this.divIdUpdatedSuccessfully(divId);
|
||||
},
|
||||
error => this.handleUpdateError("System error updating class", error)
|
||||
);
|
||||
if(!this.formGroup.valid) {
|
||||
this.divIdsModalOpen(this.alertModalUpdateDivId, "Update", "Update Class");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
} else {
|
||||
this._helpContentService.updateDivId(<DivId> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
divId => {
|
||||
this.divIdUpdatedSuccessfully(divId);
|
||||
},
|
||||
error => this.handleUpdateError("System error updating class", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
|
||||
import { Page } from "../../domain/page";
|
||||
import { DivId } from "../../domain/divId";
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'div-content-form',
|
||||
|
@ -41,7 +43,7 @@ export class DivContentFormComponent implements OnInit{
|
|||
public errorMessage: string = '';
|
||||
@Input() updateErrorMessage: string = '';
|
||||
|
||||
constructor(private route: ActivatedRoute, private _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
||||
|
||||
ngOnInit() {
|
||||
this.myForm = this.form;
|
||||
|
@ -50,28 +52,38 @@ export class DivContentFormComponent implements OnInit{
|
|||
this.properties = data.envSpecific;
|
||||
this.route.queryParams.subscribe(params => {
|
||||
|
||||
if(this.pageId) {
|
||||
this.showPageSelect = false;
|
||||
this.getDivs(this.pageId);
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} 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));
|
||||
}
|
||||
}
|
||||
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);
|
||||
this.getCommunity(this.communityPid);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public pageSelected(event) {
|
||||
this.getDivs(event.target.value);
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.getDivs(event.target.value);
|
||||
}
|
||||
}
|
||||
|
||||
public divIdSelected(div: DivId) {
|
||||
|
@ -79,34 +91,44 @@ export class DivContentFormComponent implements OnInit{
|
|||
}
|
||||
|
||||
public getCommunity(communityPid: string) {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = '';
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
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._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)
|
||||
);
|
||||
this.myForm.patchValue({
|
||||
community: this.communityId
|
||||
});
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving community', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public getDivs(pageId: string) {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = '';
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = '';
|
||||
|
||||
this._helpContentService.getDivIdsFull(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||
divs => {
|
||||
this.availableDivs = divs;
|
||||
this.pageId = pageId;
|
||||
this._helpContentService.getDivIdsFull(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||
divs => {
|
||||
this.availableDivs = divs;
|
||||
this.pageId = pageId;
|
||||
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error));
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error));
|
||||
}
|
||||
}
|
||||
|
||||
// public selectedDiv(event) {
|
||||
|
|
|
@ -10,6 +10,9 @@ import { DivId } from "../../domain/divId";
|
|||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'div-help-contents',
|
||||
templateUrl: './div-help-contents.component.html',
|
||||
|
@ -75,19 +78,28 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
constructor(private route: ActivatedRoute, private _helpService: HelpContentService, private router : Router) {}
|
||||
|
||||
getPage(pageId: string) {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
||||
this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.page = page;
|
||||
this.getDivHelpContents(this.selectedCommunityPid);
|
||||
},
|
||||
error => this.handleError('System error retrieving page', error));
|
||||
this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.page = page;
|
||||
this.getDivHelpContents(this.selectedCommunityPid);
|
||||
},
|
||||
error => this.handleError('System error retrieving page', error));
|
||||
}
|
||||
}
|
||||
|
||||
getPages(community_pid: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
@ -98,6 +110,7 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
this.getDivHelpContents(this.selectedCommunityPid);
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error));
|
||||
}
|
||||
}
|
||||
|
||||
public countDivHelpContents() {
|
||||
|
@ -114,6 +127,10 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
}
|
||||
|
||||
getDivHelpContents(community_pid: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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>;
|
||||
|
@ -137,6 +154,7 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving page contents', error));
|
||||
}
|
||||
}
|
||||
|
||||
public toggleCheckBoxes(event) {
|
||||
|
@ -169,15 +187,24 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
}
|
||||
|
||||
private confirmModalOpen() {
|
||||
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();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -188,6 +215,7 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error deleting the selected class content(s)', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private deleteDivHelpContentsFromArray(ids : string[]) : void {
|
||||
|
@ -210,6 +238,10 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
}
|
||||
|
||||
public toggleDivHelpContents(status : boolean, ids : string[]) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -226,6 +258,7 @@ export class DivHelpContentsComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error changing the status of the selected page content(s)', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public divHelpContentSavedSuccessfully(divHelpContent: DivHelpContent) {
|
||||
|
|
|
@ -6,6 +6,9 @@ import { DivHelpContent } from "../../domain/div-help-content";
|
|||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'edit-div-help-content',
|
||||
templateUrl: 'edit-div-help-content.component.html',
|
||||
|
@ -65,19 +68,28 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
|
|||
}
|
||||
|
||||
private getDivHelpContent(divContentId: string) {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
this.updateErrorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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).subscribe(
|
||||
divHelpContent => {
|
||||
this.updateForm(divHelpContent);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving class help content', error));
|
||||
this._helpContentService.getDivHelpContent(divContentId, this.properties.adminToolsAPIURL).subscribe(
|
||||
divHelpContent => {
|
||||
this.updateForm(divHelpContent);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving class help content', error));
|
||||
}
|
||||
}
|
||||
|
||||
getDivId(divId: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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).subscribe(
|
||||
|
@ -87,11 +99,12 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
|
|||
if(!this.pageId) {
|
||||
this.formComponent.getDivs("");
|
||||
}
|
||||
|
||||
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving class', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private updateForm(divHelpContent : DivHelpContent) {
|
||||
|
@ -103,6 +116,10 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
|
|||
}
|
||||
|
||||
private saveCustom() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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 = "";
|
||||
|
@ -124,6 +141,7 @@ export class EditDivHelpContentComponent implements OnInit, OnDestroy{
|
|||
} else {
|
||||
this.errorMessage = "Please fill all required fields";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private cancelCustom() {
|
||||
|
|
|
@ -5,6 +5,9 @@ import { DivHelpContent } from "../../domain/div-help-content";
|
|||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'new-div-help-content',
|
||||
templateUrl: 'new-div-help-content.component.html',
|
||||
|
@ -43,6 +46,10 @@ export class NewDivHelpContentComponent {
|
|||
}
|
||||
|
||||
private saveCustom() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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 = "";
|
||||
|
@ -64,6 +71,7 @@ export class NewDivHelpContentComponent {
|
|||
} else {
|
||||
this.errorMessage = "Please fill all required fields";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private cancelCustom() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { ModalFormComponent } from "../modal-form.component";
|
||||
|
@ -9,6 +9,7 @@ import { CheckEntity, Entity } from "../../domain/entity";
|
|||
import { Community } from "../../domain/community";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'entities',
|
||||
|
@ -68,8 +69,12 @@ export class EntitiesComponent implements OnInit {
|
|||
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _helpContentService: HelpContentService) {}
|
||||
getEntities(community_pid: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
@ -87,6 +92,7 @@ export class EntitiesComponent implements OnInit {
|
|||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving entities', error));
|
||||
}
|
||||
}
|
||||
|
||||
// public showModal():void {
|
||||
|
@ -128,15 +134,24 @@ export class EntitiesComponent implements OnInit {
|
|||
}
|
||||
|
||||
private confirmDeleteEntitiesModalOpen() {
|
||||
this.alertModalDeleteEntities.cancelButton = true;
|
||||
this.alertModalDeleteEntities.okButton = true;
|
||||
this.alertModalDeleteEntities.alertTitle = "Delete Confirmation";
|
||||
this.alertModalDeleteEntities.message = "Are you sure you want to delete the selected entity(-ies)?";
|
||||
this.alertModalDeleteEntities.okButtonText = "Yes";
|
||||
this.alertModalDeleteEntities.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.alertModalDeleteEntities.cancelButton = true;
|
||||
this.alertModalDeleteEntities.okButton = true;
|
||||
this.alertModalDeleteEntities.alertTitle = "Delete Confirmation";
|
||||
this.alertModalDeleteEntities.message = "Are you sure you want to delete the selected entity(-ies)?";
|
||||
this.alertModalDeleteEntities.okButtonText = "Yes";
|
||||
this.alertModalDeleteEntities.open();
|
||||
}
|
||||
}
|
||||
|
||||
public confirmedDeleteEntities(data: any) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -147,6 +162,7 @@ export class EntitiesComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error deleting the selected entities', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public editEntity(i : number) {
|
||||
|
@ -164,39 +180,54 @@ export class EntitiesComponent implements OnInit {
|
|||
}
|
||||
|
||||
private entitiesModalOpen(modal: any, title: string, yesBtn: string) {
|
||||
modal.cancelButton = true;
|
||||
modal.okButton = true;
|
||||
modal.alertTitle = title;
|
||||
modal.okButtonText = yesBtn;
|
||||
modal.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
modal.cancelButton = true;
|
||||
modal.okButton = true;
|
||||
modal.alertTitle = title;
|
||||
modal.okButtonText = yesBtn;
|
||||
modal.open();
|
||||
}
|
||||
}
|
||||
|
||||
public entitySaveConfirmed(data: any) {
|
||||
if(!this.formGroup.valid) {
|
||||
this.entitiesModalOpen(this.alertModalSaveEntity, "Save", "Add a new Entity");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.modalErrorMessage = "";
|
||||
this._helpContentService.saveEntity(<Entity> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
entity => {
|
||||
this.entitySavedSuccessfully(entity);
|
||||
},
|
||||
error => this.handleUpdateError("System error creating entity", error)
|
||||
);
|
||||
if(!this.formGroup.valid) {
|
||||
this.entitiesModalOpen(this.alertModalSaveEntity, "Save", "Add a new Entity");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
} else {
|
||||
this.modalErrorMessage = "";
|
||||
this._helpContentService.saveEntity(<Entity> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
entity => {
|
||||
this.entitySavedSuccessfully(entity);
|
||||
},
|
||||
error => this.handleUpdateError("System error creating entity", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public entityUpdateConfirmed(data: any) {
|
||||
if(!this.formGroup.valid) {
|
||||
this.entitiesModalOpen(this.alertModalUpdateEntity, "Update", "Update Entity");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this._helpContentService.updateEntity(<Entity> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
entity => {
|
||||
this.entityUpdatedSuccessfully(entity);
|
||||
},
|
||||
error => this.handleUpdateError("System error updating entity", error)
|
||||
);
|
||||
if(!this.formGroup.valid) {
|
||||
this.entitiesModalOpen(this.alertModalUpdateEntity, "Update", "Update Entity");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
} else {
|
||||
this._helpContentService.updateEntity(<Entity> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
entity => {
|
||||
this.entityUpdatedSuccessfully(entity);
|
||||
},
|
||||
error => this.handleUpdateError("System error updating entity", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -257,29 +288,39 @@ export class EntitiesComponent implements OnInit {
|
|||
}
|
||||
|
||||
private confirmRelatedPagesModalOpen() {
|
||||
this.alertModalRelatedPages.cancelButton = true;
|
||||
this.alertModalRelatedPages.okButton = true;
|
||||
this.alertModalRelatedPages.alertTitle = "Warning";
|
||||
this.alertModalRelatedPages.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.alertModalRelatedPages.okButtonText = "Yes";
|
||||
this.alertModalRelatedPages.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.alertModalRelatedPages.cancelButton = true;
|
||||
this.alertModalRelatedPages.okButton = true;
|
||||
this.alertModalRelatedPages.alertTitle = "Warning";
|
||||
this.alertModalRelatedPages.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.alertModalRelatedPages.okButtonText = "Yes";
|
||||
this.alertModalRelatedPages.open();
|
||||
}
|
||||
}
|
||||
|
||||
public continueToggling(event: any) {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
this._helpContentService.toggleEntities(this.selectedCommunityPid,this.toggleIds,this.toggleStatus, this.properties.adminToolsAPIURL).subscribe(
|
||||
() => {
|
||||
for(let id of this.toggleIds) {
|
||||
let i = this.checkboxes.findIndex(_ => _.entity._id == id);
|
||||
this.checkboxes[i].entity.isEnabled=this.toggleStatus;
|
||||
}
|
||||
this.applyCheck(false);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleUpdateError('System error changing the status of the selected entity(-ies)', error)
|
||||
);
|
||||
this._helpContentService.toggleEntities(this.selectedCommunityPid,this.toggleIds,this.toggleStatus, this.properties.adminToolsAPIURL).subscribe(
|
||||
() => {
|
||||
for(let id of this.toggleIds) {
|
||||
let i = this.checkboxes.findIndex(_ => _.entity._id == id);
|
||||
this.checkboxes[i].entity.isEnabled=this.toggleStatus;
|
||||
}
|
||||
this.applyCheck(false);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleUpdateError('System error changing the status of the selected entity(-ies)', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,6 +9,9 @@ import { PageHelpContent } from "../../domain/page-help-content";
|
|||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'edit-page-help-content',
|
||||
templateUrl: 'edit-page-help-content.component.html',
|
||||
|
@ -69,16 +72,21 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
|
|||
}
|
||||
|
||||
private getPageHelpContent(pageContentId: string) {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
this.updateErrorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL).subscribe(
|
||||
pageHelpContent => {
|
||||
this.updateForm(pageHelpContent);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving page help content', error));
|
||||
this._helpContentService.getPageHelpContent(pageContentId as string, this.properties.adminToolsAPIURL).subscribe(
|
||||
pageHelpContent => {
|
||||
this.updateForm(pageHelpContent);
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving page help content', error));
|
||||
}
|
||||
}
|
||||
|
||||
private updateForm(pageHelpContent : PageHelpContent) {
|
||||
|
@ -89,6 +97,10 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
|
|||
}
|
||||
|
||||
private saveCustom() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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 = "";
|
||||
|
@ -109,6 +121,7 @@ export class EditPageHelpContentComponent implements OnInit, OnDestroy{
|
|||
} else {
|
||||
this.errorMessage = "Please fill all required fields";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private cancelCustom() {
|
||||
|
|
|
@ -8,6 +8,9 @@ import { PageHelpContent } from "../../domain/page-help-content";
|
|||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'new-page-help-content',
|
||||
templateUrl: 'new-page-help-content.component.html',
|
||||
|
@ -46,7 +49,10 @@ export class NewPageHelpContentComponent {
|
|||
}
|
||||
|
||||
private saveCustom() {
|
||||
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
//this.errorMessage = null;
|
||||
|
||||
if(this.formComponent.myForm.valid) {
|
||||
|
@ -69,6 +75,7 @@ export class NewPageHelpContentComponent {
|
|||
} else {
|
||||
this.errorMessage = "Please fill all required fields";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private cancelCustom() {
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { Component, OnInit, Input } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { FormGroup, FormBuilder, Validators } from "@angular/forms";
|
||||
import { Page } from "../../domain/page";
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'page-content-form',
|
||||
|
@ -30,7 +32,7 @@ export class PageContentFormComponent implements OnInit{
|
|||
public errorMessage: string = '';
|
||||
@Input() updateErrorMessage: string = '';
|
||||
|
||||
constructor(private route: ActivatedRoute,private _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
||||
|
||||
ngOnInit() {
|
||||
this.myForm = this.form;
|
||||
|
@ -38,12 +40,17 @@ export class PageContentFormComponent implements OnInit{
|
|||
.subscribe((data: { envSpecific: EnvProperties }) => {
|
||||
this.properties = data.envSpecific;
|
||||
|
||||
this._helpContentService.getPages(this.properties.adminToolsAPIURL, this.communityPid).subscribe(
|
||||
pages => {
|
||||
this.availablePages = pages;
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error));
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this._helpContentService.getPages(this.properties.adminToolsAPIURL, this.communityPid).subscribe(
|
||||
pages => {
|
||||
this.availablePages = pages;
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -3,16 +3,18 @@
|
|||
*/
|
||||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { DeleteConfirmationDialogComponent } from "../delete-confirmation-dialog.component";
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { PageHelpContent, CheckPageHelpContent, PageHelpContentFilterOptions } from "../../domain/page-help-content";
|
||||
import { Page } from "../../domain/page";
|
||||
import {Router} from "@angular/router";
|
||||
import { Community } from "../../domain/community";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
import {SafeHtmlPipe} from '../../openaireLibrary/utils/pipes/safeHTML.pipe';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'page-help-contents',
|
||||
templateUrl: './page-help-contents.component.html',
|
||||
|
@ -86,32 +88,42 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
// this.formGroup = this.formComponent.form;
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute, private _helpService: HelpContentService, private router : Router) {}
|
||||
constructor(private route: ActivatedRoute, private router : Router, private _helpService: HelpContentService) {}
|
||||
|
||||
getPage(pageId: string) {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
||||
this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.page = page;
|
||||
this.getPageHelpContents(this.selectedCommunityPid);
|
||||
},
|
||||
error => this.handleError('System error retrieving page', error));
|
||||
this._helpService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.page = page;
|
||||
this.getPageHelpContents(this.selectedCommunityPid);
|
||||
},
|
||||
error => this.handleError('System error retrieving page', error));
|
||||
}
|
||||
}
|
||||
|
||||
getPages(community_pid: string) {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
||||
this._helpService.getCommunityPages(community_pid, "", this.properties.adminToolsAPIURL).subscribe(
|
||||
pages => {
|
||||
this.pages = pages;
|
||||
this.getPageHelpContents(this.selectedCommunityPid);
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error));
|
||||
this._helpService.getCommunityPages(community_pid, "", this.properties.adminToolsAPIURL).subscribe(
|
||||
pages => {
|
||||
this.pages = pages;
|
||||
this.getPageHelpContents(this.selectedCommunityPid);
|
||||
},
|
||||
error => this.handleError('System error retrieving pages', error));
|
||||
}
|
||||
}
|
||||
|
||||
public countPageHelpContents() {
|
||||
|
@ -128,6 +140,10 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
}
|
||||
|
||||
getPageHelpContents(community_pid: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this._helpService.getCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe(
|
||||
pageHelpContents => {
|
||||
this.pageHelpContents = pageHelpContents as Array<PageHelpContent>;
|
||||
|
@ -148,6 +164,7 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving page contents', error));
|
||||
}
|
||||
}
|
||||
|
||||
// public showModal():void {
|
||||
|
@ -184,15 +201,24 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
}
|
||||
|
||||
private confirmModalOpen() {
|
||||
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();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -203,6 +229,7 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error deleting the selected page content(s)', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private deletePageHelpContentsFromArray(ids : string[]) : void {
|
||||
|
@ -225,6 +252,10 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
}
|
||||
|
||||
public togglePageHelpContents(status : boolean, ids : string[]) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -242,6 +273,7 @@ export class PageHelpContentsComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error changing the status of the selected page content(s)', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public pageHelpContentSavedSuccessfully(pageHelpContent: PageHelpContent) {
|
||||
|
|
|
@ -10,6 +10,9 @@ import { HtmlPageContentFormComponent } from "./html-page-content-form.component
|
|||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
import { Subscription } from "rxjs/Subscription";
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'edit-htmlpage-content',
|
||||
templateUrl: './edit-htmlpage-content.component.html',
|
||||
|
@ -74,27 +77,37 @@ export class EditHtmlPageContentComponent implements OnInit {
|
|||
}
|
||||
|
||||
private getPage(communityId: string, pageId: string) {
|
||||
this._helpContentService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.pageName = page.name;
|
||||
this.getHtmlPageContent(communityId, page.route);
|
||||
},
|
||||
error => this.handleError('System error retrieving page', error));
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this._helpContentService.getPage(pageId, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.pageName = page.name;
|
||||
this.getHtmlPageContent(communityId, page.route);
|
||||
},
|
||||
error => this.handleError('System error retrieving page', error));
|
||||
}
|
||||
}
|
||||
|
||||
private getHtmlPageContent(communityId: string, pageRoute: string) {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
this.updateErrorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
this.router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this.router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
this._htmlContentService.getHtmlPageContent(communityId, pageRoute, this.properties.adminToolsAPIURL).subscribe(
|
||||
htmlPageContent => {
|
||||
if(htmlPageContent.length > 0) {
|
||||
this.updateForm(htmlPageContent[0]);
|
||||
}
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving page help content', error));
|
||||
this._htmlContentService.getHtmlPageContent(communityId, pageRoute, this.properties.adminToolsAPIURL).subscribe(
|
||||
htmlPageContent => {
|
||||
if(htmlPageContent.length > 0) {
|
||||
this.updateForm(htmlPageContent[0]);
|
||||
}
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving page help content', error));
|
||||
}
|
||||
}
|
||||
|
||||
private updateForm(htmlPageContent : HtmlPageContent) {
|
||||
|
@ -103,6 +116,10 @@ export class EditHtmlPageContentComponent implements OnInit {
|
|||
}
|
||||
|
||||
private saveCustom() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this.router.url);
|
||||
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 = "";
|
||||
|
@ -124,6 +141,7 @@ export class EditHtmlPageContentComponent implements OnInit {
|
|||
this.mode = "edit";
|
||||
this.errorMessage = "Please fill all required fields";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private cancelCustom() {
|
||||
|
|
|
@ -2,12 +2,15 @@
|
|||
* Created by stefania on 7/13/17.
|
||||
*/
|
||||
import {Component, OnInit, Input} from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import {FormGroup, FormArray, FormBuilder, Validators} from "@angular/forms";
|
||||
import {Entity} from '../../domain/entity';
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'page-form',
|
||||
templateUrl: './page-form.component.html',
|
||||
|
@ -29,7 +32,7 @@ export class PageFormComponent implements OnInit{
|
|||
public showLoading: boolean = false;
|
||||
public errorMessage: string = '';
|
||||
|
||||
constructor(private route: ActivatedRoute,public _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
||||
constructor(private route: ActivatedRoute, private _router: Router, public _fb: FormBuilder, private _helpContentService: HelpContentService){}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.route.data
|
||||
|
@ -39,49 +42,59 @@ export class PageFormComponent implements OnInit{
|
|||
}
|
||||
|
||||
public toggle() {
|
||||
this.myForm.value.isCollapsed = !this.myForm.value.isCollapsed;
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.myForm.value.isCollapsed = !this.myForm.value.isCollapsed;
|
||||
|
||||
if(!this.myForm.value.isCollapsed) {
|
||||
let includedEntities: Set<String> = new Set<String>();
|
||||
for(let entityName of this.myForm.value.entities) {
|
||||
includedEntities.add(entityName._id);
|
||||
}
|
||||
|
||||
let allEntities = this.allEntities;
|
||||
|
||||
let self = this;
|
||||
allEntities.forEach(function (status, entity, map) {
|
||||
if(includedEntities.has(entity._id)) {
|
||||
self.allEntities.set(entity, true);
|
||||
} else {
|
||||
self.allEntities.set(entity, false);
|
||||
if(!this.myForm.value.isCollapsed) {
|
||||
let includedEntities: Set<String> = new Set<String>();
|
||||
for(let entityName of this.myForm.value.entities) {
|
||||
includedEntities.add(entityName._id);
|
||||
}
|
||||
});
|
||||
|
||||
let allEntities = this.allEntities;
|
||||
|
||||
let self = this;
|
||||
allEntities.forEach(function (status, entity, map) {
|
||||
if(includedEntities.has(entity._id)) {
|
||||
self.allEntities.set(entity, true);
|
||||
} else {
|
||||
self.allEntities.set(entity, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if(!this.gotEntities) {
|
||||
this.gotEntities = true;
|
||||
this.getEntities(includedEntities);
|
||||
if(!this.gotEntities) {
|
||||
this.gotEntities = true;
|
||||
this.getEntities(includedEntities);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public getEntities(includedEntities: Set<String>) {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.errorMessage = "";
|
||||
|
||||
this._helpContentService.getEntities(this.properties.adminToolsAPIURL).subscribe(
|
||||
entities => {
|
||||
for(let entity of entities) {
|
||||
if(includedEntities.has(entity._id)) {
|
||||
this.allEntities.set(entity, true);
|
||||
} else {
|
||||
this.allEntities.set(entity, false);
|
||||
this._helpContentService.getEntities(this.properties.adminToolsAPIURL).subscribe(
|
||||
entities => {
|
||||
for(let entity of entities) {
|
||||
if(includedEntities.has(entity._id)) {
|
||||
this.allEntities.set(entity, true);
|
||||
} else {
|
||||
this.allEntities.set(entity, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving community entities', error));
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving community entities', error));
|
||||
}
|
||||
}
|
||||
|
||||
public getKeys( map) {
|
||||
|
@ -128,21 +141,26 @@ export class PageFormComponent implements OnInit{
|
|||
}
|
||||
|
||||
public toggleEntity(status : boolean, id : string, entity: Entity) {
|
||||
let index: number = -1;
|
||||
for(let i=0; i<this.myForm.get('entities').value.length; i++) {
|
||||
if(this.myForm.get('entities').value[i]._id == entity._id) {
|
||||
index = i;
|
||||
break;
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
let index: number = -1;
|
||||
for(let i=0; i<this.myForm.get('entities').value.length; i++) {
|
||||
if(this.myForm.get('entities').value[i]._id == entity._id) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.allEntities.set(entity, status);
|
||||
this.allEntities.set(entity, status);
|
||||
|
||||
if(status && index<0) {
|
||||
this.myForm.value.entities.push(entity);
|
||||
} else if(!status){
|
||||
if(index >= 0) {
|
||||
this.myForm.value.entities.splice(index, 1);
|
||||
if(status && index<0) {
|
||||
this.myForm.value.entities.push(entity);
|
||||
} else if(!status){
|
||||
if(index >= 0) {
|
||||
this.myForm.value.entities.splice(index, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,10 +134,10 @@
|
|||
<!-- <fab *ngIf="isPortalAdministrator" (clicked)="showModal()"></fab> -->
|
||||
<fab *ngIf="isPortalAdministrator" (clicked)="newPage()"></fab>
|
||||
</div>
|
||||
<modal-form #saveModal [saveText]="'Save'" [titleText]="'Add a new Page'" [formGroup]="formGroup" [type]="'page'"
|
||||
<!-- <modal-form #saveModal [saveText]="'Save'" [titleText]="'Add a new Page'" [formGroup]="formGroup" [type]="'page'"
|
||||
[isModalShown]="isModalShown" (emmitObject)="pageSavedSuccessfully($event)" (emmitError)="handleUpdateError($event)">
|
||||
<page-form [group]="formGroup"></page-form>
|
||||
</modal-form>
|
||||
</modal-form> -->
|
||||
|
||||
<!--<modal-form #updateModal [saveText]="'Update'" [titleText]="'Update Page'" [formGroup]="formGroup" [type]="'page'"
|
||||
[isModalShown]="isModalShown" (emmitObject)="pageUpdatedSuccessfully($event)" (emmitError)="handleUpdateError($event)">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
* Created by stefania on 7/13/17.
|
||||
*/
|
||||
import { Component, ViewChild, OnInit } from '@angular/core';
|
||||
import { ActivatedRoute } from "@angular/router";
|
||||
import { ActivatedRoute, Router } from "@angular/router";
|
||||
import { HelpContentService } from "../../services/help-content.service";
|
||||
import { FormGroup } from "@angular/forms";
|
||||
import { ModalFormComponent } from "../modal-form.component";
|
||||
|
@ -13,6 +13,7 @@ import { Community } from "../../domain/community";
|
|||
import { Entity } from "../../domain/entity";
|
||||
import { EnvProperties } from '../../openaireLibrary/utils/properties/env-properties';
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'pages',
|
||||
|
@ -83,9 +84,13 @@ export class PagesComponent implements OnInit {
|
|||
});
|
||||
}
|
||||
|
||||
constructor(private route: ActivatedRoute, private _helpContentService: HelpContentService) {}
|
||||
constructor(private route: ActivatedRoute, private _router: Router, private _helpContentService: HelpContentService) {}
|
||||
|
||||
getPages(community_pid: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
@ -107,15 +112,21 @@ export class PagesComponent implements OnInit {
|
|||
},
|
||||
error => this.handleError('System error retrieving pages', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
getPagesWithDivIds(community_pid: string) {
|
||||
this._helpContentService.getPagesWithDivIds(community_pid, this.properties.adminToolsAPIURL).subscribe(
|
||||
pages => {
|
||||
this.pageWithDivIds = pages;
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving information about pages\' classes', error));
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this._helpContentService.getPagesWithDivIds(community_pid, 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[]) {
|
||||
|
@ -179,15 +190,24 @@ export class PagesComponent implements OnInit {
|
|||
}
|
||||
|
||||
private confirmModalOpen() {
|
||||
this.alertModalDeletePages.cancelButton = true;
|
||||
this.alertModalDeletePages.okButton = true;
|
||||
this.alertModalDeletePages.alertTitle = "Delete Confirmation";
|
||||
this.alertModalDeletePages.message = "Are you sure you want to delete the selected page(s)?";
|
||||
this.alertModalDeletePages.okButtonText = "Yes";
|
||||
this.alertModalDeletePages.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.alertModalDeletePages.cancelButton = true;
|
||||
this.alertModalDeletePages.okButton = true;
|
||||
this.alertModalDeletePages.alertTitle = "Delete Confirmation";
|
||||
this.alertModalDeletePages.message = "Are you sure you want to delete the selected page(s)?";
|
||||
this.alertModalDeletePages.okButtonText = "Yes";
|
||||
this.alertModalDeletePages.open();
|
||||
}
|
||||
}
|
||||
|
||||
public confirmedDeletePages(data: any) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -198,6 +218,7 @@ export class PagesComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error deleting the selected pages', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public editPage(i : number) {
|
||||
|
@ -218,39 +239,54 @@ export class PagesComponent implements OnInit {
|
|||
}
|
||||
|
||||
private pagesModalOpen(modal: any, title: string, yesBtn: string) {
|
||||
modal.cancelButton = true;
|
||||
modal.okButton = true;
|
||||
modal.alertTitle = title;
|
||||
modal.okButtonText = yesBtn;
|
||||
modal.open();
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
modal.cancelButton = true;
|
||||
modal.okButton = true;
|
||||
modal.alertTitle = title;
|
||||
modal.okButtonText = yesBtn;
|
||||
modal.open();
|
||||
}
|
||||
}
|
||||
|
||||
public pageSaveConfirmed(data: any) {
|
||||
if(!this.formGroup.valid) {
|
||||
this.pagesModalOpen(this.alertModalSavePage, "Save", "Add a new Page");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.modalErrorMessage = "";
|
||||
this._helpContentService.savePage(<Page> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.pageSavedSuccessfully(page);
|
||||
},
|
||||
error => this.handleUpdateError("System error creating page", error)
|
||||
);
|
||||
if(!this.formGroup.valid) {
|
||||
this.pagesModalOpen(this.alertModalSavePage, "Save", "Add a new Page");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
} else {
|
||||
this.modalErrorMessage = "";
|
||||
this._helpContentService.savePage(<Page> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.pageSavedSuccessfully(page);
|
||||
},
|
||||
error => this.handleUpdateError("System error creating page", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public pageUpdateConfirmed(data: any) {
|
||||
if(!this.formGroup.valid) {
|
||||
this.pagesModalOpen(this.alertModalUpdatePage, "Update", "Update Page");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this._helpContentService.updatePage(<Page> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.pageUpdatedSuccessfully(page);
|
||||
},
|
||||
error => this.handleUpdateError("System error updating page", error)
|
||||
);
|
||||
if(!this.formGroup.valid) {
|
||||
this.pagesModalOpen(this.alertModalUpdatePage, "Update", "Update Page");
|
||||
this.modalErrorMessage = "Please fill in all required fields marked with *";
|
||||
} else {
|
||||
this._helpContentService.updatePage(<Page> this.formGroup.value, this.properties.adminToolsAPIURL).subscribe(
|
||||
page => {
|
||||
this.pageUpdatedSuccessfully(page);
|
||||
},
|
||||
error => this.handleUpdateError("System error updating page", error)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -317,6 +353,10 @@ export class PagesComponent implements OnInit {
|
|||
}
|
||||
|
||||
public togglePages(status : boolean, ids : string[]) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -331,6 +371,7 @@ export class PagesComponent implements OnInit {
|
|||
},
|
||||
error => this.handleUpdateError('System error changing the status of the selected page(s)', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public capitalizeFirstLetter(str: string) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Component, OnInit} from '@angular/core';
|
||||
import {HelpContentService} from '../../services/help-content.service';
|
||||
import {ActivatedRoute} from '@angular/router';
|
||||
import {ActivatedRoute, Router} from '@angular/router';
|
||||
import {EnvProperties} from '../../openaireLibrary/utils/properties/env-properties';
|
||||
import { Community } from '../../domain/community';
|
||||
import { DomSanitizer } from '@angular/platform-browser';
|
||||
|
@ -9,6 +9,9 @@ import {availableEntitiesMap, StatisticsDisplay, StatisticsSummary} from '../../
|
|||
import {Observable} from 'rxjs/Observable';
|
||||
import {ConfigurationService} from '../../openaireLibrary/utils/configuration/configuration.service';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'stats',
|
||||
templateUrl: 'stats.component.html'
|
||||
|
@ -46,6 +49,7 @@ export class StatsComponent implements OnInit {
|
|||
constructor(private contentService: HelpContentService,
|
||||
private configService: ConfigurationService,
|
||||
private route: ActivatedRoute,
|
||||
private _router: Router,
|
||||
private sanitizer: DomSanitizer,
|
||||
private titleCase: TitleCasePipe) {}
|
||||
|
||||
|
@ -64,6 +68,10 @@ export class StatsComponent implements OnInit {
|
|||
}
|
||||
|
||||
getStatistics() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
// this.loadingMessage = 'Retrieving statistics';
|
||||
// this.errorMessage = '';
|
||||
this.showLoading = true;
|
||||
|
@ -92,9 +100,14 @@ export class StatsComponent implements OnInit {
|
|||
this.getDisplayOptions();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
getDisplayOptions() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.contentService.getCommunityAdminStatisticsChoices(this.properties.adminToolsAPIURL, this.communityId)
|
||||
.subscribe(
|
||||
res => {
|
||||
|
@ -108,9 +121,14 @@ export class StatsComponent implements OnInit {
|
|||
this.getCommunityInfo();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
getCommunityInfo() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.log(`calling ${this.properties.adminToolsAPIURL}/communityFull/${this.communityId}`);
|
||||
this.configService.getCommunityInformation(this.properties.adminToolsAPIURL, this.communityId).subscribe(
|
||||
res => {
|
||||
|
@ -123,9 +141,14 @@ export class StatsComponent implements OnInit {
|
|||
this.onChangeEntity(this.entitiesList[0]);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onChangeEntity (entity: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
|
||||
this.deactivatedEntity = false;
|
||||
|
@ -156,6 +179,7 @@ export class StatsComponent implements OnInit {
|
|||
}
|
||||
|
||||
this.showLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
changeDisplayedProjectChart(chartName: string) {
|
||||
|
@ -190,6 +214,10 @@ export class StatsComponent implements OnInit {
|
|||
}
|
||||
|
||||
toggleShowAllInMonitor(entity: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -304,10 +332,14 @@ export class StatsComponent implements OnInit {
|
|||
this.loadingMessage = '';
|
||||
}
|
||||
);*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
toggleShowAllInDashboard(entity: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -376,9 +408,14 @@ export class StatsComponent implements OnInit {
|
|||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
toggleShowInMonitor(entity: string, chartsOrNumbers: string, title: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -397,9 +434,14 @@ export class StatsComponent implements OnInit {
|
|||
this.showLoading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
toggleShowInDashboard(entity: string, chartsOrNumbers: string, title: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
||||
|
@ -418,6 +460,7 @@ export class StatsComponent implements OnInit {
|
|||
this.showLoading = false;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
getCamelCaseString (inputString: string) {
|
||||
|
|
|
@ -5,11 +5,15 @@ import {ActivatedRoute, Router} from '@angular/router';
|
|||
|
||||
import {HelpContentService} from "../../../services/help-content.service";
|
||||
import {CommunityService} from "../../../openaireLibrary/connect/community/community.service";
|
||||
import {SubjectsService} from "../subjects.service"
|
||||
import {SubjectsService} from "../subjects.service"
|
||||
import {EnvProperties} from '../../../openaireLibrary/utils/properties/env-properties';
|
||||
|
||||
import {CommunityInfo} from '../../../openaireLibrary/connect/community/communityInfo';
|
||||
import { concat } from 'rxjs/observable/concat';
|
||||
|
||||
import {Session} from '../../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
import { concat } from 'rxjs/observable/concat';
|
||||
@Component({
|
||||
selector: 'subjects-edit-form',
|
||||
templateUrl: './subjects-edit-form.component.html',
|
||||
|
@ -56,26 +60,31 @@ export class SubjectsEditFormComponent implements OnInit{
|
|||
communityId => {
|
||||
this.communityId = communityId['communityId'];
|
||||
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
this.errorMessage = "";
|
||||
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
|
||||
community => {
|
||||
this.community = community;
|
||||
this.params = {community: encodeURIComponent('"' + community.queryId + '"')};
|
||||
this.originalSubjects = [];
|
||||
for (var i = 0; i < this.community.subjects.length; i++) {
|
||||
this.originalSubjects.push(this.community.subjects[i]);
|
||||
}
|
||||
if (this.community.subjects.length == 0) {
|
||||
this.community.subjects.push("");
|
||||
}
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving community profile', error)
|
||||
);
|
||||
this._communityService.getCommunity(this.properties, this.properties.communityAPI+this.communityId).subscribe (
|
||||
community => {
|
||||
this.community = community;
|
||||
this.params = {community: encodeURIComponent('"' + community.queryId + '"')};
|
||||
this.originalSubjects = [];
|
||||
for (var i = 0; i < this.community.subjects.length; i++) {
|
||||
this.originalSubjects.push(this.community.subjects[i]);
|
||||
}
|
||||
if (this.community.subjects.length == 0) {
|
||||
this.community.subjects.push("");
|
||||
}
|
||||
this.showLoading = false;
|
||||
},
|
||||
error => this.handleError('System error retrieving community profile', error)
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -84,14 +93,28 @@ export class SubjectsEditFormComponent implements OnInit{
|
|||
|
||||
|
||||
public addSubject() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.community.subjects.push("");
|
||||
}
|
||||
}
|
||||
|
||||
public removeSubject(i: any) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.community.subjects.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public resetForm(communityId: string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if (communityId != null && communityId != '') {
|
||||
this.showLoading = true;
|
||||
this.updateErrorMessage = "";
|
||||
|
@ -108,6 +131,7 @@ export class SubjectsEditFormComponent implements OnInit{
|
|||
);
|
||||
}
|
||||
this.resetChange();
|
||||
}
|
||||
}
|
||||
|
||||
// save(newValue){
|
||||
|
@ -142,7 +166,10 @@ export class SubjectsEditFormComponent implements OnInit{
|
|||
|
||||
}
|
||||
public updateSubjects() {
|
||||
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this.showLoading = true;
|
||||
var subjectsToDeleteAr = this.getSubjectsExistOnlyInFirst(this.originalSubjects, this.community.subjects);
|
||||
|
@ -182,6 +209,7 @@ export class SubjectsEditFormComponent implements OnInit{
|
|||
|
||||
}
|
||||
this.resetChange();
|
||||
}
|
||||
}
|
||||
afterUpdateActions(res){
|
||||
this.community.subjects = res["subjects"];
|
||||
|
|
|
@ -13,6 +13,8 @@ import {RouterHelper} from '../../openaireLib
|
|||
import {ErrorCodes} from '../../openaireLibrary/utils/properties/errorCodes';
|
||||
import {SearchUtilsClass} from '../../openaireLibrary/searchPages/searchUtils/searchUtils.class';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'manage-subscribers',
|
||||
|
@ -172,6 +174,10 @@ export class ManageSubscribersComponent implements OnInit {
|
|||
}
|
||||
|
||||
public goTo(page:number = 1) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.subscribersSearchUtils.page=page;
|
||||
|
||||
var table = $('#dpTable').DataTable();
|
||||
|
@ -180,6 +186,7 @@ export class ManageSubscribersComponent implements OnInit {
|
|||
var info = table.page.info();
|
||||
console.info("records: "+info.recordsDisplay);
|
||||
this.subscribersSearchUtils.totalResults = info.recordsDisplay;
|
||||
}
|
||||
}
|
||||
|
||||
totalPages(): number {
|
||||
|
@ -191,6 +198,10 @@ export class ManageSubscribersComponent implements OnInit {
|
|||
}
|
||||
|
||||
public removeSubscriber(email:string) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.selectedSubscriberEmail = email;
|
||||
this.alertModalDeleteSubscriber.cancelButton = true;
|
||||
this.alertModalDeleteSubscriber.okButton = true;
|
||||
|
@ -204,9 +215,14 @@ export class ManageSubscribersComponent implements OnInit {
|
|||
this.alertModalDeleteSubscriber.message += "will be removed from your community. Are you sure?";
|
||||
this.alertModalDeleteSubscriber.okButtonText = "Yes";
|
||||
this.alertModalDeleteSubscriber.open();
|
||||
}
|
||||
}
|
||||
|
||||
public confirmedDeleteSubscriber() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
console.info("REMOVE: "+ this.selectedSubscriberEmail);
|
||||
this.subRemove = this._subscribeService.unSubscribeToCommunity(this.communityId, this.selectedSubscriberEmail, this.properties.adminToolsAPIURL).subscribe(
|
||||
result => {
|
||||
|
@ -229,9 +245,14 @@ export class ManageSubscribersComponent implements OnInit {
|
|||
this.rerender();
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public _getCommunitySubscribers(){
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.subscribersSearchUtils.status = this.errorCodes.LOADING;
|
||||
this.disableForms = true;
|
||||
this.communitySubscribers = [];
|
||||
|
@ -286,5 +307,6 @@ export class ManageSubscribersComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,9 @@ import {SearchUtilsClass} from '../../openaireLib
|
|||
import {ManageZenodoCommunitiesService} from './manage-zenodo-communities.service';
|
||||
import {ZenodoCommunityInfo} from './zenodoCommunity/zenodoCommunityInfo';
|
||||
|
||||
import {Session} from '../../openaireLibrary/login/utils/helper.class';
|
||||
import {LoginErrorCodes} from '../../openaireLibrary/login/utils/guardHelper.class';
|
||||
|
||||
@Component({
|
||||
selector: 'manage-zenodo-communities',
|
||||
templateUrl: './manage-zenodo-communities.component.html',
|
||||
|
@ -44,19 +47,24 @@ export class ManageZenodoCommunitiesComponent implements OnInit {
|
|||
this.route.queryParams.subscribe(
|
||||
communityId => {
|
||||
this.communityId = communityId['communityId'];
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this._manageΖenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities+"?page="+this.zenodoCommunitySearchUtils.page+"&size="+this.rowsOnPage).subscribe(
|
||||
zenodoCommunities => {
|
||||
this.zenodoCommunities = zenodoCommunities;
|
||||
console.log(zenodoCommunities);
|
||||
console.log(this.zenodoCommunitySearchUtils.page);
|
||||
});
|
||||
this._manageΖenodoCommunitieService.getTotalZenodoCommunities(this.properties, this.properties.zenodoCommunities).subscribe(
|
||||
totalZenodoCommunities => {
|
||||
this.totalZenodoCommunities = totalZenodoCommunities;
|
||||
this.zenodoCommunitySearchUtils.totalResults = totalZenodoCommunities;
|
||||
console.log(totalZenodoCommunities);
|
||||
});
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this._manageΖenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities+"?page="+this.zenodoCommunitySearchUtils.page+"&size="+this.rowsOnPage).subscribe(
|
||||
zenodoCommunities => {
|
||||
this.zenodoCommunities = zenodoCommunities;
|
||||
console.log(zenodoCommunities);
|
||||
console.log(this.zenodoCommunitySearchUtils.page);
|
||||
});
|
||||
this._manageΖenodoCommunitieService.getTotalZenodoCommunities(this.properties, this.properties.zenodoCommunities).subscribe(
|
||||
totalZenodoCommunities => {
|
||||
this.totalZenodoCommunities = totalZenodoCommunities;
|
||||
this.zenodoCommunitySearchUtils.totalResults = totalZenodoCommunities;
|
||||
console.log(totalZenodoCommunities);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -65,6 +73,10 @@ export class ManageZenodoCommunitiesComponent implements OnInit {
|
|||
}
|
||||
|
||||
public search() {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.zenodoCommunitySearchUtils.page = 1;
|
||||
if (this.communityId != null && this.communityId != '') {
|
||||
this._manageΖenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities+"?q="+this.zenodoCommunitySearchUtils.keyword+"&page="+this.zenodoCommunitySearchUtils.page+"&size="+this.rowsOnPage).subscribe(
|
||||
|
@ -73,9 +85,14 @@ export class ManageZenodoCommunitiesComponent implements OnInit {
|
|||
console.log(zenodoCommunities);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public goTo(page:number = 1) {
|
||||
if(!Session.isLoggedIn()){
|
||||
console.info(this._router.url);
|
||||
this._router.navigate(['/user-info'], { queryParams: { "errorCode": LoginErrorCodes.NOT_VALID, "redirectUrl": this._router.url} });
|
||||
} else {
|
||||
this.zenodoCommunitySearchUtils.page=page;
|
||||
console.log("Page is: "+page);
|
||||
this._manageΖenodoCommunitieService.getZenodoCommunities(this.properties, this.properties.zenodoCommunities+"?page="+this.zenodoCommunitySearchUtils.page+"&size="+this.rowsOnPage).subscribe(
|
||||
|
@ -84,6 +101,7 @@ export class ManageZenodoCommunitiesComponent implements OnInit {
|
|||
console.log(zenodoCommunities);
|
||||
console.log(this.zenodoCommunitySearchUtils.page);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
totalPages(): number {
|
||||
|
|
Loading…
Reference in New Issue