Add umbrella in stakeholder and adjust some admin pages.

This commit is contained in:
Konstantinos Triantafyllou 2024-05-21 11:05:16 +03:00
parent c1a8151184
commit 8bb2ebef3e
9 changed files with 59 additions and 35 deletions

View File

@ -1,13 +1,12 @@
import {StakeholderConfiguration} from "../../monitor-admin/utils/indicator-utils";
export class User {
email: string;
firstname: string;
lastname: string;
id: string;
fullname: string;
expirationDate: number;
expirationDate?: number;
role: string[];
accessToken?: string;
orcid?: string;

View File

@ -237,6 +237,7 @@ export class EditStakeholderComponent extends StakeholderBaseComponent {
isUpload: this.fb.control(this.stakeholder.isUpload),
copy: this.fb.control(this.stakeholder.copy),
logoUrl: this.fb.control(this.stakeholder.logoUrl),
umbrella: this.fb.control(!!this.stakeholder.umbrella)
});
if (this.stakeholder.isUpload) {
this.stakeholderFb.get('logoUrl').clearValidators();
@ -264,6 +265,7 @@ export class EditStakeholderComponent extends StakeholderBaseComponent {
}));
this.stakeholderFb.setControl('defaultId', this.fb.control(this.stakeholder.defaultId, (this.isDefault && !this.isNew) ? [] : Validators.required));
if (!this.isNew) {
this.stakeholderFb.get('umbrella').disable();
this.notification = NotificationUtils.editStakeholder(this.user.firstname + ' ' + this.user.lastname, this.stakeholder.name);
this.notify.reset(this.notification.message);
if (this.isAdmin) {
@ -381,7 +383,7 @@ export class EditStakeholderComponent extends StakeholderBaseComponent {
}
this.removePhoto();
this.subscriptions.push(this.stakeholderService.buildStakeholder(this.properties.monitorServiceAPIURL,
this.stakeholderFb.getRawValue(), copyId).subscribe(stakeholder => {
this.stakeholderFb.getRawValue(), copyId, true).subscribe(stakeholder => {
this.notification.entity = stakeholder._id;
this.notification.stakeholder = stakeholder.alias;
this.notification.stakeholderType = stakeholder.type;

View File

@ -14,7 +14,6 @@ import {ActivatedRoute} from "@angular/router";
export class GeneralComponent extends BaseComponent implements OnInit {
public stakeholder: Stakeholder;
public alias: string[];
public defaultStakeholders: Stakeholder[];
public loading: boolean = false;
@ViewChild('editStakeholderComponent') editStakeholderComponent: EditStakeholderComponent;
@ -33,13 +32,8 @@ export class GeneralComponent extends BaseComponent implements OnInit {
if(this.stakeholder) {
this.title = this.stakeholder.name + " | General";
this.setMetadata();
let data = zip(
this.stakeholderService.getDefaultStakeholders(this.properties.monitorServiceAPIURL),
this.stakeholderService.getAlias(this.properties.monitorServiceAPIURL)
);
this.subscriptions.push(data.subscribe(res => {
this.defaultStakeholders = res[0];
this.alias = res[1];
this.subscriptions.push(this.stakeholderService.getAlias(this.properties.monitorServiceAPIURL).subscribe(alias => {
this.alias = alias;
this.reset();
this.loading = false;
}));
@ -48,7 +42,7 @@ export class GeneralComponent extends BaseComponent implements OnInit {
}
public reset() {
this.editStakeholderComponent.init(this.stakeholder, this.alias, this.defaultStakeholders, this.stakeholder.defaultId == null, false, true)
this.editStakeholderComponent.init(this.stakeholder, this.alias, [], this.stakeholder.defaultId == null, false, true)
}
public save() {

View File

@ -39,7 +39,8 @@
[totalResults]="displayDefaultStakeholders.length">
</paging-no-load>
</div>
<div class="uk-grid uk-child-width-1-3@l uk-child-width-1-2@m uk-child-width-1-1 uk-grid-match" uk-grid>
<div class="uk-grid uk-child-width-1-3@l uk-child-width-1-2@m uk-child-width-1-1 uk-grid-match"
uk-grid>
<ng-template ngFor
[ngForOf]="displayDefaultStakeholders.slice((currentTemplatesPage-1)*pageSize, currentTemplatesPage*pageSize)"
let-stakeholder>

View File

@ -73,16 +73,15 @@ export class ManageStakeholdersComponent extends StakeholderBaseComponent implem
this.user = user;
}));
let data = zip(
this.stakeholderService.getDefaultStakeholders(this.properties.monitorServiceAPIURL),
this.stakeholderService.getMyStakeholders(this.properties.monitorServiceAPIURL),
this.stakeholderService.getAlias(this.properties.monitorServiceAPIURL)
);
this.subscriptions.push(data.subscribe(res => {
this.defaultStakeholders = res[0];
this.stakeholders = res[1];
this.displayDefaultStakeholders = res[0];
this.displayStakeholders = res[1];
this.alias = res[2];
this.defaultStakeholders = res[0].templates;
this.stakeholders = res[0].standalone;
this.displayDefaultStakeholders = res[0].templates;
this.displayStakeholders = res[0].standalone;
this.alias = res[1];
this.loading = false;
}, error => {
this.loading = false;

View File

@ -26,6 +26,8 @@ class Entities {
ri = 'Research Initiative';
organization = 'Research Institution';
project = 'Project';
publisher = 'Publisher';
journal = 'Journal';
country = 'National';
datasource = 'Repository';
researcher = 'Researcher';
@ -35,6 +37,8 @@ class Entities {
ris = 'Research Initiatives';
organizations = 'Research Institutions';
projects = 'Projects';
publishers = 'Publishers';
journals = 'Journals';
datasources = 'Repositories';
researchers = 'Researchers';
}
@ -51,7 +55,9 @@ export class StakeholderConfiguration {
{value: 'funder', label: StakeholderConfiguration.ENTITIES.funder},
{value: 'ri', label: StakeholderConfiguration.ENTITIES.ri},
{value: 'organization', label: StakeholderConfiguration.ENTITIES.organization},
{value: 'project', label: StakeholderConfiguration.ENTITIES.project}
{value: 'project', label: StakeholderConfiguration.ENTITIES.project},
{value: 'publisher', label: StakeholderConfiguration.ENTITIES.publisher},
{value: 'journal', label: StakeholderConfiguration.ENTITIES.journal}
];
public static LOCALES: Option[] = [
{value: "en", label: 'English'},

View File

@ -16,6 +16,13 @@ export type Format = 'NUMBER' | 'PERCENTAGE';
export type Visibility = 'PUBLIC' | 'PRIVATE' | 'RESTRICTED';
export type Overlay = 'embed' | 'description' | false;
export class ManageStakeholder {
templates: Stakeholder[];
standalone: Stakeholder[];
dependent: Stakeholder[];
umbrella: Stakeholder[];
}
export class Stakeholder {
_id: string;
type: StakeholderType;
@ -38,6 +45,8 @@ export class Stakeholder {
description: string;
topics: any[];
copy: boolean = true;
standalone: boolean = true;
umbrella: Umbrella;
details?: any;
constructor(_id: string, type: StakeholderType, index_id: string, index_name: string, index_shortName: string, alias: string, visibility: Visibility, logoUrl: string, defaultId: string = null, description: string = null) {
@ -52,6 +61,7 @@ export class Stakeholder {
this.logoUrl = logoUrl;
this.description = description;
this.copy = !!this.defaultId && this.defaultId !== '-1';
this.standalone = true;
this.topics = [];
}
@ -80,6 +90,11 @@ export class StakeholderInfo extends Stakeholder {
}
}
export class Umbrella {
types: string[];
children: any[];
}
export class Topic {
_id: string;
name: string;

View File

@ -1,7 +1,15 @@
import {Injectable} from "@angular/core";
import {HttpClient} from "@angular/common/http";
import {BehaviorSubject, from, Observable, Subscriber} from "rxjs";
import {Indicator, Section, Stakeholder, StakeholderInfo, SubCategory, Visibility} from "../entities/stakeholder";
import {
Indicator,
ManageStakeholder,
Section,
Stakeholder,
StakeholderInfo,
SubCategory,
Visibility
} from "../entities/stakeholder";
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {map} from "rxjs/operators";
import {properties} from "../../../../environments/environment";
@ -104,27 +112,27 @@ export class StakeholderService {
}));
}
getMyStakeholders(url: string, type: string = null): Observable<(Stakeholder & StakeholderInfo)[]> {
return this.http.get<Stakeholder[]>(url + '/my-stakeholder' + ((type) ? ('?type=' + type) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
return HelperFunctions.copy(Stakeholder.checkIsUpload(stakeholders));
getMyStakeholders(url: string, type: string = null): Observable<ManageStakeholder> {
return this.http.get<ManageStakeholder>(url + '/my-stakeholder' + ((type) ? ('?type=' + type) : ''), CustomOptions.registryOptions()).pipe(map(manageStakeholder => {
return HelperFunctions.copy({
templates: Stakeholder.checkIsUpload(manageStakeholder.templates),
standalone: Stakeholder.checkIsUpload(manageStakeholder.standalone),
dependent: Stakeholder.checkIsUpload(manageStakeholder.dependent),
umbrella: Stakeholder.checkIsUpload(manageStakeholder.umbrella),
});
}));
}
getDefaultStakeholders(url: string, type: string = null): Observable<Stakeholder[]> {
return this.http.get<Stakeholder[]>(url + '/stakeholder/default' + ((type) ? ('?type=' + type) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => {
return HelperFunctions.copy(Stakeholder.checkIsUpload(stakeholders));
}));
}
buildStakeholder(url: string, stakeholder: Stakeholder, copyId: string): Observable<Stakeholder> {
buildStakeholder(url: string, stakeholder: Stakeholder, copyId: string, umbrella: boolean = false): Observable<Stakeholder> {
if (stakeholder.alias && stakeholder.alias.startsWith('/')) {
stakeholder.alias = stakeholder.alias.slice(1);
}
let copy = {
let buildStakeholder = {
stakeholder: stakeholder,
copyId: copyId
copyId: copyId,
umbrella: umbrella
}
return this.http.post<Stakeholder>(url + '/build-stakeholder', copy, CustomOptions.registryOptions()).pipe(map(stakeholder => {
return this.http.post<Stakeholder>(url + '/build-stakeholder', buildStakeholder, CustomOptions.registryOptions()).pipe(map(stakeholder => {
return HelperFunctions.copy(Stakeholder.checkIsUpload(stakeholder));
}));
}

View File

@ -51,7 +51,7 @@ export class UserManagementService {
public getUserInfoAt(index = 0): Observable<User> {
return this.http.get<User>(UserManagementService.userInfoUrl(index), CustomOptions.registryOptions()).pipe(map(userInfo => {
return new User(userInfo);
}))
}));
}