Add stasProfile input in edit-stakeholder and replace its value in all indicators URL.
This commit is contained in:
parent
9a5de31d58
commit
be7fd26f7b
|
@ -15,6 +15,7 @@ import {NotifyFormComponent} from "../../openaireLibrary/notifications/notify-fo
|
|||
import {NotificationUtils} from "../../openaireLibrary/notifications/notification-utils";
|
||||
import {Notification} from "../../openaireLibrary/notifications/notifications";
|
||||
import {NotificationHandler} from "../../openaireLibrary/utils/notification-handler";
|
||||
import {StatsProfilesService} from "../../stats-profiles/stats-profiles.service";
|
||||
|
||||
@Component({
|
||||
selector: 'edit-stakeholder',
|
||||
|
@ -29,18 +30,23 @@ import {NotificationHandler} from "../../openaireLibrary/utils/notification-hand
|
|||
<div input [formInput]="stakeholderFb.get('alias')"
|
||||
placeholder="URL Alias"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-3@m">
|
||||
<div class="uk-width-1-2@m">
|
||||
<div input [formInput]="stakeholderFb.get('index_id')"
|
||||
placeholder="Index ID"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-3@m">
|
||||
<div class="uk-width-1-2@m">
|
||||
<div input [formInput]="stakeholderFb.get('index_name')"
|
||||
placeholder="Index Name"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-3@m">
|
||||
<div class="uk-width-1-2@m">
|
||||
<div input [formInput]="stakeholderFb.get('index_shortName')"
|
||||
placeholder="Index Short Name"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-2@m">
|
||||
<div *ngIf="statsProfiles" input [formInput]="stakeholderFb.get('statsProfile')" [type]="'autocomplete_soft'"
|
||||
[options]="statsProfiles" [showOptionsOnEmpty]="true"
|
||||
placeholder="Stats Profile"></div>
|
||||
</div>
|
||||
<div class="uk-width-1-1">
|
||||
<div input [type]="'textarea'" placeholder="Description"
|
||||
[rows]="4" [formInput]="stakeholderFb.get('description')"></div>
|
||||
|
@ -119,8 +125,9 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
public stakeholder: Stakeholder;
|
||||
public isDefault: boolean;
|
||||
public isNew: boolean;
|
||||
public loading: boolean = false;
|
||||
public loading: boolean = false;
|
||||
public types: Option[];
|
||||
public statsProfiles: string[];
|
||||
public properties: EnvProperties = properties;
|
||||
private subscriptions: any[] = [];
|
||||
/**
|
||||
|
@ -137,6 +144,7 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
|
||||
constructor(private fb: UntypedFormBuilder,
|
||||
private stakeholderService: StakeholderService,
|
||||
private statsProfileService: StatsProfilesService,
|
||||
private utilsService: UtilitiesService, private userManagementService: UserManagementService,) {
|
||||
}
|
||||
|
||||
|
@ -154,6 +162,14 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
this.isNew = isNew;
|
||||
this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => {
|
||||
this.user = user;
|
||||
if(this.isCurator) {
|
||||
this.subscriptions.push(this.statsProfileService.getStatsProfile().subscribe(statsProfiles => {
|
||||
this.statsProfiles = statsProfiles.map(statsProfile => statsProfile.name);
|
||||
console.log()
|
||||
}));
|
||||
} else {
|
||||
this.statsProfiles = [];
|
||||
}
|
||||
this.types = this.stakeholderUtils.getTypesByUserRoles(this.user, this.stakeholder.alias);
|
||||
this.stakeholderFb = this.fb.group({
|
||||
_id: this.fb.control(this.stakeholder._id),
|
||||
|
@ -163,6 +179,7 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
index_name: this.fb.control(this.stakeholder.index_name, Validators.required),
|
||||
index_id: this.fb.control(this.stakeholder.index_id, Validators.required),
|
||||
index_shortName: this.fb.control(this.stakeholder.index_shortName, Validators.required),
|
||||
statsProfile: this.fb.control(this.stakeholder.statsProfile, Validators.required),
|
||||
creationDate: this.fb.control(this.stakeholder.creationDate),
|
||||
alias: this.fb.control(this.stakeholder.alias,
|
||||
[
|
||||
|
@ -215,6 +232,11 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
}, 0);
|
||||
}
|
||||
} else {
|
||||
if(!this.isCurator) {
|
||||
setTimeout(() => {
|
||||
this.stakeholderFb.get('statsProfile').disable();
|
||||
}, 0);
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.stakeholderFb.get('alias').disable();
|
||||
this.stakeholderFb.get('index_id').disable();
|
||||
|
@ -239,6 +261,10 @@ export class EditStakeholderComponent implements OnDestroy {
|
|||
return Session.isPortalAdministrator(this.user);
|
||||
}
|
||||
|
||||
public get isCurator() {
|
||||
return this.stakeholder && (this.isAdmin || Session.isCurator(this.stakeholder.type, this.user));
|
||||
}
|
||||
|
||||
public get disabled(): boolean {
|
||||
return (this.stakeholderFb && this.stakeholderFb.invalid) ||
|
||||
(this.stakeholderFb && this.stakeholderFb.pristine && !this.isNew && !this.file) ||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 6a2ac8cc4e1a77c10f632eccfd73b91082fe4a4a
|
||||
Subproject commit e88bb206dcfbe6da62542c45794d4fe6e552fb09
|
|
@ -1,20 +1,25 @@
|
|||
import {
|
||||
ChartHelper, FilterType,
|
||||
Indicator, IndicatorFilterUtils,
|
||||
IndicatorPath, IndicatorPathType, IndicatorType,
|
||||
ChartHelper,
|
||||
FilterType,
|
||||
Indicator,
|
||||
IndicatorFilterUtils,
|
||||
IndicatorPath,
|
||||
IndicatorPathType,
|
||||
IndicatorType,
|
||||
SourceType,
|
||||
Stakeholder,
|
||||
StakeholderEntities,
|
||||
SubCategory,
|
||||
Topic, Visibility,
|
||||
StakeholderEntities
|
||||
Topic,
|
||||
Visibility
|
||||
} from "../openaireLibrary/monitor/entities/stakeholder";
|
||||
import {AbstractControl, ValidatorFn, Validators} from "@angular/forms";
|
||||
import {Option} from "../openaireLibrary/sharedComponents/input/input.component";
|
||||
import {Session} from "../openaireLibrary/login/utils/helper.class";
|
||||
import {HelperFunctions} from "../openaireLibrary/utils/HelperFunctions.class";
|
||||
import {properties} from "../../environments/environment";
|
||||
|
||||
export class StakeholderUtils {
|
||||
|
||||
statuses: Option[] = [
|
||||
{value: 'PUBLIC', label: 'Public'},
|
||||
{value: 'RESTRICTED', label: 'Restricted'},
|
||||
|
@ -190,25 +195,12 @@ export class IndicatorUtils {
|
|||
sourceTypes: Option[] = [
|
||||
{value: 'stats-tool', label: 'Statistics tool'}
|
||||
];
|
||||
isPublic: Option[] = [
|
||||
{icon: 'public', value: true, label: 'Public'},
|
||||
{icon: 'lock', value: false, label: 'Private'},
|
||||
];
|
||||
|
||||
isActive: Option[] = [
|
||||
{icon: 'brightness_1', iconClass: '', value: true, label: 'Active'},
|
||||
{icon: 'brightness_1', value: false, label: 'Inactive'},
|
||||
];
|
||||
|
||||
chartTypesIcons: Map<string, string> = new Map([
|
||||
['pie', 'pie_chart'],
|
||||
['table', 'table_chart'],
|
||||
['line', 'show_chart'],
|
||||
['column', 'bar_chart'],
|
||||
['bar', 'notes'],
|
||||
['other', 'perm_media']
|
||||
]);
|
||||
|
||||
getChartTypes(initialType) {
|
||||
let types: Option[] = [];
|
||||
if (this.basicChartTypes.indexOf(initialType) != -1) {
|
||||
|
@ -230,14 +222,8 @@ export class IndicatorUtils {
|
|||
}
|
||||
}
|
||||
|
||||
isPublicIcon: Map<boolean, string> = new Map([
|
||||
[true, 'public'],
|
||||
[false, 'lock']
|
||||
]);
|
||||
|
||||
isActiveIcon: string = 'brightness_1';
|
||||
|
||||
ignoredParameters = ['index_name', 'index_id', 'index_shortName'];
|
||||
statsProfileParameter = 'profile';
|
||||
|
||||
parametersValidators: Map<string, any> = new Map<string, any>([
|
||||
['start_year', [Validators.required, Validators.pattern('^\\d+$')]],
|
||||
|
@ -246,6 +232,9 @@ export class IndicatorUtils {
|
|||
|
||||
public getFullUrl(stakeholder: Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startYear: string = null, endYear: string = null): string {
|
||||
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
|
||||
if (stakeholder.statsProfile) {
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix).join(stakeholder.statsProfile)
|
||||
}
|
||||
if (indicatorPath.parameters) {
|
||||
Object.keys(indicatorPath.parameters).forEach(key => {
|
||||
let replacedValue = indicatorPath.parameters[key];
|
||||
|
@ -305,7 +294,7 @@ export class IndicatorUtils {
|
|||
}
|
||||
|
||||
}
|
||||
//For numbers (e.g from stats-api , search service, etc)
|
||||
//For numbers (e.g. from stats-api , search service, etc)
|
||||
if (indicatorPath.url.indexOf(ChartHelper.prefix + 'index_id' + ChartHelper.suffix) != -1) {
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_id' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_id))
|
||||
}
|
||||
|
@ -321,6 +310,9 @@ export class IndicatorUtils {
|
|||
public getFullUrlWithFilters(stakeholder: Stakeholder, indicatorPath: IndicatorPath, fundingL0: string = null, startYear: string = null, endYear: string = null, coFunded: boolean = false): string {
|
||||
indicatorPath.filtersApplied = 0;
|
||||
let replacedUrl = indicatorPath.chartObject ? indicatorPath.chartObject : indicatorPath.url;
|
||||
if (stakeholder.statsProfile) {
|
||||
replacedUrl = replacedUrl.split(ChartHelper.prefix + this.statsProfileParameter + ChartHelper.suffix).join(stakeholder.statsProfile)
|
||||
}
|
||||
if (indicatorPath.parameters) {
|
||||
Object.keys(indicatorPath.parameters).forEach(key => {
|
||||
let replacedValue = indicatorPath.parameters[key];
|
||||
|
@ -387,6 +379,7 @@ export class IndicatorUtils {
|
|||
replacedUrl = replacedUrl.split(ChartHelper.prefix + 'index_shortName' + ChartHelper.suffix).join(encodeURIComponent(stakeholder.index_shortName))
|
||||
}
|
||||
//Check apply enhancements return this.applySchemaEnhancements( ..);
|
||||
console.log(replacedUrl);
|
||||
return (indicatorPath.chartObject ? indicatorPath.url + encodeURIComponent(replacedUrl) : replacedUrl);
|
||||
|
||||
}
|
||||
|
@ -621,6 +614,7 @@ export class IndicatorUtils {
|
|||
this.extractStartYear(chart, indicatorPath);
|
||||
this.extractEndYear(chart, indicatorPath);
|
||||
indicatorPath.chartObject = JSON.stringify(chart);
|
||||
console.log(indicatorPath);
|
||||
}
|
||||
} else if (source === 'old') {
|
||||
indicatorPath.url = url.split("data=")[0].split("/stats/")[1] + "data=";
|
||||
|
@ -690,6 +684,9 @@ export class IndicatorUtils {
|
|||
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;
|
||||
}
|
||||
|
@ -716,6 +713,9 @@ export class IndicatorUtils {
|
|||
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;
|
||||
}
|
||||
|
@ -740,6 +740,9 @@ export class IndicatorUtils {
|
|||
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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue