mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Refactor frontend data models
This commit is contained in:
@@ -18,9 +18,9 @@ import { TourNgBootstrapModule, TourService } from 'ngx-ui-tour-ng-bootstrap'
|
||||
import { LogoComponent } from '../common/logo/logo.component'
|
||||
import { of, throwError } from 'rxjs'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { CdkDragDrop, DragDropModule } from '@angular/cdk/drag-drop'
|
||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'
|
||||
import { SavedView } from 'src/app/data/saved-view'
|
||||
|
||||
const saved_views = [
|
||||
{
|
||||
@@ -167,7 +167,7 @@ describe('DashboardComponent', () => {
|
||||
const toastSpy = jest.spyOn(toastService, 'showInfo')
|
||||
jest.spyOn(settingsService, 'storeSettings').mockReturnValue(of(true))
|
||||
component.onDrop({ previousIndex: 0, currentIndex: 1 } as CdkDragDrop<
|
||||
PaperlessSavedView[]
|
||||
SavedView[]
|
||||
>)
|
||||
expect(settingsSpy).toHaveBeenCalledWith([
|
||||
saved_views[2],
|
||||
@@ -190,7 +190,7 @@ describe('DashboardComponent', () => {
|
||||
.spyOn(settingsService, 'storeSettings')
|
||||
.mockReturnValue(throwError(() => new Error('unable to save')))
|
||||
component.onDrop({ previousIndex: 0, currentIndex: 2 } as CdkDragDrop<
|
||||
PaperlessSavedView[]
|
||||
SavedView[]
|
||||
>)
|
||||
expect(toastSpy).toHaveBeenCalled()
|
||||
})
|
||||
|
@@ -3,9 +3,9 @@ import { SavedViewService } from 'src/app/services/rest/saved-view.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
import { ComponentWithPermissions } from '../with-permissions/with-permissions.component'
|
||||
import { TourService } from 'ngx-ui-tour-ng-bootstrap'
|
||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'
|
||||
import { SavedView } from 'src/app/data/saved-view'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import {
|
||||
CdkDragDrop,
|
||||
CdkDragEnd,
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
styleUrls: ['./dashboard.component.scss'],
|
||||
})
|
||||
export class DashboardComponent extends ComponentWithPermissions {
|
||||
public dashboardViews: PaperlessSavedView[] = []
|
||||
public dashboardViews: SavedView[] = []
|
||||
constructor(
|
||||
public settingsService: SettingsService,
|
||||
public savedViewService: SavedViewService,
|
||||
@@ -57,7 +57,7 @@ export class DashboardComponent extends ComponentWithPermissions {
|
||||
this.settingsService.globalDropzoneEnabled = true
|
||||
}
|
||||
|
||||
onDrop(event: CdkDragDrop<PaperlessSavedView[]>) {
|
||||
onDrop(event: CdkDragDrop<SavedView[]>) {
|
||||
moveItemInArray(
|
||||
this.dashboardViews,
|
||||
event.previousIndex,
|
||||
|
@@ -12,7 +12,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { of, Subject } from 'rxjs'
|
||||
import { routes } from 'src/app/app-routing.module'
|
||||
import { FILTER_HAS_TAGS_ALL } from 'src/app/data/filter-rule-type'
|
||||
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view'
|
||||
import { SavedView } from 'src/app/data/saved-view'
|
||||
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
||||
import { PermissionsGuard } from 'src/app/guards/permissions.guard'
|
||||
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
|
||||
@@ -31,7 +31,7 @@ import { SafeUrlPipe } from 'src/app/pipes/safeurl.pipe'
|
||||
import { DragDropModule } from '@angular/cdk/drag-drop'
|
||||
import { PreviewPopupComponent } from 'src/app/components/common/preview-popup/preview-popup.component'
|
||||
|
||||
const savedView: PaperlessSavedView = {
|
||||
const savedView: SavedView = {
|
||||
id: 1,
|
||||
name: 'Saved View 1',
|
||||
sort_field: 'added',
|
||||
|
@@ -8,11 +8,11 @@ import {
|
||||
} from '@angular/core'
|
||||
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 { Document } from 'src/app/data/document'
|
||||
import { SavedView } from 'src/app/data/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 { Tag } from 'src/app/data/tag'
|
||||
import {
|
||||
FILTER_CORRESPONDENT,
|
||||
FILTER_HAS_TAGS_ALL,
|
||||
@@ -46,9 +46,9 @@ export class SavedViewWidgetComponent
|
||||
}
|
||||
|
||||
@Input()
|
||||
savedView: PaperlessSavedView
|
||||
savedView: SavedView
|
||||
|
||||
documents: PaperlessDocument[] = []
|
||||
documents: Document[] = []
|
||||
|
||||
unsubscribeNotifier: Subject<any> = new Subject()
|
||||
|
||||
@@ -101,7 +101,7 @@ export class SavedViewWidgetComponent
|
||||
}
|
||||
}
|
||||
|
||||
clickTag(tag: PaperlessTag, event: MouseEvent) {
|
||||
clickTag(tag: Tag, event: MouseEvent) {
|
||||
event.preventDefault()
|
||||
event.stopImmediatePropagation()
|
||||
|
||||
@@ -110,15 +110,15 @@ export class SavedViewWidgetComponent
|
||||
])
|
||||
}
|
||||
|
||||
getPreviewUrl(document: PaperlessDocument): string {
|
||||
getPreviewUrl(document: Document): string {
|
||||
return this.documentService.getPreviewUrl(document.id)
|
||||
}
|
||||
|
||||
getDownloadUrl(document: PaperlessDocument): string {
|
||||
getDownloadUrl(document: Document): string {
|
||||
return this.documentService.getDownloadUrl(document.id)
|
||||
}
|
||||
|
||||
mouseEnterPreviewButton(doc: PaperlessDocument) {
|
||||
mouseEnterPreviewButton(doc: Document) {
|
||||
const newPopover = this.popovers.get(this.documents.indexOf(doc))
|
||||
if (this.popover !== newPopover && this.popover?.isOpen())
|
||||
this.popover.close()
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component, QueryList, ViewChildren } from '@angular/core'
|
||||
import { NgbAlert } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { ComponentWithPermissions } from 'src/app/components/with-permissions/with-permissions.component'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import {
|
||||
ConsumerStatusService,
|
||||
FileStatus,
|
||||
|
Reference in New Issue
Block a user