truncate long mime types + limit total types displayed

This commit is contained in:
shamoon
2023-03-18 14:25:37 -07:00
parent f3eedec402
commit 2bc7f0b8e0
4 changed files with 27 additions and 21 deletions

View File

@@ -48,6 +48,20 @@ export class StatisticsWidgetComponent implements OnInit, OnDestroy {
this.loading = true
this.getStatistics().subscribe((statistics) => {
this.loading = false
// truncate the list and sum others
if (statistics.document_file_type_counts?.length > 4) {
let others = statistics.document_file_type_counts.slice(4)
statistics.document_file_type_counts =
statistics.document_file_type_counts.slice(0, 4)
statistics.document_file_type_counts.push({
mime_type: $localize`other`,
mime_type_count: others.reduce(
(currentValue, documentFileType) =>
documentFileType.mime_type_count + currentValue,
0
),
})
}
this.statistics = statistics
})
}