From ec9f78b761b39e9b9786fae14919fa1fcb4f8704 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Wed, 14 Oct 2020 12:37:06 +0200 Subject: [PATCH] FEAT #14383 TIME 2 Begin front technical informations --- src/frontend/app/app.module.ts | 3 + .../technical-information.component.html | 34 ++++++ .../technical-information.component.scss | 1 + .../technical-information.component.ts | 113 ++++++++++++++++++ .../app/process/process.component.html | 3 + src/frontend/app/process/process.component.ts | 5 + src/lang/lang-fr.json | 5 +- 7 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 src/frontend/app/indexation/technical-information/technical-information.component.html create mode 100644 src/frontend/app/indexation/technical-information/technical-information.component.scss create mode 100644 src/frontend/app/indexation/technical-information/technical-information.component.ts diff --git a/src/frontend/app/app.module.ts b/src/frontend/app/app.module.ts index c2526167a82..0b8403f9e56 100755 --- a/src/frontend/app/app.module.ts +++ b/src/frontend/app/app.module.ts @@ -83,6 +83,7 @@ import { SentNumericPackagePageComponent } from './sentResource/sent-numeric-pac import { ThesaurusModalComponent } from './tag/indexing/thesaurus/thesaurus-modal.component'; import { SelectIndexingModelComponent } from './indexation/select-indexing-model/select-indexing-model.component'; import { FilterToolComponent } from './search/filter-tool/filter-tool.component'; +import { TechnicalInformationComponent } from './indexation/technical-information/technical-information.component'; import { SearchComponent } from './search/search.component'; import { SearchResultListComponent } from './search/result-list/search-result-list.component'; @@ -238,6 +239,7 @@ export class MyHammerConfig extends HammerGestureConfig { SendToRecordManagementComponent, CheckReplyRecordManagementComponent, CheckAcknowledgmentRecordManagementComponent, + TechnicalInformationComponent ], exports : [ SharedModule @@ -294,6 +296,7 @@ export class MyHammerConfig extends HammerGestureConfig { PrintDepositListActionComponent, ViewDocActionComponent, ReconcileActionComponent, + TechnicalInformationComponent ], providers: [ { provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }, diff --git a/src/frontend/app/indexation/technical-information/technical-information.component.html b/src/frontend/app/indexation/technical-information/technical-information.component.html new file mode 100644 index 00000000000..5f64edb848f --- /dev/null +++ b/src/frontend/app/indexation/technical-information/technical-information.component.html @@ -0,0 +1,34 @@ +<div class="mat-dialog-content-container"> + <h1 mat-dialog-title> + <span style="flex: 1;" [title]="this.translate.instant('lang.linkResource')"> + {{'lang.technicalInformations' | translate}} + </span> + <button [title]="this.translate.instant('lang.close')" mat-icon-button (click)="dialogRef.close();"> + <mat-icon class="fa fa-times"></mat-icon> + </button></h1> + <div mat-dialog-content> + <div *ngIf="loading" class="loading" color="primary"> + <mat-spinner></mat-spinner> + </div> + <mat-form-field *ngFor="let data of techData | keyvalue"> + <mat-icon matPrefix [class]="data.value.icon" color="primary" style="width: 30px;"></mat-icon> + <mat-label>{{'lang.'+data.key | translate}}</mat-label> + <input matInput [value]="data.value.value" readonly> + </mat-form-field> + + <mat-accordion> + <mat-expansion-panel expanded> + <mat-expansion-panel-header> + <mat-panel-title> + Informations complémentaires + </mat-panel-title> + </mat-expansion-panel-header> + <mat-form-field *ngFor="let custom of customsData | keyvalue"> + <mat-icon matPrefix [class]="custom.value.icon" color="primary" style="width: 30px;"></mat-icon> + <mat-label>{{custom.value.label}}</mat-label> + <input matInput [value]="custom.value.value" readonly> + </mat-form-field> + </mat-expansion-panel> + </mat-accordion> + </div> +</div> \ No newline at end of file diff --git a/src/frontend/app/indexation/technical-information/technical-information.component.scss b/src/frontend/app/indexation/technical-information/technical-information.component.scss new file mode 100644 index 00000000000..a51c80f154a --- /dev/null +++ b/src/frontend/app/indexation/technical-information/technical-information.component.scss @@ -0,0 +1 @@ +@import '../../../css/vars.scss'; diff --git a/src/frontend/app/indexation/technical-information/technical-information.component.ts b/src/frontend/app/indexation/technical-information/technical-information.component.ts new file mode 100644 index 00000000000..5884c2e4b45 --- /dev/null +++ b/src/frontend/app/indexation/technical-information/technical-information.component.ts @@ -0,0 +1,113 @@ +import { Component, OnInit, Inject } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { TranslateService } from '@ngx-translate/core'; +import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; +import { AppService } from '@service/app.service'; +import { FunctionsService } from '@service/functions.service'; +import { catchError, exhaustMap, tap } from 'rxjs/operators'; +import { NotificationService } from '@service/notification/notification.service'; +import { of } from 'rxjs'; +import { DatePipe } from '@angular/common'; + + +@Component({ + templateUrl: 'technical-information.component.html', + styleUrls: ['technical-information.component.scss'] +}) +export class TechnicalInformationComponent implements OnInit { + + loading: boolean = false; + + techData: any = { + format: { + label: 'fileFormat', + value: '', + icon: 'far fa-file-archive' + }, + size: { + label: 'filesize', + value: '', + icon: 'fas fa-cubes' + }, + creationDate: { + label: 'creationDate', + value: '', + icon: 'fas fa-calendar-day' + }, + fingerprint: { + label: 'fingerprint', + value: '', + icon: 'fas fa-fingerprint' + }, + docserverPath: { + label: 'docserverPath', + value: '', + icon: 'fas fa-terminal' + }, + filename: { + label: 'filename', + value: '', + icon: 'fas fa-quote-right' + }, + fulltext: { + label: 'fulltext', + value: '', + icon: 'far fa-file-alt' + } + }; + + customsData: any = {}; + customs: any = {}; + + constructor( + public translate: TranslateService, + public http: HttpClient, + private notify: NotificationService, + public dialog: MatDialog, + public dialogRef: MatDialogRef<TechnicalInformationComponent>, + @Inject(MAT_DIALOG_DATA) public data: any, + public appService: AppService, + public functions: FunctionsService, + private datePipe: DatePipe + ) { } + + ngOnInit(): void { + this.fetchData(); + } + + fetchData() { + this.http.get(`../rest/resources/${this.data.resId}/fileInformation`).pipe( + tap((data: any) => { + this.techData.format.value = data.information.format, + this.techData.fingerprint.value = data.information.fingerprint, + this.techData.size.value = data.information.filesize, + this.techData.fulltext.value = data.information.fulltext_result, + this.loading = false; + + }), + exhaustMap(() => this.http.get('../rest/customFields')), + tap((data: any) => { + data.customFields.map((info: any) => { + this.customs[info.id] = { + label : info.label, + type : info.type + }; + }); + }), + exhaustMap(() => this.http.get(`../rest/resources/${this.data.resId}`)), + tap((data: any) => { + Object.keys(data.customFields).forEach(key => { + this.customsData[key] = { + label: this.customs[key]['label'], + value: data.customFields[key], + icon: 'fas fa-hashtag' + }; + }); + }), + catchError((err: any) => { + this.notify.handleSoftErrors(err); + return of(false); + }) + ).subscribe(); + } +} diff --git a/src/frontend/app/process/process.component.html b/src/frontend/app/process/process.component.html index a22cf5443e9..bb1a7e0aacb 100644 --- a/src/frontend/app/process/process.component.html +++ b/src/frontend/app/process/process.component.html @@ -14,6 +14,9 @@ </div> <div class="indexing-form-container"> <div *ngIf="!isModalOpen() && currentTool !== 'dashboard'" style="display: flex;justify-content: flex-end;"> + <button mat-icon-button (click)="openTechnicalInfo()" color="primary" [title]="this.translate.instant('lang.showTechnicalInfo')"> + <mat-icon class="far fa-file-code"></mat-icon> + </button> <button mat-icon-button (click)="createModal()" color="primary" [title]="this.translate.instant('lang.openInExternalModal')"> <mat-icon class="fas fa-external-link-alt"></mat-icon> </button> diff --git a/src/frontend/app/process/process.component.ts b/src/frontend/app/process/process.component.ts index e44f96e803a..da9e3ed8d2d 100755 --- a/src/frontend/app/process/process.component.ts +++ b/src/frontend/app/process/process.component.ts @@ -26,6 +26,7 @@ import { AvisWorkflowComponent } from '../avis/avis-workflow.component'; import { FunctionsService } from '@service/functions.service'; import { PrintedFolderModalComponent } from '../printedFolder/printed-folder-modal.component'; import { of, Subscription } from 'rxjs'; +import { TechnicalInformationComponent } from '@appRoot/indexation/technical-information/technical-information.component'; @Component({ @@ -633,6 +634,10 @@ export class ProcessComponent implements OnInit, OnDestroy { this.modalModule.push(this.processTool.filter(module => module.id === this.currentTool)[0]); } + openTechnicalInfo() { + this.dialog.open(TechnicalInformationComponent, { panelClass: 'maarch-modal', autoFocus: false, data: { resId : this.currentResourceInformations.resId} }); + } + removeModal(index: number) { if (this.modalModule[index].id === 'info' && this.indexingForm.isResourceModified()) { const dialogRef = this.openConfirmModification(); diff --git a/src/lang/lang-fr.json b/src/lang/lang-fr.json index d53979b6708..67294078b27 100644 --- a/src/lang/lang-fr.json +++ b/src/lang/lang-fr.json @@ -2085,5 +2085,8 @@ "producerServiceDoesNotExists": "Le service producteur n'existe pas dans MaarchRM", "nextPage": "Page suivante", "prevPage": "Page précédente", - "onlySingleResourceAllowed": "Seule une ressource peut être traité par cette action" + "onlySingleResourceAllowed": "Seule une ressource peut être traité par cette action", + "showTechnicalInfo": "Afficher les informations techniques", + "filename": "Nom de fichier", + "size": "Taille" } -- GitLab