diff --git a/src/frontend/app/indexation/technical-information/technical-information.component.html b/src/frontend/app/indexation/technical-information/technical-information.component.html index 5f64edb848f44be12ecdeefd2373b7c7f0166520..d682942b05f770e35a8043272b4ddcf99125e333 100644 --- a/src/frontend/app/indexation/technical-information/technical-information.component.html +++ b/src/frontend/app/indexation/technical-information/technical-information.component.html @@ -16,7 +16,7 @@ <input matInput [value]="data.value.value" readonly> </mat-form-field> - <mat-accordion> + <mat-accordion *ngIf="!isEmptyCustom()"> <mat-expansion-panel expanded> <mat-expansion-panel-header> <mat-panel-title> diff --git a/src/frontend/app/indexation/technical-information/technical-information.component.ts b/src/frontend/app/indexation/technical-information/technical-information.component.ts index 5884c2e4b4594afd3fe345dad1f24683ccfc4a7a..3e2c2921613c54427263c1074982581d6f7f801f 100644 --- a/src/frontend/app/indexation/technical-information/technical-information.component.ts +++ b/src/frontend/app/indexation/technical-information/technical-information.component.ts @@ -80,7 +80,7 @@ export class TechnicalInformationComponent implements OnInit { 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.size.value = this.functions.formatBytes(data.information.filesize), this.techData.fulltext.value = data.information.fulltext_result, this.loading = false; @@ -97,11 +97,13 @@ export class TechnicalInformationComponent implements OnInit { 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' - }; + if (this.customs[key]['mode'] === 'technical') { + this.customsData[key] = { + label: this.customs[key]['label'], + value: data.customFields[key], + icon: 'fas fa-hashtag' + }; + } }); }), catchError((err: any) => { @@ -110,4 +112,8 @@ export class TechnicalInformationComponent implements OnInit { }) ).subscribe(); } + + isEmptyCustom() { + return Object.keys(this.customsData).length === 0; + } } diff --git a/src/frontend/service/functions.service.ts b/src/frontend/service/functions.service.ts index b6ac00717781e09dc431c67a0bfa9129effd19df..499f1d605e3632a9807f2df78ff92077e9305c4e 100644 --- a/src/frontend/service/functions.service.ts +++ b/src/frontend/service/functions.service.ts @@ -154,4 +154,16 @@ export class FunctionsService { console.log(info); } } + + formatBytes(bytes: number, decimals = 2) { + if (bytes === 0) { return '0 Octet'; } + + const k = 1024; + const dm = decimals < 0 ? 0 : decimals; + const sizes = ['Octets', 'KO', 'MO', 'GO', 'TO', 'PO', 'EO', 'ZO', 'YO']; + + const i = Math.floor(Math.log(bytes) / Math.log(k)); + + return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i]; + } }