[Library|Trunk]

- Admin tools:
	-- update methods for pages/ helpcontent to be page specific. 
	-- add count method for all pages - helpcontents
	-- fix order issue win update form


git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60515 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
argiro.kokogiannaki 2021-02-26 10:36:17 +00:00
parent 6335da03c5
commit 455b84aa56
5 changed files with 56 additions and 23 deletions

View File

@ -31,8 +31,9 @@
</div> </div>
</div> </div>
</div> </div>
<div class="uk-card uk-card-default uk-position-relative uk-padding-large " style="min-height: 60vh"> <div class="uk-card uk-card-default uk-position-relative " style="min-height: 60vh">
<div style="max-height: 60vh"> <div style="max-height: 60vh" class="uk-padding-large uk-overflow-auto">
<div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div> <div *ngIf="errorMessage" class="uk-alert uk-alert-danger" role="alert">{{errorMessage}}</div>
<div class="uk-animation-fade uk-width-1-1" role="alert"> <div class="uk-animation-fade uk-width-1-1" role="alert">
<div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div> <div *ngIf="updateErrorMessage" class="uk-alert uk-alert-danger" role="alert">{{updateErrorMessage}}</div>

View File

@ -8,7 +8,7 @@ import {EnvProperties} from '../../utils/properties/env-properties';
import {Session} from '../../login/utils/helper.class'; import {Session} from '../../login/utils/helper.class';
import {LoginErrorCodes} from '../../login/utils/guardHelper.class'; import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {properties} from '../../../../environments/environment'; import {properties} from '../../../../environments/environment';
import {Subscriber, Subscription} from 'rxjs'; import {from, Observable, Subscriber, Subscription} from 'rxjs';
import {HelperFunctions} from '../../utils/HelperFunctions.class'; import {HelperFunctions} from '../../utils/HelperFunctions.class';
import {PageHelpContent} from '../../utils/entities/adminTool/page-help-content'; import {PageHelpContent} from '../../utils/entities/adminTool/page-help-content';
@ -53,13 +53,14 @@ export class PageContentFormComponent implements OnInit{
if (!this.pageId) { if (!this.pageId) {
this._router.navigate(['../'], {relativeTo: this.route}); this._router.navigate(['../'], {relativeTo: this.route});
} }
this.getPage(this.pageId); /* this.getPage(this.pageId);
if (this.pageContentId) { if (this.pageContentId) {
this.getPageHelpContent(this.pageContentId); this.getPageHelpContent(this.pageContentId);
}else{ }else{
this.myForm = this.form; this.myForm = this.form;
} }*/
this.getInfo(this.pageId);
if (!Session.isLoggedIn()) { if (!Session.isLoggedIn()) {
this._router.navigate(['/user-info'], { this._router.navigate(['/user-info'], {
@ -80,7 +81,41 @@ export class PageContentFormComponent implements OnInit{
} }
}); });
} }
private getPage(pageId: string) { getInfo(pageId: string){
this.showLoading = true;
let obs = Observable.zip(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid), this._helpContentService.getCommunityPageHelpContents(this.communityPid, this.properties.adminToolsAPIURL, pageId));
this.subs.push(obs.subscribe(
results => {
this.page = results[0];
if(this.properties.adminToolsPortalType != this.page.portalType) {
this._router.navigate(['../'], {relativeTo: this.route});
}
let countPageContents = results[1]?results[1].length:0;
console.log(results[1]);
for (let content of (results[1] as Array<PageHelpContent>)) {
// if(content.page['_id'] == pageId){
// countPageContents++;
if(this.pageContentId && this.pageContentId == content._id) {
this.pageHelpContent = content;
// this.pageHelpContent.page = pageId;
// this.pageHelpContent.portal = this.communityPid;
}
// }
}
this.setOptions(this.page, countPageContents + (this.pageHelpContent?0:1));
if(!this.pageContentId) {
this.myForm = this.form;
this.initFormWithSelectOptions();
}else{
this.updateForm(this.pageHelpContent);
}
this.showLoading = false;
},
error => this.handleError('System error retrieving page with id: '+pageId, error)
));
}
/*private getPage(pageId: string) {
this.subs.push(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe( this.subs.push(this._helpContentService.getPageByPortal(pageId,this.properties.adminToolsAPIURL, this.communityPid).subscribe(
page => { page => {
if(this.properties.adminToolsPortalType != page.portalType) { if(this.properties.adminToolsPortalType != page.portalType) {
@ -126,7 +161,7 @@ export class PageContentFormComponent implements OnInit{
}, },
error => this.handleError('System error retrieving page help content', error))); error => this.handleError('System error retrieving page help content', error)));
} }
} }*/
private updateForm(pageHelpContent : PageHelpContent) { private updateForm(pageHelpContent : PageHelpContent) {
this.pageHelpContent = pageHelpContent; this.pageHelpContent = pageHelpContent;
this.myForm = this.form; this.myForm = this.form;

View File

@ -181,24 +181,18 @@ export class PageHelpContentsComponent implements OnInit {
} }
}); });
} else { } else {
this.subscriptions.push(this._helpService.getCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe( this.subscriptions.push(this._helpService.getCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL, this.selectedPageId).subscribe(
pageHelpContents => { pageHelpContents => {
this.pageHelpContents = pageHelpContents as Array<PageHelpContent>; this.pageHelpContents = pageHelpContents as Array<PageHelpContent>;
this.counter.all = this.pageHelpContents.length; this.counter.all = this.pageHelpContents.length;
this.checkboxes = []; this.checkboxes = [];
for (let i = this.pageHelpContents.length - 1; i >= 0; i -= 1) { for (let i = this.pageHelpContents.length - 1; i >= 0; i -= 1) {
//for (let i = 0; i < this.pageHelpContents.length; i++) {
let page: Page = this.pageHelpContents[i].page as Page;
if (!this.selectedPageId || (page._id == this.selectedPageId)) {
this.cutContent(this.pageHelpContents[i]); this.cutContent(this.pageHelpContents[i]);
this.checkboxes.unshift(<CheckPageHelpContent>{ this.checkboxes.unshift(<CheckPageHelpContent>{
pageHelpContent: this.pageHelpContents[i], pageHelpContent: this.pageHelpContents[i],
checked: false checked: false
}); });
} else {
this.pageHelpContents.splice(i, 1);
}
} }
this.countPageHelpContents(); this.countPageHelpContents();
@ -379,7 +373,7 @@ export class PageHelpContentsComponent implements OnInit {
this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent: _, checked: false}) this.checkboxes.push(<CheckPageHelpContent>{pageHelpContent: _, checked: false})
} }
); );
this.countPageHelpContents(); // this.countPageHelpContents();
} }
public filterByPage(event: any) { public filterByPage(event: any) {

View File

@ -520,11 +520,9 @@ export class PagesComponent implements OnInit {
} }
} }
getPageHelpContents(community_pid: string) { getPageHelpContents(community_pid: string) {
this.subscriptions.push(this._helpContentService.getCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe( this.subscriptions.push(this._helpContentService.countCommunityPageHelpContents(community_pid, this.properties.adminToolsAPIURL).subscribe(
pageHelpContents => { pageHelpContentsCount => {
for (let content of (pageHelpContents as Array<PageHelpContent>)) { this.pageHelpContents = pageHelpContentsCount;
this.pageHelpContents[content.page['_id']] = this.pageHelpContents[content.page['_id']]?this.pageHelpContents[content.page['_id']]+1:1;
}
}, },
error => this.handleError('System error retrieving page contents', error))); error => this.handleError('System error retrieving page contents', error)));
} }

View File

@ -225,12 +225,17 @@ export class HelpContentService {
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
getCommunityPageHelpContents(pid: string, helpContentUrl:string) { getCommunityPageHelpContents(pid: string, helpContentUrl:string, pageId:string = null) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent') return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + (pageId ? '/' + pageId : '') + '/pagehelpcontent')
//.map(res => <Array<PageHelpContent>> res.json())
.pipe(catchError(this.handleError));
}
//http://duffy.di.uoa.gr:8080/uoa-admin-tools/connect/connect/pagehelpcontent/page/count
countCommunityPageHelpContents(pid: string, helpContentUrl:string ) {
return this.http.get<Array<PageHelpContent>>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/page/count')
//.map(res => <Array<PageHelpContent>> res.json()) //.map(res => <Array<PageHelpContent>> res.json())
.pipe(catchError(this.handleError)); .pipe(catchError(this.handleError));
} }
getPageHelpContent(id : string, helpContentUrl:string, pid: string) { getPageHelpContent(id : string, helpContentUrl:string, pid: string) {
return this.http.get<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + id) return this.http.get<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + id)
//.map(res => <PageHelpContent> res.json()) //.map(res => <PageHelpContent> res.json())