From 787209d1e4e335b5a219fb9b1de79335baaca2d6 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Sat, 23 Sep 2023 00:10:51 -0700 Subject: [PATCH] Updated dashboard --- .../page-header/page-header.component.html | 6 ++- .../page-header/page-header.component.spec.ts | 2 +- .../dashboard/dashboard.component.html | 43 +++++++++++-------- .../saved-view-widget.component.html | 20 ++++++--- .../saved-view-widget.component.scss | 10 ++++- .../saved-view-widget.component.spec.ts | 1 + .../saved-view-widget.component.ts | 22 ++++++++-- .../statistics-widget.component.html | 27 ++++++++++++ .../statistics-widget.component.spec.ts | 7 ++- .../statistics-widget.component.ts | 14 +++++- .../upload-file-widget.component.html | 10 ++--- .../widget-frame/widget-frame.component.html | 4 +- src-ui/src/theme.scss | 4 ++ src/documents/tests/test_api.py | 11 +++++ src/documents/views.py | 37 ++++++++++++++++ 15 files changed, 177 insertions(+), 41 deletions(-) diff --git a/src-ui/src/app/components/common/page-header/page-header.component.html b/src-ui/src/app/components/common/page-header/page-header.component.html index 1174ee044..fe6906c88 100644 --- a/src-ui/src/app/components/common/page-header/page-header.component.html +++ b/src-ui/src/app/components/common/page-header/page-header.component.html @@ -1,7 +1,9 @@
-

{{title}}

-

{{subTitle}}

+

+ {{title}} + {{subTitle}} +

diff --git a/src-ui/src/app/components/common/page-header/page-header.component.spec.ts b/src-ui/src/app/components/common/page-header/page-header.component.spec.ts index cff375429..dbecb150f 100644 --- a/src-ui/src/app/components/common/page-header/page-header.component.spec.ts +++ b/src-ui/src/app/components/common/page-header/page-header.component.spec.ts @@ -25,7 +25,7 @@ describe('PageHeaderComponent', () => { component.title = 'Foo' component.subTitle = 'Bar' fixture.detectChanges() - expect(fixture.nativeElement.textContent).toContain('FooBar') + expect(fixture.nativeElement.textContent).toContain('Foo Bar') }) it('should set html title', () => { diff --git a/src-ui/src/app/components/dashboard/dashboard.component.html b/src-ui/src/app/components/dashboard/dashboard.component.html index 538f6a910..9c62f7add 100644 --- a/src-ui/src/app/components/dashboard/dashboard.component.html +++ b/src-ui/src/app/components/dashboard/dashboard.component.html @@ -1,29 +1,36 @@ - +
-
-
- +
+
+
Loading... +
+ +
+ +
+ + + +
+ +
+
- - - -
- - - +
+
+
+
+
+ +
+
+
-
- - - - - -
diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html index 9082d0cd8..115741736 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.html @@ -3,20 +3,28 @@ Show all - +
+ + - - + + +
Created TitleTagsCorrespondent
{{doc.created_date | customDate}} - {{doc.title | documentTitle}} + {{doc.created_date | customDate}} + {{doc.title | documentTitle}} + + + + {{(doc.correspondent$ | async)?.name}}
- @@ -26,7 +34,7 @@ - + diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss index 941d474d4..bf1894b48 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.scss @@ -5,9 +5,12 @@ table { th:first-child { width: 25%; + @media (min-width: 768px) { + width: 15%; + } } -tbody app-tag { +tbody pngx-tag { cursor: pointer; } @@ -22,3 +25,8 @@ tr:hover .btn-group { opacity: 1; pointer-events: all; } + +td.py-3 { + padding-top: 0.75em !important; + padding-bottom: 0.75em !important; +} diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.spec.ts b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.spec.ts index 7e1a77ae8..7b9c5c8b0 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.spec.ts +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.spec.ts @@ -52,6 +52,7 @@ const documentResults = [ { id: 3, title: 'doc3', + correspondent: 0, }, ] diff --git a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts index efc288378..982aeebaa 100644 --- a/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts +++ b/src-ui/src/app/components/dashboard/widgets/saved-view-widget/saved-view-widget.component.ts @@ -6,18 +6,22 @@ import { QueryList, ViewChildren, } from '@angular/core' -import { Router } from '@angular/router' +import { Params, Router } from '@angular/router' import { Subject, takeUntil } from 'rxjs' import { PaperlessDocument } from 'src/app/data/paperless-document' import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' import { ConsumerStatusService } from 'src/app/services/consumer-status.service' import { DocumentService } from 'src/app/services/rest/document.service' import { PaperlessTag } from 'src/app/data/paperless-tag' -import { FILTER_HAS_TAGS_ALL } from 'src/app/data/filter-rule-type' +import { + FILTER_CORRESPONDENT, + FILTER_HAS_TAGS_ALL, +} from 'src/app/data/filter-rule-type' import { OpenDocumentsService } from 'src/app/services/open-documents.service' import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { ComponentWithPermissions } from 'src/app/components/with-permissions/with-permissions.component' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' +import { queryParamsFromFilterRules } from 'src/app/utils/query-params' @Component({ selector: 'pngx-saved-view-widget', @@ -38,7 +42,8 @@ export class SavedViewWidgetComponent private router: Router, private list: DocumentListViewService, private consumerStatusService: ConsumerStatusService, - public openDocumentsService: OpenDocumentsService + public openDocumentsService: OpenDocumentsService, + public documentListViewService: DocumentListViewService ) { super() } @@ -141,4 +146,15 @@ export class SavedViewWidgetComponent mouseLeaveCard() { this.popover?.close() } + + getCorrespondentQueryParams(correspondentId: number): Params { + return correspondentId !== undefined + ? queryParamsFromFilterRules([ + { + rule_type: FILTER_CORRESPONDENT, + value: correspondentId.toString(), + }, + ]) + : null + } } 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 3561bbcf4..f42100414 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 @@ -42,5 +42,32 @@
+ + diff --git a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.spec.ts b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.spec.ts index da07b7186..5bddfaab1 100644 --- a/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.spec.ts +++ b/src-ui/src/app/components/dashboard/widgets/statistics-widget/statistics-widget.component.spec.ts @@ -11,6 +11,7 @@ import { environment } from 'src/environments/environment' import { RouterTestingModule } from '@angular/router/testing' import { routes } from 'src/app/app-routing.module' import { PermissionsGuard } from 'src/app/guards/permissions.guard' +import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' describe('StatisticsWidgetComponent', () => { let component: StatisticsWidgetComponent @@ -19,7 +20,11 @@ describe('StatisticsWidgetComponent', () => { beforeEach(async () => { TestBed.configureTestingModule({ - declarations: [StatisticsWidgetComponent, WidgetFrameComponent], + declarations: [ + StatisticsWidgetComponent, + WidgetFrameComponent, + IfPermissionsDirective, + ], providers: [PermissionsGuard], imports: [ HttpClientTestingModule, 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 be7221975..a662126b0 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 @@ -6,6 +6,7 @@ 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' import * as mimeTypeNames from 'mime-names' +import { ComponentWithPermissions } from 'src/app/components/with-permissions/with-permissions.component' export interface Statistics { documents_total?: number @@ -13,6 +14,10 @@ export interface Statistics { inbox_tag?: number document_file_type_counts?: DocumentFileType[] character_count?: number + tag_count?: number + correspondent_count?: number + document_type_count?: number + storage_path_count?: number } interface DocumentFileType { @@ -25,14 +30,19 @@ interface DocumentFileType { templateUrl: './statistics-widget.component.html', styleUrls: ['./statistics-widget.component.scss'], }) -export class StatisticsWidgetComponent implements OnInit, OnDestroy { +export class StatisticsWidgetComponent + extends ComponentWithPermissions + implements OnInit, OnDestroy +{ loading: boolean = true constructor( private http: HttpClient, private consumerStatusService: ConsumerStatusService, private documentListViewService: DocumentListViewService - ) {} + ) { + super() + } statistics: Statistics = {} diff --git a/src-ui/src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html b/src-ui/src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html index af1dd533b..e5d64b777 100644 --- a/src-ui/src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html +++ b/src-ui/src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html @@ -8,12 +8,12 @@ -
-
+
+ + (onFileOver)="fileOver($event)" (onFileLeave)="fileLeave($event)" dropZoneClassName="bg-light card h-100" + multiple="true" contentClassName="justify-content-center d-flex flex-column text-muted align-items-center py-5 px-2 h-100" [showBrowseBtn]=true + browseBtnClassName="btn btn-sm btn-outline-primary mt-2" i18n-dropZoneLabel i18n-browseBtnLabel>

{{getStatusSummary()}}

diff --git a/src-ui/src/app/components/dashboard/widgets/widget-frame/widget-frame.component.html b/src-ui/src/app/components/dashboard/widgets/widget-frame/widget-frame.component.html index 2fb15b090..d814e4afe 100644 --- a/src-ui/src/app/components/dashboard/widgets/widget-frame/widget-frame.component.html +++ b/src-ui/src/app/components/dashboard/widgets/widget-frame/widget-frame.component.html @@ -1,7 +1,7 @@ -
+
-
{{title}}
+
{{title}}
Loading...
diff --git a/src-ui/src/theme.scss b/src-ui/src/theme.scss index 028174044..ac5654c14 100644 --- a/src-ui/src/theme.scss +++ b/src-ui/src/theme.scss @@ -214,6 +214,10 @@ $form-check-radio-checked-bg-image-dark: url("data:image/svg+xml,