From f3eedec402dbd1221fdce4661ecad23d5ff509f6 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 18 Mar 2023 01:42:41 -0700 Subject: [PATCH] Improved statistics widget --- src-ui/messages.xlf | 48 +++++++++++++++---- .../statistics-widget.component.html | 44 ++++++++++++++++- .../statistics-widget.component.scss | 3 ++ .../statistics-widget.component.ts | 29 ++++++++++- src-ui/src/theme.scss | 8 ++++ src/documents/tests/test_api.py | 32 +++++++++++-- src/documents/views.py | 36 ++++++++++++-- 7 files changed, 179 insertions(+), 21 deletions(-) diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 1f46b1d6c..284beceb2 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -1826,7 +1826,7 @@ Not assigned src/app/components/common/filterable-dropdown/filterable-dropdown.component.ts - 321 + 335 Filter drop down element to filter for documents with no correspondent/type/tag assigned @@ -2202,20 +2202,48 @@ 1 - - Documents in inbox: - - src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html - 3 - - - - Total documents: + + Go to inbox src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html 4 + + Documents in inbox + + src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html + 5 + + + + Go to documents + + src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html + 8 + + + + Total documents + + src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html + 9 + + + + Total characters + + src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html + 13 + + + + File types + + src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html + 17 + + Upload new documents diff --git a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html index 5bba41a4d..ad971b491 100644 --- a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html +++ b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.html @@ -1,6 +1,46 @@ -

Documents in inbox: {{statistics?.documents_inbox}}

-

Total documents: {{statistics?.documents_total}}

+
+ + Documents in inbox: + {{statistics?.documents_inbox}} + + + Total documents: + {{statistics?.documents_total}} + +
+ Total characters: + {{statistics?.character_count | number}} +
+
+
File types:
+
+
+ {{filetype.mime_type}} + {{getFileTypePercent(filetype) | number: '1.0-1'}}% +
+
+
+ +
diff --git a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.scss b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.scss index e69de29bb..74f88314c 100644 --- a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.scss +++ b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.scss @@ -0,0 +1,3 @@ +.flex-column { + row-gap: 0.2rem; +} diff --git a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts index 3d9f7b5e7..1b4daa300 100644 --- a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts +++ b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.ts @@ -1,12 +1,25 @@ import { HttpClient } from '@angular/common/http' import { Component, OnDestroy, OnInit } from '@angular/core' import { Observable, Subscription } from 'rxjs' +import { + FILTER_HAS_TAGS_ALL, + FILTER_IS_IN_INBOX, +} from 'src/app/data/filter-rule-type' import { ConsumerStatusService } from 'src/app/services/consumer-status.service' +import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { environment } from 'src/environments/environment' export interface Statistics { documents_total?: number documents_inbox?: number + inbox_tag?: number + document_file_type_counts?: DocumentFileType[] + character_count?: number +} + +interface DocumentFileType { + mime_type: string + mime_type_count: number } @Component({ @@ -19,7 +32,8 @@ export class StatisticsWidgetComponent implements OnInit, OnDestroy { constructor( private http: HttpClient, - private consumerStatusService: ConsumerStatusService + private consumerStatusService: ConsumerStatusService, + private documentListViewService: DocumentListViewService ) {} statistics: Statistics = {} @@ -50,4 +64,17 @@ export class StatisticsWidgetComponent implements OnInit, OnDestroy { ngOnDestroy(): void { this.subscription.unsubscribe() } + + goToInbox() { + this.documentListViewService.quickFilter([ + { + rule_type: FILTER_HAS_TAGS_ALL, + value: this.statistics.inbox_tag.toString(), + }, + ]) + } + + getFileTypePercent(filetype: DocumentFileType): number { + return (filetype.mime_type_count / this.statistics?.documents_total) * 100 + } } diff --git a/src-ui/src/theme.scss b/src-ui/src/theme.scss index 69fbc68cc..39071e41f 100644 --- a/src-ui/src/theme.scss +++ b/src-ui/src/theme.scss @@ -223,6 +223,14 @@ $form-check-radio-checked-bg-image-dark: url("data:image/svg+xml,