Skip to content
Snippets Groups Projects
Commit b85814a2 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FEAT #14383 TIME 0:40 format size + only show technical

parent 8cbec821
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
......@@ -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;
}
}
......@@ -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];
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment