[umbrella]: Fix hasDashboard guard. Add publisher condition in indicator generator.

This commit is contained in:
Konstantinos Triantafyllou 2024-06-12 12:38:00 +03:00
parent 179f0c4cd2
commit e1cc4f87aa
4 changed files with 32 additions and 7 deletions

View File

@ -18,7 +18,7 @@ import {ManageStakeholdersComponent} from "./manageStakeholders.component";
<div page-content> <div page-content>
<div header class="uk-margin-bottom"> <div header class="uk-margin-bottom">
<sidebar-mobile-toggle class="uk-margin-top uk-hidden@m uk-display-block"></sidebar-mobile-toggle> <sidebar-mobile-toggle class="uk-margin-top uk-hidden@m uk-display-block"></sidebar-mobile-toggle>
<div *ngIf="stakeholderCategories.length > 2" class="uk-margin-remove-bottom uk-margin-medium-top"> <div *ngIf="stakeholderCategories.length > 1" class="uk-margin-remove-bottom uk-margin-medium-top">
<slider-tabs [type]="'dynamic'" (activeEmitter)="active = $event"> <slider-tabs [type]="'dynamic'" (activeEmitter)="active = $event">
<slider-tab *ngFor="let category of stakeholderCategories" [tabTitle]="category.plural" <slider-tab *ngFor="let category of stakeholderCategories" [tabTitle]="category.plural"
[tabId]="category.value" [active]="active === category.value"></slider-tab> [tabId]="category.value" [active]="active === category.value"></slider-tab>
@ -98,6 +98,7 @@ export class ManageAllComponent extends StakeholderBaseComponent implements OnIn
} else if(!this.isCurator()) { } else if(!this.isCurator()) {
this.stakeholderCategories = this.stakeholderCategories.filter(category => category.value !== 'templates'); this.stakeholderCategories = this.stakeholderCategories.filter(category => category.value !== 'templates');
} }
this.active = this.stakeholderCategories[0].value;
})); }));
let data = zip( let data = zip(
this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL), this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL),

View File

@ -56,7 +56,7 @@ declare var UIkit;
</div> </div>
</a> </a>
</li> </li>
<li class="uk-nav-divider"></li> <li *ngIf="i > 0 || i < umbrella.types.length - 1" class="uk-nav-divider"></li>
<li> <li>
<a (click)="deleteTypeOpen(i); hide(element)"> <a (click)="deleteTypeOpen(i); hide(element)">
<div class="uk-flex uk-flex-middle"> <div class="uk-flex uk-flex-middle">

View File

@ -768,6 +768,7 @@ export class IndicatorUtils {
this.extractOrganization(obj, stakeholder); this.extractOrganization(obj, stakeholder);
this.extractDatasource(obj, stakeholder); this.extractDatasource(obj, stakeholder);
this.extractResearcher(obj, stakeholder); this.extractResearcher(obj, stakeholder);
this.extractPublisher(obj, stakeholder);
} }
private extractFunder(obj, stakeholder: Stakeholder) { private extractFunder(obj, stakeholder: Stakeholder) {
@ -849,6 +850,33 @@ export class IndicatorUtils {
} }
} }
private extractPublisher(obj, stakeholder: Stakeholder) {
// works for .publisher
if (stakeholder.type != 'publisher') {
return;
}
for (let query of this.getQueryObjectName(obj) ? obj[this.getDescriptionObjectName(obj)][this.getQueryObjectName(obj)] : obj[this.getDescriptionObjectName(obj)]) {
if (query["query"]["profile"]) {
query["query"]["profile"] = ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix;
}
if (!query["query"]["filters"]) {
return;
}
for (let filter of query["query"]["filters"]) {
for (let gfilter of filter["groupFilters"]) {
let replacedValue = this.replaceIndexValues(gfilter["values"][0], stakeholder);
console.log(replacedValue)
if (replacedValue) { // don't proceed in replacement if no replaced value matches
if (gfilter["field"].indexOf(".publisher") != -1) {
console.log(gfilter["values"][0])
gfilter["values"][0] = replacedValue;
}
}
}
}
}
}
private extractDatasource(obj, stakeholder: Stakeholder) { private extractDatasource(obj, stakeholder: Stakeholder) {
// works for .datasource.name and .HostedBy datasource // works for .datasource.name and .HostedBy datasource
// and .datasource.id // and .datasource.id

View File

@ -16,11 +16,7 @@ export class HasDashboardGuard {
} }
check(path: string, alias: string, type: string, child: string): Observable<boolean> | boolean { check(path: string, alias: string, type: string, child: string): Observable<boolean> | boolean {
let get = this.stakeholderService.getStakeholder(alias); return (child?this.stakeholderService.getChildStakeholder(alias, type, child):this.stakeholderService.getStakeholder(alias)).pipe(take(1), map(stakeholder => {
if(child) {
get = this.stakeholderService.getChildStakeholder(alias, type, child);
}
return get.pipe(take(1), map(stakeholder => {
return stakeholder.standalone || (!!stakeholder && !!child); return stakeholder.standalone || (!!stakeholder && !!child);
}),tap(authorized => { }),tap(authorized => {
if(!authorized){ if(!authorized){