Skip to content

Commit

Permalink
Use entity role in usercards #5434
Browse files Browse the repository at this point in the history
Signed-off-by: ClementBouvierN <clement.bouvierneveu@rte-france.com>
  • Loading branch information
ClementBouvierN committed Jan 9, 2024
1 parent 8556cdc commit f677e20
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
20 changes: 16 additions & 4 deletions config/docker/users.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,70 +94,82 @@ operatorfabric.users.default:
description: Control Center FR North
parents : ["ENTITY_FR"]
labels: ["FR1 label"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY2_FR
name: Control Center FR South
description: Control Center FR South
parents : ["ENTITY_FR"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY3_FR
name: Control Center FR East
description: Control Center FR East
parents : ["ENTITY_FR"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY4_FR
name: Control Center FR West
description: Control Center FR West
parents : ["ENTITY_FR"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY_FR
name: French Control Centers
description: French Control Centers
roles: ["ACTIVITY_AREA_GROUP"]
entityAllowedToSendCard: false
roles: ["CARD_RECEIVER"]
- id: EUROPEAN_SUPERVISION_CENTERS
name: European Supervision Centers
description: European Supervision Centers
roles: ["ACTIVITY_AREA_GROUP"]
entityAllowedToSendCard: false
roles: ["CARD_RECEIVER"]
- id: IT_SUPERVISOR_ENTITY
name: IT SUPERVISION CENTER
description: IT SUPERVISION CENTER
parents : ["EUROPEAN_SUPERVISION_CENTERS"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY1_IT
name: Control Center IT North
description: Control Center IT North
parents : ["ENTITY_IT"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY2_IT
name: Control Center IT Center
description: Control Center IT Center
parents : ["ENTITY_IT"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY3_IT
name: Control Center IT South
description: Control Center IT South
parents : ["ENTITY_IT"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY_IT
name: Italian Control Centers
description: Italian Control Centers
entityAllowedToSendCard: false
roles: ["ACTIVITY_AREA_GROUP"]
roles: ["CARD_RECEIVER", "ACTIVITY_AREA_GROUP"]
- id: ENTITY1_NL
name: Control Center NL North
description: Control Center NL North
parents : ["ENTITY_NL"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY2_NL
name: Control Center NL South
description: Control Center NL South
parents : ["ENTITY_NL"]
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY_NL
name: Dutch Control Centers
description: Dutch Control Centers
entityAllowedToSendCard: false
roles: ["ACTIVITY_AREA_GROUP"]
roles: ["CARD_RECEIVER", "ACTIVITY_AREA_GROUP"]
- id: ENTITY1_EU
name: North Europe Control Center
description: North Europe Control Center
entityAllowedToSendCard: true
roles: ["CARD_SENDER", "CARD_RECEIVER"]
- id: ENTITY2_EU
name: South Europe Control Center
description: South Europe Control Center
entityAllowedToSendCard: true
roles: ["CARD_SENDER", "CARD_RECEIVER"]
user-settings:
- login: operator3_fr
description: Da Operator Rulez
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2022-2023, RTE (http://www.rte-france.com)
/* Copyright (c) 2022-2024, RTE (http://www.rte-france.com)
* See AUTHORS.txt
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand All @@ -15,6 +15,7 @@ import {Entity} from '@ofModel/entity.model';
import {FormControl, FormGroup} from '@angular/forms';
import {MultiSelectConfig, MultiSelectOption} from '@ofModel/multiselect.model';
import {OpfabAPIService} from 'app/business/services/opfabAPI.service';
import { RolesEnum } from '@ofModel/roles.model';

@Component({
selector: 'of-usercard-recipients-form',
Expand Down Expand Up @@ -85,35 +86,45 @@ export class UserCardRecipientsFormComponent implements OnInit, OnChanges {
this.recipientsOptions = [];
EntitiesService
.getEntities()
.forEach((entity) =>
this.recipientsOptions.push(new MultiSelectOption(entity.id, this.getEntityLabel(entity)))
.forEach((entity) => {
if (entity.roles.includes(RolesEnum.CARD_RECEIVER)) {
this.recipientsOptions.push(new MultiSelectOption(entity.id, this.getEntityLabel(entity)))
}
}
);
}

private loadRecipientsForInformationOptions() {
this.recipientsForInformationOptions = [];
EntitiesService
.getEntities()
.forEach((entity) =>
.forEach((entity) => {
if (entity.roles.includes(RolesEnum.CARD_RECEIVER)) {
this.recipientsForInformationOptions.push(new MultiSelectOption(entity.id, this.getEntityLabel(entity)))
}
}
);
}

private loadRestrictedRecipientList(recipients: EntitiesTree[]): void {
this.recipientsOptions = [];
EntitiesService
.resolveEntities(recipients)
.forEach((entity) =>
this.recipientsOptions.push(new MultiSelectOption(entity.id, this.getEntityLabel(entity)))
.forEach((entity) => {
if (entity.roles.includes(RolesEnum.CARD_RECEIVER)) {
this.recipientsOptions.push(new MultiSelectOption(entity.id, this.getEntityLabel(entity))) }
}
);
}

private loadRestrictedRecipientForInformationList(recipientsForInformation: EntitiesTree[]): void {
this.recipientsForInformationOptions = [];
EntitiesService
.resolveEntities(recipientsForInformation)
.forEach((entity) =>
this.recipientsForInformationOptions.push(new MultiSelectOption(entity.id, this.getEntityLabel(entity)))
.forEach((entity) => {
if (entity.roles.includes(RolesEnum.CARD_RECEIVER)) {
this.recipientsForInformationOptions.push(new MultiSelectOption(entity.id, this.getEntityLabel(entity))) }
}
);
}

Expand Down
5 changes: 3 additions & 2 deletions ui/main/src/app/modules/usercard/usercard.component.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2018-2023, RTE (http://www.rte-france.com)
/* Copyright (c) 2018-2024, RTE (http://www.rte-france.com)
* See AUTHORS.txt
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
Expand Down Expand Up @@ -38,6 +38,7 @@ import {ServerResponseStatus} from 'app/business/server/serverResponse';
import {SystemNotificationService} from '../../business/services/notifications/system-notification.service';
import {Observable} from 'rxjs';
import {OpfabAPIService} from 'app/business/services/opfabAPI.service';
import { RolesEnum } from '@ofModel/roles.model';

@Component({
selector: 'of-usercard',
Expand Down Expand Up @@ -332,7 +333,7 @@ export class UserCardComponent implements OnInit, OnDestroy {

allowedUserEntities.forEach((userEntityId) => {
const entity = EntitiesService.getEntities().find((e) => e.id === userEntityId);
if (entity.entityAllowedToSendCard) entitiesList.push({value: entity.id, label: entity.name});
if (entity.roles.includes(RolesEnum.CARD_SENDER)) entitiesList.push({value: entity.id, label: entity.name});
});
return entitiesList;
}
Expand Down

0 comments on commit f677e20

Please sign in to comment.