diff --git a/ui/ui-frontend/projects/pastis/src/app/core/services/file.service.ts b/ui/ui-frontend/projects/pastis/src/app/core/services/file.service.ts index f738da0b0eab000c92835f532f5b6bbaa5b1a1b1..619db9f915e04c1443f2eee2526fba30ed4e3294 100644 --- a/ui/ui-frontend/projects/pastis/src/app/core/services/file.service.ts +++ b/ui/ui-frontend/projects/pastis/src/app/core/services/file.service.ts @@ -35,9 +35,9 @@ same conditions as regards security. 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 {Injectable} from '@angular/core'; +import {Injectable, OnDestroy} from '@angular/core'; import {MatDialog} from '@angular/material/dialog'; -import {BehaviorSubject, ReplaySubject} from 'rxjs'; +import {BehaviorSubject, ReplaySubject, Subscription} from 'rxjs'; import {SedaCardinalityConstants, SedaData, SedaElementConstants} from '../../profile/edit-profile/classes/seda-data'; import {FileNode, TypeConstants} from '../../profile/edit-profile/classes/file-node'; import {PastisDialogConfirmComponent} from '../../shared/pastis-dialog/pastis-dialog-confirm/pastis-dialog-confirm.component'; @@ -52,7 +52,7 @@ import { NoticeProfile, ProfileResponse } from '../../profile/edit-profile/class providedIn: 'root' }) -export class FileService { +export class FileService implements OnDestroy { currentTree = new ReplaySubject<FileNode[]>(); notice = new BehaviorSubject<NoticeProfile>(null); @@ -71,6 +71,8 @@ export class FileService { parentNodeMap = new Map<FileNode, FileNode>(); sedaDataArchiveUnit : SedaData; + private _profileServiceGetProfileSubscription : Subscription; + constructor(private profileService: ProfileService, private fileMetadataService: FileTreeMetadataService, private dialog: MatDialog, private sedaService: SedaService) { } @@ -80,6 +82,9 @@ export class FileService { */ updateTreeWithProfile(profileResponse: ProfileResponse) { this.profileService.profileMode = profileResponse.type; + this.profileService.profileName = profileResponse.name; + this.profileService.profileId = profileResponse.id; + let sedaDataArray: SedaData[] = [this.sedaService.sedaRules[0]]; this.linkFileNodeToSedaData(null, [profileResponse.profile], sedaDataArray); this.currentTree.next([profileResponse.profile]); @@ -94,7 +99,7 @@ export class FileService { * @param id id of profile to get */ getProfileAndUpdateTree(id:number){ - this.profileService.getProfile(id).subscribe((response) => { + this._profileServiceGetProfileSubscription = this.profileService.getProfile(id).subscribe((response) => { this.updateTreeWithProfile(response); }); } @@ -387,4 +392,11 @@ export class FileService { this.fileMetadataService.dataSource.next(dataTable); } } + + ngOnDestroy() { + console.log('fileService.currentTreeLoaded2 ' + this.currentTreeLoaded) + if(this._profileServiceGetProfileSubscription!= null){ + this._profileServiceGetProfileSubscription.unsubscribe(); + } + } } diff --git a/ui/ui-frontend/projects/pastis/src/app/core/services/profile.service.ts b/ui/ui-frontend/projects/pastis/src/app/core/services/profile.service.ts index 91a7cb8a63495ce230c7692b748a7ddcada25b9d..6f2637600a6e8a7a822a6cc0f04f99a590735f14 100644 --- a/ui/ui-frontend/projects/pastis/src/app/core/services/profile.service.ts +++ b/ui/ui-frontend/projects/pastis/src/app/core/services/profile.service.ts @@ -53,6 +53,8 @@ export class ProfileService { private apiServerPath: string; public profileMode : string; + public profileName: string; + public profileId: number; constructor(private apiService: PastisApiService, private pastisConfig: PastisConfiguration) { this.apiServerPath = isDevMode() ? environment.apiServerUrl : pastisConfig.apiPastisUrl; diff --git a/ui/ui-frontend/projects/pastis/src/app/main/main.component.html b/ui/ui-frontend/projects/pastis/src/app/main/main.component.html index 24c3e0048cce90ed9cbfac21fadc1fee9fbb5579..5904183a6207fc0fd014c3536c39a295defa7971 100644 --- a/ui/ui-frontend/projects/pastis/src/app/main/main.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/main/main.component.html @@ -11,7 +11,7 @@ <mat-sidenav #sidenav mode="side" [(opened)]="opened" (opened)="events.push('open!')" (closed)="events.push('close!')" class='pastis-side-nav'> - <pastis-edit-profile [profileId]="profileId"></pastis-edit-profile> + <pastis-edit-profile *ngIf="fileService.currentTreeLoaded"></pastis-edit-profile> </mat-sidenav> <mat-sidenav-content > <div class="pastis-entete-bandeau"></div> diff --git a/ui/ui-frontend/projects/pastis/src/app/main/main.component.ts b/ui/ui-frontend/projects/pastis/src/app/main/main.component.ts index a786f51541c9d60c05faf62c879ec41488fcfe64..472f719f0d9f66a6d95e67717cace44ac75b8169 100644 --- a/ui/ui-frontend/projects/pastis/src/app/main/main.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/main/main.component.ts @@ -40,7 +40,7 @@ import {CdkTextareaAutosize} from '@angular/cdk/text-field'; import {ActivatedRoute, Router} from '@angular/router'; import {ToggleSidenavService} from '../core/services/toggle-sidenav.service'; import {ToastContainerDirective, ToastrService} from 'ngx-toastr'; -import {Subscription} from 'rxjs'; +import {BehaviorSubject, ReplaySubject, Subscription} from 'rxjs'; import {EditProfileComponent} from '../profile/edit-profile/edit-profile.component'; import {FileNode, FileNodeInsertAttributeParams, FileNodeInsertParams} from "../profile/edit-profile/classes/file-node"; import { FileService } from '../core/services/file.service'; @@ -63,12 +63,13 @@ export class MainComponent implements OnInit, OnDestroy { opened: boolean; events: string[] = []; - profileId: number; noticeDisplay: boolean; - noticeDisplaySub: Subscription; uploadedProfileResponse: ProfileResponse; + private _noticeDisplaySubscription: Subscription; + private _routeParamsSubscription : Subscription; + constructor(private route: ActivatedRoute,private sideNavService : ToggleSidenavService, private toastrService: ToastrService, public fileService: FileService, private router: Router) { this.uploadedProfileResponse = this.router.getCurrentNavigation().extras.state as ProfileResponse; @@ -77,23 +78,27 @@ export class MainComponent implements OnInit, OnDestroy { this.opened = status; }) - this.noticeDisplaySub = this.sideNavService.noticeSelected.subscribe(statusNotice => { + this._noticeDisplaySubscription = this.sideNavService.noticeSelected.subscribe(statusNotice => { this.noticeDisplay = statusNotice; console.log('consolee ======> status'+ this.noticeDisplay) }) } ngOnInit() { + this.fileService.currentTreeLoaded = false; + this.fileService.currentTree = new ReplaySubject<FileNode[]>(); + this.fileService.allData = new BehaviorSubject<FileNode[]>([]); this.toastrService.overlayContainer = this.toastContainer; - this.route.params.subscribe(params => { - this.profileId = params['id']; + this._routeParamsSubscription = this.route.params.subscribe(params => { + let profileId = params['id']; // If a profileId has been defined, it is retrieved from backend - if (this.profileId != undefined) { - this.fileService.getProfileAndUpdateTree(this.profileId); + if (profileId !== undefined) { + this.fileService.getProfileAndUpdateTree(profileId); } else { // Otherwise we must have an user uploaded profile - this.profileId = this.uploadedProfileResponse.id; + this.uploadedProfileResponse.id = null; + this.uploadedProfileResponse.name = 'Nouveau Profil'; this.fileService.updateTreeWithProfile(this.uploadedProfileResponse); } }); @@ -131,7 +136,12 @@ export class MainComponent implements OnInit, OnDestroy { } ngOnDestroy(): void { - this.noticeDisplaySub.unsubscribe(); + if(this._noticeDisplaySubscription!= null){ + this._noticeDisplaySubscription.unsubscribe(); + } + if(this._routeParamsSubscription!= null){ + this._routeParamsSubscription.unsubscribe(); + } } } diff --git a/ui/ui-frontend/projects/pastis/src/app/notice/notice.component.html b/ui/ui-frontend/projects/pastis/src/app/notice/notice.component.html index 0c2e4ded59dd0bfc4b1152cae0ca790ce2d7bf3c..147ff461463219860de3bb76cfdaa01a60c255de 100644 --- a/ui/ui-frontend/projects/pastis/src/app/notice/notice.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/notice/notice.component.html @@ -8,7 +8,15 @@ <div class="pastis-metadata-option-container"> <!-- Top left panel container --> <div class="pastis-metadata-option-entete-1"> - <h5><i class="vitamui-icon vitamui-icon-dossier-physique"></i>{{profileModeLabel}}</h5> + <h5> + <i class="vitamui-icon vitamui-icon-dossier-physique"></i> + <ng-container *ngIf="this.profileService.profileMode==='PUA'"> + {{'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PUA' | translate}} + </ng-container> + <ng-container *ngIf="this.profileService.profileMode==='PA'"> + {{'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PA' | translate}} + </ng-container> + </h5> </div> <!--Top right panel container--> <div class="pastis-metadata-option-entete-2"> diff --git a/ui/ui-frontend/projects/pastis/src/app/notice/notice.component.ts b/ui/ui-frontend/projects/pastis/src/app/notice/notice.component.ts index abda3acbc2a0af95012443a1b9f64b1c67da1fc1..a16b18c8780a753e2fad8601b9105f7a8a3dd282 100644 --- a/ui/ui-frontend/projects/pastis/src/app/notice/notice.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/notice/notice.component.ts @@ -48,6 +48,7 @@ import { FileService } from '../core/services/file.service'; import { BreadcrumbDataTop } from '../profile/edit-profile/classes/breadcrumb'; import { StartupService } from 'ui-frontend-common'; import { environment } from '../../environments/environment'; + @Component({ selector: 'pastis-notice', templateUrl: './notice.component.html', @@ -124,8 +125,8 @@ export class NoticeComponent implements OnInit, OnDestroy { ngOnInit() { this.languagePopup = false; this.docPath = this.isStandalone ? 'assets/doc/Standalone - Documentation APP - PASTIS.pdf' : 'assets/doc/VITAM UI - Documentation APP - PASTIS.pdf'; - this.profileModeLabel = this.profileService.profileMode==='PUA'?'Profil d\'Unité Archivistique':'Profil d\'Archivage'; - this.breadcrumbDataTop = [{ label: 'Portail', url: this.startupService.getPortalUrl(), external: true},{ label: 'Créer et gérer un profil d\'archivage', url: '/'}, { label: this.profileModeLabel }]; + this.profileModeLabel = this.profileService.profileMode==='PUA'?"PROFILE.EDIT_PROFILE.BREADCRUMB.PUA":"PROFILE.EDIT_PROFILE.BREADCRUMB.PA"; + this.breadcrumbDataTop = [{ label: "PROFILE.EDIT_PROFILE.BREADCRUMB.PORTAIL", url: this.startupService.getPortalUrl(), external: true},{ label: "PROFILE.EDIT_PROFILE.BREADCRUMB.CREER_ET_GERER_PROFIL", url: '/'}, { label: this.profileModeLabel }]; this.openedSub = this.sideNavService.isOpened.subscribe((status) => { this.opened = status; diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/classes/file-node.ts b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/classes/file-node.ts index b50ba65cff5e767a20ff26048ca8aabf2bd527c2..2a0f23a3f9881370b764dbca6b798c16d51f5811 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/classes/file-node.ts +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/classes/file-node.ts @@ -123,9 +123,9 @@ export interface FileNodeInsertAttributeParams { } export enum nodeNameToLabel { -'notice' = 'Notice', -'ArchiveTransfer' = 'Entête', -'ManagementMetadata' = 'Règles', -'DescriptiveMetadata' = 'Unités d\'archives', -'DataObjectPackage' = 'Objets' +'notice' = 'PROFILE.EDIT_PROFILE.NOTICE_TAB', +'ArchiveTransfer' = 'PROFILE.EDIT_PROFILE.ENTETE', +'ManagementMetadata' = 'PROFILE.EDIT_PROFILE.REGLES', +'DescriptiveMetadata' = 'PROFILE.EDIT_PROFILE.UNITES_ARCHIVES', +'DataObjectPackage' = 'PROFILE.EDIT_PROFILE.OBJETS' } diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/classes/profile-response.ts b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/classes/profile-response.ts index 3c37b99da86c9115e1864d12d791d40829d7e016..143c99ae06e7ba9a0ee09cd0339d1713ecc0deb4 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/classes/profile-response.ts +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/classes/profile-response.ts @@ -3,10 +3,12 @@ import { FileNode } from "./file-node"; export interface ProfileResponse{ id:number; + name: string; profile: FileNode; notice?: NoticeProfile; type: string; } + export interface NoticeProfile{ Description: string; _id: string; diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/edit-profile.component.html b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/edit-profile.component.html index b1e1200ebabca4150d00c2fb3fdc6a12a75f7755..4e9942c1d784f6f3f0ef6d363a8dcd813d5d446e 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/edit-profile.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/edit-profile.component.html @@ -5,10 +5,11 @@ <div class="pastis-edit-profile-header-name"> <p class="text large bold text-primary"> - <ng-container>{{getProfileName(profileId)}}</ng-container> + <ng-container>{{this.profileService.profileName}}</ng-container> + </p> </div> - <div class="pastis-edit-profile-header-id"> - <p class="text medium light">{{'PROFILE.EDIT_PROFILE.PROFILE_ID' | translate}} : {{profileId}}</p> + <div *ngIf="this.profileService.profileId!==null" class="pastis-edit-profile-header-id"> + <p class="text medium light">{{'PROFILE.EDIT_PROFILE.PROFILE_ID' | translate}} : {{this.profileService.profileId}}</p> </div> </div> <div class ="mat-table"> @@ -19,12 +20,12 @@ (selectedTabChange)="loadProfile($event)" fxFill> - <mat-tab label="{{puaMode ? tabLabels[5] : tabLabels[0]}}" *ngIf="canShowOnPuaMode(0)"> + <mat-tab label="{{(puaMode ? tabLabels[5] : tabLabels[0]) | translate}}" *ngIf="canShowOnPuaMode(0)"> </mat-tab> - <mat-tab label="{{tabLabels[1]}}" *ngIf="canShowOnPuaMode(1)"> + <mat-tab label="{{tabLabels[1] | translate}}" *ngIf="canShowOnPuaMode(1)"> <div class="pastis-tab-container" > <ng-template matTabContent> - <pastis-file-tree + <pastis-file-tree *ngIf="fileService.currentTreeLoaded" [rootElementName] = "rootNames[1]" [rootElementShowName]="displayedRootNames[1]" [childrenListToExclude]="headerTabChildrenToExclude" @@ -35,10 +36,10 @@ </div> </mat-tab> - <mat-tab label="{{tabLabels[2]}}" *ngIf="canShowOnPuaMode(2)"> + <mat-tab label="{{tabLabels[2] | translate}}" *ngIf="canShowOnPuaMode(2)"> <div class="pastis-tab-container"> <ng-template matTabContent> - <pastis-file-tree + <pastis-file-tree *ngIf="fileService.currentTreeLoaded" [rootElementName]="rootNames[2]" [rootElementShowName]="displayedRootNames[2]" [childrenListToInclude]="rulesTabChildrenToInclude" @@ -50,10 +51,10 @@ </div> </mat-tab> - <mat-tab label="{{puaMode ? tabLabels[6] : tabLabels[3]}}" *ngIf="canShowOnPuaMode(3)"> + <mat-tab label="{{(puaMode ? tabLabels[6] : tabLabels[3]) | translate}}" *ngIf="canShowOnPuaMode(3)"> <div class="pastis-tab-container"> <ng-template matTabContent> - <pastis-file-tree + <pastis-file-tree *ngIf="fileService.currentTreeLoaded" [rootElementName]="rootNames[3]" [rootElementShowName]="displayedRootNames[3]" [childrenListToInclude]="treeTabChildrenToInclude" @@ -65,10 +66,10 @@ </div> </mat-tab> - <mat-tab label="{{tabLabels[4]}}" *ngIf="canShowOnPuaMode(4)"> + <mat-tab label="{{tabLabels[4] | translate}}" *ngIf="canShowOnPuaMode(4)"> <div class="pastis-tab-container"> <ng-template matTabContent> - <pastis-file-tree + <pastis-file-tree *ngIf="fileService.currentTreeLoaded" [rootElementName]="rootNames[4]" [rootElementShowName]="displayedRootNames[4]" [childrenListToInclude]="objectTabChildrenToInclude" diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/edit-profile.component.ts b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/edit-profile.component.ts index 078fe46b1b8be1a185285f43d911f8741e80601e..5dd013209235feb766b2c02dc4f4893a1500bc46 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/edit-profile.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/edit-profile.component.ts @@ -36,23 +36,20 @@ 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, OnDestroy, ViewChild, Input } from '@angular/core'; +import { Component, OnDestroy, ViewChild } from '@angular/core'; import { ToggleSidenavService } from '../../core/services/toggle-sidenav.service'; import { FileService } from '../../core/services/file.service'; import { SedaService } from '../../core/services/seda.service'; - import { FileNode } from './classes/file-node'; import { MatTabChangeEvent } from '@angular/material/tabs'; import { MatTreeNestedDataSource } from '@angular/material/tree'; import { NestedTreeControl } from '@angular/cdk/tree'; -import { BehaviorSubject} from 'rxjs'; +import { BehaviorSubject, Subscription} from 'rxjs'; import { FileTreeComponent } from './file-tree/file-tree.component'; import { SedaData } from './classes/seda-data'; import { NgxUiLoaderService } from 'ngx-ui-loader'; import { ProfileService } from 'projects/pastis/src/app/core/services/profile.service'; -import { ProfileDescription } from '../list-profile/models/profile-description.model'; import { FileTreeService } from './file-tree/file-tree.service'; -import { Router} from '@angular/router'; import {TranslateService} from '@ngx-translate/core'; import {environment} from "../../../environments/environment"; @@ -71,13 +68,6 @@ export interface UploadedProfileResponse { export class EditProfileComponent implements OnDestroy { - @Input() - profileId: number; - - profileName: string; - - profileList: ProfileDescription[]; - nodeToSend: FileNode; sedaParentNode: SedaData; @@ -134,30 +124,23 @@ export class EditProfileComponent implements OnDestroy { @ViewChild(FileTreeComponent, {static: false}) fileTreeComponent: FileTreeComponent; noticeSelected: boolean; + private _fileServiceCurrentTreeSubscription : Subscription; constructor(private sedaService: SedaService, private fileService: FileService, - private sideNavService: ToggleSidenavService, private profileService: ProfileService, - private loaderService: NgxUiLoaderService, private fileTreeService:FileTreeService, private router: Router, + private sideNavService: ToggleSidenavService, public profileService: ProfileService, + private loaderService: NgxUiLoaderService, private fileTreeService:FileTreeService, private translateService: TranslateService) { } initAll(){ - - if(this.router.url != '/new'){ - this.profileService.getAllProfiles().subscribe(profileList => { - if (profileList) { - this.profileList = profileList; - } - }) - } if(!this.isStandalone){ - this.noticeTab = this.translated('.NOTICE_TAB'); - this.entete = this.translated('.ENTETE'); - this.regles = this.translated('.REGLES'); - this.unitesArchives = this.translated('.UNITES_ARCHIVES'); - this.objets = this.translated('.OBJETS'); - this.noticePuaMode = this.translated('.NOTICE_PUA_MODE'); - this.unitesArchivesPuaMode= this.translated('.UNITES_ARCHIVES_PUA_MODE'); + this.noticeTab = 'PROFILE.EDIT_PROFILE.NOTICE_TAB'; + this.entete = 'PROFILE.EDIT_PROFILE.ENTETE'; + this.regles = 'PROFILE.EDIT_PROFILE.REGLES'; + this.unitesArchives = 'PROFILE.EDIT_PROFILE.UNITES_ARCHIVES'; + this.objets = 'PROFILE.EDIT_PROFILE.OBJETS'; + this.noticePuaMode = 'PROFILE.EDIT_PROFILE.NOTICE_PUA_MODE'; + this.unitesArchivesPuaMode= 'PROFILE.EDIT_PROFILE.UNITES_ARCHIVES_PUA_MODE'; } this.tabLabels.push(this.noticeTab, this.entete, this.regles, this.unitesArchives, this.objets, this.noticePuaMode,this.unitesArchivesPuaMode); //Set tab and metadata rules according to profile type @@ -202,7 +185,7 @@ export class EditProfileComponent implements OnDestroy { } ngAfterViewInit () { - this.fileService.currentTree.subscribe(response => { + this._fileServiceCurrentTreeSubscription = this.fileService.currentTree.subscribe(response => { this.initActiveTabAndProfileMode(); this.initAll(); if (response && response!==undefined) { @@ -308,23 +291,10 @@ export class EditProfileComponent implements OnDestroy { return this.profileService.profileMode === "PUA" ? (tabIndex === 0 || tabIndex === 3 || tabIndex === 5) : true; } - getProfileName(profileId: number): string{ - if(profileId == undefined) { - return null - }; - if(this.profileList != undefined){ - let profiles: ProfileDescription[] = this.profileList.filter(profile => profile.id == profileId); - this.profileName = profiles[0].baseName; - if(this.profileName != undefined){ - return profiles[0].baseName; - } - } - - return null; - - } - ngOnDestroy() { + if(this._fileServiceCurrentTreeSubscription!= null){ + this._fileServiceCurrentTreeSubscription.unsubscribe(); + } } } diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html index 38fefd3c4bc1e43f82fddb6d8b64d8cef3731d78..f2be850a295b49ee004d90d8902f9b0b266db6bf 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.html @@ -8,7 +8,15 @@ <div class="pastis-metadata-option-container"> <!-- Top left panel container --> <div class="pastis-metadata-option-entete-1"> - <h5><i class="vitamui-icon vitamui-icon-dossier-physique"></i>{{profileModeLabel}}</h5> + <h5> + <i class="vitamui-icon vitamui-icon-dossier-physique"></i> + <ng-container *ngIf="this.profileService.profileMode==='PUA'"> + {{'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PUA' | translate}} + </ng-container> + <ng-container *ngIf="this.profileService.profileMode==='PA'"> + {{'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PA' | translate}} + </ng-container> + </h5> <pastis-breadcrumb [data]="breadcrumbDataMetadata" (selected)="navigateMetadata($event)"> @@ -166,18 +174,17 @@ <mat-menu #menu="matMenu" [overlapTrigger]="false" class="pastis-menu-item-vitam"> <!-- Dupliquer--> - <mat-divider *ngIf="isDuplicated(element.nomDuChamp)" style="border-top-color:#E0E0E0;"> + <mat-divider *ngIf="isDuplicated(element.nomDuChamp) && this.profileService.profileMode==='PA'" style="border-top-color:#E0E0E0;"> </mat-divider> - <button *ngIf="isDuplicated(element.nomDuChamp)" mat-menu-item (click)="onDuplicateNode(element.id)"> + <button *ngIf="isDuplicated(element.nomDuChamp) && this.profileService.profileMode==='PA'" mat-menu-item (click)="onDuplicateNode(element.id)"> <mat-icon style="color:#757575">filter_none</mat-icon> <span class="text normal">{{'PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.DUPLIQUER' | translate}}</span> </button> <!-- @Attributs--> - <mat-divider *ngIf="hasAttributes(element.nomDuChamp)" style="border-top-color:#E0E0E0;"></mat-divider> - <button *ngIf="hasAttributes(element.nomDuChamp);" (click)="onEditAttributesClick(element.id)" + <mat-divider *ngIf="hasAttributes(element.nomDuChamp) && this.profileService.profileMode==='PA'" style="border-top-color:#E0E0E0;"></mat-divider> + <button *ngIf="hasAttributes(element.nomDuChamp) && this.profileService.profileMode==='PA'" (click)="onEditAttributesClick(element.id)" mat-menu-item> <i class="vitamui-icon vitamui-icon-alternate_email_black_24dp" style="margin-right: 16px; ->>>>>>> feat/test vertical-align: middle; color:#757575; font-size: 1.77em;"> diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts index 43d3ed5fd390a9957ae4c851dbbd096ad847902c..d30aa26d01634ae81033eaa13732497e7cf51d92 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree-metadata/file-tree-metadata.component.ts @@ -183,7 +183,7 @@ export class FileTreeMetadataComponent { constructor(private fileService: FileService, private fileMetadataService: FileTreeMetadataService, private sedaService: SedaService, private fb: FormBuilder, private notificationService: NotificationService, private router: Router, private startupService: StartupService, - private profileService: ProfileService, private fileTreeService:FileTreeService, private metadataLanguageService: PastisPopupMetadataLanguageService, + public profileService: ProfileService, private fileTreeService:FileTreeService, private metadataLanguageService: PastisPopupMetadataLanguageService, private translateService: TranslateService) { this.config = { @@ -224,11 +224,11 @@ export class FileTreeMetadataComponent { this.clickedNode = node; // BreadCrumb for navigation through metadatas if (node && node!==undefined) { - let breadCrumbNodeLabel: string = node.name ; + let breadCrumbNodeLabel: string = node.name; this.fileService.tabRootNode.subscribe(tabRootNode => { if (tabRootNode){ let tabLabel = (<any>nodeNameToLabel)[tabRootNode.name]; - this.breadcrumbDataMetadata = [{ label: tabLabel, node: tabRootNode}]; + this.breadcrumbDataMetadata = [{ label: this.onResolveName(tabLabel), node: tabRootNode}]; if (tabRootNode.name !== breadCrumbNodeLabel){ if(node.parent){ if (node.parent.name!==tabRootNode.name){ @@ -237,7 +237,7 @@ export class FileTreeMetadataComponent { this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([ { label: '...' } ]); } } - this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([ { label: node.parent.name, node: node.parent } ]); + this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([ { label: this.onResolveName(node.parent.name), node: node.parent } ]); } this.breadcrumbDataMetadata = this.breadcrumbDataMetadata.concat([ { label: breadCrumbNodeLabel } ]); } @@ -247,8 +247,8 @@ export class FileTreeMetadataComponent { } }); // BreadCrump Top for navigation - this.profileModeLabel = this.profileService.profileMode==='PUA'?'Profil d\'Unité Archivistique':'Profil d\'Archivage'; - this.breadcrumbDataTop = [{ label: 'Portail', url: this.startupService.getPortalUrl(), external: true},{ label: 'Créer et gérer un profil d\'archivage', url: '/'}, { label: this.profileModeLabel }]; + this.profileModeLabel = this.profileService.profileMode==='PUA'?"PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PUA":"PROFILE.EDIT_PROFILE.FILE_TREE_METADATA.PA"; + this.breadcrumbDataTop = [{ label: "PROFILE.EDIT_PROFILE.BREADCRUMB.PORTAIL", url: this.startupService.getPortalUrl(), external: true},{ label: "PROFILE.EDIT_PROFILE.BREADCRUMB.CREER_ET_GERER_PROFIL", url: '/'}, { label: this.profileModeLabel }]; this._fileServiceSubscription = this.fileService.currentTree.subscribe(fileTree => { if (fileTree) { diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree/file-tree.component.html b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree/file-tree.component.html index e7c49a5984dec01e157132bf8cd6e22ebcd1a499..973b6710f53f67aa8defbbf5596ea39a8b424819 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree/file-tree.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree/file-tree.component.html @@ -3,7 +3,7 @@ <!-- Nested tree node--> <mat-nested-tree-node *matTreeNodeDef="let node;when:hasNestedChild"> - <div *ngIf="node.name === rootElementName && (activeTabIndex === 3 && !puaMode) " class="pastis-btn-container-add-ua"> + <div *ngIf="node.name === rootElementName && (activeTabIndex === 3 && this.profileService.profileMode === 'PA') " class="pastis-btn-container-add-ua"> <button class="btn primary" (click)= addArchiveUnit(node)> {{'PROFILE.EDIT_PROFILE.FILE_TREE.AJOUTER_UA' | translate}} </button> @@ -15,7 +15,7 @@ > <!--Root node name--> - <span *ngIf="node.name === rootElementName && !puaMode" class="pastis-tree-node-root-name"> + <span *ngIf="node.name === rootElementName && this.profileService.profileMode === 'PA'" class="pastis-tree-node-root-name"> <span [ngStyle]="{'margin-left': calculateNodePosition(node) + 'px'}"> {{rootElementShowName}} </span> @@ -51,7 +51,7 @@ tooltip="Ajouter une UA" tooltip-class="pastis-tooltip-class"> <!--Button plus--> - <button class="pastis-btn-add-ua" *ngIf="!puaMode" (click)= "addArchiveUnit(node)"> + <button class="pastis-btn-add-ua" *ngIf="this.profileService.profileMode === 'PA'" (click)= "addArchiveUnit(node)"> <i class="vitamui-icon vitamui-icon-add" style="color: var(--vitamui-primary);"></i> <span class="pastis-btn-add-ua-text">{{'PROFILE.EDIT_PROFILE.FILE_TREE.AJOUTER_UA_ICON' | translate}}</span> </button> @@ -60,14 +60,8 @@ </div> <mat-divider class="pastis-divider"></mat-divider> </span> - - </mat-list-item> - - - - <ul [hidden]="!fileTreeService.nestedTreeControl.isExpanded(node)" class="pastis-tree-ul"> <ng-container matTreeNodeOutlet></ng-container> </ul> diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree/file-tree.component.ts b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree/file-tree.component.ts index d6ad6a6efe4303eec601d5dc0f3e3dc2a99b2118..a25991df5456bc9f592a7542335dcdcde73d3907 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree/file-tree.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/profile/edit-profile/file-tree/file-tree.component.ts @@ -52,6 +52,7 @@ import { FileTreeService } from './file-tree.service'; import {DuplicateMetadataComponent} from "../../../user-actions/duplicate-metadata/duplicate-metadata.component"; import {LangChangeEvent, TranslateService} from "@ngx-translate/core"; import {environment} from "../../../../environments/environment"; +import { ProfileService } from '../../../core/services/profile.service'; const FILE_TREE_TRANSLATE_PATH = 'PROFILE.EDIT_PROFILE.FILE_TREE'; @@ -163,9 +164,9 @@ export class FileTreeComponent implements OnDestroy { private _fileTreeServiceUpdateMedataTable: Subscription; constructor(private fileService: FileService, private loggingService: NotificationService, - private fileMetadataService: FileTreeMetadataService, - private sedaService: SedaService, private sedaLanguageService: PastisPopupMetadataLanguageService, public fileTreeService:FileTreeService, - private translateService: TranslateService) { } + private fileMetadataService: FileTreeMetadataService, private sedaService: SedaService, + private sedaLanguageService: PastisPopupMetadataLanguageService, public fileTreeService:FileTreeService, + private translateService: TranslateService, public profileService: ProfileService) { } ngOnInit() { if(!this.isStandalone){ diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/list-profile/list-profile.component.html b/ui/ui-frontend/projects/pastis/src/app/profile/list-profile/list-profile.component.html index 148541d2a1b736f37de8fbbd0fe055803ff83145..b837e566ab4c8cc4d1fd673a29c5ab778bda2d3b 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/list-profile/list-profile.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/profile/list-profile/list-profile.component.html @@ -7,7 +7,6 @@ <pastis-title-breadcrumb *ngIf="!isStandalone" class="breadcrumbTop" [data]="breadcrumbDataTop" (selected)="navigate($event)"> - {{'PROFILE.LIST_PROFILE.CREER_GERER_PROFILE_ARCHIVAGE' | translate}} </pastis-title-breadcrumb> <vitamui-common-banner [searchbarPlaceholder]="'PROFILE.LIST_PROFILE.SEARCH_PLACEHOLDER' | translate" diff --git a/ui/ui-frontend/projects/pastis/src/app/profile/list-profile/list-profile.component.ts b/ui/ui-frontend/projects/pastis/src/app/profile/list-profile/list-profile.component.ts index ee00c5514f3e2d49f3ca5320a6a330f351ce7825..7cf0cfdceb829774eb049337f58d1b91cd434bc2 100644 --- a/ui/ui-frontend/projects/pastis/src/app/profile/list-profile/list-profile.component.ts +++ b/ui/ui-frontend/projects/pastis/src/app/profile/list-profile/list-profile.component.ts @@ -78,8 +78,6 @@ export class ListProfileComponent implements OnInit { buttonIsClicked: boolean; - data = ["portail"] - search: string; _uploadProfileSub: Subscription; @@ -99,7 +97,8 @@ export class ListProfileComponent implements OnInit { private startupService: StartupService) { } ngOnInit() { - this.breadcrumbDataTop = [{ label: 'Portail', url: this.startupService.getPortalUrl(), external: true},{ label: 'Créer et gérer un profil d\'archivage', url: '/'}]; + this.breadcrumbDataTop = [{ label: "PROFILE.EDIT_PROFILE.BREADCRUMB.PORTAIL", url: this.startupService.getPortalUrl(), external: true},{ label: "PROFILE.EDIT_PROFILE.BREADCRUMB.CREER_ET_GERER_PROFIL", url: '/'}]; + this.ngxLoader.startLoader('table-profiles'); // start non-master loader this.profileService.getAllProfiles().subscribe(profileList => { if (profileList) { diff --git a/ui/ui-frontend/projects/pastis/src/app/shared/pastis-breadcrumb-components/pastis-breadcrumb/pastis-breadcrumb.component.html b/ui/ui-frontend/projects/pastis/src/app/shared/pastis-breadcrumb-components/pastis-breadcrumb/pastis-breadcrumb.component.html index 662d067a963d764a23c427b98bf803fda73123cf..597287f4cec467a0ef9e909dbeecfa1dfb0f77e0 100644 --- a/ui/ui-frontend/projects/pastis/src/app/shared/pastis-breadcrumb-components/pastis-breadcrumb/pastis-breadcrumb.component.html +++ b/ui/ui-frontend/projects/pastis/src/app/shared/pastis-breadcrumb-components/pastis-breadcrumb/pastis-breadcrumb.component.html @@ -27,7 +27,7 @@ <div class="pastis-breadcrumb"> <ng-container *ngFor="let d of data; let last = last"> - <span (click)="onClick(d, !last)">{{d.label}}</span> + <span (click)="onClick(d, !last)">{{d.label | translate}}</span> <i *ngIf="!last" class="material-icons px-2">trending_flat</i> </ng-container> </div> diff --git a/ui/ui-frontend/projects/pastis/src/app/shared/shared.module.ts b/ui/ui-frontend/projects/pastis/src/app/shared/shared.module.ts index 2ebdb3094b5e45f3b5ce3fe8af78713205ee0e96..557a91882d3970272261fa9032a542b2c597e479 100644 --- a/ui/ui-frontend/projects/pastis/src/app/shared/shared.module.ts +++ b/ui/ui-frontend/projects/pastis/src/app/shared/shared.module.ts @@ -52,6 +52,7 @@ import {CenterMatmenuDirective} from "../profile/edit-profile/file-tree-metadata import { PastisPopupMetadataLanguageComponent } from './pastis-popup-metadata-language/pastis-popup-metadata-language.component'; import { PastisBreadcrumbComponent } from './pastis-breadcrumb-components/pastis-breadcrumb/pastis-breadcrumb.component'; import { PastisTitleBreadcrumbComponent } from './pastis-breadcrumb-components/pastis-title-breadcrumb/pastis-title-breadcrumb.component'; +import { TranslateModule } from '@ngx-translate/core'; @NgModule({ declarations: [ @@ -70,7 +71,8 @@ import { PastisTitleBreadcrumbComponent } from './pastis-breadcrumb-components/p TooltipModule, PastisMaterialModule, MatSlideToggleModule, - PortalModule + PortalModule, + TranslateModule ], entryComponents: [PastisDialogConfirmComponent, PastisUnderConstructionComponent], exports: [ diff --git a/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json b/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json index d124184072a172a54e15526e3314cfb69d2e4d38..f02f19ba3d064a0582373abb546f9896dc36f868 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n/en.json @@ -39,6 +39,10 @@ "NOM_PUA": "Name of the archival unit profile", "NOM_PA": "Archive profile name", "PROFILE_ID": "Username", + "BREADCRUMB":{ + "PORTAIL": "Portal", + "CREER_ET_GERER_PROFIL": "Create and manage documentary profiles" + }, "FILE_TREE": { "AJOUTER_UA": "ADD A UA", "AJOUTER_UA_ICON": "ADD A UA", @@ -73,6 +77,8 @@ "POPUP_DUPLICATE_TITRE_TWO": "its content and configuration (cardinalities and comments)" }, "FILE_TREE_METADATA": { + "PUA": "Archiving Unit Profile", + "PA": "Archiving Profile", "SEARCH_PLACEHOLDER": "Find metadata in the table", "NOTIFICATION_AJOUT_METADONNEE": "ArchiveUnit metadata has been added", "BOUTON_AJOUT_METADONNEE": "Add metadata", @@ -101,7 +107,6 @@ } }, "LIST_PROFILE": { - "CREER_GERER_PROFILE_ARCHIVAGE": "create and manage archiving profiles", "SEARCH_PLACEHOLDER": "Search for a profile by its title", "CREER_NOUVEAU_PROFIL": "create a new profile", "IMPORTER_PROFIL": "import a profile", diff --git a/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json b/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json index 64956041436040702fdb490273f65c0bbc3817ac..0e6a3b604138a0d174d2c7c8552b5e8b0766d3ca 100644 --- a/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json +++ b/ui/ui-frontend/projects/pastis/src/assets/i18n/fr.json @@ -40,6 +40,10 @@ "NOM_PUA": "Nom du profil d unité archivistique", "NOM_PA": "Nom du profil d'archivage", "PROFILE_ID": "Identifiant", + "BREADCRUMB":{ + "PORTAIL": "Portail", + "CREER_ET_GERER_PROFIL": "Créer et gérer des profils documentaires" + }, "FILE_TREE": { "AJOUTER_UA": "Ajouter une UA", "AJOUTER_UA_ICON": "AJOUTER UNE UA", @@ -74,6 +78,8 @@ "POPUP_DUPLICATE_TITRE_TWO": "son contenu et son paramétrage (cardinalités et commentaire)" }, "FILE_TREE_METADATA": { + "PUA": "Profil d'Unité Archivistique", + "PA": "Profil d'Archivage", "SEARCH_PLACEHOLDER": "Rechercher une métadonnée dans le tableau", "NOTIFICATION_AJOUT_METADONNEE": "La métadonnée ArchiveUnit a été ajoutée", "BOUTON_AJOUT_METADONNEE": "Ajouter une métadonnée", @@ -102,7 +108,6 @@ } }, "LIST_PROFILE": { - "CREER_GERER_PROFILE_ARCHIVAGE": "créer et gérer des profils d’archivage", "SEARCH_PLACEHOLDER": "Recherche un profil par son intitulé", "CREER_NOUVEAU_PROFIL": "créer un nouveau profil", "IMPORTER_PROFIL": "importer un profil", diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/ProfileResponse.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/ProfileResponse.java index b6bd6723d53451f1359959b0e3cffad62121463e..f15089efa28e984de4d64cb1ab7b9f54c835f0b8 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/ProfileResponse.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/model/profiles/ProfileResponse.java @@ -28,42 +28,15 @@ package fr.gouv.vitamui.pastis.model.profiles; import fr.gouv.vitamui.pastis.model.ElementProperties; +import lombok.Getter; +import lombok.Setter; +@Getter +@Setter public class ProfileResponse { Long id; + String name; ElementProperties profile; Notice notice; String type; - - public ElementProperties getProfile() { - return profile; - } - - public void setProfile(ElementProperties profile) { - this.profile = profile; - } - - public Long getId() { - return id; - } - - public void setId(Long id) { - this.id = id; - } - - public Notice getNotice() { - return notice; - } - - public void setNotice(Notice notice) { - this.notice = notice; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } } diff --git a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/ProfileService.java b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/ProfileService.java index c7bb4fa939470e882d93f74723505a611555d5c3..f8739682e9f13b44ffa79a94be588d3b22cddbb2 100644 --- a/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/ProfileService.java +++ b/ui/ui-pastis/src/main/java/fr/gouv/vitamui/pastis/util/ProfileService.java @@ -221,6 +221,7 @@ public class ProfileService { profileResponse.setId(profileToEdit.getId()); profileResponse.setType(profileToEdit.getType()); + profileResponse.setName(profileToEdit.getBaseName()); if (profileResponse.getType().equals("PA")) { XMLReader xmlReader = XMLReaderFactory.createXMLReader(); @@ -254,7 +255,10 @@ public class ProfileService { try { String fileExtension = file.getOriginalFilename().split("\\.")[1]; + String profileName = file.getOriginalFilename().split("\\.(?=[^\\.]+$)")[0]; profileResponse.setType(fileExtension.equals("rng") ? "PA":"PUA"); + profileResponse.setName(profileName); + InputStream fileInputStream = file.getInputStream(); InputSource inputSource = new InputSource(file.getInputStream());