Refactor frontend data models

This commit is contained in:
shamoon 2023-12-19 22:36:35 -08:00
parent 5723bd8dd8
commit 66b2d90c50
120 changed files with 640 additions and 706 deletions

View File

@ -1,5 +1,5 @@
import { SettingsService } from './services/settings.service' import { SettingsService } from './services/settings.service'
import { SETTINGS_KEYS } from './data/paperless-uisettings' import { SETTINGS_KEYS } from './data/ui-settings'
import { Component, OnDestroy, OnInit, Renderer2 } from '@angular/core' import { Component, OnDestroy, OnInit, Renderer2 } from '@angular/core'
import { Router } from '@angular/router' import { Router } from '@angular/router'
import { Subscription, first } from 'rxjs' import { Subscription, first } from 'rxjs'

View File

@ -13,8 +13,8 @@ import {
import { NgSelectModule } from '@ng-select/ng-select' import { NgSelectModule } from '@ng-select/ng-select'
import { of, throwError } from 'rxjs' import { of, throwError } from 'rxjs'
import { routes } from 'src/app/app-routing.module' import { routes } from 'src/app/app-routing.module'
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' import { SavedView } from 'src/app/data/saved-view'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { PermissionsGuard } from 'src/app/guards/permissions.guard'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
@ -138,7 +138,7 @@ describe('SettingsComponent', () => {
of({ of({
all: savedViews.map((v) => v.id), all: savedViews.map((v) => v.id),
count: savedViews.length, count: savedViews.length,
results: (savedViews as PaperlessSavedView[]).concat([]), results: (savedViews as SavedView[]).concat([]),
}) })
) )
} }
@ -226,9 +226,7 @@ describe('SettingsComponent', () => {
savedViewPatchSpy.mockClear() savedViewPatchSpy.mockClear()
// succeed saved views // succeed saved views
savedViewPatchSpy.mockReturnValueOnce( savedViewPatchSpy.mockReturnValueOnce(of(savedViews as SavedView[]))
of(savedViews as PaperlessSavedView[])
)
component.saveSettings() component.saveSettings()
expect(toastErrorSpy).not.toHaveBeenCalled() expect(toastErrorSpy).not.toHaveBeenCalled()
expect(savedViewPatchSpy).toHaveBeenCalled() expect(savedViewPatchSpy).toHaveBeenCalled()
@ -335,7 +333,7 @@ describe('SettingsComponent', () => {
const toastSpy = jest.spyOn(toastService, 'showInfo') const toastSpy = jest.spyOn(toastService, 'showInfo')
const deleteSpy = jest.spyOn(savedViewService, 'delete') const deleteSpy = jest.spyOn(savedViewService, 'delete')
deleteSpy.mockReturnValue(of(true)) deleteSpy.mockReturnValue(of(true))
component.deleteSavedView(savedViews[0] as PaperlessSavedView) component.deleteSavedView(savedViews[0] as SavedView)
expect(deleteSpy).toHaveBeenCalled() expect(deleteSpy).toHaveBeenCalled()
expect(toastSpy).toHaveBeenCalledWith( expect(toastSpy).toHaveBeenCalledWith(
`Saved view "${savedViews[0].name}" deleted.` `Saved view "${savedViews[0].name}" deleted.`

View File

@ -21,10 +21,10 @@ import {
takeUntil, takeUntil,
tap, tap,
} from 'rxjs' } from 'rxjs'
import { PaperlessGroup } from 'src/app/data/paperless-group' import { Group } from 'src/app/data/group'
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' import { SavedView } from 'src/app/data/saved-view'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { import {
PermissionsService, PermissionsService,
@ -98,7 +98,7 @@ export class SettingsComponent
savedViews: this.savedViewGroup, savedViews: this.savedViewGroup,
}) })
savedViews: PaperlessSavedView[] savedViews: SavedView[]
store: BehaviorSubject<any> store: BehaviorSubject<any>
storeSub: Subscription storeSub: Subscription
@ -107,8 +107,8 @@ export class SettingsComponent
unsubscribeNotifier: Subject<any> = new Subject() unsubscribeNotifier: Subject<any> = new Subject()
savePending: boolean = false savePending: boolean = false
users: PaperlessUser[] users: User[]
groups: PaperlessGroup[] groups: Group[]
get computedDateLocale(): string { get computedDateLocale(): string {
return ( return (
@ -368,7 +368,7 @@ export class SettingsComponent
this.settings.organizingSidebarSavedViews = false this.settings.organizingSidebarSavedViews = false
} }
deleteSavedView(savedView: PaperlessSavedView) { deleteSavedView(savedView: SavedView) {
this.savedViewService.delete(savedView).subscribe(() => { this.savedViewService.delete(savedView).subscribe(() => {
this.savedViewGroup.removeControl(savedView.id.toString()) this.savedViewGroup.removeControl(savedView.id.toString())
this.savedViews.splice(this.savedViews.indexOf(savedView), 1) this.savedViews.splice(this.savedViews.indexOf(savedView), 1)
@ -531,7 +531,7 @@ export class SettingsComponent
saveSettings() { saveSettings() {
// only patch views that have actually changed // only patch views that have actually changed
const changed: PaperlessSavedView[] = [] const changed: SavedView[] = []
Object.values(this.savedViewGroup.controls) Object.values(this.savedViewGroup.controls)
.filter((g: FormGroup) => !g.pristine) .filter((g: FormGroup) => !g.pristine)
.forEach((group: FormGroup) => { .forEach((group: FormGroup) => {

View File

@ -41,8 +41,8 @@ import { TextComponent } from '../../common/input/text/text.component'
import { PageHeaderComponent } from '../../common/page-header/page-header.component' import { PageHeaderComponent } from '../../common/page-header/page-header.component'
import { SettingsComponent } from '../settings/settings.component' import { SettingsComponent } from '../settings/settings.component'
import { UsersAndGroupsComponent } from './users-groups.component' import { UsersAndGroupsComponent } from './users-groups.component'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { PaperlessGroup } from 'src/app/data/paperless-group' import { Group } from 'src/app/data/group'
const users = [ const users = [
{ id: 1, username: 'user1', is_superuser: false }, { id: 1, username: 'user1', is_superuser: false },
@ -119,7 +119,7 @@ describe('UsersAndGroupsComponent', () => {
of({ of({
all: users.map((a) => a.id), all: users.map((a) => a.id),
count: users.length, count: users.length,
results: (users as PaperlessUser[]).concat([]), results: (users as User[]).concat([]),
}) })
) )
} }
@ -128,7 +128,7 @@ describe('UsersAndGroupsComponent', () => {
of({ of({
all: groups.map((r) => r.id), all: groups.map((r) => r.id),
count: groups.length, count: groups.length,
results: (groups as PaperlessGroup[]).concat([]), results: (groups as Group[]).concat([]),
}) })
) )
} }

View File

@ -1,8 +1,8 @@
import { Component, OnDestroy, OnInit } from '@angular/core' import { Component, OnDestroy, OnInit } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { Subject, first, takeUntil } from 'rxjs' import { Subject, first, takeUntil } from 'rxjs'
import { PaperlessGroup } from 'src/app/data/paperless-group' import { Group } from 'src/app/data/group'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { PermissionsService } from 'src/app/services/permissions.service' import { PermissionsService } from 'src/app/services/permissions.service'
import { GroupService } from 'src/app/services/rest/group.service' import { GroupService } from 'src/app/services/rest/group.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
@ -23,8 +23,8 @@ export class UsersAndGroupsComponent
extends ComponentWithPermissions extends ComponentWithPermissions
implements OnInit, OnDestroy implements OnInit, OnDestroy
{ {
users: PaperlessUser[] users: User[]
groups: PaperlessGroup[] groups: Group[]
unsubscribeNotifier: Subject<any> = new Subject() unsubscribeNotifier: Subject<any> = new Subject()
@ -69,7 +69,7 @@ export class UsersAndGroupsComponent
this.unsubscribeNotifier.next(true) this.unsubscribeNotifier.next(true)
} }
editUser(user: PaperlessUser = null) { editUser(user: User = null) {
var modal = this.modalService.open(UserEditDialogComponent, { var modal = this.modalService.open(UserEditDialogComponent, {
backdrop: 'static', backdrop: 'static',
size: 'xl', size: 'xl',
@ -80,7 +80,7 @@ export class UsersAndGroupsComponent
modal.componentInstance.object = user modal.componentInstance.object = user
modal.componentInstance.succeeded modal.componentInstance.succeeded
.pipe(takeUntil(this.unsubscribeNotifier)) .pipe(takeUntil(this.unsubscribeNotifier))
.subscribe((newUser: PaperlessUser) => { .subscribe((newUser: User) => {
if ( if (
newUser.id === this.settings.currentUser.id && newUser.id === this.settings.currentUser.id &&
(modal.componentInstance as UserEditDialogComponent).passwordIsSet (modal.componentInstance as UserEditDialogComponent).passwordIsSet
@ -107,7 +107,7 @@ export class UsersAndGroupsComponent
}) })
} }
deleteUser(user: PaperlessUser) { deleteUser(user: User) {
let modal = this.modalService.open(ConfirmDialogComponent, { let modal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
@ -133,7 +133,7 @@ export class UsersAndGroupsComponent
}) })
} }
editGroup(group: PaperlessGroup = null) { editGroup(group: Group = null) {
var modal = this.modalService.open(GroupEditDialogComponent, { var modal = this.modalService.open(GroupEditDialogComponent, {
backdrop: 'static', backdrop: 'static',
size: 'lg', size: 'lg',
@ -157,7 +157,7 @@ export class UsersAndGroupsComponent
}) })
} }
deleteGroup(group: PaperlessGroup) { deleteGroup(group: Group) {
let modal = this.modalService.open(ConfirmDialogComponent, { let modal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })

View File

@ -15,11 +15,11 @@ import { RouterTestingModule } from '@angular/router/testing'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { SavedViewService } from 'src/app/services/rest/saved-view.service' import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { PermissionsService } from 'src/app/services/permissions.service' import { PermissionsService } from 'src/app/services/permissions.service'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { RemoteVersionService } from 'src/app/services/rest/remote-version.service' import { RemoteVersionService } from 'src/app/services/rest/remote-version.service'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { Observable, of, tap, throwError } from 'rxjs' import { of, throwError } from 'rxjs'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { environment } from 'src/environments/environment' import { environment } from 'src/environments/environment'
import { OpenDocumentsService } from 'src/app/services/open-documents.service' import { OpenDocumentsService } from 'src/app/services/open-documents.service'
@ -31,7 +31,7 @@ import { FILTER_FULLTEXT_QUERY } from 'src/app/data/filter-rule-type'
import { routes } from 'src/app/app-routing.module' import { routes } from 'src/app/app-routing.module'
import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { PermissionsGuard } from 'src/app/guards/permissions.guard'
import { CdkDragDrop, DragDropModule } from '@angular/cdk/drag-drop' 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'
import { ProfileEditDialogComponent } from '../common/profile-edit-dialog/profile-edit-dialog.component' import { ProfileEditDialogComponent } from '../common/profile-edit-dialog/profile-edit-dialog.component'
const saved_views = [ const saved_views = [
@ -356,7 +356,7 @@ describe('AppFrameComponent', () => {
const toastSpy = jest.spyOn(toastService, 'showInfo') const toastSpy = jest.spyOn(toastService, 'showInfo')
jest.spyOn(settingsService, 'storeSettings').mockReturnValue(of(true)) jest.spyOn(settingsService, 'storeSettings').mockReturnValue(of(true))
component.onDrop({ previousIndex: 0, currentIndex: 1 } as CdkDragDrop< component.onDrop({ previousIndex: 0, currentIndex: 1 } as CdkDragDrop<
PaperlessSavedView[] SavedView[]
>) >)
expect(settingsSpy).toHaveBeenCalledWith([ expect(settingsSpy).toHaveBeenCalledWith([
saved_views[2], saved_views[2],
@ -379,7 +379,7 @@ describe('AppFrameComponent', () => {
.spyOn(settingsService, 'storeSettings') .spyOn(settingsService, 'storeSettings')
.mockReturnValue(throwError(() => new Error('unable to save'))) .mockReturnValue(throwError(() => new Error('unable to save')))
component.onDrop({ previousIndex: 0, currentIndex: 2 } as CdkDragDrop< component.onDrop({ previousIndex: 0, currentIndex: 2 } as CdkDragDrop<
PaperlessSavedView[] SavedView[]
>) >)
expect(toastSpy).toHaveBeenCalled() expect(toastSpy).toHaveBeenCalled()
}) })

View File

@ -10,7 +10,7 @@ import {
first, first,
catchError, catchError,
} from 'rxjs/operators' } from 'rxjs/operators'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { OpenDocumentsService } from 'src/app/services/open-documents.service' import { OpenDocumentsService } from 'src/app/services/open-documents.service'
import { SavedViewService } from 'src/app/services/rest/saved-view.service' import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { SearchService } from 'src/app/services/rest/search.service' import { SearchService } from 'src/app/services/rest/search.service'
@ -25,7 +25,7 @@ import {
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { TasksService } from 'src/app/services/tasks.service' import { TasksService } from 'src/app/services/tasks.service'
import { ComponentCanDeactivate } from 'src/app/guards/dirty-doc.guard' import { ComponentCanDeactivate } from 'src/app/guards/dirty-doc.guard'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { ComponentWithPermissions } from '../with-permissions/with-permissions.component' import { ComponentWithPermissions } from '../with-permissions/with-permissions.component'
import { import {
@ -33,7 +33,7 @@ import {
PermissionsService, PermissionsService,
PermissionType, PermissionType,
} from 'src/app/services/permissions.service' } from 'src/app/services/permissions.service'
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' import { SavedView } from 'src/app/data/saved-view'
import { import {
CdkDragStart, CdkDragStart,
CdkDragEnd, CdkDragEnd,
@ -132,7 +132,7 @@ export class AppFrameComponent
this.closeMenu() this.closeMenu()
} }
get openDocuments(): PaperlessDocument[] { get openDocuments(): Document[] {
return this.openDocumentsService.getOpenDocuments() return this.openDocumentsService.getOpenDocuments()
} }
@ -200,7 +200,7 @@ export class AppFrameComponent
]) ])
} }
closeDocument(d: PaperlessDocument) { closeDocument(d: Document) {
this.openDocumentsService this.openDocumentsService
.closeDocument(d) .closeDocument(d)
.pipe(first()) .pipe(first())
@ -250,7 +250,7 @@ export class AppFrameComponent
this.settingsService.globalDropzoneEnabled = true this.settingsService.globalDropzoneEnabled = true
} }
onDrop(event: CdkDragDrop<PaperlessSavedView[]>) { onDrop(event: CdkDragDrop<SavedView[]>) {
const sidebarViews = this.savedViewService.sidebarViews.concat([]) const sidebarViews = this.savedViewService.sidebarViews.concat([])
moveItemInArray(sidebarViews, event.previousIndex, event.currentIndex) moveItemInArray(sidebarViews, event.previousIndex, event.currentIndex)

View File

@ -8,10 +8,7 @@ import {
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { of } from 'rxjs' import { of } from 'rxjs'
import { import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
PaperlessCustomField,
PaperlessCustomFieldDataType,
} from 'src/app/data/paperless-custom-field'
import { SelectComponent } from '../input/select/select.component' import { SelectComponent } from '../input/select/select.component'
import { NgSelectModule } from '@ng-select/ng-select' import { NgSelectModule } from '@ng-select/ng-select'
import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { FormsModule, ReactiveFormsModule } from '@angular/forms'
@ -24,16 +21,16 @@ import {
import { CustomFieldEditDialogComponent } from '../edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component' import { CustomFieldEditDialogComponent } from '../edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
import { By } from '@angular/platform-browser' import { By } from '@angular/platform-browser'
const fields: PaperlessCustomField[] = [ const fields: CustomField[] = [
{ {
id: 0, id: 0,
name: 'Field 1', name: 'Field 1',
data_type: PaperlessCustomFieldDataType.Integer, data_type: CustomFieldDataType.Integer,
}, },
{ {
id: 1, id: 1,
name: 'Field 2', name: 'Field 2',
data_type: PaperlessCustomFieldDataType.String, data_type: CustomFieldDataType.String,
}, },
] ]

View File

@ -7,8 +7,8 @@ import {
} from '@angular/core' } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { Subject, first, takeUntil } from 'rxjs' import { Subject, first, takeUntil } from 'rxjs'
import { PaperlessCustomField } from 'src/app/data/paperless-custom-field' import { CustomField } from 'src/app/data/custom-field'
import { PaperlessCustomFieldInstance } from 'src/app/data/paperless-custom-field-instance' import { CustomFieldInstance } from 'src/app/data/custom-field-instance'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { CustomFieldEditDialogComponent } from '../edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component' import { CustomFieldEditDialogComponent } from '../edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
@ -31,16 +31,16 @@ export class CustomFieldsDropdownComponent implements OnDestroy {
disabled: boolean = false disabled: boolean = false
@Input() @Input()
existingFields: PaperlessCustomFieldInstance[] = [] existingFields: CustomFieldInstance[] = []
@Output() @Output()
added: EventEmitter<PaperlessCustomField> = new EventEmitter() added: EventEmitter<CustomField> = new EventEmitter()
@Output() @Output()
created: EventEmitter<PaperlessCustomField> = new EventEmitter() created: EventEmitter<CustomField> = new EventEmitter()
private customFields: PaperlessCustomField[] = [] private customFields: CustomField[] = []
public unusedFields: PaperlessCustomField[] public unusedFields: CustomField[]
public name: string public name: string
@ -88,8 +88,8 @@ export class CustomFieldsDropdownComponent implements OnDestroy {
} }
public getCustomFieldFromInstance( public getCustomFieldFromInstance(
instance: PaperlessCustomFieldInstance instance: CustomFieldInstance
): PaperlessCustomField { ): CustomField {
return this.customFields.find((f) => f.id === instance.field) return this.customFields.find((f) => f.id === instance.field)
} }

View File

@ -4,11 +4,11 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { first } from 'rxjs' import { first } from 'rxjs'
import { import {
DocumentSource, DocumentSource,
PaperlessConsumptionTemplate, ConsumptionTemplate,
} from 'src/app/data/paperless-consumption-template' } from 'src/app/data/consumption-template'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path' import { StoragePath } from 'src/app/data/storage-path'
import { ConsumptionTemplateService } from 'src/app/services/rest/consumption-template.service' import { ConsumptionTemplateService } from 'src/app/services/rest/consumption-template.service'
import { CorrespondentService } from 'src/app/services/rest/correspondent.service' import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
import { DocumentTypeService } from 'src/app/services/rest/document-type.service' import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
@ -17,9 +17,9 @@ import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { EditDialogComponent } from '../edit-dialog.component' import { EditDialogComponent } from '../edit-dialog.component'
import { MailRuleService } from 'src/app/services/rest/mail-rule.service' import { MailRuleService } from 'src/app/services/rest/mail-rule.service'
import { PaperlessMailRule } from 'src/app/data/paperless-mail-rule' import { MailRule } from 'src/app/data/mail-rule'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { PaperlessCustomField } from 'src/app/data/paperless-custom-field' import { CustomField } from 'src/app/data/custom-field'
export const DOCUMENT_SOURCE_OPTIONS = [ export const DOCUMENT_SOURCE_OPTIONS = [
{ {
@ -41,13 +41,13 @@ export const DOCUMENT_SOURCE_OPTIONS = [
templateUrl: './consumption-template-edit-dialog.component.html', templateUrl: './consumption-template-edit-dialog.component.html',
styleUrls: ['./consumption-template-edit-dialog.component.scss'], styleUrls: ['./consumption-template-edit-dialog.component.scss'],
}) })
export class ConsumptionTemplateEditDialogComponent extends EditDialogComponent<PaperlessConsumptionTemplate> { export class ConsumptionTemplateEditDialogComponent extends EditDialogComponent<ConsumptionTemplate> {
templates: PaperlessConsumptionTemplate[] templates: ConsumptionTemplate[]
correspondents: PaperlessCorrespondent[] correspondents: Correspondent[]
documentTypes: PaperlessDocumentType[] documentTypes: DocumentType[]
storagePaths: PaperlessStoragePath[] storagePaths: StoragePath[]
mailRules: PaperlessMailRule[] mailRules: MailRule[]
customFields: PaperlessCustomField[] customFields: CustomField[]
constructor( constructor(
service: ConsumptionTemplateService, service: ConsumptionTemplateService,

View File

@ -3,7 +3,7 @@ import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model' import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { CorrespondentService } from 'src/app/services/rest/correspondent.service' import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -13,7 +13,7 @@ import { SettingsService } from 'src/app/services/settings.service'
templateUrl: './correspondent-edit-dialog.component.html', templateUrl: './correspondent-edit-dialog.component.html',
styleUrls: ['./correspondent-edit-dialog.component.scss'], styleUrls: ['./correspondent-edit-dialog.component.scss'],
}) })
export class CorrespondentEditDialogComponent extends EditDialogComponent<PaperlessCorrespondent> { export class CorrespondentEditDialogComponent extends EditDialogComponent<Correspondent> {
constructor( constructor(
service: CorrespondentService, service: CorrespondentService,
activeModal: NgbActiveModal, activeModal: NgbActiveModal,

View File

@ -1,10 +1,7 @@
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { FormGroup, FormControl } from '@angular/forms' import { FormGroup, FormControl } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { import { DATA_TYPE_LABELS, CustomField } from 'src/app/data/custom-field'
DATA_TYPE_LABELS,
PaperlessCustomField,
} from 'src/app/data/paperless-custom-field'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -16,7 +13,7 @@ import { EditDialogComponent, EditDialogMode } from '../edit-dialog.component'
styleUrls: ['./custom-field-edit-dialog.component.scss'], styleUrls: ['./custom-field-edit-dialog.component.scss'],
}) })
export class CustomFieldEditDialogComponent export class CustomFieldEditDialogComponent
extends EditDialogComponent<PaperlessCustomField> extends EditDialogComponent<CustomField>
implements OnInit implements OnInit
{ {
constructor( constructor(

View File

@ -3,7 +3,7 @@ import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model' import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { DocumentTypeService } from 'src/app/services/rest/document-type.service' import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -13,7 +13,7 @@ import { SettingsService } from 'src/app/services/settings.service'
templateUrl: './document-type-edit-dialog.component.html', templateUrl: './document-type-edit-dialog.component.html',
styleUrls: ['./document-type-edit-dialog.component.scss'], styleUrls: ['./document-type-edit-dialog.component.scss'],
}) })
export class DocumentTypeEditDialogComponent extends EditDialogComponent<PaperlessDocumentType> { export class DocumentTypeEditDialogComponent extends EditDialogComponent<DocumentType> {
constructor( constructor(
service: DocumentTypeService, service: DocumentTypeService,
activeModal: NgbActiveModal, activeModal: NgbActiveModal,

View File

@ -23,8 +23,8 @@ import {
MATCH_NONE, MATCH_NONE,
MATCH_ALL, MATCH_ALL,
} from 'src/app/data/matching-model' } from 'src/app/data/matching-model'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { TagService } from 'src/app/services/rest/tag.service' import { TagService } from 'src/app/services/rest/tag.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -38,7 +38,7 @@ import { EditDialogComponent, EditDialogMode } from './edit-dialog.component'
</div> </div>
`, `,
}) })
class TestComponent extends EditDialogComponent<PaperlessTag> { class TestComponent extends EditDialogComponent<Tag> {
constructor( constructor(
service: TagService, service: TagService,
activeModal: NgbActiveModal, activeModal: NgbActiveModal,

View File

@ -9,12 +9,12 @@ import {
} from 'src/app/data/matching-model' } from 'src/app/data/matching-model'
import { ObjectWithId } from 'src/app/data/object-with-id' import { ObjectWithId } from 'src/app/data/object-with-id'
import { ObjectWithPermissions } from 'src/app/data/object-with-permissions' import { ObjectWithPermissions } from 'src/app/data/object-with-permissions'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service' import { AbstractPaperlessService } from 'src/app/services/rest/abstract-paperless-service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { PermissionsFormObject } from '../input/permissions/permissions-form/permissions-form.component' import { PermissionsFormObject } from '../input/permissions/permissions-form/permissions-form.component'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
export enum EditDialogMode { export enum EditDialogMode {
CREATE = 0, CREATE = 0,
@ -33,7 +33,7 @@ export abstract class EditDialogComponent<
private settingsService: SettingsService private settingsService: SettingsService
) {} ) {}
users: PaperlessUser[] users: User[]
@Input() @Input()
dialogMode: EditDialogMode = EditDialogMode.CREATE dialogMode: EditDialogMode = EditDialogMode.CREATE

View File

@ -2,7 +2,7 @@ import { Component } from '@angular/core'
import { FormControl, FormGroup } from '@angular/forms' import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
import { PaperlessGroup } from 'src/app/data/paperless-group' import { Group } from 'src/app/data/group'
import { GroupService } from 'src/app/services/rest/group.service' import { GroupService } from 'src/app/services/rest/group.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -12,7 +12,7 @@ import { SettingsService } from 'src/app/services/settings.service'
templateUrl: './group-edit-dialog.component.html', templateUrl: './group-edit-dialog.component.html',
styleUrls: ['./group-edit-dialog.component.scss'], styleUrls: ['./group-edit-dialog.component.scss'],
}) })
export class GroupEditDialogComponent extends EditDialogComponent<PaperlessGroup> { export class GroupEditDialogComponent extends EditDialogComponent<Group> {
constructor( constructor(
service: GroupService, service: GroupService,
activeModal: NgbActiveModal, activeModal: NgbActiveModal,

View File

@ -11,7 +11,7 @@ import {
import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { NgSelectModule } from '@ng-select/ng-select' import { NgSelectModule } from '@ng-select/ng-select'
import { IMAPSecurity } from 'src/app/data/paperless-mail-account' import { IMAPSecurity } from 'src/app/data/mail-account'
import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'

View File

@ -2,10 +2,7 @@ import { Component, ViewChild } from '@angular/core'
import { FormControl, FormGroup } from '@angular/forms' import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal, NgbAlert } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal, NgbAlert } from '@ng-bootstrap/ng-bootstrap'
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
import { import { IMAPSecurity, MailAccount } from 'src/app/data/mail-account'
IMAPSecurity,
PaperlessMailAccount,
} from 'src/app/data/paperless-mail-account'
import { MailAccountService } from 'src/app/services/rest/mail-account.service' import { MailAccountService } from 'src/app/services/rest/mail-account.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -21,7 +18,7 @@ const IMAP_SECURITY_OPTIONS = [
templateUrl: './mail-account-edit-dialog.component.html', templateUrl: './mail-account-edit-dialog.component.html',
styleUrls: ['./mail-account-edit-dialog.component.scss'], styleUrls: ['./mail-account-edit-dialog.component.scss'],
}) })
export class MailAccountEditDialogComponent extends EditDialogComponent<PaperlessMailAccount> { export class MailAccountEditDialogComponent extends EditDialogComponent<MailAccount> {
testActive: boolean = false testActive: boolean = false
testResult: string testResult: string
alertTimeout alertTimeout

View File

@ -7,7 +7,7 @@ import { of } from 'rxjs'
import { import {
MailMetadataCorrespondentOption, MailMetadataCorrespondentOption,
MailAction, MailAction,
} from 'src/app/data/paperless-mail-rule' } from 'src/app/data/mail-rule'
import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe' import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe'

View File

@ -3,17 +3,17 @@ import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { first } from 'rxjs' import { first } from 'rxjs'
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { PaperlessMailAccount } from 'src/app/data/paperless-mail-account' import { MailAccount } from 'src/app/data/mail-account'
import { import {
MailAction, MailAction,
MailFilterAttachmentType, MailFilterAttachmentType,
MailMetadataCorrespondentOption, MailMetadataCorrespondentOption,
MailMetadataTitleOption, MailMetadataTitleOption,
PaperlessMailRule, MailRule,
MailRuleConsumptionScope, MailRuleConsumptionScope,
} from 'src/app/data/paperless-mail-rule' } from 'src/app/data/mail-rule'
import { CorrespondentService } from 'src/app/services/rest/correspondent.service' import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
import { DocumentTypeService } from 'src/app/services/rest/document-type.service' import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
import { MailAccountService } from 'src/app/services/rest/mail-account.service' import { MailAccountService } from 'src/app/services/rest/mail-account.service'
@ -109,10 +109,10 @@ const METADATA_CORRESPONDENT_OPTIONS = [
templateUrl: './mail-rule-edit-dialog.component.html', templateUrl: './mail-rule-edit-dialog.component.html',
styleUrls: ['./mail-rule-edit-dialog.component.scss'], styleUrls: ['./mail-rule-edit-dialog.component.scss'],
}) })
export class MailRuleEditDialogComponent extends EditDialogComponent<PaperlessMailRule> { export class MailRuleEditDialogComponent extends EditDialogComponent<MailRule> {
accounts: PaperlessMailAccount[] accounts: MailAccount[]
correspondents: PaperlessCorrespondent[] correspondents: Correspondent[]
documentTypes: PaperlessDocumentType[] documentTypes: DocumentType[]
constructor( constructor(
service: MailRuleService, service: MailRuleService,

View File

@ -3,7 +3,7 @@ import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model' import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path' import { StoragePath } from 'src/app/data/storage-path'
import { StoragePathService } from 'src/app/services/rest/storage-path.service' import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -13,7 +13,7 @@ import { SettingsService } from 'src/app/services/settings.service'
templateUrl: './storage-path-edit-dialog.component.html', templateUrl: './storage-path-edit-dialog.component.html',
styleUrls: ['./storage-path-edit-dialog.component.scss'], styleUrls: ['./storage-path-edit-dialog.component.scss'],
}) })
export class StoragePathEditDialogComponent extends EditDialogComponent<PaperlessStoragePath> { export class StoragePathEditDialogComponent extends EditDialogComponent<StoragePath> {
constructor( constructor(
service: StoragePathService, service: StoragePathService,
activeModal: NgbActiveModal, activeModal: NgbActiveModal,

View File

@ -2,7 +2,7 @@ import { Component } from '@angular/core'
import { FormControl, FormGroup } from '@angular/forms' import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { TagService } from 'src/app/services/rest/tag.service' import { TagService } from 'src/app/services/rest/tag.service'
import { randomColor } from 'src/app/utils/color' import { randomColor } from 'src/app/utils/color'
import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model' import { DEFAULT_MATCHING_ALGORITHM } from 'src/app/data/matching-model'
@ -14,7 +14,7 @@ import { SettingsService } from 'src/app/services/settings.service'
templateUrl: './tag-edit-dialog.component.html', templateUrl: './tag-edit-dialog.component.html',
styleUrls: ['./tag-edit-dialog.component.scss'], styleUrls: ['./tag-edit-dialog.component.scss'],
}) })
export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> { export class TagEditDialogComponent extends EditDialogComponent<Tag> {
constructor( constructor(
service: TagService, service: TagService,
activeModal: NgbActiveModal, activeModal: NgbActiveModal,

View File

@ -3,8 +3,8 @@ import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { first } from 'rxjs' import { first } from 'rxjs'
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component' import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
import { PaperlessGroup } from 'src/app/data/paperless-group' import { Group } from 'src/app/data/group'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { GroupService } from 'src/app/services/rest/group.service' import { GroupService } from 'src/app/services/rest/group.service'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -15,10 +15,10 @@ import { SettingsService } from 'src/app/services/settings.service'
styleUrls: ['./user-edit-dialog.component.scss'], styleUrls: ['./user-edit-dialog.component.scss'],
}) })
export class UserEditDialogComponent export class UserEditDialogComponent
extends EditDialogComponent<PaperlessUser> extends EditDialogComponent<User>
implements OnInit implements OnInit
{ {
groups: PaperlessGroup[] groups: Group[]
passwordIsSet: boolean = false passwordIsSet: boolean = false
constructor( constructor(

View File

@ -13,7 +13,7 @@ import {
} from './filterable-dropdown.component' } from './filterable-dropdown.component'
import { FilterPipe } from 'src/app/pipes/filter.pipe' import { FilterPipe } from 'src/app/pipes/filter.pipe'
import { NgbModule } from '@ng-bootstrap/ng-bootstrap' import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { import {
DEFAULT_MATCHING_ALGORITHM, DEFAULT_MATCHING_ALGORITHM,
MATCH_ALL, MATCH_ALL,
@ -26,7 +26,7 @@ import { TagComponent } from '../tag/tag.component'
import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { ClearableBadgeComponent } from '../clearable-badge/clearable-badge.component' import { ClearableBadgeComponent } from '../clearable-badge/clearable-badge.component'
const items: PaperlessTag[] = [ const items: Tag[] = [
{ {
id: 1, id: 1,
name: 'Tag1', name: 'Tag1',

View File

@ -4,7 +4,7 @@ import {
ToggleableItemState, ToggleableItemState,
} from './toggleable-dropdown-button.component' } from './toggleable-dropdown-button.component'
import { TagComponent } from '../../tag/tag.component' import { TagComponent } from '../../tag/tag.component'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
describe('ToggleableDropdownButtonComponent', () => { describe('ToggleableDropdownButtonComponent', () => {
let component: ToggleableDropdownButtonComponent let component: ToggleableDropdownButtonComponent
@ -26,7 +26,7 @@ describe('ToggleableDropdownButtonComponent', () => {
id: 1, id: 1,
name: 'Test Tag', name: 'Test Tag',
is_inbox_tag: false, is_inbox_tag: false,
} as PaperlessTag } as Tag
fixture.detectChanges() fixture.detectChanges()
expect(component.isTag).toBeTruthy() expect(component.isTag).toBeTruthy()

View File

@ -13,7 +13,7 @@ import {
catchError, catchError,
} from 'rxjs' } from 'rxjs'
import { FILTER_TITLE } from 'src/app/data/filter-rule-type' import { FILTER_TITLE } from 'src/app/data/filter-rule-type'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { DocumentService } from 'src/app/services/rest/document.service' import { DocumentService } from 'src/app/services/rest/document.service'
import { AbstractInputComponent } from '../abstract-input' import { AbstractInputComponent } from '../abstract-input'
@ -34,9 +34,9 @@ export class DocumentLinkComponent
implements OnInit, OnDestroy implements OnInit, OnDestroy
{ {
documentsInput$ = new Subject<string>() documentsInput$ = new Subject<string>()
foundDocuments$: Observable<PaperlessDocument[]> foundDocuments$: Observable<Document[]>
loading = false loading = false
selectedDocuments: PaperlessDocument[] = [] selectedDocuments: Document[] = []
private unsubscribeNotifier: Subject<any> = new Subject() private unsubscribeNotifier: Subject<any> = new Subject()
@ -104,21 +104,18 @@ export class DocumentLinkComponent
) )
} }
unselect(document: PaperlessDocument): void { unselect(document: Document): void {
this.selectedDocuments = this.selectedDocuments.filter( this.selectedDocuments = this.selectedDocuments.filter(
(d) => d.id !== document.id (d) => d.id !== document.id
) )
this.onChange(this.selectedDocuments.map((d) => d.id)) this.onChange(this.selectedDocuments.map((d) => d.id))
} }
compareDocuments( compareDocuments(document: Document, selectedDocument: Document) {
document: PaperlessDocument,
selectedDocument: PaperlessDocument
) {
return document.id === selectedDocument.id return document.id === selectedDocument.id
} }
trackByFn(item: PaperlessDocument) { trackByFn(item: Document) {
return item.id return item.id
} }

View File

@ -1,6 +1,6 @@
import { Component, forwardRef, Input, OnInit } from '@angular/core' import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { FormControl, FormGroup, NG_VALUE_ACCESSOR } from '@angular/forms' import { FormControl, FormGroup, NG_VALUE_ACCESSOR } from '@angular/forms'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { AbstractInputComponent } from '../../abstract-input' import { AbstractInputComponent } from '../../abstract-input'
export interface PermissionsFormObject { export interface PermissionsFormObject {
@ -34,7 +34,7 @@ export class PermissionsFormComponent
implements OnInit implements OnInit
{ {
@Input() @Input()
users: PaperlessUser[] users: User[]
@Input() @Input()
accordion: boolean = false accordion: boolean = false

View File

@ -1,7 +1,7 @@
import { Component, forwardRef, Input, OnInit } from '@angular/core' import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { NG_VALUE_ACCESSOR } from '@angular/forms' import { NG_VALUE_ACCESSOR } from '@angular/forms'
import { first } from 'rxjs/operators' import { first } from 'rxjs/operators'
import { PaperlessGroup } from 'src/app/data/paperless-group' import { Group } from 'src/app/data/group'
import { GroupService } from 'src/app/services/rest/group.service' import { GroupService } from 'src/app/services/rest/group.service'
import { AbstractInputComponent } from '../../abstract-input' import { AbstractInputComponent } from '../../abstract-input'
@ -17,8 +17,8 @@ import { AbstractInputComponent } from '../../abstract-input'
templateUrl: './permissions-group.component.html', templateUrl: './permissions-group.component.html',
styleUrls: ['./permissions-group.component.scss'], styleUrls: ['./permissions-group.component.scss'],
}) })
export class PermissionsGroupComponent extends AbstractInputComponent<PaperlessGroup> { export class PermissionsGroupComponent extends AbstractInputComponent<Group> {
groups: PaperlessGroup[] groups: Group[]
constructor(groupService: GroupService) { constructor(groupService: GroupService) {
super() super()

View File

@ -1,7 +1,7 @@
import { Component, forwardRef, Input, OnInit } from '@angular/core' import { Component, forwardRef, Input, OnInit } from '@angular/core'
import { NG_VALUE_ACCESSOR } from '@angular/forms' import { NG_VALUE_ACCESSOR } from '@angular/forms'
import { first } from 'rxjs/operators' import { first } from 'rxjs/operators'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { AbstractInputComponent } from '../../abstract-input' import { AbstractInputComponent } from '../../abstract-input'
@ -18,10 +18,8 @@ import { AbstractInputComponent } from '../../abstract-input'
templateUrl: './permissions-user.component.html', templateUrl: './permissions-user.component.html',
styleUrls: ['./permissions-user.component.scss'], styleUrls: ['./permissions-user.component.scss'],
}) })
export class PermissionsUserComponent extends AbstractInputComponent< export class PermissionsUserComponent extends AbstractInputComponent<User[]> {
PaperlessUser[] users: User[]
> {
users: PaperlessUser[]
constructor(userService: UserService, settings: SettingsService) { constructor(userService: UserService, settings: SettingsService) {
super() super()

View File

@ -10,7 +10,7 @@ import {
NG_VALUE_ACCESSOR, NG_VALUE_ACCESSOR,
} from '@angular/forms' } from '@angular/forms'
import { SelectComponent } from './select.component' import { SelectComponent } from './select.component'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { import {
DEFAULT_MATCHING_ALGORITHM, DEFAULT_MATCHING_ALGORITHM,
MATCH_ALL, MATCH_ALL,
@ -18,7 +18,7 @@ import {
import { NgSelectModule } from '@ng-select/ng-select' import { NgSelectModule } from '@ng-select/ng-select'
import { RouterTestingModule } from '@angular/router/testing' import { RouterTestingModule } from '@angular/router/testing'
const items: PaperlessTag[] = [ const items: Tag[] = [
{ {
id: 1, id: 1,
name: 'Tag1', name: 'Tag1',

View File

@ -5,7 +5,7 @@ import {
NG_VALUE_ACCESSOR, NG_VALUE_ACCESSOR,
} from '@angular/forms' } from '@angular/forms'
import { TagsComponent } from './tags.component' import { TagsComponent } from './tags.component'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { import {
DEFAULT_MATCHING_ALGORITHM, DEFAULT_MATCHING_ALGORITHM,
MATCH_ALL, MATCH_ALL,
@ -31,7 +31,7 @@ import { PermissionsFormComponent } from '../permissions/permissions-form/permis
import { SelectComponent } from '../select/select.component' import { SelectComponent } from '../select/select.component'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
const tags: PaperlessTag[] = [ const tags: Tag[] = [
{ {
id: 1, id: 1,
name: 'Tag1', name: 'Tag1',

View File

@ -9,7 +9,7 @@ import {
} from '@angular/core' } from '@angular/core'
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { TagEditDialogComponent } from '../../edit-dialog/tag-edit-dialog/tag-edit-dialog.component' import { TagEditDialogComponent } from '../../edit-dialog/tag-edit-dialog/tag-edit-dialog.component'
import { TagService } from 'src/app/services/rest/tag.service' import { TagService } from 'src/app/services/rest/tag.service'
import { EditDialogMode } from '../../edit-dialog/edit-dialog.component' import { EditDialogMode } from '../../edit-dialog/edit-dialog.component'
@ -81,13 +81,13 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
horizontal: boolean = false horizontal: boolean = false
@Output() @Output()
filterDocuments = new EventEmitter<PaperlessTag[]>() filterDocuments = new EventEmitter<Tag[]>()
@ViewChild('tagSelect') select: NgSelectComponent @ViewChild('tagSelect') select: NgSelectComponent
value: number[] = [] value: number[] = []
tags: PaperlessTag[] = [] tags: Tag[] = []
public createTagRef: (name) => void public createTagRef: (name) => void

View File

@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'
import { FormControl, FormGroup } from '@angular/forms' import { FormControl, FormGroup } from '@angular/forms'
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap' import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
import { ObjectWithPermissions } from 'src/app/data/object-with-permissions' import { ObjectWithPermissions } from 'src/app/data/object-with-permissions'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
@Component({ @Component({
@ -11,7 +11,7 @@ import { UserService } from 'src/app/services/rest/user.service'
styleUrls: ['./permissions-dialog.component.scss'], styleUrls: ['./permissions-dialog.component.scss'],
}) })
export class PermissionsDialogComponent { export class PermissionsDialogComponent {
users: PaperlessUser[] users: User[]
private o: ObjectWithPermissions = undefined private o: ObjectWithPermissions = undefined
constructor( constructor(

View File

@ -1,6 +1,6 @@
import { Component, EventEmitter, Input, Output } from '@angular/core' import { Component, EventEmitter, Input, Output } from '@angular/core'
import { first } from 'rxjs' import { first } from 'rxjs'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { import {
PermissionAction, PermissionAction,
PermissionType, PermissionType,
@ -55,7 +55,7 @@ export class PermissionsFilterDropdownComponent extends ComponentWithPermissions
@Output() @Output()
ownerFilterSet = new EventEmitter<PermissionsSelectionModel>() ownerFilterSet = new EventEmitter<PermissionsSelectionModel>()
users: PaperlessUser[] users: User[]
hideUnowned: boolean hideUnowned: boolean

View File

@ -5,7 +5,7 @@ import { PdfViewerComponent } from '../pdf-viewer/pdf-viewer.component'
import { By } from '@angular/platform-browser' import { By } from '@angular/platform-browser'
import { SafeUrlPipe } from 'src/app/pipes/safeurl.pipe' import { SafeUrlPipe } from 'src/app/pipes/safeurl.pipe'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { HttpClientTestingModule } from '@angular/common/http/testing' import { HttpClientTestingModule } from '@angular/common/http/testing'
import { DocumentService } from 'src/app/services/rest/document.service' import { DocumentService } from 'src/app/services/rest/document.service'

View File

@ -1,6 +1,6 @@
import { Component, Input } from '@angular/core' import { Component, Input } from '@angular/core'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { DocumentService } from 'src/app/services/rest/document.service' import { DocumentService } from 'src/app/services/rest/document.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
@ -11,7 +11,7 @@ import { SettingsService } from 'src/app/services/settings.service'
}) })
export class PreviewPopupComponent { export class PreviewPopupComponent {
@Input() @Input()
document: PaperlessDocument document: Document
error = false error = false

View File

@ -10,10 +10,7 @@ import {
} from '@angular/core/testing' } from '@angular/core/testing'
import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { FormsModule, ReactiveFormsModule } from '@angular/forms'
import { of, throwError } from 'rxjs' import { of, throwError } from 'rxjs'
import { import { FileVersion, ShareLink } from 'src/app/data/share-link'
PaperlessFileVersion,
PaperlessShareLink,
} from 'src/app/data/paperless-share-link'
import { ShareLinkService } from 'src/app/services/rest/share-link.service' import { ShareLinkService } from 'src/app/services/rest/share-link.service'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { environment } from 'src/environments/environment' import { environment } from 'src/environments/environment'
@ -60,7 +57,7 @@ describe('ShareLinksDropdownComponent', () => {
slug: '1234slug', slug: '1234slug',
created: now.toISOString(), created: now.toISOString(),
document: 99, document: 99,
file_version: PaperlessFileVersion.Archive, file_version: FileVersion.Archive,
expiration: expiration7days.toISOString(), expiration: expiration7days.toISOString(),
}, },
{ {
@ -68,7 +65,7 @@ describe('ShareLinksDropdownComponent', () => {
slug: '1234slug', slug: '1234slug',
created: now.toISOString(), created: now.toISOString(),
document: 99, document: 99,
file_version: PaperlessFileVersion.Original, file_version: FileVersion.Original,
expiration: null, expiration: null,
}, },
]) ])
@ -152,7 +149,7 @@ describe('ShareLinksDropdownComponent', () => {
deleteSpy.mockReturnValue(of(true)) deleteSpy.mockReturnValue(of(true))
const refreshSpy = jest.spyOn(component, 'refresh') const refreshSpy = jest.spyOn(component, 'refresh')
component.delete({ id: 12 } as PaperlessShareLink) component.delete({ id: 12 } as ShareLink)
fixture.detectChanges() fixture.detectChanges()
expect(deleteSpy).toHaveBeenCalledWith({ id: 12 }) expect(deleteSpy).toHaveBeenCalledWith({ id: 12 })
expect(refreshSpy).toHaveBeenCalled() expect(refreshSpy).toHaveBeenCalled()
@ -178,18 +175,18 @@ describe('ShareLinksDropdownComponent', () => {
expect( expect(
component.getDaysRemaining({ component.getDaysRemaining({
expiration: expiration7days.toISOString(), expiration: expiration7days.toISOString(),
} as PaperlessShareLink) } as ShareLink)
).toEqual('7 days') ).toEqual('7 days')
expect( expect(
component.getDaysRemaining({ component.getDaysRemaining({
expiration: expiration1day.toISOString(), expiration: expiration1day.toISOString(),
} as PaperlessShareLink) } as ShareLink)
).toEqual('1 day') ).toEqual('1 day')
}) })
// coverage // coverage
it('should support share', () => { it('should support share', () => {
const link = { slug: '12345slug' } as PaperlessShareLink const link = { slug: '12345slug' } as ShareLink
if (!('share' in navigator)) if (!('share' in navigator))
Object.defineProperty(navigator, 'share', { value: (obj: any) => {} }) Object.defineProperty(navigator, 'share', { value: (obj: any) => {} })
// const navigatorSpy = jest.spyOn(navigator, 'share') // const navigatorSpy = jest.spyOn(navigator, 'share')

View File

@ -1,9 +1,6 @@
import { Component, Input, OnInit } from '@angular/core' import { Component, Input, OnInit } from '@angular/core'
import { first } from 'rxjs' import { first } from 'rxjs'
import { import { ShareLink, FileVersion } from 'src/app/data/share-link'
PaperlessShareLink,
PaperlessFileVersion,
} from 'src/app/data/paperless-share-link'
import { ShareLinkService } from 'src/app/services/rest/share-link.service' import { ShareLinkService } from 'src/app/services/rest/share-link.service'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { environment } from 'src/environments/environment' import { environment } from 'src/environments/environment'
@ -41,7 +38,7 @@ export class ShareLinksDropdownComponent implements OnInit {
@Input() @Input()
hasArchiveVersion: boolean = true hasArchiveVersion: boolean = true
shareLinks: PaperlessShareLink[] shareLinks: ShareLink[]
loading: boolean = false loading: boolean = false
@ -83,21 +80,21 @@ export class ShareLinksDropdownComponent implements OnInit {
}) })
} }
getShareUrl(link: PaperlessShareLink): string { getShareUrl(link: ShareLink): string {
const apiURL = new URL(environment.apiBaseUrl) const apiURL = new URL(environment.apiBaseUrl)
return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${ return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${
link.slug link.slug
}` }`
} }
getDaysRemaining(link: PaperlessShareLink): string { getDaysRemaining(link: ShareLink): string {
const days: number = Math.round( const days: number = Math.round(
(Date.parse(link.expiration) - Date.now()) / (1000 * 60 * 60 * 24) (Date.parse(link.expiration) - Date.now()) / (1000 * 60 * 60 * 24)
) )
return days === 1 ? $localize`1 day` : $localize`${days} days` return days === 1 ? $localize`1 day` : $localize`${days} days`
} }
copy(link: PaperlessShareLink) { copy(link: ShareLink) {
const success = this.clipboard.copy(this.getShareUrl(link)) const success = this.clipboard.copy(this.getShareUrl(link))
if (success) { if (success) {
this.copied = link.id this.copied = link.id
@ -107,17 +104,17 @@ export class ShareLinksDropdownComponent implements OnInit {
} }
} }
canShare(link: PaperlessShareLink): boolean { canShare(link: ShareLink): boolean {
return ( return (
navigator?.canShare && navigator.canShare({ url: this.getShareUrl(link) }) navigator?.canShare && navigator.canShare({ url: this.getShareUrl(link) })
) )
} }
share(link: PaperlessShareLink) { share(link: ShareLink) {
navigator.share({ url: this.getShareUrl(link) }) navigator.share({ url: this.getShareUrl(link) })
} }
delete(link: PaperlessShareLink) { delete(link: ShareLink) {
this.shareLinkService.delete(link).subscribe({ this.shareLinkService.delete(link).subscribe({
next: () => { next: () => {
this.refresh() this.refresh()
@ -138,9 +135,7 @@ export class ShareLinksDropdownComponent implements OnInit {
this.shareLinkService this.shareLinkService
.createLinkForDocument( .createLinkForDocument(
this._documentId, this._documentId,
this.useArchiveVersion this.useArchiveVersion ? FileVersion.Archive : FileVersion.Original,
? PaperlessFileVersion.Archive
: PaperlessFileVersion.Original,
expiration expiration
) )
.subscribe({ .subscribe({

View File

@ -1,9 +1,9 @@
import { ComponentFixture, TestBed } from '@angular/core/testing' import { ComponentFixture, TestBed } from '@angular/core/testing'
import { TagComponent } from './tag.component' import { TagComponent } from './tag.component'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { By } from '@angular/platform-browser' import { By } from '@angular/platform-browser'
const tag: PaperlessTag = { const tag: Tag = {
id: 1, id: 1,
color: '#ff0000', color: '#ff0000',
name: 'Tag1', name: 'Tag1',

View File

@ -1,5 +1,5 @@
import { Component, Input } from '@angular/core' import { Component, Input } from '@angular/core'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
@Component({ @Component({
selector: 'pngx-tag', selector: 'pngx-tag',
@ -10,7 +10,7 @@ export class TagComponent {
constructor() {} constructor() {}
@Input() @Input()
tag: PaperlessTag tag: Tag
@Input() @Input()
linkTitle: string = '' linkTitle: string = ''

View File

@ -18,9 +18,9 @@ import { TourNgBootstrapModule, TourService } from 'ngx-ui-tour-ng-bootstrap'
import { LogoComponent } from '../common/logo/logo.component' import { LogoComponent } from '../common/logo/logo.component'
import { of, throwError } from 'rxjs' import { of, throwError } from 'rxjs'
import { ToastService } from 'src/app/services/toast.service' 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 { 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 = [ const saved_views = [
{ {
@ -167,7 +167,7 @@ describe('DashboardComponent', () => {
const toastSpy = jest.spyOn(toastService, 'showInfo') const toastSpy = jest.spyOn(toastService, 'showInfo')
jest.spyOn(settingsService, 'storeSettings').mockReturnValue(of(true)) jest.spyOn(settingsService, 'storeSettings').mockReturnValue(of(true))
component.onDrop({ previousIndex: 0, currentIndex: 1 } as CdkDragDrop< component.onDrop({ previousIndex: 0, currentIndex: 1 } as CdkDragDrop<
PaperlessSavedView[] SavedView[]
>) >)
expect(settingsSpy).toHaveBeenCalledWith([ expect(settingsSpy).toHaveBeenCalledWith([
saved_views[2], saved_views[2],
@ -190,7 +190,7 @@ describe('DashboardComponent', () => {
.spyOn(settingsService, 'storeSettings') .spyOn(settingsService, 'storeSettings')
.mockReturnValue(throwError(() => new Error('unable to save'))) .mockReturnValue(throwError(() => new Error('unable to save')))
component.onDrop({ previousIndex: 0, currentIndex: 2 } as CdkDragDrop< component.onDrop({ previousIndex: 0, currentIndex: 2 } as CdkDragDrop<
PaperlessSavedView[] SavedView[]
>) >)
expect(toastSpy).toHaveBeenCalled() expect(toastSpy).toHaveBeenCalled()
}) })

View File

@ -3,9 +3,9 @@ import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { ComponentWithPermissions } from '../with-permissions/with-permissions.component' import { ComponentWithPermissions } from '../with-permissions/with-permissions.component'
import { TourService } from 'ngx-ui-tour-ng-bootstrap' 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 { 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 { import {
CdkDragDrop, CdkDragDrop,
CdkDragEnd, CdkDragEnd,
@ -19,7 +19,7 @@ import {
styleUrls: ['./dashboard.component.scss'], styleUrls: ['./dashboard.component.scss'],
}) })
export class DashboardComponent extends ComponentWithPermissions { export class DashboardComponent extends ComponentWithPermissions {
public dashboardViews: PaperlessSavedView[] = [] public dashboardViews: SavedView[] = []
constructor( constructor(
public settingsService: SettingsService, public settingsService: SettingsService,
public savedViewService: SavedViewService, public savedViewService: SavedViewService,
@ -57,7 +57,7 @@ export class DashboardComponent extends ComponentWithPermissions {
this.settingsService.globalDropzoneEnabled = true this.settingsService.globalDropzoneEnabled = true
} }
onDrop(event: CdkDragDrop<PaperlessSavedView[]>) { onDrop(event: CdkDragDrop<SavedView[]>) {
moveItemInArray( moveItemInArray(
this.dashboardViews, this.dashboardViews,
event.previousIndex, event.previousIndex,

View File

@ -12,7 +12,7 @@ import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
import { of, Subject } from 'rxjs' import { of, Subject } from 'rxjs'
import { routes } from 'src/app/app-routing.module' import { routes } from 'src/app/app-routing.module'
import { FILTER_HAS_TAGS_ALL } from 'src/app/data/filter-rule-type' 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 { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { PermissionsGuard } from 'src/app/guards/permissions.guard'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' 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 { DragDropModule } from '@angular/cdk/drag-drop'
import { PreviewPopupComponent } from 'src/app/components/common/preview-popup/preview-popup.component' import { PreviewPopupComponent } from 'src/app/components/common/preview-popup/preview-popup.component'
const savedView: PaperlessSavedView = { const savedView: SavedView = {
id: 1, id: 1,
name: 'Saved View 1', name: 'Saved View 1',
sort_field: 'added', sort_field: 'added',

View File

@ -8,11 +8,11 @@ import {
} from '@angular/core' } from '@angular/core'
import { Params, Router } from '@angular/router' import { Params, Router } from '@angular/router'
import { Subject, takeUntil } from 'rxjs' import { Subject, takeUntil } from 'rxjs'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' import { SavedView } from 'src/app/data/saved-view'
import { ConsumerStatusService } from 'src/app/services/consumer-status.service' import { ConsumerStatusService } from 'src/app/services/consumer-status.service'
import { DocumentService } from 'src/app/services/rest/document.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 { import {
FILTER_CORRESPONDENT, FILTER_CORRESPONDENT,
FILTER_HAS_TAGS_ALL, FILTER_HAS_TAGS_ALL,
@ -46,9 +46,9 @@ export class SavedViewWidgetComponent
} }
@Input() @Input()
savedView: PaperlessSavedView savedView: SavedView
documents: PaperlessDocument[] = [] documents: Document[] = []
unsubscribeNotifier: Subject<any> = new Subject() 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.preventDefault()
event.stopImmediatePropagation() event.stopImmediatePropagation()
@ -110,15 +110,15 @@ export class SavedViewWidgetComponent
]) ])
} }
getPreviewUrl(document: PaperlessDocument): string { getPreviewUrl(document: Document): string {
return this.documentService.getPreviewUrl(document.id) return this.documentService.getPreviewUrl(document.id)
} }
getDownloadUrl(document: PaperlessDocument): string { getDownloadUrl(document: Document): string {
return this.documentService.getDownloadUrl(document.id) return this.documentService.getDownloadUrl(document.id)
} }
mouseEnterPreviewButton(doc: PaperlessDocument) { mouseEnterPreviewButton(doc: Document) {
const newPopover = this.popovers.get(this.documents.indexOf(doc)) const newPopover = this.popovers.get(this.documents.indexOf(doc))
if (this.popover !== newPopover && this.popover?.isOpen()) if (this.popover !== newPopover && this.popover?.isOpen())
this.popover.close() this.popover.close()

View File

@ -1,7 +1,7 @@
import { Component, QueryList, ViewChildren } from '@angular/core' import { Component, QueryList, ViewChildren } from '@angular/core'
import { NgbAlert } from '@ng-bootstrap/ng-bootstrap' import { NgbAlert } from '@ng-bootstrap/ng-bootstrap'
import { ComponentWithPermissions } from 'src/app/components/with-permissions/with-permissions.component' 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 { import {
ConsumerStatusService, ConsumerStatusService,
FileStatus, FileStatus,

View File

@ -30,11 +30,11 @@ import {
FILTER_CREATED_AFTER, FILTER_CREATED_AFTER,
FILTER_CREATED_BEFORE, FILTER_CREATED_BEFORE,
} from 'src/app/data/filter-rule-type' } from 'src/app/data/filter-rule-type'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path' import { StoragePath } from 'src/app/data/storage-path'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { PermissionsGuard } from 'src/app/guards/permissions.guard'
@ -67,11 +67,11 @@ import { DocumentNotesComponent } from '../document-notes/document-notes.compone
import { DocumentDetailComponent } from './document-detail.component' import { DocumentDetailComponent } from './document-detail.component'
import { ShareLinksDropdownComponent } from '../common/share-links-dropdown/share-links-dropdown.component' import { ShareLinksDropdownComponent } from '../common/share-links-dropdown/share-links-dropdown.component'
import { CustomFieldsDropdownComponent } from '../common/custom-fields-dropdown/custom-fields-dropdown.component' import { CustomFieldsDropdownComponent } from '../common/custom-fields-dropdown/custom-fields-dropdown.component'
import { PaperlessCustomFieldDataType } from 'src/app/data/paperless-custom-field' import { CustomFieldDataType } from 'src/app/data/custom-field'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { PdfViewerComponent } from '../common/pdf-viewer/pdf-viewer.component' import { PdfViewerComponent } from '../common/pdf-viewer/pdf-viewer.component'
const doc: PaperlessDocument = { const doc: Document = {
id: 3, id: 3,
title: 'Doc 3', title: 'Doc 3',
correspondent: 11, correspondent: 11,
@ -111,13 +111,13 @@ const customFields = [
{ {
id: 0, id: 0,
name: 'Field 1', name: 'Field 1',
data_type: PaperlessCustomFieldDataType.String, data_type: CustomFieldDataType.String,
created: new Date(), created: new Date(),
}, },
{ {
id: 1, id: 1,
name: 'Custom Field 2', name: 'Custom Field 2',
data_type: PaperlessCustomFieldDataType.Integer, data_type: CustomFieldDataType.Integer,
created: new Date(), created: new Date(),
}, },
] ]
@ -732,7 +732,7 @@ describe('DocumentDetailComponent', () => {
id: 22, id: 22,
name: 'Correspondent22', name: 'Correspondent22',
last_correspondence: new Date().toISOString(), last_correspondence: new Date().toISOString(),
} as PaperlessCorrespondent } as Correspondent
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter') const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
component.filterDocuments([object]) component.filterDocuments([object])
expect(qfSpy).toHaveBeenCalledWith([ expect(qfSpy).toHaveBeenCalledWith([
@ -745,7 +745,7 @@ describe('DocumentDetailComponent', () => {
it('should support quick filtering by doc type', () => { it('should support quick filtering by doc type', () => {
initNormally() initNormally()
const object = { id: 22, name: 'DocumentType22' } as PaperlessDocumentType const object = { id: 22, name: 'DocumentType22' } as DocumentType
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter') const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
component.filterDocuments([object]) component.filterDocuments([object])
expect(qfSpy).toHaveBeenCalledWith([ expect(qfSpy).toHaveBeenCalledWith([
@ -762,7 +762,7 @@ describe('DocumentDetailComponent', () => {
id: 22, id: 22,
name: 'StoragePath22', name: 'StoragePath22',
path: '/foo/bar/', path: '/foo/bar/',
} as PaperlessStoragePath } as StoragePath
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter') const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
component.filterDocuments([object]) component.filterDocuments([object])
expect(qfSpy).toHaveBeenCalledWith([ expect(qfSpy).toHaveBeenCalledWith([
@ -781,14 +781,14 @@ describe('DocumentDetailComponent', () => {
is_inbox_tag: true, is_inbox_tag: true,
color: '#ff0000', color: '#ff0000',
text_color: '#000000', text_color: '#000000',
} as PaperlessTag } as Tag
const object2 = { const object2 = {
id: 23, id: 23,
name: 'Tag22', name: 'Tag22',
is_inbox_tag: true, is_inbox_tag: true,
color: '#ff0000', color: '#ff0000',
text_color: '#000000', text_color: '#000000',
} as PaperlessTag } as Tag
const qfSpy = jest.spyOn(documentListViewService, 'quickFilter') const qfSpy = jest.spyOn(documentListViewService, 'quickFilter')
component.filterDocuments([object1, object2]) component.filterDocuments([object1, object2])
expect(qfSpy).toHaveBeenCalledWith([ expect(qfSpy).toHaveBeenCalledWith([

View File

@ -7,11 +7,11 @@ import {
NgbNav, NgbNav,
NgbNavChangeEvent, NgbNavChangeEvent,
} from '@ng-bootstrap/ng-bootstrap' } from '@ng-bootstrap/ng-bootstrap'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { PaperlessDocumentMetadata } from 'src/app/data/paperless-document-metadata' import { DocumentMetadata } from 'src/app/data/document-metadata'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe' import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { OpenDocumentsService } from 'src/app/services/open-documents.service' import { OpenDocumentsService } from 'src/app/services/open-documents.service'
@ -34,7 +34,7 @@ import {
debounceTime, debounceTime,
distinctUntilChanged, distinctUntilChanged,
} from 'rxjs/operators' } from 'rxjs/operators'
import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-suggestions' import { DocumentSuggestions } from 'src/app/data/document-suggestions'
import { import {
FILTER_CORRESPONDENT, FILTER_CORRESPONDENT,
FILTER_CREATED_AFTER, FILTER_CREATED_AFTER,
@ -45,28 +45,25 @@ import {
FILTER_STORAGE_PATH, FILTER_STORAGE_PATH,
} from 'src/app/data/filter-rule-type' } from 'src/app/data/filter-rule-type'
import { StoragePathService } from 'src/app/services/rest/storage-path.service' import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path' import { StoragePath } from 'src/app/data/storage-path'
import { StoragePathEditDialogComponent } from '../common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component' import { StoragePathEditDialogComponent } from '../common/edit-dialog/storage-path-edit-dialog/storage-path-edit-dialog.component'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { import {
PermissionAction, PermissionAction,
PermissionsService, PermissionsService,
PermissionType, PermissionType,
} from 'src/app/services/permissions.service' } from 'src/app/services/permissions.service'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { PaperlessDocumentNote } from 'src/app/data/paperless-document-note' import { DocumentNote } from 'src/app/data/document-note'
import { HttpClient } from '@angular/common/http' import { HttpClient } from '@angular/common/http'
import { ComponentWithPermissions } from '../with-permissions/with-permissions.component' import { ComponentWithPermissions } from '../with-permissions/with-permissions.component'
import { EditDialogMode } from '../common/edit-dialog/edit-dialog.component' import { EditDialogMode } from '../common/edit-dialog/edit-dialog.component'
import { ObjectWithId } from 'src/app/data/object-with-id' import { ObjectWithId } from 'src/app/data/object-with-id'
import { FilterRule } from 'src/app/data/filter-rule' import { FilterRule } from 'src/app/data/filter-rule'
import { ISODateAdapter } from 'src/app/utils/ngb-iso-date-adapter' import { ISODateAdapter } from 'src/app/utils/ngb-iso-date-adapter'
import { import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
PaperlessCustomField, import { CustomFieldInstance } from 'src/app/data/custom-field-instance'
PaperlessCustomFieldDataType,
} from 'src/app/data/paperless-custom-field'
import { PaperlessCustomFieldInstance } from 'src/app/data/paperless-custom-field-instance'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { PDFDocumentProxy } from '../common/pdf-viewer/typings' import { PDFDocumentProxy } from '../common/pdf-viewer/typings'
@ -111,10 +108,10 @@ export class DocumentDetailComponent
networkActive = false networkActive = false
documentId: number documentId: number
document: PaperlessDocument document: Document
metadata: PaperlessDocumentMetadata metadata: DocumentMetadata
suggestions: PaperlessDocumentSuggestions suggestions: DocumentSuggestions
users: PaperlessUser[] users: User[]
title: string title: string
titleSubject: Subject<string> = new Subject() titleSubject: Subject<string> = new Subject()
@ -123,9 +120,9 @@ export class DocumentDetailComponent
downloadUrl: string downloadUrl: string
downloadOriginalUrl: string downloadOriginalUrl: string
correspondents: PaperlessCorrespondent[] correspondents: Correspondent[]
documentTypes: PaperlessDocumentType[] documentTypes: DocumentType[]
storagePaths: PaperlessStoragePath[] storagePaths: StoragePath[]
documentForm: FormGroup = new FormGroup({ documentForm: FormGroup = new FormGroup({
title: new FormControl(''), title: new FormControl(''),
@ -155,8 +152,8 @@ export class DocumentDetailComponent
ogDate: Date ogDate: Date
customFields: PaperlessCustomField[] customFields: CustomField[]
public readonly PaperlessCustomFieldDataType = PaperlessCustomFieldDataType public readonly PaperlessCustomFieldDataType = CustomFieldDataType
@ViewChild('nav') nav: NgbNav @ViewChild('nav') nav: NgbNav
@ViewChild('pdfPreview') set pdfPreview(element) { @ViewChild('pdfPreview') set pdfPreview(element) {
@ -409,7 +406,7 @@ export class DocumentDetailComponent
]) ])
} }
updateComponent(doc: PaperlessDocument) { updateComponent(doc: Document) {
this.document = doc this.document = doc
this.requiresPassword = false this.requiresPassword = false
// this.customFields = doc.custom_fields.concat([]) // this.customFields = doc.custom_fields.concat([])
@ -825,13 +822,13 @@ export class DocumentDetailComponent
) )
} }
notesUpdated(notes: PaperlessDocumentNote[]) { notesUpdated(notes: DocumentNote[]) {
this.document.notes = notes this.document.notes = notes
this.openDocumentService.refreshDocument(this.documentId) this.openDocumentService.refreshDocument(this.documentId)
} }
get userIsOwner(): boolean { get userIsOwner(): boolean {
let doc: PaperlessDocument = Object.assign({}, this.document) let doc: Document = Object.assign({}, this.document)
// dont disable while editing // dont disable while editing
if (this.document && this.store?.value.permissions_form?.owner) { if (this.document && this.store?.value.permissions_form?.owner) {
doc.owner = this.store?.value.permissions_form?.owner doc.owner = this.store?.value.permissions_form?.owner
@ -840,7 +837,7 @@ export class DocumentDetailComponent
} }
get userCanEdit(): boolean { get userCanEdit(): boolean {
let doc: PaperlessDocument = Object.assign({}, this.document) let doc: Document = Object.assign({}, this.document)
// dont disable while editing // dont disable while editing
if (this.document && this.store?.value.permissions_form?.owner) { if (this.document && this.store?.value.permissions_form?.owner) {
doc.owner = this.store?.value.permissions_form?.owner doc.owner = this.store?.value.permissions_form?.owner
@ -877,25 +874,25 @@ export class DocumentDetailComponent
// Correspondent // Correspondent
return { return {
rule_type: FILTER_CORRESPONDENT, rule_type: FILTER_CORRESPONDENT,
value: (i as PaperlessCorrespondent).id.toString(), value: (i as Correspondent).id.toString(),
} }
} else if (i.hasOwnProperty('path')) { } else if (i.hasOwnProperty('path')) {
// Storage Path // Storage Path
return { return {
rule_type: FILTER_STORAGE_PATH, rule_type: FILTER_STORAGE_PATH,
value: (i as PaperlessStoragePath).id.toString(), value: (i as StoragePath).id.toString(),
} }
} else if (i.hasOwnProperty('is_inbox_tag')) { } else if (i.hasOwnProperty('is_inbox_tag')) {
// Tag // Tag
return { return {
rule_type: FILTER_HAS_TAGS_ALL, rule_type: FILTER_HAS_TAGS_ALL,
value: (i as PaperlessTag).id.toString(), value: (i as Tag).id.toString(),
} }
} else { } else {
// Document Type, has no specific props // Document Type, has no specific props
return { return {
rule_type: FILTER_DOCUMENT_TYPE, rule_type: FILTER_DOCUMENT_TYPE,
value: (i as PaperlessDocumentType).id.toString(), value: (i as DocumentType).id.toString(),
} }
} }
}) })
@ -916,8 +913,8 @@ export class DocumentDetailComponent
} }
public getCustomFieldFromInstance( public getCustomFieldFromInstance(
instance: PaperlessCustomFieldInstance instance: CustomFieldInstance
): PaperlessCustomField { ): CustomField {
return this.customFields?.find((f) => f.id === instance.field) return this.customFields?.find((f) => f.id === instance.field)
} }
@ -941,7 +938,7 @@ export class DocumentDetailComponent
}) })
} }
public addField(field: PaperlessCustomField) { public addField(field: CustomField) {
this.document.custom_fields.push({ this.document.custom_fields.push({
field: field.id, field: field.id,
value: null, value: null,
@ -951,7 +948,7 @@ export class DocumentDetailComponent
this.updateFormForCustomFields(true) this.updateFormForCustomFields(true)
} }
public removeField(fieldInstance: PaperlessCustomFieldInstance) { public removeField(fieldInstance: CustomFieldInstance) {
this.document.custom_fields.splice( this.document.custom_fields.splice(
this.document.custom_fields.indexOf(fieldInstance), this.document.custom_fields.indexOf(fieldInstance),
1 1

View File

@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit } from '@angular/core' import { Component, OnDestroy, OnInit } from '@angular/core'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { TagService } from 'src/app/services/rest/tag.service' import { TagService } from 'src/app/services/rest/tag.service'
import { CorrespondentService } from 'src/app/services/rest/correspondent.service' import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
import { DocumentTypeService } from 'src/app/services/rest/document-type.service' import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
@ -23,8 +23,8 @@ import { SettingsService } from 'src/app/services/settings.service'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { saveAs } from 'file-saver' import { saveAs } from 'file-saver'
import { StoragePathService } from 'src/app/services/rest/storage-path.service' import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path' import { StoragePath } from 'src/app/data/storage-path'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component' import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component' import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component'
import { import {
@ -44,10 +44,10 @@ export class BulkEditorComponent
extends ComponentWithPermissions extends ComponentWithPermissions
implements OnInit, OnDestroy implements OnInit, OnDestroy
{ {
tags: PaperlessTag[] tags: Tag[]
correspondents: PaperlessCorrespondent[] correspondents: Correspondent[]
documentTypes: PaperlessDocumentType[] documentTypes: DocumentType[]
storagePaths: PaperlessStoragePath[] storagePaths: StoragePath[]
tagSelectionModel = new FilterableDropdownSelectionModel() tagSelectionModel = new FilterableDropdownSelectionModel()
correspondentSelectionModel = new FilterableDropdownSelectionModel() correspondentSelectionModel = new FilterableDropdownSelectionModel()

View File

@ -5,11 +5,11 @@ import {
Output, Output,
ViewChild, ViewChild,
} from '@angular/core' } from '@angular/core'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { DocumentService } from 'src/app/services/rest/document.service' import { DocumentService } from 'src/app/services/rest/document.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component' import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
@Component({ @Component({
@ -36,7 +36,7 @@ export class DocumentCardLargeComponent extends ComponentWithPermissions {
} }
@Input() @Input()
document: PaperlessDocument document: Document
@Output() @Output()
dblClickDocument = new EventEmitter() dblClickDocument = new EventEmitter()

View File

@ -20,7 +20,7 @@ import { DocumentCardSmallComponent } from './document-card-small.component'
import { of } from 'rxjs' import { of } from 'rxjs'
import { By } from '@angular/platform-browser' import { By } from '@angular/platform-browser'
import { TagComponent } from '../../common/tag/tag.component' import { TagComponent } from '../../common/tag/tag.component'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { IsNumberPipe } from 'src/app/pipes/is-number.pipe' import { IsNumberPipe } from 'src/app/pipes/is-number.pipe'
import { PreviewPopupComponent } from '../../common/preview-popup/preview-popup.component' import { PreviewPopupComponent } from '../../common/preview-popup/preview-popup.component'
@ -89,10 +89,7 @@ describe('DocumentCardSmallComponent', () => {
fixture.debugElement.queryAll(By.directive(TagComponent)) fixture.debugElement.queryAll(By.directive(TagComponent))
).toHaveLength(5) ).toHaveLength(5)
component.document.tags = [1, 2] component.document.tags = [1, 2]
component.document.tags$ = of([ component.document.tags$ = of([{ id: 1 } as Tag, { id: 2 } as Tag])
{ id: 1 } as PaperlessTag,
{ id: 2 } as PaperlessTag,
])
fixture.detectChanges() fixture.detectChanges()
expect( expect(
fixture.debugElement.queryAll(By.directive(TagComponent)) fixture.debugElement.queryAll(By.directive(TagComponent))

View File

@ -6,11 +6,11 @@ import {
ViewChild, ViewChild,
} from '@angular/core' } from '@angular/core'
import { map } from 'rxjs/operators' import { map } from 'rxjs/operators'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { DocumentService } from 'src/app/services/rest/document.service' import { DocumentService } from 'src/app/services/rest/document.service'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap' import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component' import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
@Component({ @Component({
@ -33,7 +33,7 @@ export class DocumentCardSmallComponent extends ComponentWithPermissions {
toggleSelected = new EventEmitter() toggleSelected = new EventEmitter()
@Input() @Input()
document: PaperlessDocument document: Document
@Output() @Output()
dblClickDocument = new EventEmitter() dblClickDocument = new EventEmitter()

View File

@ -34,7 +34,7 @@ import {
import { Subject, of, throwError } from 'rxjs' import { Subject, of, throwError } from 'rxjs'
import { SavedViewService } from 'src/app/services/rest/saved-view.service' import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import { ActivatedRoute, Router, convertToParamMap } from '@angular/router' import { ActivatedRoute, Router, convertToParamMap } from '@angular/router'
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' import { SavedView } from 'src/app/data/saved-view'
import { import {
FILTER_FULLTEXT_MORELIKE, FILTER_FULLTEXT_MORELIKE,
FILTER_FULLTEXT_QUERY, FILTER_FULLTEXT_QUERY,
@ -47,7 +47,7 @@ import { DocumentCardSmallComponent } from './document-card-small/document-card-
import { DocumentCardLargeComponent } from './document-card-large/document-card-large.component' import { DocumentCardLargeComponent } from './document-card-large/document-card-large.component'
import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe' import { DocumentTitlePipe } from 'src/app/pipes/document-title.pipe'
import { UsernamePipe } from 'src/app/pipes/username.pipe' import { UsernamePipe } from 'src/app/pipes/username.pipe'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { import {
DOCUMENT_SORT_FIELDS, DOCUMENT_SORT_FIELDS,
DOCUMENT_SORT_FIELDS_FULLTEXT, DOCUMENT_SORT_FIELDS_FULLTEXT,
@ -61,10 +61,10 @@ import { CheckComponent } from '../common/input/check/check.component'
import { HttpErrorResponse } from '@angular/common/http' import { HttpErrorResponse } from '@angular/common/http'
import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { PermissionsGuard } from 'src/app/guards/permissions.guard'
import { SettingsService } from 'src/app/services/settings.service' import { SettingsService } from 'src/app/services/settings.service'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { IsNumberPipe } from 'src/app/pipes/is-number.pipe' import { IsNumberPipe } from 'src/app/pipes/is-number.pipe'
const docs: PaperlessDocument[] = [ const docs: Document[] = [
{ {
id: 1, id: 1,
title: 'Doc1', title: 'Doc1',
@ -222,7 +222,7 @@ describe('DocumentListComponent', () => {
}) })
it('should load saved view from URL', () => { it('should load saved view from URL', () => {
const view: PaperlessSavedView = { const view: SavedView = {
id: 10, id: 10,
sort_field: 'added', sort_field: 'added',
sort_reverse: true, sort_reverse: true,
@ -264,7 +264,7 @@ describe('DocumentListComponent', () => {
}) })
it('should load saved view from query params', () => { it('should load saved view from query params', () => {
const view: PaperlessSavedView = { const view: SavedView = {
id: 10, id: 10,
sort_field: 'added', sort_field: 'added',
sort_reverse: true, sort_reverse: true,
@ -412,7 +412,7 @@ describe('DocumentListComponent', () => {
}) })
it('should support saving an edited view', () => { it('should support saving an edited view', () => {
const view: PaperlessSavedView = { const view: SavedView = {
id: 10, id: 10,
name: 'Saved View 10', name: 'Saved View 10',
sort_field: 'added', sort_field: 'added',
@ -448,7 +448,7 @@ describe('DocumentListComponent', () => {
}) })
it('should support edited view saving as', () => { it('should support edited view saving as', () => {
const view: PaperlessSavedView = { const view: SavedView = {
id: 10, id: 10,
name: 'Saved View 10', name: 'Saved View 10',
sort_field: 'added', sort_field: 'added',
@ -494,7 +494,7 @@ describe('DocumentListComponent', () => {
}) })
it('should handle error on edited view saving as', () => { it('should handle error on edited view saving as', () => {
const view: PaperlessSavedView = { const view: SavedView = {
id: 10, id: 10,
name: 'Saved View 10', name: 'Saved View 10',
sort_field: 'added', sort_field: 'added',

View File

@ -15,9 +15,9 @@ import {
isFullTextFilterRule, isFullTextFilterRule,
} from 'src/app/utils/filter-rules' } from 'src/app/utils/filter-rules'
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type' import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view' import { SavedView } from 'src/app/data/saved-view'
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings' import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
import { import {
SortableDirective, SortableDirective,
SortEvent, SortEvent,
@ -67,7 +67,7 @@ export class DocumentListComponent
displayMode = 'smallCards' // largeCards, smallCards, details displayMode = 'smallCards' // largeCards, smallCards, details
unmodifiedFilterRules: FilterRule[] = [] unmodifiedFilterRules: FilterRule[] = []
private unmodifiedSavedView: PaperlessSavedView private unmodifiedSavedView: SavedView
private unsubscribeNotifier: Subject<any> = new Subject() private unsubscribeNotifier: Subject<any> = new Subject()
@ -192,7 +192,7 @@ export class DocumentListComponent
saveViewConfig() { saveViewConfig() {
if (this.list.activeSavedViewId != null) { if (this.list.activeSavedViewId != null) {
let savedView: PaperlessSavedView = { let savedView: SavedView = {
id: this.list.activeSavedViewId, id: this.list.activeSavedViewId,
filter_rules: this.list.filterRules, filter_rules: this.list.filterRules,
sort_field: this.list.sortField, sort_field: this.list.sortField,
@ -229,7 +229,7 @@ export class DocumentListComponent
modal.componentInstance.defaultName = this.filterEditor.generateFilterName() modal.componentInstance.defaultName = this.filterEditor.generateFilterName()
modal.componentInstance.saveClicked.pipe(first()).subscribe((formValue) => { modal.componentInstance.saveClicked.pipe(first()).subscribe((formValue) => {
modal.componentInstance.buttonsEnabled = false modal.componentInstance.buttonsEnabled = false
let savedView: PaperlessSavedView = { let savedView: SavedView = {
name: formValue.name, name: formValue.name,
show_on_dashboard: formValue.showOnDashboard, show_on_dashboard: formValue.showOnDashboard,
show_in_sidebar: formValue.showInSideBar, show_in_sidebar: formValue.showInSideBar,
@ -260,11 +260,11 @@ export class DocumentListComponent
}) })
} }
openDocumentDetail(document: PaperlessDocument) { openDocumentDetail(document: Document) {
this.router.navigate(['documents', document.id]) this.router.navigate(['documents', document.id])
} }
toggleSelected(document: PaperlessDocument, event: MouseEvent): void { toggleSelected(document: Document, event: MouseEvent): void {
if (!event.shiftKey) this.list.toggleSelected(document) if (!event.shiftKey) this.list.toggleSelected(document)
else this.list.selectRangeTo(document) else this.list.selectRangeTo(document)
} }
@ -295,7 +295,7 @@ export class DocumentListComponent
]) ])
} }
trackByDocumentId(index, item: PaperlessDocument) { trackByDocumentId(index, item: Document) {
return item.id return item.id
} }

View File

@ -49,11 +49,11 @@ import {
FILTER_CUSTOM_FIELDS, FILTER_CUSTOM_FIELDS,
FILTER_SHARED_BY_USER, FILTER_SHARED_BY_USER,
} from 'src/app/data/filter-rule-type' } from 'src/app/data/filter-rule-type'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path' import { StoragePath } from 'src/app/data/storage-path'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
import { FilterPipe } from 'src/app/pipes/filter.pipe' import { FilterPipe } from 'src/app/pipes/filter.pipe'
@ -78,7 +78,7 @@ import {
} from '../../common/permissions-filter-dropdown/permissions-filter-dropdown.component' } from '../../common/permissions-filter-dropdown/permissions-filter-dropdown.component'
import { FilterEditorComponent } from './filter-editor.component' import { FilterEditorComponent } from './filter-editor.component'
const tags: PaperlessTag[] = [ const tags: Tag[] = [
{ {
id: 2, id: 2,
name: 'Tag2', name: 'Tag2',
@ -89,7 +89,7 @@ const tags: PaperlessTag[] = [
}, },
] ]
const correspondents: PaperlessCorrespondent[] = [ const correspondents: Correspondent[] = [
{ {
id: 12, id: 12,
name: 'Corresp12', name: 'Corresp12',
@ -100,7 +100,7 @@ const correspondents: PaperlessCorrespondent[] = [
}, },
] ]
const document_types: PaperlessDocumentType[] = [ const document_types: DocumentType[] = [
{ {
id: 22, id: 22,
name: 'DocType22', name: 'DocType22',
@ -111,7 +111,7 @@ const document_types: PaperlessDocumentType[] = [
}, },
] ]
const storage_paths: PaperlessStoragePath[] = [ const storage_paths: StoragePath[] = [
{ {
id: 32, id: 32,
name: 'StoragePath32', name: 'StoragePath32',
@ -122,7 +122,7 @@ const storage_paths: PaperlessStoragePath[] = [
}, },
] ]
const users: PaperlessUser[] = [ const users: User[] = [
{ {
id: 1, id: 1,
username: 'user1', username: 'user1',

View File

@ -8,9 +8,9 @@ import {
ViewChild, ViewChild,
ElementRef, ElementRef,
} from '@angular/core' } from '@angular/core'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { Subject, Subscription } from 'rxjs' import { Subject, Subscription } from 'rxjs'
import { debounceTime, distinctUntilChanged, filter } from 'rxjs/operators' import { debounceTime, distinctUntilChanged, filter } from 'rxjs/operators'
import { DocumentTypeService } from 'src/app/services/rest/document-type.service' import { DocumentTypeService } from 'src/app/services/rest/document-type.service'
@ -62,8 +62,8 @@ import {
SelectionData, SelectionData,
SelectionDataItem, SelectionDataItem,
} from 'src/app/services/rest/document.service' } from 'src/app/services/rest/document.service'
import { PaperlessDocument } from 'src/app/data/paperless-document' import { Document } from 'src/app/data/document'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path' import { StoragePath } from 'src/app/data/storage-path'
import { StoragePathService } from 'src/app/services/rest/storage-path.service' import { StoragePathService } from 'src/app/services/rest/storage-path.service'
import { RelativeDate } from '../../common/date-dropdown/date-dropdown.component' import { RelativeDate } from '../../common/date-dropdown/date-dropdown.component'
import { import {
@ -230,10 +230,10 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
@ViewChild('textFilterInput') @ViewChild('textFilterInput')
textFilterInput: ElementRef textFilterInput: ElementRef
tags: PaperlessTag[] = [] tags: Tag[] = []
correspondents: PaperlessCorrespondent[] = [] correspondents: Correspondent[] = []
documentTypes: PaperlessDocumentType[] = [] documentTypes: DocumentType[] = []
storagePaths: PaperlessStoragePath[] = [] storagePaths: StoragePath[] = []
tagDocumentCounts: SelectionDataItem[] tagDocumentCounts: SelectionDataItem[]
correspondentDocumentCounts: SelectionDataItem[] correspondentDocumentCounts: SelectionDataItem[]
@ -242,7 +242,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
_textFilter = '' _textFilter = ''
_moreLikeId: number _moreLikeId: number
_moreLikeDoc: PaperlessDocument _moreLikeDoc: Document
get textFilterTargets() { get textFilterTargets() {
if (this.textFilterTarget == TEXT_FILTER_TARGET_FULLTEXT_MORELIKE) { if (this.textFilterTarget == TEXT_FILTER_TARGET_FULLTEXT_MORELIKE) {

View File

@ -5,7 +5,7 @@ import { UserService } from 'src/app/services/rest/user.service'
import { of, throwError } from 'rxjs' import { of, throwError } from 'rxjs'
import { DocumentNotesService } from 'src/app/services/rest/document-notes.service' import { DocumentNotesService } from 'src/app/services/rest/document-notes.service'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { PaperlessDocumentNote } from 'src/app/data/paperless-document-note' import { DocumentNote } from 'src/app/data/document-note'
import { HttpClientTestingModule } from '@angular/common/http/testing' import { HttpClientTestingModule } from '@angular/common/http/testing'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
@ -14,7 +14,7 @@ import { By } from '@angular/platform-browser'
import { PermissionsService } from 'src/app/services/permissions.service' import { PermissionsService } from 'src/app/services/permissions.service'
import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { FormsModule, ReactiveFormsModule } from '@angular/forms'
const notes: PaperlessDocumentNote[] = [ const notes: DocumentNote[] = [
{ {
id: 23, id: 23,
note: 'Note 23', note: 'Note 23',

View File

@ -1,11 +1,11 @@
import { Component, Input, Output, EventEmitter } from '@angular/core' import { Component, Input, Output, EventEmitter } from '@angular/core'
import { DocumentNotesService } from 'src/app/services/rest/document-notes.service' import { DocumentNotesService } from 'src/app/services/rest/document-notes.service'
import { PaperlessDocumentNote } from 'src/app/data/paperless-document-note' import { DocumentNote } from 'src/app/data/document-note'
import { FormControl, FormGroup } from '@angular/forms' import { FormControl, FormGroup } from '@angular/forms'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { ComponentWithPermissions } from '../with-permissions/with-permissions.component' import { ComponentWithPermissions } from '../with-permissions/with-permissions.component'
import { UserService } from 'src/app/services/rest/user.service' import { UserService } from 'src/app/services/rest/user.service'
import { PaperlessUser } from 'src/app/data/paperless-user' import { User } from 'src/app/data/user'
@Component({ @Component({
selector: 'pngx-document-notes', selector: 'pngx-document-notes',
@ -24,14 +24,14 @@ export class DocumentNotesComponent extends ComponentWithPermissions {
documentId: number documentId: number
@Input() @Input()
notes: PaperlessDocumentNote[] = [] notes: DocumentNote[] = []
@Input() @Input()
addDisabled: boolean = false addDisabled: boolean = false
@Output() @Output()
updated: EventEmitter<PaperlessDocumentNote[]> = new EventEmitter() updated: EventEmitter<DocumentNote[]> = new EventEmitter()
users: PaperlessUser[] users: User[]
constructor( constructor(
private notesService: DocumentNotesService, private notesService: DocumentNotesService,
@ -82,7 +82,7 @@ export class DocumentNotesComponent extends ComponentWithPermissions {
}) })
} }
displayName(note: PaperlessDocumentNote): string { displayName(note: DocumentNote): string {
if (!note.user) return '' if (!note.user) return ''
const user = this.users?.find((u) => u.id === note.user) const user = this.users?.find((u) => u.id === note.user)
if (!user) return '' if (!user) return ''

View File

@ -11,8 +11,8 @@ import {
import { of, throwError } from 'rxjs' import { of, throwError } from 'rxjs'
import { import {
DocumentSource, DocumentSource,
PaperlessConsumptionTemplate, ConsumptionTemplate,
} from 'src/app/data/paperless-consumption-template' } from 'src/app/data/consumption-template'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { ConsumptionTemplateService } from 'src/app/services/rest/consumption-template.service' import { ConsumptionTemplateService } from 'src/app/services/rest/consumption-template.service'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
@ -22,7 +22,7 @@ import { ConsumptionTemplatesComponent } from './consumption-templates.component
import { ConsumptionTemplateEditDialogComponent } from '../../common/edit-dialog/consumption-template-edit-dialog/consumption-template-edit-dialog.component' import { ConsumptionTemplateEditDialogComponent } from '../../common/edit-dialog/consumption-template-edit-dialog/consumption-template-edit-dialog.component'
import { PermissionsService } from 'src/app/services/permissions.service' import { PermissionsService } from 'src/app/services/permissions.service'
const templates: PaperlessConsumptionTemplate[] = [ const templates: ConsumptionTemplate[] = [
{ {
id: 0, id: 0,
name: 'Template 1', name: 'Template 1',

View File

@ -2,7 +2,7 @@ import { Component, OnInit } from '@angular/core'
import { ConsumptionTemplateService } from 'src/app/services/rest/consumption-template.service' import { ConsumptionTemplateService } from 'src/app/services/rest/consumption-template.service'
import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component' import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component'
import { Subject, takeUntil } from 'rxjs' import { Subject, takeUntil } from 'rxjs'
import { PaperlessConsumptionTemplate } from 'src/app/data/paperless-consumption-template' import { ConsumptionTemplate } from 'src/app/data/consumption-template'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
import { PermissionsService } from 'src/app/services/permissions.service' import { PermissionsService } from 'src/app/services/permissions.service'
@ -22,7 +22,7 @@ export class ConsumptionTemplatesComponent
extends ComponentWithPermissions extends ComponentWithPermissions
implements OnInit implements OnInit
{ {
public templates: PaperlessConsumptionTemplate[] = [] public templates: ConsumptionTemplate[] = []
private unsubscribeNotifier: Subject<any> = new Subject() private unsubscribeNotifier: Subject<any> = new Subject()
@ -48,13 +48,13 @@ export class ConsumptionTemplatesComponent
}) })
} }
getSourceList(template: PaperlessConsumptionTemplate): string { getSourceList(template: ConsumptionTemplate): string {
return template.sources return template.sources
.map((id) => DOCUMENT_SOURCE_OPTIONS.find((s) => s.id === id).name) .map((id) => DOCUMENT_SOURCE_OPTIONS.find((s) => s.id === id).name)
.join(', ') .join(', ')
} }
editTemplate(rule: PaperlessConsumptionTemplate) { editTemplate(rule: ConsumptionTemplate) {
const modal = this.modalService.open( const modal = this.modalService.open(
ConsumptionTemplateEditDialogComponent, ConsumptionTemplateEditDialogComponent,
{ {
@ -82,7 +82,7 @@ export class ConsumptionTemplatesComponent
}) })
} }
deleteTemplate(rule: PaperlessConsumptionTemplate) { deleteTemplate(rule: ConsumptionTemplate) {
const modal = this.modalService.open(ConfirmDialogComponent, { const modal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })

View File

@ -1,7 +1,7 @@
import { Component } from '@angular/core' import { Component } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { FILTER_HAS_CORRESPONDENT_ANY } from 'src/app/data/filter-rule-type' import { FILTER_HAS_CORRESPONDENT_ANY } from 'src/app/data/filter-rule-type'
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent' import { Correspondent } from 'src/app/data/correspondent'
import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe' import { CustomDatePipe } from 'src/app/pipes/custom-date.pipe'
import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { import {
@ -19,7 +19,7 @@ import { ManagementListComponent } from '../management-list/management-list.comp
styleUrls: ['./../management-list/management-list.component.scss'], styleUrls: ['./../management-list/management-list.component.scss'],
providers: [{ provide: CustomDatePipe }], providers: [{ provide: CustomDatePipe }],
}) })
export class CorrespondentListComponent extends ManagementListComponent<PaperlessCorrespondent> { export class CorrespondentListComponent extends ManagementListComponent<Correspondent> {
constructor( constructor(
correspondentsService: CorrespondentService, correspondentsService: CorrespondentService,
modalService: NgbModal, modalService: NgbModal,
@ -43,7 +43,7 @@ export class CorrespondentListComponent extends ManagementListComponent<Paperles
{ {
key: 'last_correspondence', key: 'last_correspondence',
name: $localize`Last used`, name: $localize`Last used`,
valueFn: (c: PaperlessCorrespondent) => { valueFn: (c: Correspondent) => {
if (c.last_correspondence) { if (c.last_correspondence) {
let date = new Date(c.last_correspondence) let date = new Date(c.last_correspondence)
if (date.toString() == 'Invalid Date') { if (date.toString() == 'Invalid Date') {
@ -63,7 +63,7 @@ export class CorrespondentListComponent extends ManagementListComponent<Paperles
) )
} }
getDeleteMessage(object: PaperlessCorrespondent) { getDeleteMessage(object: Correspondent) {
return $localize`Do you really want to delete the correspondent "${object.name}"?` return $localize`Do you really want to delete the correspondent "${object.name}"?`
} }
} }

View File

@ -1,10 +1,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing' import { ComponentFixture, TestBed } from '@angular/core/testing'
import { CustomFieldsComponent } from './custom-fields.component' import { CustomFieldsComponent } from './custom-fields.component'
import { import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
PaperlessCustomField,
PaperlessCustomFieldDataType,
} from 'src/app/data/paperless-custom-field'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { HttpClientTestingModule } from '@angular/common/http/testing' import { HttpClientTestingModule } from '@angular/common/http/testing'
import { FormsModule, ReactiveFormsModule } from '@angular/forms' import { FormsModule, ReactiveFormsModule } from '@angular/forms'
@ -23,16 +20,16 @@ import { ConfirmDialogComponent } from '../../common/confirm-dialog/confirm-dial
import { PageHeaderComponent } from '../../common/page-header/page-header.component' import { PageHeaderComponent } from '../../common/page-header/page-header.component'
import { CustomFieldEditDialogComponent } from '../../common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component' import { CustomFieldEditDialogComponent } from '../../common/edit-dialog/custom-field-edit-dialog/custom-field-edit-dialog.component'
const fields: PaperlessCustomField[] = [ const fields: CustomField[] = [
{ {
id: 0, id: 0,
name: 'Field 1', name: 'Field 1',
data_type: PaperlessCustomFieldDataType.String, data_type: CustomFieldDataType.String,
}, },
{ {
id: 1, id: 1,
name: 'Field 2', name: 'Field 2',
data_type: PaperlessCustomFieldDataType.Integer, data_type: CustomFieldDataType.Integer,
}, },
] ]

View File

@ -1,10 +1,7 @@
import { Component, OnInit } from '@angular/core' import { Component, OnInit } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { Subject, takeUntil } from 'rxjs' import { Subject, takeUntil } from 'rxjs'
import { import { DATA_TYPE_LABELS, CustomField } from 'src/app/data/custom-field'
DATA_TYPE_LABELS,
PaperlessCustomField,
} from 'src/app/data/paperless-custom-field'
import { PermissionsService } from 'src/app/services/permissions.service' import { PermissionsService } from 'src/app/services/permissions.service'
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service' import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
import { ToastService } from 'src/app/services/toast.service' import { ToastService } from 'src/app/services/toast.service'
@ -22,7 +19,7 @@ export class CustomFieldsComponent
extends ComponentWithPermissions extends ComponentWithPermissions
implements OnInit implements OnInit
{ {
public fields: PaperlessCustomField[] = [] public fields: CustomField[] = []
private unsubscribeNotifier: Subject<any> = new Subject() private unsubscribeNotifier: Subject<any> = new Subject()
constructor( constructor(
@ -47,7 +44,7 @@ export class CustomFieldsComponent
}) })
} }
editField(field: PaperlessCustomField) { editField(field: CustomField) {
const modal = this.modalService.open(CustomFieldEditDialogComponent) const modal = this.modalService.open(CustomFieldEditDialogComponent)
modal.componentInstance.dialogMode = field modal.componentInstance.dialogMode = field
? EditDialogMode.EDIT ? EditDialogMode.EDIT
@ -67,7 +64,7 @@ export class CustomFieldsComponent
}) })
} }
deleteField(field: PaperlessCustomField) { deleteField(field: CustomField) {
const modal = this.modalService.open(ConfirmDialogComponent, { const modal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
@ -92,7 +89,7 @@ export class CustomFieldsComponent
}) })
} }
getDataType(field: PaperlessCustomField): string { getDataType(field: CustomField): string {
return DATA_TYPE_LABELS.find((l) => l.id === field.data_type).name return DATA_TYPE_LABELS.find((l) => l.id === field.data_type).name
} }
} }

View File

@ -1,7 +1,7 @@
import { Component } from '@angular/core' import { Component } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { FILTER_HAS_DOCUMENT_TYPE_ANY } from 'src/app/data/filter-rule-type' import { FILTER_HAS_DOCUMENT_TYPE_ANY } from 'src/app/data/filter-rule-type'
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type' import { DocumentType } from 'src/app/data/document-type'
import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { import {
PermissionsService, PermissionsService,
@ -17,7 +17,7 @@ import { ManagementListComponent } from '../management-list/management-list.comp
templateUrl: './../management-list/management-list.component.html', templateUrl: './../management-list/management-list.component.html',
styleUrls: ['./../management-list/management-list.component.scss'], styleUrls: ['./../management-list/management-list.component.scss'],
}) })
export class DocumentTypeListComponent extends ManagementListComponent<PaperlessDocumentType> { export class DocumentTypeListComponent extends ManagementListComponent<DocumentType> {
constructor( constructor(
documentTypeService: DocumentTypeService, documentTypeService: DocumentTypeService,
modalService: NgbModal, modalService: NgbModal,
@ -40,7 +40,7 @@ export class DocumentTypeListComponent extends ManagementListComponent<Paperless
) )
} }
getDeleteMessage(object: PaperlessDocumentType) { getDeleteMessage(object: DocumentType) {
return $localize`Do you really want to delete the document type "${object.name}"?` return $localize`Do you really want to delete the document type "${object.name}"?`
} }
} }

View File

@ -13,8 +13,8 @@ import {
import { NgSelectModule } from '@ng-select/ng-select' import { NgSelectModule } from '@ng-select/ng-select'
import { of, throwError } from 'rxjs' import { of, throwError } from 'rxjs'
import { routes } from 'src/app/app-routing.module' import { routes } from 'src/app/app-routing.module'
import { PaperlessMailAccount } from 'src/app/data/paperless-mail-account' import { MailAccount } from 'src/app/data/mail-account'
import { PaperlessMailRule } from 'src/app/data/paperless-mail-rule' import { MailRule } from 'src/app/data/mail-rule'
import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { PermissionsGuard } from 'src/app/guards/permissions.guard' import { PermissionsGuard } from 'src/app/guards/permissions.guard'
@ -118,7 +118,7 @@ describe('MailComponent', () => {
of({ of({
all: mailAccounts.map((a) => a.id), all: mailAccounts.map((a) => a.id),
count: mailAccounts.length, count: mailAccounts.length,
results: (mailAccounts as PaperlessMailAccount[]).concat([]), results: (mailAccounts as MailAccount[]).concat([]),
}) })
) )
} }
@ -127,7 +127,7 @@ describe('MailComponent', () => {
of({ of({
all: mailRules.map((r) => r.id), all: mailRules.map((r) => r.id),
count: mailRules.length, count: mailRules.length,
results: (mailRules as PaperlessMailRule[]).concat([]), results: (mailRules as MailRule[]).concat([]),
}) })
) )
} }
@ -163,7 +163,7 @@ describe('MailComponent', () => {
completeSetup() completeSetup()
let modal: NgbModalRef let modal: NgbModalRef
modalService.activeInstances.subscribe((refs) => (modal = refs[0])) modalService.activeInstances.subscribe((refs) => (modal = refs[0]))
component.editMailAccount(mailAccounts[0] as PaperlessMailAccount) component.editMailAccount(mailAccounts[0] as MailAccount)
let editDialog = modal.componentInstance as MailAccountEditDialogComponent let editDialog = modal.componentInstance as MailAccountEditDialogComponent
const toastErrorSpy = jest.spyOn(toastService, 'showError') const toastErrorSpy = jest.spyOn(toastService, 'showError')
const toastInfoSpy = jest.spyOn(toastService, 'showInfo') const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
@ -181,7 +181,7 @@ describe('MailComponent', () => {
completeSetup() completeSetup()
let modal: NgbModalRef let modal: NgbModalRef
modalService.activeInstances.subscribe((refs) => (modal = refs[0])) modalService.activeInstances.subscribe((refs) => (modal = refs[0]))
component.deleteMailAccount(mailAccounts[0] as PaperlessMailAccount) component.deleteMailAccount(mailAccounts[0] as MailAccount)
const deleteDialog = modal.componentInstance as ConfirmDialogComponent const deleteDialog = modal.componentInstance as ConfirmDialogComponent
const deleteSpy = jest.spyOn(mailAccountService, 'delete') const deleteSpy = jest.spyOn(mailAccountService, 'delete')
const toastErrorSpy = jest.spyOn(toastService, 'showError') const toastErrorSpy = jest.spyOn(toastService, 'showError')
@ -202,7 +202,7 @@ describe('MailComponent', () => {
completeSetup() completeSetup()
let modal: NgbModalRef let modal: NgbModalRef
modalService.activeInstances.subscribe((refs) => (modal = refs[0])) modalService.activeInstances.subscribe((refs) => (modal = refs[0]))
component.editMailRule(mailRules[0] as PaperlessMailRule) component.editMailRule(mailRules[0] as MailRule)
const editDialog = modal.componentInstance as MailRuleEditDialogComponent const editDialog = modal.componentInstance as MailRuleEditDialogComponent
const toastErrorSpy = jest.spyOn(toastService, 'showError') const toastErrorSpy = jest.spyOn(toastService, 'showError')
const toastInfoSpy = jest.spyOn(toastService, 'showInfo') const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
@ -220,7 +220,7 @@ describe('MailComponent', () => {
completeSetup() completeSetup()
let modal: NgbModalRef let modal: NgbModalRef
modalService.activeInstances.subscribe((refs) => (modal = refs[0])) modalService.activeInstances.subscribe((refs) => (modal = refs[0]))
component.deleteMailRule(mailRules[0] as PaperlessMailRule) component.deleteMailRule(mailRules[0] as MailRule)
const deleteDialog = modal.componentInstance as ConfirmDialogComponent const deleteDialog = modal.componentInstance as ConfirmDialogComponent
const deleteSpy = jest.spyOn(mailRuleService, 'delete') const deleteSpy = jest.spyOn(mailRuleService, 'delete')
const toastErrorSpy = jest.spyOn(toastService, 'showError') const toastErrorSpy = jest.spyOn(toastService, 'showError')
@ -257,7 +257,7 @@ describe('MailComponent', () => {
const toastErrorSpy = jest.spyOn(toastService, 'showError') const toastErrorSpy = jest.spyOn(toastService, 'showError')
const toastInfoSpy = jest.spyOn(toastService, 'showInfo') const toastInfoSpy = jest.spyOn(toastService, 'showInfo')
const rulePatchSpy = jest.spyOn(mailRuleService, 'patch') const rulePatchSpy = jest.spyOn(mailRuleService, 'patch')
component.editPermissions(mailRules[0] as PaperlessMailRule) component.editPermissions(mailRules[0] as MailRule)
expect(modal).not.toBeUndefined() expect(modal).not.toBeUndefined()
let dialog = modal.componentInstance as PermissionsDialogComponent let dialog = modal.componentInstance as PermissionsDialogComponent
expect(dialog.object).toEqual(mailRules[0]) expect(dialog.object).toEqual(mailRules[0])
@ -268,7 +268,7 @@ describe('MailComponent', () => {
dialog.confirmClicked.emit(perms) dialog.confirmClicked.emit(perms)
expect(rulePatchSpy).toHaveBeenCalled() expect(rulePatchSpy).toHaveBeenCalled()
expect(toastErrorSpy).toHaveBeenCalled() expect(toastErrorSpy).toHaveBeenCalled()
rulePatchSpy.mockReturnValueOnce(of(mailRules[0] as PaperlessMailRule)) rulePatchSpy.mockReturnValueOnce(of(mailRules[0] as MailRule))
dialog.confirmClicked.emit(perms) dialog.confirmClicked.emit(perms)
expect(toastInfoSpy).toHaveBeenCalledWith('Permissions updated') expect(toastInfoSpy).toHaveBeenCalledWith('Permissions updated')
@ -293,7 +293,7 @@ describe('MailComponent', () => {
let modal: NgbModalRef let modal: NgbModalRef
modalService.activeInstances.subscribe((refs) => (modal = refs[0])) modalService.activeInstances.subscribe((refs) => (modal = refs[0]))
const accountPatchSpy = jest.spyOn(mailAccountService, 'patch') const accountPatchSpy = jest.spyOn(mailAccountService, 'patch')
component.editPermissions(mailAccounts[0] as PaperlessMailAccount) component.editPermissions(mailAccounts[0] as MailAccount)
expect(modal).not.toBeUndefined() expect(modal).not.toBeUndefined()
let dialog = modal.componentInstance as PermissionsDialogComponent let dialog = modal.componentInstance as PermissionsDialogComponent
expect(dialog.object).toEqual(mailAccounts[0]) expect(dialog.object).toEqual(mailAccounts[0])

View File

@ -2,8 +2,8 @@ import { Component, OnInit, OnDestroy } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { Subject, first, takeUntil } from 'rxjs' import { Subject, first, takeUntil } from 'rxjs'
import { ObjectWithPermissions } from 'src/app/data/object-with-permissions' import { ObjectWithPermissions } from 'src/app/data/object-with-permissions'
import { PaperlessMailAccount } from 'src/app/data/paperless-mail-account' import { MailAccount } from 'src/app/data/mail-account'
import { PaperlessMailRule } from 'src/app/data/paperless-mail-rule' import { MailRule } from 'src/app/data/mail-rule'
import { import {
PermissionsService, PermissionsService,
PermissionAction, PermissionAction,
@ -28,8 +28,8 @@ export class MailComponent
extends ComponentWithPermissions extends ComponentWithPermissions
implements OnInit, OnDestroy implements OnInit, OnDestroy
{ {
mailAccounts: PaperlessMailAccount[] = [] mailAccounts: MailAccount[] = []
mailRules: PaperlessMailRule[] = [] mailRules: MailRule[] = []
unsubscribeNotifier: Subject<any> = new Subject() unsubscribeNotifier: Subject<any> = new Subject()
@ -76,7 +76,7 @@ export class MailComponent
this.unsubscribeNotifier.next(true) this.unsubscribeNotifier.next(true)
} }
editMailAccount(account: PaperlessMailAccount = null) { editMailAccount(account: MailAccount = null) {
const modal = this.modalService.open(MailAccountEditDialogComponent, { const modal = this.modalService.open(MailAccountEditDialogComponent, {
backdrop: 'static', backdrop: 'static',
size: 'xl', size: 'xl',
@ -105,7 +105,7 @@ export class MailComponent
}) })
} }
deleteMailAccount(account: PaperlessMailAccount) { deleteMailAccount(account: MailAccount) {
const modal = this.modalService.open(ConfirmDialogComponent, { const modal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
@ -137,7 +137,7 @@ export class MailComponent
}) })
} }
editMailRule(rule: PaperlessMailRule = null) { editMailRule(rule: MailRule = null) {
const modal = this.modalService.open(MailRuleEditDialogComponent, { const modal = this.modalService.open(MailRuleEditDialogComponent, {
backdrop: 'static', backdrop: 'static',
size: 'xl', size: 'xl',
@ -164,7 +164,7 @@ export class MailComponent
}) })
} }
deleteMailRule(rule: PaperlessMailRule) { deleteMailRule(rule: MailRule) {
const modal = this.modalService.open(ConfirmDialogComponent, { const modal = this.modalService.open(ConfirmDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
@ -193,7 +193,7 @@ export class MailComponent
}) })
} }
editPermissions(object: PaperlessMailRule | PaperlessMailAccount) { editPermissions(object: MailRule | MailAccount) {
const modal = this.modalService.open(PermissionsDialogComponent, { const modal = this.modalService.open(PermissionsDialogComponent, {
backdrop: 'static', backdrop: 'static',
}) })
@ -202,9 +202,8 @@ export class MailComponent
dialog.object = object dialog.object = object
modal.componentInstance.confirmClicked.subscribe((permissions) => { modal.componentInstance.confirmClicked.subscribe((permissions) => {
modal.componentInstance.buttonsEnabled = false modal.componentInstance.buttonsEnabled = false
const service: AbstractPaperlessService< const service: AbstractPaperlessService<MailRule | MailAccount> =
PaperlessMailRule | PaperlessMailAccount 'account' in object ? this.mailRuleService : this.mailAccountService
> = 'account' in object ? this.mailRuleService : this.mailAccountService
object.owner = permissions['owner'] object.owner = permissions['owner']
object['set_permissions'] = permissions['set_permissions'] object['set_permissions'] = permissions['set_permissions']
service.patch(object).subscribe({ service.patch(object).subscribe({

View File

@ -15,7 +15,7 @@ import {
NgbPaginationModule, NgbPaginationModule,
} from '@ng-bootstrap/ng-bootstrap' } from '@ng-bootstrap/ng-bootstrap'
import { of, throwError } from 'rxjs' import { of, throwError } from 'rxjs'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive' import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
import { SortableDirective } from 'src/app/directives/sortable.directive' import { SortableDirective } from 'src/app/directives/sortable.directive'
import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe' import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe'
@ -37,7 +37,7 @@ import { MATCH_NONE } from 'src/app/data/matching-model'
import { MATCH_LITERAL } from 'src/app/data/matching-model' import { MATCH_LITERAL } from 'src/app/data/matching-model'
import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component' import { PermissionsDialogComponent } from '../../common/permissions-dialog/permissions-dialog.component'
const tags: PaperlessTag[] = [ const tags: Tag[] = [
{ {
id: 1, id: 1,
name: 'Tag1 Foo', name: 'Tag1 Foo',
@ -57,8 +57,8 @@ const tags: PaperlessTag[] = [
] ]
describe('ManagementListComponent', () => { describe('ManagementListComponent', () => {
let component: ManagementListComponent<PaperlessTag> let component: ManagementListComponent<Tag>
let fixture: ComponentFixture<ManagementListComponent<PaperlessTag>> let fixture: ComponentFixture<ManagementListComponent<Tag>>
let tagService: TagService let tagService: TagService
let modalService: NgbModal let modalService: NgbModal
let toastService: ToastService let toastService: ToastService
@ -151,8 +151,7 @@ describe('ManagementListComponent', () => {
createButton.triggerEventHandler('click') createButton.triggerEventHandler('click')
expect(modal).not.toBeUndefined() expect(modal).not.toBeUndefined()
const editDialog = const editDialog = modal.componentInstance as EditDialogComponent<Tag>
modal.componentInstance as EditDialogComponent<PaperlessTag>
// fail first // fail first
editDialog.failed.emit({ error: 'error creating item' }) editDialog.failed.emit({ error: 'error creating item' })
@ -176,8 +175,7 @@ describe('ManagementListComponent', () => {
editButton.triggerEventHandler('click') editButton.triggerEventHandler('click')
expect(modal).not.toBeUndefined() expect(modal).not.toBeUndefined()
const editDialog = const editDialog = modal.componentInstance as EditDialogComponent<Tag>
modal.componentInstance as EditDialogComponent<PaperlessTag>
expect(editDialog.object).toEqual(tags[0]) expect(editDialog.object).toEqual(tags[0])
// fail first // fail first

View File

@ -1,7 +1,7 @@
import { Component } from '@angular/core' import { Component } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { FILTER_HAS_STORAGE_PATH_ANY } from 'src/app/data/filter-rule-type' import { FILTER_HAS_STORAGE_PATH_ANY } from 'src/app/data/filter-rule-type'
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path' import { StoragePath } from 'src/app/data/storage-path'
import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { import {
PermissionsService, PermissionsService,
@ -17,7 +17,7 @@ import { ManagementListComponent } from '../management-list/management-list.comp
templateUrl: './../management-list/management-list.component.html', templateUrl: './../management-list/management-list.component.html',
styleUrls: ['./../management-list/management-list.component.scss'], styleUrls: ['./../management-list/management-list.component.scss'],
}) })
export class StoragePathListComponent extends ManagementListComponent<PaperlessStoragePath> { export class StoragePathListComponent extends ManagementListComponent<StoragePath> {
constructor( constructor(
directoryService: StoragePathService, directoryService: StoragePathService,
modalService: NgbModal, modalService: NgbModal,
@ -40,7 +40,7 @@ export class StoragePathListComponent extends ManagementListComponent<PaperlessS
{ {
key: 'path', key: 'path',
name: $localize`Path`, name: $localize`Path`,
valueFn: (c: PaperlessStoragePath) => { valueFn: (c: StoragePath) => {
return c.path return c.path
}, },
}, },
@ -48,7 +48,7 @@ export class StoragePathListComponent extends ManagementListComponent<PaperlessS
) )
} }
getDeleteMessage(object: PaperlessStoragePath) { getDeleteMessage(object: StoragePath) {
return $localize`Do you really want to delete the storage path "${object.name}"?` return $localize`Do you really want to delete the storage path "${object.name}"?`
} }
} }

View File

@ -1,7 +1,7 @@
import { Component } from '@angular/core' import { Component } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { FILTER_HAS_TAGS_ALL } from 'src/app/data/filter-rule-type' import { FILTER_HAS_TAGS_ALL } from 'src/app/data/filter-rule-type'
import { PaperlessTag } from 'src/app/data/paperless-tag' import { Tag } from 'src/app/data/tag'
import { DocumentListViewService } from 'src/app/services/document-list-view.service' import { DocumentListViewService } from 'src/app/services/document-list-view.service'
import { import {
PermissionsService, PermissionsService,
@ -17,7 +17,7 @@ import { ManagementListComponent } from '../management-list/management-list.comp
templateUrl: './../management-list/management-list.component.html', templateUrl: './../management-list/management-list.component.html',
styleUrls: ['./../management-list/management-list.component.scss'], styleUrls: ['./../management-list/management-list.component.scss'],
}) })
export class TagListComponent extends ManagementListComponent<PaperlessTag> { export class TagListComponent extends ManagementListComponent<Tag> {
constructor( constructor(
tagService: TagService, tagService: TagService,
modalService: NgbModal, modalService: NgbModal,
@ -41,7 +41,7 @@ export class TagListComponent extends ManagementListComponent<PaperlessTag> {
key: 'color', key: 'color',
name: $localize`Color`, name: $localize`Color`,
rendersHtml: true, rendersHtml: true,
valueFn: (t: PaperlessTag) => { valueFn: (t: Tag) => {
return `<span class="badge" style="color: ${t.text_color}; background-color: ${t.color}">${t.color}</span>` return `<span class="badge" style="color: ${t.text_color}; background-color: ${t.color}">${t.color}</span>`
}, },
}, },
@ -49,7 +49,7 @@ export class TagListComponent extends ManagementListComponent<PaperlessTag> {
) )
} }
getDeleteMessage(object: PaperlessTag) { getDeleteMessage(object: Tag) {
return $localize`Do you really want to delete the tag "${object.name}"?` return $localize`Do you really want to delete the tag "${object.name}"?`
} }
} }

View File

@ -0,0 +1,43 @@
import { ObjectWithId } from './object-with-id'
export enum DocumentSource {
ConsumeFolder = 1,
ApiUpload = 2,
MailFetch = 3,
}
export interface ConsumptionTemplate extends ObjectWithId {
name: string
order: number
sources: DocumentSource[]
filter_filename: string
filter_path?: string
filter_mailrule?: number // MailRule.id
assign_title?: string
assign_tags?: number[] // Tag.id
assign_document_type?: number // DocumentType.id
assign_correspondent?: number // Correspondent.id
assign_storage_path?: number // StoragePath.id
assign_owner?: number // User.id
assign_view_users?: number[] // [User.id]
assign_view_groups?: number[] // [Group.id]
assign_change_users?: number[] // [User.id]
assign_change_groups?: number[] // [Group.id]
assign_custom_fields?: number[] // [CustomField.id]
}

View File

@ -1,5 +1,5 @@
import { MatchingModel } from './matching-model' import { MatchingModel } from './matching-model'
export interface PaperlessCorrespondent extends MatchingModel { export interface Correspondent extends MatchingModel {
last_correspondence?: string // Date last_correspondence?: string // Date
} }

View File

@ -0,0 +1,8 @@
import { ObjectWithId } from './object-with-id'
export interface CustomFieldInstance extends ObjectWithId {
document: number // Document
field: number // CustomField
created: Date
value?: any
}

View File

@ -1,6 +1,6 @@
import { ObjectWithId } from './object-with-id' import { ObjectWithId } from './object-with-id'
export enum PaperlessCustomFieldDataType { export enum CustomFieldDataType {
String = 'string', String = 'string',
Url = 'url', Url = 'url',
Date = 'date', Date = 'date',
@ -13,41 +13,41 @@ export enum PaperlessCustomFieldDataType {
export const DATA_TYPE_LABELS = [ export const DATA_TYPE_LABELS = [
{ {
id: PaperlessCustomFieldDataType.Boolean, id: CustomFieldDataType.Boolean,
name: $localize`Boolean`, name: $localize`Boolean`,
}, },
{ {
id: PaperlessCustomFieldDataType.Date, id: CustomFieldDataType.Date,
name: $localize`Date`, name: $localize`Date`,
}, },
{ {
id: PaperlessCustomFieldDataType.Integer, id: CustomFieldDataType.Integer,
name: $localize`Integer`, name: $localize`Integer`,
}, },
{ {
id: PaperlessCustomFieldDataType.Float, id: CustomFieldDataType.Float,
name: $localize`Number`, name: $localize`Number`,
}, },
{ {
id: PaperlessCustomFieldDataType.Monetary, id: CustomFieldDataType.Monetary,
name: $localize`Monetary`, name: $localize`Monetary`,
}, },
{ {
id: PaperlessCustomFieldDataType.String, id: CustomFieldDataType.String,
name: $localize`Text`, name: $localize`Text`,
}, },
{ {
id: PaperlessCustomFieldDataType.Url, id: CustomFieldDataType.Url,
name: $localize`Url`, name: $localize`Url`,
}, },
{ {
id: PaperlessCustomFieldDataType.DocumentLink, id: CustomFieldDataType.DocumentLink,
name: $localize`Document Link`, name: $localize`Document Link`,
}, },
] ]
export interface PaperlessCustomField extends ObjectWithId { export interface CustomField extends ObjectWithId {
data_type: PaperlessCustomFieldDataType data_type: CustomFieldDataType
name: string name: string
created?: Date created?: Date
} }

View File

@ -1,4 +1,4 @@
export interface PaperlessDocumentMetadata { export interface DocumentMetadata {
original_checksum?: string original_checksum?: string
archived_checksum?: string archived_checksum?: string

View File

@ -0,0 +1,7 @@
import { ObjectWithId } from './object-with-id'
export interface DocumentNote extends ObjectWithId {
created?: Date
note?: string
user?: number // User
}

View File

@ -1,4 +1,4 @@
export interface PaperlessDocumentSuggestions { export interface DocumentSuggestions {
tags?: number[] tags?: number[]
correspondents?: number[] correspondents?: number[]

View File

@ -0,0 +1,3 @@
import { MatchingModel } from './matching-model'
export interface DocumentType extends MatchingModel {}

View File

@ -0,0 +1,66 @@
import { Correspondent } from './correspondent'
import { Tag } from './tag'
import { DocumentType } from './document-type'
import { Observable } from 'rxjs'
import { StoragePath } from './storage-path'
import { ObjectWithPermissions } from './object-with-permissions'
import { DocumentNote } from './document-note'
import { CustomFieldInstance } from './custom-field-instance'
export interface SearchHit {
score?: number
rank?: number
highlights?: string
note_highlights?: string
}
export interface Document extends ObjectWithPermissions {
correspondent$?: Observable<Correspondent>
correspondent?: number
document_type$?: Observable<DocumentType>
document_type?: number
storage_path$?: Observable<StoragePath>
storage_path?: number
title?: string
content?: string
tags$?: Observable<Tag[]>
tags?: number[]
checksum?: string
// UTC
created?: Date
// localized date
created_date?: Date
modified?: Date
added?: Date
original_file_name?: string
archived_file_name?: string
download_url?: string
thumbnail_url?: string
archive_serial_number?: number
notes?: DocumentNote[]
__search_hit__?: SearchHit
custom_fields?: CustomFieldInstance[]
}

View File

@ -1,6 +1,6 @@
import { ObjectWithId } from './object-with-id' import { ObjectWithId } from './object-with-id'
export interface PaperlessGroup extends ObjectWithId { export interface Group extends ObjectWithId {
name?: string name?: string
user_count?: number // not implemented yet user_count?: number // not implemented yet

View File

@ -6,7 +6,7 @@ export enum IMAPSecurity {
STARTTLS = 3, STARTTLS = 3,
} }
export interface PaperlessMailAccount extends ObjectWithPermissions { export interface MailAccount extends ObjectWithPermissions {
name: string name: string
imap_server: string imap_server: string

View File

@ -32,7 +32,7 @@ export enum MailMetadataCorrespondentOption {
FromCustom = 4, FromCustom = 4,
} }
export interface PaperlessMailRule extends ObjectWithPermissions { export interface MailRule extends ObjectWithPermissions {
name: string name: string
account: number // PaperlessMailAccount.id account: number // PaperlessMailAccount.id

View File

@ -1,43 +0,0 @@
import { ObjectWithId } from './object-with-id'
export enum DocumentSource {
ConsumeFolder = 1,
ApiUpload = 2,
MailFetch = 3,
}
export interface PaperlessConsumptionTemplate extends ObjectWithId {
name: string
order: number
sources: DocumentSource[]
filter_filename: string
filter_path?: string
filter_mailrule?: number // PaperlessMailRule.id
assign_title?: string
assign_tags?: number[] // PaperlessTag.id
assign_document_type?: number // PaperlessDocumentType.id
assign_correspondent?: number // PaperlessCorrespondent.id
assign_storage_path?: number // PaperlessStoragePath.id
assign_owner?: number // PaperlessUser.id
assign_view_users?: number[] // [PaperlessUser.id]
assign_view_groups?: number[] // [PaperlessGroup.id]
assign_change_users?: number[] // [PaperlessUser.id]
assign_change_groups?: number[] // [PaperlessGroup.id]
assign_custom_fields?: number[] // [PaperlessCustomField.id]
}

View File

@ -1,9 +0,0 @@
import { ObjectWithId } from './object-with-id'
import { PaperlessCustomField } from './paperless-custom-field'
export interface PaperlessCustomFieldInstance extends ObjectWithId {
document: number // PaperlessDocument
field: number // PaperlessCustomField
created: Date
value?: any
}

View File

@ -1,7 +0,0 @@
import { ObjectWithId } from './object-with-id'
export interface PaperlessDocumentNote extends ObjectWithId {
created?: Date
note?: string
user?: number // PaperlessUser
}

View File

@ -1,3 +0,0 @@
import { MatchingModel } from './matching-model'
export interface PaperlessDocumentType extends MatchingModel {}

View File

@ -1,66 +0,0 @@
import { PaperlessCorrespondent } from './paperless-correspondent'
import { PaperlessTag } from './paperless-tag'
import { PaperlessDocumentType } from './paperless-document-type'
import { Observable } from 'rxjs'
import { PaperlessStoragePath } from './paperless-storage-path'
import { ObjectWithPermissions } from './object-with-permissions'
import { PaperlessDocumentNote } from './paperless-document-note'
import { PaperlessCustomFieldInstance } from './paperless-custom-field-instance'
export interface SearchHit {
score?: number
rank?: number
highlights?: string
note_highlights?: string
}
export interface PaperlessDocument extends ObjectWithPermissions {
correspondent$?: Observable<PaperlessCorrespondent>
correspondent?: number
document_type$?: Observable<PaperlessDocumentType>
document_type?: number
storage_path$?: Observable<PaperlessStoragePath>
storage_path?: number
title?: string
content?: string
tags$?: Observable<PaperlessTag[]>
tags?: number[]
checksum?: string
// UTC
created?: Date
// localized date
created_date?: Date
modified?: Date
added?: Date
original_file_name?: string
archived_file_name?: string
download_url?: string
thumbnail_url?: string
archive_serial_number?: number
notes?: PaperlessDocumentNote[]
__search_hit__?: SearchHit
custom_fields?: PaperlessCustomFieldInstance[]
}

View File

@ -1,7 +1,7 @@
import { FilterRule } from './filter-rule' import { FilterRule } from './filter-rule'
import { ObjectWithPermissions } from './object-with-permissions' import { ObjectWithPermissions } from './object-with-permissions'
export interface PaperlessSavedView extends ObjectWithPermissions { export interface SavedView extends ObjectWithPermissions {
name?: string name?: string
show_on_dashboard?: boolean show_on_dashboard?: boolean

View File

@ -1,18 +1,18 @@
import { ObjectWithPermissions } from './object-with-permissions' import { ObjectWithPermissions } from './object-with-permissions'
export enum PaperlessFileVersion { export enum FileVersion {
Archive = 'archive', Archive = 'archive',
Original = 'original', Original = 'original',
} }
export interface PaperlessShareLink extends ObjectWithPermissions { export interface ShareLink extends ObjectWithPermissions {
created: string // Date created: string // Date
expiration?: string // Date expiration?: string // Date
slug: string slug: string
document: number // PaperlessDocument document: number // Document
file_version: string file_version: string
} }

View File

@ -1,5 +1,5 @@
import { MatchingModel } from './matching-model' import { MatchingModel } from './matching-model'
export interface PaperlessStoragePath extends MatchingModel { export interface StoragePath extends MatchingModel {
path?: string path?: string
} }

View File

@ -1,6 +1,6 @@
import { MatchingModel } from './matching-model' import { MatchingModel } from './matching-model'
export interface PaperlessTag extends MatchingModel { export interface Tag extends MatchingModel {
color?: string color?: string
text_color?: string text_color?: string

View File

@ -1,12 +1,12 @@
import { PaperlessUser } from './paperless-user' import { User } from './user'
export interface PaperlessUiSettings { export interface UiSettings {
user: PaperlessUser user: User
settings: Object settings: Object
permissions: string[] permissions: string[]
} }
export interface PaperlessUiSetting { export interface UiSetting {
key: string key: string
type: string type: string
default: any default: any
@ -53,7 +53,7 @@ export const SETTINGS_KEYS = {
DEFAULT_PERMS_EDIT_GROUPS: 'general-settings:permissions:default-edit-groups', DEFAULT_PERMS_EDIT_GROUPS: 'general-settings:permissions:default-edit-groups',
} }
export const SETTINGS: PaperlessUiSetting[] = [ export const SETTINGS: UiSetting[] = [
{ {
key: SETTINGS_KEYS.LANGUAGE, key: SETTINGS_KEYS.LANGUAGE,
type: 'string', type: 'string',

View File

@ -1,6 +1,6 @@
import { ObjectWithId } from './object-with-id' import { ObjectWithId } from './object-with-id'
export interface PaperlessUser extends ObjectWithId { export interface User extends ObjectWithId {
username?: string username?: string
first_name?: string first_name?: string
last_name?: string last_name?: string
@ -8,7 +8,7 @@ export interface PaperlessUser extends ObjectWithId {
is_staff?: boolean is_staff?: boolean
is_active?: boolean is_active?: boolean
is_superuser?: boolean is_superuser?: boolean
groups?: number[] // PaperlessGroup[] groups?: number[] // Group[]
user_permissions?: string[] user_permissions?: string[]
inherited_permissions?: string[] inherited_permissions?: string[]
} }

View File

@ -4,7 +4,7 @@ import { DocumentListComponent } from '../components/document-list/document-list
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { ConfirmDialogComponent } from '../components/common/confirm-dialog/confirm-dialog.component' import { ConfirmDialogComponent } from '../components/common/confirm-dialog/confirm-dialog.component'
import { SettingsService } from '../services/settings.service' import { SettingsService } from '../services/settings.service'
import { SETTINGS_KEYS } from '../data/paperless-uisettings' import { SETTINGS_KEYS } from '../data/ui-settings'
@Injectable() @Injectable()
export class DirtySavedViewGuard { export class DirtySavedViewGuard {

View File

@ -1,6 +1,6 @@
import { DatePipe } from '@angular/common' import { DatePipe } from '@angular/common'
import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core' import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core'
import { SETTINGS_KEYS } from '../data/paperless-uisettings' import { SETTINGS_KEYS } from '../data/ui-settings'
import { SettingsService } from '../services/settings.service' import { SettingsService } from '../services/settings.service'
const FORMAT_TO_ISO_FORMAT = { const FORMAT_TO_ISO_FORMAT = {

View File

@ -5,13 +5,13 @@ import {
PermissionType, PermissionType,
PermissionsService, PermissionsService,
} from '../services/permissions.service' } from '../services/permissions.service'
import { PaperlessUser } from '../data/paperless-user' import { User } from '../data/user'
@Pipe({ @Pipe({
name: 'username', name: 'username',
}) })
export class UsernamePipe implements PipeTransform { export class UsernamePipe implements PipeTransform {
users: PaperlessUser[] users: User[]
constructor( constructor(
permissionsService: PermissionsService, permissionsService: PermissionsService,
@ -33,7 +33,7 @@ export class UsernamePipe implements PipeTransform {
: $localize`Shared` : $localize`Shared`
} }
getName(user: PaperlessUser): string { getName(user: User): string {
if (!user) return '' if (!user) return ''
const name = [user.first_name, user.last_name].join(' ') const name = [user.first_name, user.last_name].join(' ')
if (name.length > 1) return name.trim() if (name.length > 1) return name.trim()

View File

@ -12,13 +12,13 @@ import {
FILTER_HAS_TAGS_ALL, FILTER_HAS_TAGS_ALL,
FILTER_HAS_TAGS_ANY, FILTER_HAS_TAGS_ANY,
} from '../data/filter-rule-type' } from '../data/filter-rule-type'
import { PaperlessSavedView } from '../data/paperless-saved-view' import { SavedView } from '../data/saved-view'
import { FilterRule } from '../data/filter-rule' import { FilterRule } from '../data/filter-rule'
import { RouterTestingModule } from '@angular/router/testing' import { RouterTestingModule } from '@angular/router/testing'
import { routes } from 'src/app/app-routing.module' import { routes } from 'src/app/app-routing.module'
import { PermissionsGuard } from '../guards/permissions.guard' import { PermissionsGuard } from '../guards/permissions.guard'
import { SettingsService } from './settings.service' import { SettingsService } from './settings.service'
import { SETTINGS_KEYS } from '../data/paperless-uisettings' import { SETTINGS_KEYS } from '../data/ui-settings'
const documents = [ const documents = [
{ {
@ -69,7 +69,7 @@ const filterRules: FilterRule[] = [
}, },
] ]
const view: PaperlessSavedView = { const view: SavedView = {
id: 3, id: 3,
name: 'Saved View', name: 'Saved View',
sort_field: 'added', sort_field: 'added',

View File

@ -7,9 +7,9 @@ import {
cloneFilterRules, cloneFilterRules,
isFullTextFilterRule, isFullTextFilterRule,
} from '../utils/filter-rules' } from '../utils/filter-rules'
import { PaperlessDocument } from '../data/paperless-document' import { Document } from '../data/document'
import { PaperlessSavedView } from '../data/paperless-saved-view' import { SavedView } from '../data/saved-view'
import { SETTINGS_KEYS } from '../data/paperless-uisettings' import { SETTINGS_KEYS } from '../data/ui-settings'
import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys' import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys'
import { paramsFromViewState, paramsToViewState } from '../utils/query-params' import { paramsFromViewState, paramsToViewState } from '../utils/query-params'
import { import {
@ -31,7 +31,7 @@ export interface ListViewState {
/** /**
* Current paginated list of documents displayed. * Current paginated list of documents displayed.
*/ */
documents?: PaperlessDocument[] documents?: Document[]
currentPage: number currentPage: number
@ -149,7 +149,7 @@ export class DocumentListViewService {
this.unsubscribeNotifier.next(true) this.unsubscribeNotifier.next(true)
} }
activateSavedView(view: PaperlessSavedView) { activateSavedView(view: SavedView) {
this.rangeSelectionAnchorIndex = this.lastRangeSelectionToIndex = null this.rangeSelectionAnchorIndex = this.lastRangeSelectionToIndex = null
if (view) { if (view) {
this._activeSavedViewId = view.id this._activeSavedViewId = view.id
@ -159,16 +159,13 @@ export class DocumentListViewService {
} }
} }
activateSavedViewWithQueryParams( activateSavedViewWithQueryParams(view: SavedView, queryParams: ParamMap) {
view: PaperlessSavedView,
queryParams: ParamMap
) {
const viewState = paramsToViewState(queryParams) const viewState = paramsToViewState(queryParams)
this.activateSavedView(view) this.activateSavedView(view)
this.currentPage = viewState.currentPage this.currentPage = viewState.currentPage
} }
loadSavedView(view: PaperlessSavedView, closeCurrentView: boolean = false) { loadSavedView(view: SavedView, closeCurrentView: boolean = false) {
if (closeCurrentView) { if (closeCurrentView) {
this._activeSavedViewId = null this._activeSavedViewId = null
} }
@ -350,7 +347,7 @@ export class DocumentListViewService {
this.saveDocumentListView() this.saveDocumentListView()
} }
get documents(): PaperlessDocument[] { get documents(): Document[] {
return this.activeListViewState.documents return this.activeListViewState.documents
} }
@ -494,18 +491,18 @@ export class DocumentListViewService {
}) })
} }
isSelected(d: PaperlessDocument) { isSelected(d: Document) {
return this.selected.has(d.id) return this.selected.has(d.id)
} }
toggleSelected(d: PaperlessDocument): void { toggleSelected(d: Document): void {
if (this.selected.has(d.id)) this.selected.delete(d.id) if (this.selected.has(d.id)) this.selected.delete(d.id)
else this.selected.add(d.id) else this.selected.add(d.id)
this.rangeSelectionAnchorIndex = this.documentIndexInCurrentView(d.id) this.rangeSelectionAnchorIndex = this.documentIndexInCurrentView(d.id)
this.lastRangeSelectionToIndex = null this.lastRangeSelectionToIndex = null
} }
selectRangeTo(d: PaperlessDocument) { selectRangeTo(d: Document) {
if (this.rangeSelectionAnchorIndex !== null) { if (this.rangeSelectionAnchorIndex !== null) {
const documentToIndex = this.documentIndexInCurrentView(d.id) const documentToIndex = this.documentIndexInCurrentView(d.id)
const fromIndex = Math.min( const fromIndex = Math.min(

View File

@ -1,5 +1,5 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { PaperlessDocument } from '../data/paperless-document' import { Document } from '../data/document'
import { OPEN_DOCUMENT_SERVICE } from '../data/storage-keys' import { OPEN_DOCUMENT_SERVICE } from '../data/storage-keys'
import { DocumentService } from './rest/document.service' import { DocumentService } from './rest/document.service'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
@ -29,7 +29,7 @@ export class OpenDocumentsService {
} }
} }
private openDocuments: PaperlessDocument[] = [] private openDocuments: Document[] = []
private dirtyDocuments: Set<number> = new Set<number>() private dirtyDocuments: Set<number> = new Set<number>()
refreshDocument(id: number) { refreshDocument(id: number) {
@ -48,15 +48,15 @@ export class OpenDocumentsService {
} }
} }
getOpenDocuments(): PaperlessDocument[] { getOpenDocuments(): Document[] {
return this.openDocuments return this.openDocuments
} }
getOpenDocument(id: number): PaperlessDocument { getOpenDocument(id: number): Document {
return this.openDocuments.find((d) => d.id == id) return this.openDocuments.find((d) => d.id == id)
} }
openDocument(doc: PaperlessDocument): Observable<boolean> { openDocument(doc: Document): Observable<boolean> {
if (this.openDocuments.find((d) => d.id == doc.id) == null) { if (this.openDocuments.find((d) => d.id == doc.id) == null) {
if (this.openDocuments.length == this.MAX_OPEN_DOCUMENTS) { if (this.openDocuments.length == this.MAX_OPEN_DOCUMENTS) {
// at max, ensure changes arent lost // at max, ensure changes arent lost
@ -74,13 +74,13 @@ export class OpenDocumentsService {
return of(true) return of(true)
} }
private finishOpenDocument(doc: PaperlessDocument) { private finishOpenDocument(doc: Document) {
this.openDocuments.unshift(doc) this.openDocuments.unshift(doc)
this.dirtyDocuments.delete(doc.id) this.dirtyDocuments.delete(doc.id)
this.save() this.save()
} }
setDirty(doc: PaperlessDocument, dirty: boolean) { setDirty(doc: Document, dirty: boolean) {
if (!this.openDocuments.find((d) => d.id == doc.id)) return if (!this.openDocuments.find((d) => d.id == doc.id)) return
if (dirty) this.dirtyDocuments.add(doc.id) if (dirty) this.dirtyDocuments.add(doc.id)
else this.dirtyDocuments.delete(doc.id) else this.dirtyDocuments.delete(doc.id)
@ -90,7 +90,7 @@ export class OpenDocumentsService {
return this.dirtyDocuments.size > 0 return this.dirtyDocuments.size > 0
} }
closeDocument(doc: PaperlessDocument): Observable<boolean> { closeDocument(doc: Document): Observable<boolean> {
let index = this.openDocuments.findIndex((d) => d.id == doc.id) let index = this.openDocuments.findIndex((d) => d.id == doc.id)
if (index == -1) return of(true) if (index == -1) return of(true)
if (!this.dirtyDocuments.has(doc.id)) { if (!this.dirtyDocuments.has(doc.id)) {

View File

@ -4,27 +4,27 @@ import {
PermissionType, PermissionType,
PermissionsService, PermissionsService,
} from './permissions.service' } from './permissions.service'
import { PaperlessDocument } from '../data/paperless-document' import { Document } from '../data/document'
describe('PermissionsService', () => { describe('PermissionsService', () => {
let permissionsService: PermissionsService let permissionsService: PermissionsService
const docUnowned: PaperlessDocument = { const docUnowned: Document = {
title: 'Doc title', title: 'Doc title',
owner: null, owner: null,
} }
const docOwned: PaperlessDocument = { const docOwned: Document = {
title: 'Doc title 2', title: 'Doc title 2',
owner: 1, owner: 1,
} }
const docNotOwned: PaperlessDocument = { const docNotOwned: Document = {
title: 'Doc title 3', title: 'Doc title 3',
owner: 2, owner: 2,
} }
const docUserViewGranted: PaperlessDocument = { const docUserViewGranted: Document = {
title: 'Doc title 4', title: 'Doc title 4',
owner: 2, owner: 2,
permissions: { permissions: {
@ -39,7 +39,7 @@ describe('PermissionsService', () => {
}, },
} }
const docUserEditGranted: PaperlessDocument = { const docUserEditGranted: Document = {
title: 'Doc title 5', title: 'Doc title 5',
owner: 2, owner: 2,
permissions: { permissions: {
@ -54,7 +54,7 @@ describe('PermissionsService', () => {
}, },
} }
const docGroupViewGranted: PaperlessDocument = { const docGroupViewGranted: Document = {
title: 'Doc title 4', title: 'Doc title 4',
owner: 2, owner: 2,
permissions: { permissions: {
@ -69,7 +69,7 @@ describe('PermissionsService', () => {
}, },
} }
const docGroupEditGranted: PaperlessDocument = { const docGroupEditGranted: Document = {
title: 'Doc title 5', title: 'Doc title 5',
owner: 2, owner: 2,
permissions: { permissions: {

View File

@ -1,6 +1,6 @@
import { Injectable } from '@angular/core' import { Injectable } from '@angular/core'
import { ObjectWithPermissions } from '../data/object-with-permissions' import { ObjectWithPermissions } from '../data/object-with-permissions'
import { PaperlessUser } from '../data/paperless-user' import { User } from '../data/user'
export enum PermissionAction { export enum PermissionAction {
Add = 'add', Add = 'add',
@ -34,9 +34,9 @@ export enum PermissionType {
}) })
export class PermissionsService { export class PermissionsService {
private permissions: string[] private permissions: string[]
private currentUser: PaperlessUser private currentUser: User
public initialize(permissions: string[], currentUser: PaperlessUser) { public initialize(permissions: string[], currentUser: User) {
this.permissions = permissions this.permissions = permissions
this.currentUser = currentUser this.currentUser = currentUser
} }

View File

@ -6,13 +6,13 @@ import { commonAbstractPaperlessServiceTests } from './abstract-paperless-servic
import { ConsumptionTemplateService } from './consumption-template.service' import { ConsumptionTemplateService } from './consumption-template.service'
import { import {
DocumentSource, DocumentSource,
PaperlessConsumptionTemplate, ConsumptionTemplate,
} from 'src/app/data/paperless-consumption-template' } from 'src/app/data/consumption-template'
let httpTestingController: HttpTestingController let httpTestingController: HttpTestingController
let service: ConsumptionTemplateService let service: ConsumptionTemplateService
const endpoint = 'consumption_templates' const endpoint = 'consumption_templates'
const templates: PaperlessConsumptionTemplate[] = [ const templates: ConsumptionTemplate[] = [
{ {
name: 'Template 1', name: 'Template 1',
id: 1, id: 1,

Some files were not shown because too many files have changed in this diff Show More