Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VAS] Bug 11702: pastis enable external identifier for PUA and PA #1488

Merged
merged 1 commit into from
Sep 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions deployment/roles/vitamui/templates/ui-pastis/application.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,18 @@ cas:

{% endif %}

list-enable-external-identifiers:
tenants:
{% if vitam_vars.functional_administration.vitam_tenants_usage_external is iterable %}
{% for tenant in vitam_vars.functional_administration.vitam_tenants_usage_external %}
{% if tenant.identifiers is defined %}
{{ tenant.name }}:
{% for external in tenant.identifiers %}
- {{ external }}
{% endfor %}
{% endif %}
{% endfor %}
{% endif %}

opentracing:
jaeger:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ knowledge of the CeCILL-C license and that you accept its terms.
*/
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { ApplicationService } from 'ui-frontend-common';

@Injectable({
providedIn: 'root'
Expand All @@ -50,14 +49,7 @@ export class PopupService {

externalIdentifierEnabled: boolean;

constructor(private applicationService: ApplicationService,) {
this.updateSlaveMode()
}

private updateSlaveMode() {
this.applicationService.isApplicationExternalIdentifierEnabled('PASTIS').subscribe((value) => {
this.externalIdentifierEnabled = value;
});
constructor() {
}

getPopUpDataOnOpen() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import { FileNode } from '../../models/file-node';
import { Profile } from '../../models/profile';
import { ProfileDescription } from '../../models/profile-description.model';
import { ProfileResponse } from '../../models/profile-response';
import { ProfileType } from '../../models/profile-type.enum';
import { PastisApiService } from '../api/api.pastis.service';
import { PastisConfiguration } from '../classes/pastis-configuration';
import { ArchivalProfileUnitApiService } from './archival-profile-unit-api.service';
Expand All @@ -63,7 +64,7 @@ export class ProfileService implements OnDestroy {
public direction: string;
public criteria?: string;

public profileMode: string;
public profileMode: ProfileType;
public profileName: string;
public profileId: string;
protected pageRequest: PageRequest;
Expand Down Expand Up @@ -124,9 +125,9 @@ export class ProfileService implements OnDestroy {
if (profiles) {
for (const profile of profiles) {
if (profile.controlSchema) {
profile.type = 'PUA';
profile.type = ProfileType.PUA;
} else {
profile.type = 'PA';
profile.type = ProfileType.PA;
}
}
this.retrievedProfiles.next(profiles);
Expand All @@ -139,13 +140,13 @@ export class ProfileService implements OnDestroy {
this.subscription3$ = this.getAllProfilesPUA().subscribe((profileListPUA: ProfileDescription[]) => {
if (profileListPUA) {
profileListPUA.forEach((p) => {
p.type = 'PUA';
p.type = ProfileType.PUA;
profiles.push(p);
});
this.subscription4$ = this.getAllProfilesPA().subscribe((profileListPA: ProfileDescription[]) => {
if (profileListPA) {
profileListPA.forEach((p) => {
p.type = 'PA';
p.type = ProfileType.PA;
profiles.push(p);
});
this.retrievedProfiles.next(profiles);
Expand Down Expand Up @@ -176,10 +177,10 @@ export class ProfileService implements OnDestroy {
};
let profile: any = cloneDeep(file[0]);

const endPointUrl = profileType === 'PA' ? this.pastisConfig.savePAasFileUrl : this.pastisConfig.savePUAasFileUrl;
const endPointUrl = profileType === ProfileType.PA ? this.pastisConfig.savePAasFileUrl : this.pastisConfig.savePUAasFileUrl;
this.fixCircularReference(profile);

if (profileType === 'PUA') {
if (profileType === ProfileType.PUA) {
profile = { elementProperties: profile, notice };
}

Expand Down Expand Up @@ -245,7 +246,7 @@ export class ProfileService implements OnDestroy {

this.subscription2$ = this.getAllProfilesPAPaginated(pageRequest).subscribe((data: ProfileDescription[]) => {
if (data) {
data.forEach(p => p.type = 'PA');
data.forEach(p => p.type = ProfileType.PA);
data.forEach(p => tabVide.push(p));
this.retrievedProfiles.next(data);
}
Expand All @@ -254,7 +255,7 @@ export class ProfileService implements OnDestroy {
this.subscription1$ = this.getAllProfilesPUAPaginated(pageRequest).subscribe((data: ProfileDescription[]) => {
// @ts-ignore
if (data) {
data.forEach(p => p.type = 'PUA');
data.forEach(p => p.type = ProfileType.PUA);
this.retrievedProfiles.next(data);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {FileNode} from './file-node';
import { FileNode } from './file-node';
import { ProfileDescription } from './profile-description.model';
import { ProfileType } from './profile-type.enum';


export interface ProfileResponse {
id: string;
name: string;
profile: FileNode;
notice?: ProfileDescription;
type: string;
type: ProfileType;
}
32 changes: 32 additions & 0 deletions ui/ui-frontend/projects/pastis/src/app/models/profile-type.enum.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2022)
*
* contact.vitam@culture.gouv.fr
*
* This software is a computer program whose purpose is to implement a digital archiving back-office system managing
* high volumetry securely and efficiently.
*
* This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free
* software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as
* circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info".
*
* As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
* users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the
* successive licensors have only limited liability.
*
* In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or
* developing or reproducing the software by the user in light of its specific status of free software, that may mean
* that it is complicated to manipulate, and that also therefore means that it is reserved for developers and
* experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the
* software's suitability as regards their requirements in conditions enabling the security of their systems and/or data
* to be ensured and, more generally, to use and operate it in the same conditions as regards security.
*
* The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you
* accept its terms.
*
*/

export enum ProfileType {
PA = 'PA',
PUA = 'PUA',
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
import { environment } from '../../../environments/environment';
import { ProfileType } from '../../models/profile-type.enum';
import { PastisDialogData } from '../../shared/pastis-dialog/classes/pastis-dialog-data';


Expand All @@ -12,6 +13,7 @@ function constantToTranslate() {
this.secondChoice = this.translated('.SECOND_CHOICE');
this.title = this.translated('.TITLE');
}

@Component({
selector: 'create-notice-choice',
templateUrl: './create-notice-choice.component.html',
Expand All @@ -35,8 +37,8 @@ export class CreateNoticeChoiceComponent implements OnInit {
constantToTranslate.call(this);
this.translatedOnChange();
} else if (this.isStandalone) {
this.firstChoice = 'PA'
this.secondChoice = 'PUA'
this.firstChoice = ProfileType.PA
this.secondChoice = ProfileType.PUA
this.title = 'Choisir le type de notice à créer :'
}
}
Expand All @@ -63,14 +65,14 @@ export class CreateNoticeChoiceComponent implements OnInit {

changeChoiceCreateProfile($event: string) {
console.log($event)
this.noticePaChoice = $event == this.firstChoice;
this.noticePaChoice = $event === this.firstChoice;
}

onYesClick() {
if (this.noticePaChoice) {
this.dialogRef.close({success: true, action: 'PA'});
this.dialogRef.close({ success: true, action: ProfileType.PA });
} else if (!this.noticePaChoice) {
this.dialogRef.close({success: true, action: 'PUA'});
this.dialogRef.close({ success: true, action: ProfileType.PUA });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ The fact that you are presently reading this means that you have had
knowledge of the CeCILL-C license and that you accept its terms.
*/
import { Component, Inject, OnInit } from '@angular/core';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
import { LangChangeEvent, TranslateService } from '@ngx-translate/core';
import { environment } from '../../../environments/environment';
import { ProfileType } from '../../models/profile-type.enum';
import { PastisDialogData } from '../../shared/pastis-dialog/classes/pastis-dialog-data';

const POPUP_CREATION_CHOICE_PATH = 'PROFILE.POP_UP_CREATION.CHOICE';
Expand All @@ -52,7 +53,7 @@ function constantToTranslate() {
@Component({
selector: 'pastis-create-profile',
templateUrl: './create-profile.component.html',
styleUrls: [ './create-profile.component.scss' ]
styleUrls: ['./create-profile.component.scss']
})
export class CreateProfileComponent implements OnInit {
firstChoice: string;
Expand All @@ -70,8 +71,8 @@ export class CreateProfileComponent implements OnInit {
constantToTranslate.call(this);
this.translatedOnChange();
} else if (this.isStandalone) {
this.firstChoice = 'PA';
this.secondChoice = 'PUA';
this.firstChoice = ProfileType.PA;
this.secondChoice = ProfileType.PUA;
this.title = 'Sélectionner un profil d\'archivage :';
}
}
Expand Down Expand Up @@ -107,9 +108,9 @@ export class CreateProfileComponent implements OnInit {

onYesClick() {
if (this.profilPaChoice) {
this.dialogRef.close({ success: true, action: 'PA' });
this.dialogRef.close({ success: true, action: ProfileType.PA });
} else if (!this.profilPaChoice) {
this.dialogRef.close({ success: true, action: 'PUA' });
this.dialogRef.close({ success: true, action: ProfileType.PUA });
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@ import { NestedTreeControl } from '@angular/cdk/tree';
import { Component, OnDestroy, ViewChild } from '@angular/core';
import { MatTabChangeEvent } from '@angular/material/tabs';
import { MatTreeNestedDataSource } from '@angular/material/tree';
import {TranslateService} from '@ngx-translate/core';
import { TranslateService } from '@ngx-translate/core';
import { NgxUiLoaderService } from 'ngx-ui-loader';
import { BehaviorSubject, Subscription} from 'rxjs';
import {environment} from '../../../environments/environment';
import { BehaviorSubject, Subscription } from 'rxjs';
import { environment } from '../../../environments/environment';
import { FileService } from '../../core/services/file.service';
import { ProfileService } from '../../core/services/profile.service';
import { SedaService } from '../../core/services/seda.service';
import { ToggleSidenavService } from '../../core/services/toggle-sidenav.service';
import { FileNode } from '../../models/file-node';
import { ProfileType } from '../../models/profile-type.enum';
import { SedaData } from '../../models/seda-data';
import { FileTreeComponent } from './file-tree/file-tree.component';
import { FileTreeService } from './file-tree/file-tree.service';
Expand Down Expand Up @@ -105,7 +106,7 @@ export class EditProfileComponent implements OnDestroy {

profile: FileNode[];

@ViewChild(FileTreeComponent, {static: false}) fileTreeComponent: FileTreeComponent;
@ViewChild(FileTreeComponent, { static: false }) fileTreeComponent: FileTreeComponent;

private _fileServiceCurrentTreeSubscription: Subscription;

Expand All @@ -117,7 +118,7 @@ export class EditProfileComponent implements OnDestroy {
}

initAll() {
this.puaMode = this.profileService.profileMode === 'PA' ? false : true;
this.puaMode = this.profileService.profileMode !== ProfileType.PA;
if (!this.isStandalone) {
this.entete = 'PROFILE.EDIT_PROFILE.ENTETE';
this.regles = 'PROFILE.EDIT_PROFILE.REGLES';
Expand Down Expand Up @@ -190,7 +191,7 @@ export class EditProfileComponent implements OnDestroy {


initActiveTabAndProfileMode() {
this.profileService.profileMode === 'PA' ? this.activeTabIndex = 0 : this.activeTabIndex = 2;
this.profileService.profileMode === ProfileType.PA ? this.activeTabIndex = 0 : this.activeTabIndex = 2;
}

loadProfile(event: MatTabChangeEvent) {
Expand All @@ -199,9 +200,9 @@ export class EditProfileComponent implements OnDestroy {
}

setTabsAndMetadataRules(tabIndex: number) {
this.collectionName = this.profileService.profileMode === 'PA' ? this.collectionNames[tabIndex] : this.collectionNames[2];
this.rootTabMetadataName = this.profileService.profileMode === 'PA' ? this.rootNames[tabIndex] : this.rootNames[2];
this.elementRules = this.profileService.profileMode === 'PA' ? this.tabShowElementRules[tabIndex] : this.tabShowElementRules[2];
this.collectionName = this.profileService.profileMode === ProfileType.PA ? this.collectionNames[tabIndex] : this.collectionNames[2];
this.rootTabMetadataName = this.profileService.profileMode === ProfileType.PA ? this.rootNames[tabIndex] : this.rootNames[2];
this.elementRules = this.profileService.profileMode === ProfileType.PA ? this.tabShowElementRules[tabIndex] : this.tabShowElementRules[2];
}

loadProfileData(tabindex: number) {
Expand All @@ -225,7 +226,7 @@ export class EditProfileComponent implements OnDestroy {

getFilteredData(rootTreeMetadataName: string): FileNode[] {
if (this.nodeToSend) {
const nodeNameToFilter = this.profileService.profileMode === 'PA' ? rootTreeMetadataName : this.nodeToSend.name;
const nodeNameToFilter = this.profileService.profileMode === ProfileType.PA ? rootTreeMetadataName : this.nodeToSend.name;
const currentNode = this.fileService.getFileNodeByName(this.fileService.allData.getValue()[0], nodeNameToFilter);
const filteredData = [];
filteredData.push(currentNode);
Expand All @@ -241,7 +242,7 @@ export class EditProfileComponent implements OnDestroy {
}

canShowOnPuaMode(tabIndex: number) {
return this.profileService.profileMode === 'PUA' ? (tabIndex === 3) : true;
return this.profileService.profileMode === ProfileType.PUA ? (tabIndex === 3) : true;
}

ngOnDestroy() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,11 @@ import { SedaService } from '../../../core/services/seda.service';
import { BreadcrumbDataMetadata, BreadcrumbDataTop } from '../../../models/breadcrumb';
import { AttributeData } from '../../../models/edit-attribute-models';
import {
CardinalityConstants,
DataTypeConstants,
DateFormatType,
FileNode,
FileNodeInsertAttributeParams,
FileNodeInsertParams,
nodeNameToLabel,
TypeConstants,
ValueOrDataConstants,
CardinalityConstants, DataTypeConstants, DateFormatType, FileNode, FileNodeInsertAttributeParams, FileNodeInsertParams, nodeNameToLabel,
TypeConstants, ValueOrDataConstants,
} from '../../../models/file-node';
import { CardinalityValues, MetadataHeaders } from '../../../models/models';
import { ProfileType } from '../../../models/profile-type.enum';
import { PuaData } from '../../../models/pua-data';
import { SedaData, SedaElementConstants } from '../../../models/seda-data';
import { PastisDialogData } from '../../../shared/pastis-dialog/classes/pastis-dialog-data';
Expand Down Expand Up @@ -305,7 +299,7 @@ export class FileTreeMetadataComponent {
});
// BreadCrump Top for navigation
this.profileModeLabel =
this.profileService.profileMode === 'PUA'
this.profileService.profileMode === ProfileType.PUA
? 'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PUA'
: 'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PA';
this.breadcrumbDataTop = [
Expand Down Expand Up @@ -611,7 +605,7 @@ export class FileTreeMetadataComponent {
popData.okLabel = this.popupControlOkLabel;
popData.cancelLabel = this.popupAnnuler;

const popUpAnswer = <string[]>await this.fileService.openPopup(popData);
const popUpAnswer = await this.fileService.openPopup(popData) as string[];
console.log('The answer for arrays control was ', popUpAnswer);
if (popUpAnswer) {
this.arrayControl = popUpAnswer;
Expand Down Expand Up @@ -926,7 +920,7 @@ export class FileTreeMetadataComponent {
}

isElementEdit(node: MetadataHeaders): boolean {
if (this.profileService.profileMode === 'PUA') {
if (this.profileService.profileMode === ProfileType.PUA) {
return false;
}
if (node.nomDuChampEdit) {
Expand Down
Loading