Merge pull request 'Production Release Monitor (1.0.4) and Monitor Dashboard (1.1.1)' (#53) from develop into master

Reviewed-on: #53
This commit is contained in:
Konstantinos Triantafyllou 2024-10-07 14:31:44 +02:00
commit 59cb69736c
4 changed files with 72 additions and 98 deletions

View File

@ -1,18 +1,33 @@
import {Component, Inject, Input, OnChanges, OnDestroy, OnInit, PLATFORM_ID, SimpleChanges} from "@angular/core";
import {
Component,
Inject,
InjectionToken,
Input,
OnChanges,
OnDestroy,
OnInit,
PLATFORM_ID,
SimpleChanges
} from "@angular/core";
import {Report} from "./cache-indicators";
import {CacheIndicatorsService} from "./cache-indicators.service";
import {interval, Subject, Subscription} from "rxjs";
import {map, switchMap, takeUntil} from "rxjs/operators";
import {isPlatformBrowser} from "@angular/common";
@Component({
selector: 'cache-indicators',
template: `
<div *ngIf="report" class="cache-progress">
<div class="uk-position-relative" [attr.uk-tooltip]="'Caching indicators process for ' + alias">
<div class="uk-progress-circle" [attr.percentage]="report.percentage?report.percentage:0" [style]="'--percentage: ' + (report.percentage?report.percentage:0)"></div>
<button *ngIf="report.percentage === 100" (click)="clear()" class="uk-icon-button uk-icon-button-xsmall uk-button-default uk-position-top-right"><icon name="close" [flex]="true" ratio="0.8"></icon></button>
</div>
</div>
<div *ngIf="report" class="cache-progress">
<div class="uk-position-relative" [attr.uk-tooltip]="'Caching indicators process for ' + alias">
<div class="uk-progress-circle" [attr.percentage]="report.percentage?report.percentage:0"
[style]="'--percentage: ' + (report.percentage?report.percentage:0)"></div>
<button *ngIf="report.percentage === 100" (click)="clear()"
class="uk-icon-button uk-icon-button-xsmall uk-button-default uk-position-top-right">
<icon name="close" [flex]="true" ratio="0.8"></icon>
</button>
</div>
</div>
`,
styleUrls: ['cache-indicators.component.less']
})
@ -24,7 +39,7 @@ export class CacheIndicatorsComponent implements OnInit, OnChanges, OnDestroy {
@Input() alias: string;
constructor(private cacheIndicatorsService: CacheIndicatorsService,
@Inject(PLATFORM_ID) private platformId) {
@Inject(PLATFORM_ID) private platformId: any) {
}
ngOnInit() {
@ -32,28 +47,30 @@ export class CacheIndicatorsComponent implements OnInit, OnChanges, OnDestroy {
}
ngOnChanges(changes: SimpleChanges) {
if(changes.alias) {
if (changes.alias) {
this.clear();
this.getReport();
}
}
getReport() {
this.clear();
this.subscriptions.push(this.cacheIndicatorsService.getReport(this.alias).subscribe(report => {
this.getReportInterval(report);
}, error => {
this.report = null;
}));
}
getReportInterval(report: Report) {
if(this.isBrowser && (this.report || !report?.completed)) {
if (this.isBrowser && (this.report || !report?.completed)) {
this.report = report;
this.subscriptions.push(interval(this.interval).pipe(
map(() => this.cacheIndicatorsService.getReport(this.alias)),
switchMap(report => report),
takeUntil(this.destroy$)).subscribe(report => {
console.log(this.alias);
takeUntil(this.destroy$)).
subscribe(report => {
this.report = report;
if(this.report.completed) {
if (this.report.completed) {
this.destroy$.next();
}
}));
@ -62,14 +79,15 @@ export class CacheIndicatorsComponent implements OnInit, OnChanges, OnDestroy {
clear() {
this.subscriptions.forEach(subscription => {
subscription.unsubscribe();
})
if (subscription instanceof Subscription) {
subscription.unsubscribe();
}
});
this.report = null;
}
get isBrowser() {
return this.platformId === 'browser';
return isPlatformBrowser(this.platformId);
}
ngOnDestroy() {

View File

@ -17,7 +17,7 @@ export class HasDashboardGuard {
check(path: string, alias: string, type: string, child: string): Observable<boolean> | boolean {
return (child?this.stakeholderService.getChildStakeholder(alias, type, child):this.stakeholderService.getStakeholder(alias)).pipe(take(1), map(stakeholder => {
return stakeholder.standalone || (!!stakeholder && !!child);
return stakeholder?.standalone || (!!stakeholder && !!child);
}),tap(authorized => {
if(!authorized){
this.router.navigate([LinksResolver.default.errorLink], {queryParams: {'page': path}});

View File

@ -54,14 +54,6 @@ export class HelpContentService {
.pipe(catchError(this.handleError));
}
// toggleEntity(selectedCommunityId: string, id : string,status : boolean) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
//
// return this.http.post(helpContentUrl + 'community/'+selectedCommunityId+'/entity/toggle?status='+ status.toString()+'&entityId='+id.toString(), options)
// .catch(this.handleError);
// }
getCommunityEntities(pid: string) {
return this.http.get<Array<Entity>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/entities')
.pipe(catchError(this.handleError));
@ -81,27 +73,8 @@ export class HelpContentService {
.pipe(catchError(this.handleError));
}
// getDivIdsFull(page_id: string, helpContentUrl:string, pid: string = null) {
// let parameters: string = "";
// if(page_id || pid) {
// parameters = "?";
// if(page_id) {
// parameters += "&page="+page_id;
// }
// if(pid) {
// parameters += "&portal="+pid;
// }
// }
//
// return this.http.get<Array<DivId>>(helpContentUrl + 'div/full'+parameters)
// //.map(res => <Array<DivId>> res.json())
// .pipe(catchError(this.handleError));
// }
// Replacing getDivIdsFull
getAllDivIdsFull() {
return this.http.get<Array<DivId>>(properties.adminToolsAPIURL + 'div/full')
//.map(res => <Array<DivId>> res.json())
.pipe(catchError(this.handleError));
}
@ -111,7 +84,6 @@ export class HelpContentService {
return this.http.get<Array<DivId>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid + '/div/full'+parameters)
.pipe(catchError(this.handleError));
}
// End of replacing getDivIdsFull
// unused
getDivId(divId: string, helpContentUrl:string) {
@ -119,6 +91,7 @@ export class HelpContentService {
.pipe(catchError(this.handleError));
}
// unused
getDivIdFull(divId: string, helpContentUrl:string, pid: string) {
return this.http.get<DivId>(helpContentUrl + properties.adminToolsPortalType + "/" + pid + '/div/'+divId+"/full")
.pipe(catchError(this.handleError));
@ -173,7 +146,6 @@ export class HelpContentService {
}
toggleDivHelpContents(ids : string[], status : boolean, pid: string) {
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/divhelpcontent/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
@ -196,7 +168,6 @@ export class HelpContentService {
}
getPageHelpContent(id : string, helpContentUrl:string, pid: string) {
return this.http.get<PageHelpContent>(helpContentUrl + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/' + id)
//.map(res => <PageHelpContent> res.json())
.pipe(catchError(this.handleError));
}
@ -208,6 +179,7 @@ export class HelpContentService {
.pipe(catchError(this.handleError));
}
// unused
updatePageHelpContent(pageHelpContent: PageHelpContent, helpContentUrl:string, pid: string) {
HelpContentService.removeNulls(pageHelpContent);
@ -216,50 +188,43 @@ export class HelpContentService {
.pipe(catchError(this.handleError));
}
deletePageHelpContents(ids : string[], pid: string) {
deletePageHelpContents(ids: string[], pid: string) {
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/delete',
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
togglePageHelpContents(ids : string[],status : boolean, pid: string) {
togglePageHelpContents(ids : string[], status : boolean, pid: string) {
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/pagehelpcontent/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
// unused
getCommunityPagesWithDivId(pid: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?div=true')
.pipe(catchError(this.handleError));
}
// getCommunityPages(pid: string, params: string, helpContentUrl:string) {
// return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages'+params, CustomOptions.getAuthOptions())
// //.map(res => <Array<Page>> res.json())
// .pipe(catchError(this.handleError));
// }
getCommunityPagesByRoute(pid: string, route: string) {
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/pages'
+ (route ? '?page_route='+route : ''))
.pipe(map(pages => (pages.length>0?pages[0]:null)), catchError(this.handleError));
}
// Replacing getCommunityPages
getCommunityPagesByType(pid: string, type: string) {
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/'+pid+'/pages'
+ (type ? '?page_type='+type : ''))
.pipe(catchError(this.handleError));
}
// End of replacing getCommunityPages
// Replacing part of getPages (now getAllPages)
// unused
getCommunityPagesWithPositions(pid: string, helpContentUrl:string) {
return this.http.get<Array<Page>>(helpContentUrl + properties.adminToolsPortalType + '/'+pid+'/pages?with_positions=true')
.pipe(catchError(this.handleError));
}
// End of replacing part of getPages (now getAllPages)
//TODO double check with konstantina - there is no param that we are asking the community pages. without pid we get all portalTypes
// TODO: double check with konstantina - there is no param that we are asking the community pages. without pid we get all portalTypes
getAllPages(pid:string = null) {//with_positions:boolean=null) {
// let parameters: string = "";
// if(pid || with_positions == true || with_positions == false) {
@ -278,7 +243,6 @@ export class HelpContentService {
getAllPagesFull() {
return this.http.get<Array<Page>>(properties.adminToolsAPIURL + 'page/full')//+(pid?("?pid="+pid):""))
//.map(res => <Array<Page>> res.json())
.pipe(catchError(this.handleError));
}
@ -286,10 +250,13 @@ export class HelpContentService {
return this.http.get<Page>(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + pid + '/page/'+pageId)
.pipe(catchError(this.handleError));
}
getPageById(pageId:string) {
return this.http.get<Page>(properties.adminToolsAPIURL + 'page/' + pageId)
.pipe(catchError(this.handleError));
}
// unused
getCommunityPageByRoute(route:string, helpContentUrl:string, pid: string) {
return this.http.get<Page>(helpContentUrl + properties.adminToolsPortalType +'/' + pid + '/page/?page_route='+route)
.pipe(catchError(this.handleError));
@ -299,12 +266,10 @@ export class HelpContentService {
HelpContentService.removeNulls(page);
return this.http.post<Page>(properties.adminToolsAPIURL + 'page/save', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Page> res.json())
.pipe(catchError(this.handleError));
}
updatePage(page: Page) {
HelpContentService.removeNulls(page);
return this.http.post<Page>(properties.adminToolsAPIURL + 'page/update', JSON.stringify(page), CustomOptions.getAuthOptionsWithBody())
@ -312,14 +277,12 @@ export class HelpContentService {
}
togglePages(selectedPortalPid: string, ids : string[], status: boolean) {
return this.http.post(properties.adminToolsAPIURL + properties.adminToolsPortalType + '/' + selectedPortalPid + '/page/toggle?status='+ status.toString(),
JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
deletePages(ids : string[]) {
return this.http.post(properties.adminToolsAPIURL + 'page/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
@ -363,7 +326,6 @@ export class HelpContentService {
return this.http.post<Menu>(properties.adminToolsAPIURL + properties.adminToolsPortalType + "/" + portalPid + "/menu/align?alignment=" + alignment, {}, CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
// unused
getCommunities( helpContentUrl:string) {
@ -371,11 +333,13 @@ export class HelpContentService {
.pipe(catchError(this.handleError));
}
// unused
getCommunity(pid: string, helpContentUrl:string) {
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+pid)
.pipe(catchError(this.handleError));
}
// unused
getCommunitiesFull( helpContentUrl:string) {
return this.http.get<Array<Portal>>(helpContentUrl + properties.adminToolsPortalType + '/full')
.pipe(catchError(this.handleError));
@ -383,18 +347,16 @@ export class HelpContentService {
getPortalsFull() {
return this.http.get<Array<Portal>>(properties.adminToolsAPIURL + 'portal/full')
//.map(res => <Array<Portal>> res.json())
.pipe(catchError(this.handleError));
}
// unused
getCommunityFull(portal_pid: string, helpContentUrl:string) {
return this.http.get<Portal>(helpContentUrl + properties.adminToolsPortalType + '/'+portal_pid+'/full')
.pipe(catchError(this.handleError));
}
saveCommunity(portal: Portal) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(portal);
return this.http.post<Portal>(properties.adminToolsAPIURL + portal.type + '/save', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
@ -402,19 +364,13 @@ export class HelpContentService {
}
updateCommunity(portal: Portal) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
HelpContentService.removeNulls(portal);
return this.http.post<Portal>(properties.adminToolsAPIURL + portal.type + '/update', JSON.stringify(portal), CustomOptions.getAuthOptionsWithBody())
//.map(res => <Portal> res.json())
.pipe(catchError(this.handleError));
}
deleteCommunities(ids : string[], portalType:string) {
// let headers = new Headers({'Content-Type': 'application/json'});
// let options = new RequestOptions({headers: headers});
deleteCommunities(ids: string[], portalType:string) {
return this.http.post(properties.adminToolsAPIURL + portalType + '/delete',JSON.stringify(ids), CustomOptions.getAuthOptionsWithBody())
.pipe(catchError(this.handleError));
}
@ -426,10 +382,6 @@ export class HelpContentService {
return throwError(error.error || 'Server error');
}
// getDataProviders() {
// return this.http.get('https://beta.services.openaire.eu/search/v2/api/datasources?format=json').map(res => <any> res.json()).map(res => res.results).do(res => {console.log(res)}).catch(this.handleError);
// }
getCommunityStatistics(apiUrl: string, portalId: string): Observable<StatisticsSummary> {
const url = `${apiUrl}communities/${portalId}`;
//console.log(`getting statistics summary from: ${url}`);

View File

@ -374,21 +374,25 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang
@Input()
set options(options: (Option | string | number) []) {
this.optionsArray = options.map(option => {
if (option === null) {
return {
label: this.noValueSelected,
value: ''
};
} else if (typeof option === 'string' || typeof option === 'number') {
return {
label: option.toString(),
value: option
};
} else {
return option;
}
});
if(options) {
this.optionsArray = options.map(option => {
if (option === null) {
return {
label: this.noValueSelected,
value: ''
};
} else if (typeof option === 'string' || typeof option === 'number') {
return {
label: option.toString(),
value: option
};
} else {
return option;
}
});
} else {
this.optionsArray = [];
}
if (!this.tooltip) {
this.tooltip = this.optionsArray.length > 0;
}