diff --git a/login/utils/helper.class.ts b/login/utils/helper.class.ts index 152cda48..b09624cf 100644 --- a/login/utils/helper.class.ts +++ b/login/utils/helper.class.ts @@ -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; diff --git a/monitor-admin/general/edit-stakeholder/edit-stakeholder.component.ts b/monitor-admin/general/edit-stakeholder/edit-stakeholder.component.ts index 05eafbd5..12ceb468 100644 --- a/monitor-admin/general/edit-stakeholder/edit-stakeholder.component.ts +++ b/monitor-admin/general/edit-stakeholder/edit-stakeholder.component.ts @@ -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; diff --git a/monitor-admin/general/general.component.ts b/monitor-admin/general/general.component.ts index 2f28f504..0c832fcf 100644 --- a/monitor-admin/general/general.component.ts +++ b/monitor-admin/general/general.component.ts @@ -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() { diff --git a/monitor-admin/manageStakeholders/manageStakeholders.component.html b/monitor-admin/manageStakeholders/manageStakeholders.component.html index c96d3f63..797a1b3f 100644 --- a/monitor-admin/manageStakeholders/manageStakeholders.component.html +++ b/monitor-admin/manageStakeholders/manageStakeholders.component.html @@ -39,7 +39,8 @@ [totalResults]="displayDefaultStakeholders.length"> -
+
diff --git a/monitor-admin/manageStakeholders/manageStakeholders.component.ts b/monitor-admin/manageStakeholders/manageStakeholders.component.ts index 22fd4ffe..9c963c8f 100644 --- a/monitor-admin/manageStakeholders/manageStakeholders.component.ts +++ b/monitor-admin/manageStakeholders/manageStakeholders.component.ts @@ -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; diff --git a/monitor-admin/utils/indicator-utils.ts b/monitor-admin/utils/indicator-utils.ts index 04dc243d..a1661e0e 100644 --- a/monitor-admin/utils/indicator-utils.ts +++ b/monitor-admin/utils/indicator-utils.ts @@ -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'}, diff --git a/monitor/entities/stakeholder.ts b/monitor/entities/stakeholder.ts index c4fbe21e..c64d199d 100644 --- a/monitor/entities/stakeholder.ts +++ b/monitor/entities/stakeholder.ts @@ -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; diff --git a/monitor/services/stakeholder.service.ts b/monitor/services/stakeholder.service.ts index 4c597cd2..d5b2ee9e 100644 --- a/monitor/services/stakeholder.service.ts +++ b/monitor/services/stakeholder.service.ts @@ -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(url + '/my-stakeholder' + ((type) ? ('?type=' + type) : ''), CustomOptions.registryOptions()).pipe(map(stakeholders => { - return HelperFunctions.copy(Stakeholder.checkIsUpload(stakeholders)); + getMyStakeholders(url: string, type: string = null): Observable { + return this.http.get(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 { - return this.http.get(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 { + buildStakeholder(url: string, stakeholder: Stakeholder, copyId: string, umbrella: boolean = false): Observable { 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(url + '/build-stakeholder', copy, CustomOptions.registryOptions()).pipe(map(stakeholder => { + return this.http.post(url + '/build-stakeholder', buildStakeholder, CustomOptions.registryOptions()).pipe(map(stakeholder => { return HelperFunctions.copy(Stakeholder.checkIsUpload(stakeholder)); })); } diff --git a/services/user-management.service.ts b/services/user-management.service.ts index 08f4c0ff..ca662ebc 100644 --- a/services/user-management.service.ts +++ b/services/user-management.service.ts @@ -51,7 +51,7 @@ export class UserManagementService { public getUserInfoAt(index = 0): Observable { return this.http.get(UserManagementService.userInfoUrl(index), CustomOptions.registryOptions()).pipe(map(userInfo => { return new User(userInfo); - })) + })); }