A community-supported supercharged document management system: scan, index and archive all your documents
Python aiangulararchivingdjangodmsdocument-managementdocument-management-systemllmmachine-learningocroptical-character-recognitionpdf
basic statistics
Jonas Winklerd67eacdd6fcf
diff --git a/src-ui/src/app/components/dashboard/dashboard.component.html b/src-ui/src/app/components/dashboard/dashboard.component.htmlindex d33dec9d6..f1a3ef1ed 100644--- a/src-ui/src/app/components/dashboard/dashboard.component.html+++ b/src-ui/src/app/components/dashboard/dashboard.component.html@@ -29,7 +29,8 @@</div><div class="col-lg"><h4>Statistics</h4>- <p>None yet.</p>+ <p>Documents in inbox: {{statistics.documents_inbox}}</p>+ <p>Total documents: {{statistics.documents_total}}</p><h4>Upload new Document</h4><form><ngx-file-dropdiff --git a/src-ui/src/app/components/dashboard/dashboard.component.ts b/src-ui/src/app/components/dashboard/dashboard.component.tsindex 1193d9e77..f8d5fb0ae 100644--- a/src-ui/src/app/components/dashboard/dashboard.component.ts+++ b/src-ui/src/app/components/dashboard/dashboard.component.ts@@ -1,9 +1,16 @@+import { HttpClient } from '@angular/common/http';import { Component, OnInit } from '@angular/core';-import { FileSystemDirectoryEntry, FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop';-import { SavedViewConfig } from 'src/app/data/saved-view-config';+import { FileSystemFileEntry, NgxFileDropEntry } from 'ngx-file-drop';+import { Observable } from 'rxjs';import { DocumentService } from 'src/app/services/rest/document.service';import { SavedViewConfigService } from 'src/app/services/saved-view-config.service';import { Toast, ToastService } from 'src/app/services/toast.service';+import { environment } from 'src/environments/environment';++export interface Statistics {+ documents_total?: number+ documents_inbox?: number+}@Component({selector: 'app-dashboard',@@ -13,10 +20,11 @@ import { Toast, ToastService } from 'src/app/services/toast.service';export class DashboardComponent implements OnInit {constructor(private documentService: DocumentService, private toastService: ToastService,- public savedViewConfigService: SavedViewConfigService) { }+ public savedViewConfigService: SavedViewConfigService, private http: HttpClient) { }savedDashboardViews = []+ statistics: Statistics = {}ngOnInit(): void {this.savedViewConfigService.getDashboardConfigs().forEach(config => {@@ -24,8 +32,14 @@ export class DashboardComponent implements OnInit {this.savedDashboardViews.push({viewConfig: config, documents: result.results})})})+ this.getStatistics().subscribe(statistics => {+ this.statistics = statistics+ })}+ getStatistics(): Observable<Statistics> {+ return this.http.get(`${environment.apiBaseUrl}statistics/`)+ }public fileOver(event){diff --git a/src/documents/views.py b/src/documents/views.pyindex 9bec12555..2ef76cb7a 100755--- a/src/documents/views.py+++ b/src/documents/views.py@@ -194,3 +194,14 @@ class SearchAutoCompleteView(APIView):return Response(index.autocomplete(self.ix, term, limit))else:return Response([])+++class StatisticsView(APIView):++ permission_classes = (IsAuthenticated,)++ def get(self, request, format=None):+ return Response({+ 'documents_total': Document.objects.all().count(),+ 'documents_inbox': Document.objects.filter(tags__is_inbox_tag=True).distinct().count()+ })diff --git a/src/paperless/urls.py b/src/paperless/urls.pyindex b78cdc1ff..16169309b 100755--- a/src/paperless/urls.py+++ b/src/paperless/urls.py@@ -14,7 +14,8 @@ from documents.views import (DocumentTypeViewSet,SearchView,IndexView,- SearchAutoCompleteView+ SearchAutoCompleteView,+ StatisticsView)api_router = DefaultRouter()@@ -31,6 +32,7 @@ urlpatterns = [url(r"^api/auth/",include(('rest_framework.urls', 'rest_framework'), namespace="rest_framework")),url(r"^api/search/autocomplete/", SearchAutoCompleteView.as_view(), name="autocomplete"),url(r"^api/search/", SearchView.as_view(), name="search"),+ url(r"^api/statistics/", StatisticsView.as_view(), name="statistics"),url(r"^api/token/", views.obtain_auth_token), url(r"^api/", include((api_router.urls, 'drf'), namespace="drf")),# Favicon