mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-07-28 18:24:38 -05:00
Refactor frontend data models
This commit is contained in:
@@ -8,10 +8,7 @@ import {
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
|
||||
import { of } from 'rxjs'
|
||||
import {
|
||||
PaperlessCustomField,
|
||||
PaperlessCustomFieldDataType,
|
||||
} from 'src/app/data/paperless-custom-field'
|
||||
import { CustomField, CustomFieldDataType } from 'src/app/data/custom-field'
|
||||
import { SelectComponent } from '../input/select/select.component'
|
||||
import { NgSelectModule } from '@ng-select/ng-select'
|
||||
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 { By } from '@angular/platform-browser'
|
||||
|
||||
const fields: PaperlessCustomField[] = [
|
||||
const fields: CustomField[] = [
|
||||
{
|
||||
id: 0,
|
||||
name: 'Field 1',
|
||||
data_type: PaperlessCustomFieldDataType.Integer,
|
||||
data_type: CustomFieldDataType.Integer,
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
name: 'Field 2',
|
||||
data_type: PaperlessCustomFieldDataType.String,
|
||||
data_type: CustomFieldDataType.String,
|
||||
},
|
||||
]
|
||||
|
||||
|
@@ -7,8 +7,8 @@ import {
|
||||
} from '@angular/core'
|
||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { Subject, first, takeUntil } from 'rxjs'
|
||||
import { PaperlessCustomField } from 'src/app/data/paperless-custom-field'
|
||||
import { PaperlessCustomFieldInstance } from 'src/app/data/paperless-custom-field-instance'
|
||||
import { CustomField } from 'src/app/data/custom-field'
|
||||
import { CustomFieldInstance } from 'src/app/data/custom-field-instance'
|
||||
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
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
|
||||
|
||||
@Input()
|
||||
existingFields: PaperlessCustomFieldInstance[] = []
|
||||
existingFields: CustomFieldInstance[] = []
|
||||
|
||||
@Output()
|
||||
added: EventEmitter<PaperlessCustomField> = new EventEmitter()
|
||||
added: EventEmitter<CustomField> = new EventEmitter()
|
||||
|
||||
@Output()
|
||||
created: EventEmitter<PaperlessCustomField> = new EventEmitter()
|
||||
created: EventEmitter<CustomField> = new EventEmitter()
|
||||
|
||||
private customFields: PaperlessCustomField[] = []
|
||||
public unusedFields: PaperlessCustomField[]
|
||||
private customFields: CustomField[] = []
|
||||
public unusedFields: CustomField[]
|
||||
|
||||
public name: string
|
||||
|
||||
@@ -88,8 +88,8 @@ export class CustomFieldsDropdownComponent implements OnDestroy {
|
||||
}
|
||||
|
||||
public getCustomFieldFromInstance(
|
||||
instance: PaperlessCustomFieldInstance
|
||||
): PaperlessCustomField {
|
||||
instance: CustomFieldInstance
|
||||
): CustomField {
|
||||
return this.customFields.find((f) => f.id === instance.field)
|
||||
}
|
||||
|
||||
|
@@ -4,11 +4,11 @@ import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { first } from 'rxjs'
|
||||
import {
|
||||
DocumentSource,
|
||||
PaperlessConsumptionTemplate,
|
||||
} from 'src/app/data/paperless-consumption-template'
|
||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
|
||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
|
||||
import { PaperlessStoragePath } from 'src/app/data/paperless-storage-path'
|
||||
ConsumptionTemplate,
|
||||
} from 'src/app/data/consumption-template'
|
||||
import { Correspondent } from 'src/app/data/correspondent'
|
||||
import { DocumentType } from 'src/app/data/document-type'
|
||||
import { StoragePath } from 'src/app/data/storage-path'
|
||||
import { ConsumptionTemplateService } from 'src/app/services/rest/consumption-template.service'
|
||||
import { CorrespondentService } from 'src/app/services/rest/correspondent.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 { EditDialogComponent } from '../edit-dialog.component'
|
||||
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 { PaperlessCustomField } from 'src/app/data/paperless-custom-field'
|
||||
import { CustomField } from 'src/app/data/custom-field'
|
||||
|
||||
export const DOCUMENT_SOURCE_OPTIONS = [
|
||||
{
|
||||
@@ -41,13 +41,13 @@ export const DOCUMENT_SOURCE_OPTIONS = [
|
||||
templateUrl: './consumption-template-edit-dialog.component.html',
|
||||
styleUrls: ['./consumption-template-edit-dialog.component.scss'],
|
||||
})
|
||||
export class ConsumptionTemplateEditDialogComponent extends EditDialogComponent<PaperlessConsumptionTemplate> {
|
||||
templates: PaperlessConsumptionTemplate[]
|
||||
correspondents: PaperlessCorrespondent[]
|
||||
documentTypes: PaperlessDocumentType[]
|
||||
storagePaths: PaperlessStoragePath[]
|
||||
mailRules: PaperlessMailRule[]
|
||||
customFields: PaperlessCustomField[]
|
||||
export class ConsumptionTemplateEditDialogComponent extends EditDialogComponent<ConsumptionTemplate> {
|
||||
templates: ConsumptionTemplate[]
|
||||
correspondents: Correspondent[]
|
||||
documentTypes: DocumentType[]
|
||||
storagePaths: StoragePath[]
|
||||
mailRules: MailRule[]
|
||||
customFields: CustomField[]
|
||||
|
||||
constructor(
|
||||
service: ConsumptionTemplateService,
|
||||
|
@@ -3,7 +3,7 @@ import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
|
||||
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 { UserService } from 'src/app/services/rest/user.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',
|
||||
styleUrls: ['./correspondent-edit-dialog.component.scss'],
|
||||
})
|
||||
export class CorrespondentEditDialogComponent extends EditDialogComponent<PaperlessCorrespondent> {
|
||||
export class CorrespondentEditDialogComponent extends EditDialogComponent<Correspondent> {
|
||||
constructor(
|
||||
service: CorrespondentService,
|
||||
activeModal: NgbActiveModal,
|
||||
|
@@ -1,10 +1,7 @@
|
||||
import { Component, OnInit } from '@angular/core'
|
||||
import { FormGroup, FormControl } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import {
|
||||
DATA_TYPE_LABELS,
|
||||
PaperlessCustomField,
|
||||
} from 'src/app/data/paperless-custom-field'
|
||||
import { DATA_TYPE_LABELS, CustomField } from 'src/app/data/custom-field'
|
||||
import { CustomFieldsService } from 'src/app/services/rest/custom-fields.service'
|
||||
import { UserService } from 'src/app/services/rest/user.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'],
|
||||
})
|
||||
export class CustomFieldEditDialogComponent
|
||||
extends EditDialogComponent<PaperlessCustomField>
|
||||
extends EditDialogComponent<CustomField>
|
||||
implements OnInit
|
||||
{
|
||||
constructor(
|
||||
|
@@ -3,7 +3,7 @@ import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
|
||||
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 { UserService } from 'src/app/services/rest/user.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',
|
||||
styleUrls: ['./document-type-edit-dialog.component.scss'],
|
||||
})
|
||||
export class DocumentTypeEditDialogComponent extends EditDialogComponent<PaperlessDocumentType> {
|
||||
export class DocumentTypeEditDialogComponent extends EditDialogComponent<DocumentType> {
|
||||
constructor(
|
||||
service: DocumentTypeService,
|
||||
activeModal: NgbActiveModal,
|
||||
|
@@ -23,8 +23,8 @@ import {
|
||||
MATCH_NONE,
|
||||
MATCH_ALL,
|
||||
} from 'src/app/data/matching-model'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { TagService } from 'src/app/services/rest/tag.service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
@@ -38,7 +38,7 @@ import { EditDialogComponent, EditDialogMode } from './edit-dialog.component'
|
||||
</div>
|
||||
`,
|
||||
})
|
||||
class TestComponent extends EditDialogComponent<PaperlessTag> {
|
||||
class TestComponent extends EditDialogComponent<Tag> {
|
||||
constructor(
|
||||
service: TagService,
|
||||
activeModal: NgbActiveModal,
|
||||
|
@@ -9,12 +9,12 @@ import {
|
||||
} from 'src/app/data/matching-model'
|
||||
import { ObjectWithId } from 'src/app/data/object-with-id'
|
||||
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 { UserService } from 'src/app/services/rest/user.service'
|
||||
import { PermissionsFormObject } from '../input/permissions/permissions-form/permissions-form.component'
|
||||
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 {
|
||||
CREATE = 0,
|
||||
@@ -33,7 +33,7 @@ export abstract class EditDialogComponent<
|
||||
private settingsService: SettingsService
|
||||
) {}
|
||||
|
||||
users: PaperlessUser[]
|
||||
users: User[]
|
||||
|
||||
@Input()
|
||||
dialogMode: EditDialogMode = EditDialogMode.CREATE
|
||||
|
@@ -2,7 +2,7 @@ import { Component } from '@angular/core'
|
||||
import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
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 { UserService } from 'src/app/services/rest/user.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',
|
||||
styleUrls: ['./group-edit-dialog.component.scss'],
|
||||
})
|
||||
export class GroupEditDialogComponent extends EditDialogComponent<PaperlessGroup> {
|
||||
export class GroupEditDialogComponent extends EditDialogComponent<Group> {
|
||||
constructor(
|
||||
service: GroupService,
|
||||
activeModal: NgbActiveModal,
|
||||
|
@@ -11,7 +11,7 @@ import {
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
|
||||
import { NgbActiveModal, NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
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 { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
|
@@ -2,10 +2,7 @@ import { Component, ViewChild } from '@angular/core'
|
||||
import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal, NgbAlert } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
|
||||
import {
|
||||
IMAPSecurity,
|
||||
PaperlessMailAccount,
|
||||
} from 'src/app/data/paperless-mail-account'
|
||||
import { IMAPSecurity, MailAccount } from 'src/app/data/mail-account'
|
||||
import { MailAccountService } from 'src/app/services/rest/mail-account.service'
|
||||
import { UserService } from 'src/app/services/rest/user.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
@@ -21,7 +18,7 @@ const IMAP_SECURITY_OPTIONS = [
|
||||
templateUrl: './mail-account-edit-dialog.component.html',
|
||||
styleUrls: ['./mail-account-edit-dialog.component.scss'],
|
||||
})
|
||||
export class MailAccountEditDialogComponent extends EditDialogComponent<PaperlessMailAccount> {
|
||||
export class MailAccountEditDialogComponent extends EditDialogComponent<MailAccount> {
|
||||
testActive: boolean = false
|
||||
testResult: string
|
||||
alertTimeout
|
||||
|
@@ -7,7 +7,7 @@ import { of } from 'rxjs'
|
||||
import {
|
||||
MailMetadataCorrespondentOption,
|
||||
MailAction,
|
||||
} from 'src/app/data/paperless-mail-rule'
|
||||
} from 'src/app/data/mail-rule'
|
||||
import { IfOwnerDirective } from 'src/app/directives/if-owner.directive'
|
||||
import { IfPermissionsDirective } from 'src/app/directives/if-permissions.directive'
|
||||
import { SafeHtmlPipe } from 'src/app/pipes/safehtml.pipe'
|
||||
|
@@ -3,17 +3,17 @@ import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { first } from 'rxjs'
|
||||
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
|
||||
import { PaperlessCorrespondent } from 'src/app/data/paperless-correspondent'
|
||||
import { PaperlessDocumentType } from 'src/app/data/paperless-document-type'
|
||||
import { PaperlessMailAccount } from 'src/app/data/paperless-mail-account'
|
||||
import { Correspondent } from 'src/app/data/correspondent'
|
||||
import { DocumentType } from 'src/app/data/document-type'
|
||||
import { MailAccount } from 'src/app/data/mail-account'
|
||||
import {
|
||||
MailAction,
|
||||
MailFilterAttachmentType,
|
||||
MailMetadataCorrespondentOption,
|
||||
MailMetadataTitleOption,
|
||||
PaperlessMailRule,
|
||||
MailRule,
|
||||
MailRuleConsumptionScope,
|
||||
} from 'src/app/data/paperless-mail-rule'
|
||||
} from 'src/app/data/mail-rule'
|
||||
import { CorrespondentService } from 'src/app/services/rest/correspondent.service'
|
||||
import { DocumentTypeService } from 'src/app/services/rest/document-type.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',
|
||||
styleUrls: ['./mail-rule-edit-dialog.component.scss'],
|
||||
})
|
||||
export class MailRuleEditDialogComponent extends EditDialogComponent<PaperlessMailRule> {
|
||||
accounts: PaperlessMailAccount[]
|
||||
correspondents: PaperlessCorrespondent[]
|
||||
documentTypes: PaperlessDocumentType[]
|
||||
export class MailRuleEditDialogComponent extends EditDialogComponent<MailRule> {
|
||||
accounts: MailAccount[]
|
||||
correspondents: Correspondent[]
|
||||
documentTypes: DocumentType[]
|
||||
|
||||
constructor(
|
||||
service: MailRuleService,
|
||||
|
@@ -3,7 +3,7 @@ import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
|
||||
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 { UserService } from 'src/app/services/rest/user.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',
|
||||
styleUrls: ['./storage-path-edit-dialog.component.scss'],
|
||||
})
|
||||
export class StoragePathEditDialogComponent extends EditDialogComponent<PaperlessStoragePath> {
|
||||
export class StoragePathEditDialogComponent extends EditDialogComponent<StoragePath> {
|
||||
constructor(
|
||||
service: StoragePathService,
|
||||
activeModal: NgbActiveModal,
|
||||
|
@@ -2,7 +2,7 @@ import { Component } from '@angular/core'
|
||||
import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
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 { randomColor } from 'src/app/utils/color'
|
||||
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',
|
||||
styleUrls: ['./tag-edit-dialog.component.scss'],
|
||||
})
|
||||
export class TagEditDialogComponent extends EditDialogComponent<PaperlessTag> {
|
||||
export class TagEditDialogComponent extends EditDialogComponent<Tag> {
|
||||
constructor(
|
||||
service: TagService,
|
||||
activeModal: NgbActiveModal,
|
||||
|
@@ -3,8 +3,8 @@ import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { first } from 'rxjs'
|
||||
import { EditDialogComponent } from 'src/app/components/common/edit-dialog/edit-dialog.component'
|
||||
import { PaperlessGroup } from 'src/app/data/paperless-group'
|
||||
import { PaperlessUser } from 'src/app/data/paperless-user'
|
||||
import { Group } from 'src/app/data/group'
|
||||
import { User } from 'src/app/data/user'
|
||||
import { GroupService } from 'src/app/services/rest/group.service'
|
||||
import { UserService } from 'src/app/services/rest/user.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'],
|
||||
})
|
||||
export class UserEditDialogComponent
|
||||
extends EditDialogComponent<PaperlessUser>
|
||||
extends EditDialogComponent<User>
|
||||
implements OnInit
|
||||
{
|
||||
groups: PaperlessGroup[]
|
||||
groups: Group[]
|
||||
passwordIsSet: boolean = false
|
||||
|
||||
constructor(
|
||||
|
@@ -13,7 +13,7 @@ import {
|
||||
} from './filterable-dropdown.component'
|
||||
import { FilterPipe } from 'src/app/pipes/filter.pipe'
|
||||
import { NgbModule } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import {
|
||||
DEFAULT_MATCHING_ALGORITHM,
|
||||
MATCH_ALL,
|
||||
@@ -26,7 +26,7 @@ import { TagComponent } from '../tag/tag.component'
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
|
||||
import { ClearableBadgeComponent } from '../clearable-badge/clearable-badge.component'
|
||||
|
||||
const items: PaperlessTag[] = [
|
||||
const items: Tag[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Tag1',
|
||||
|
@@ -4,7 +4,7 @@ import {
|
||||
ToggleableItemState,
|
||||
} from './toggleable-dropdown-button.component'
|
||||
import { TagComponent } from '../../tag/tag.component'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
|
||||
describe('ToggleableDropdownButtonComponent', () => {
|
||||
let component: ToggleableDropdownButtonComponent
|
||||
@@ -26,7 +26,7 @@ describe('ToggleableDropdownButtonComponent', () => {
|
||||
id: 1,
|
||||
name: 'Test Tag',
|
||||
is_inbox_tag: false,
|
||||
} as PaperlessTag
|
||||
} as Tag
|
||||
|
||||
fixture.detectChanges()
|
||||
expect(component.isTag).toBeTruthy()
|
||||
|
@@ -13,7 +13,7 @@ import {
|
||||
catchError,
|
||||
} from 'rxjs'
|
||||
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 { AbstractInputComponent } from '../abstract-input'
|
||||
|
||||
@@ -34,9 +34,9 @@ export class DocumentLinkComponent
|
||||
implements OnInit, OnDestroy
|
||||
{
|
||||
documentsInput$ = new Subject<string>()
|
||||
foundDocuments$: Observable<PaperlessDocument[]>
|
||||
foundDocuments$: Observable<Document[]>
|
||||
loading = false
|
||||
selectedDocuments: PaperlessDocument[] = []
|
||||
selectedDocuments: Document[] = []
|
||||
|
||||
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(
|
||||
(d) => d.id !== document.id
|
||||
)
|
||||
this.onChange(this.selectedDocuments.map((d) => d.id))
|
||||
}
|
||||
|
||||
compareDocuments(
|
||||
document: PaperlessDocument,
|
||||
selectedDocument: PaperlessDocument
|
||||
) {
|
||||
compareDocuments(document: Document, selectedDocument: Document) {
|
||||
return document.id === selectedDocument.id
|
||||
}
|
||||
|
||||
trackByFn(item: PaperlessDocument) {
|
||||
trackByFn(item: Document) {
|
||||
return item.id
|
||||
}
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||
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'
|
||||
|
||||
export interface PermissionsFormObject {
|
||||
@@ -34,7 +34,7 @@ export class PermissionsFormComponent
|
||||
implements OnInit
|
||||
{
|
||||
@Input()
|
||||
users: PaperlessUser[]
|
||||
users: User[]
|
||||
|
||||
@Input()
|
||||
accordion: boolean = false
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
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 { AbstractInputComponent } from '../../abstract-input'
|
||||
|
||||
@@ -17,8 +17,8 @@ import { AbstractInputComponent } from '../../abstract-input'
|
||||
templateUrl: './permissions-group.component.html',
|
||||
styleUrls: ['./permissions-group.component.scss'],
|
||||
})
|
||||
export class PermissionsGroupComponent extends AbstractInputComponent<PaperlessGroup> {
|
||||
groups: PaperlessGroup[]
|
||||
export class PermissionsGroupComponent extends AbstractInputComponent<Group> {
|
||||
groups: Group[]
|
||||
|
||||
constructor(groupService: GroupService) {
|
||||
super()
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Component, forwardRef, Input, OnInit } from '@angular/core'
|
||||
import { NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
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 { SettingsService } from 'src/app/services/settings.service'
|
||||
import { AbstractInputComponent } from '../../abstract-input'
|
||||
@@ -18,10 +18,8 @@ import { AbstractInputComponent } from '../../abstract-input'
|
||||
templateUrl: './permissions-user.component.html',
|
||||
styleUrls: ['./permissions-user.component.scss'],
|
||||
})
|
||||
export class PermissionsUserComponent extends AbstractInputComponent<
|
||||
PaperlessUser[]
|
||||
> {
|
||||
users: PaperlessUser[]
|
||||
export class PermissionsUserComponent extends AbstractInputComponent<User[]> {
|
||||
users: User[]
|
||||
|
||||
constructor(userService: UserService, settings: SettingsService) {
|
||||
super()
|
||||
|
@@ -10,7 +10,7 @@ import {
|
||||
NG_VALUE_ACCESSOR,
|
||||
} from '@angular/forms'
|
||||
import { SelectComponent } from './select.component'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import {
|
||||
DEFAULT_MATCHING_ALGORITHM,
|
||||
MATCH_ALL,
|
||||
@@ -18,7 +18,7 @@ import {
|
||||
import { NgSelectModule } from '@ng-select/ng-select'
|
||||
import { RouterTestingModule } from '@angular/router/testing'
|
||||
|
||||
const items: PaperlessTag[] = [
|
||||
const items: Tag[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Tag1',
|
||||
|
@@ -5,7 +5,7 @@ import {
|
||||
NG_VALUE_ACCESSOR,
|
||||
} from '@angular/forms'
|
||||
import { TagsComponent } from './tags.component'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
import {
|
||||
DEFAULT_MATCHING_ALGORITHM,
|
||||
MATCH_ALL,
|
||||
@@ -31,7 +31,7 @@ import { PermissionsFormComponent } from '../permissions/permissions-form/permis
|
||||
import { SelectComponent } from '../select/select.component'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
|
||||
const tags: PaperlessTag[] = [
|
||||
const tags: Tag[] = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Tag1',
|
||||
|
@@ -9,7 +9,7 @@ import {
|
||||
} from '@angular/core'
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms'
|
||||
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 { TagService } from 'src/app/services/rest/tag.service'
|
||||
import { EditDialogMode } from '../../edit-dialog/edit-dialog.component'
|
||||
@@ -81,13 +81,13 @@ export class TagsComponent implements OnInit, ControlValueAccessor {
|
||||
horizontal: boolean = false
|
||||
|
||||
@Output()
|
||||
filterDocuments = new EventEmitter<PaperlessTag[]>()
|
||||
filterDocuments = new EventEmitter<Tag[]>()
|
||||
|
||||
@ViewChild('tagSelect') select: NgSelectComponent
|
||||
|
||||
value: number[] = []
|
||||
|
||||
tags: PaperlessTag[] = []
|
||||
tags: Tag[] = []
|
||||
|
||||
public createTagRef: (name) => void
|
||||
|
||||
|
@@ -2,7 +2,7 @@ import { Component, EventEmitter, Input, Output } from '@angular/core'
|
||||
import { FormControl, FormGroup } from '@angular/forms'
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
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'
|
||||
|
||||
@Component({
|
||||
@@ -11,7 +11,7 @@ import { UserService } from 'src/app/services/rest/user.service'
|
||||
styleUrls: ['./permissions-dialog.component.scss'],
|
||||
})
|
||||
export class PermissionsDialogComponent {
|
||||
users: PaperlessUser[]
|
||||
users: User[]
|
||||
private o: ObjectWithPermissions = undefined
|
||||
|
||||
constructor(
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component, EventEmitter, Input, Output } from '@angular/core'
|
||||
import { first } from 'rxjs'
|
||||
import { PaperlessUser } from 'src/app/data/paperless-user'
|
||||
import { User } from 'src/app/data/user'
|
||||
import {
|
||||
PermissionAction,
|
||||
PermissionType,
|
||||
@@ -55,7 +55,7 @@ export class PermissionsFilterDropdownComponent extends ComponentWithPermissions
|
||||
@Output()
|
||||
ownerFilterSet = new EventEmitter<PermissionsSelectionModel>()
|
||||
|
||||
users: PaperlessUser[]
|
||||
users: User[]
|
||||
|
||||
hideUnowned: boolean
|
||||
|
||||
|
@@ -5,7 +5,7 @@ import { PdfViewerComponent } from '../pdf-viewer/pdf-viewer.component'
|
||||
import { By } from '@angular/platform-browser'
|
||||
import { SafeUrlPipe } from 'src/app/pipes/safeurl.pipe'
|
||||
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 { DocumentService } from 'src/app/services/rest/document.service'
|
||||
|
||||
|
@@ -1,6 +1,6 @@
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { PaperlessDocument } from 'src/app/data/paperless-document'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
|
||||
import { Document } from 'src/app/data/document'
|
||||
import { SETTINGS_KEYS } from 'src/app/data/ui-settings'
|
||||
import { DocumentService } from 'src/app/services/rest/document.service'
|
||||
import { SettingsService } from 'src/app/services/settings.service'
|
||||
|
||||
@@ -11,7 +11,7 @@ import { SettingsService } from 'src/app/services/settings.service'
|
||||
})
|
||||
export class PreviewPopupComponent {
|
||||
@Input()
|
||||
document: PaperlessDocument
|
||||
document: Document
|
||||
|
||||
error = false
|
||||
|
||||
|
@@ -10,10 +10,7 @@ import {
|
||||
} from '@angular/core/testing'
|
||||
import { FormsModule, ReactiveFormsModule } from '@angular/forms'
|
||||
import { of, throwError } from 'rxjs'
|
||||
import {
|
||||
PaperlessFileVersion,
|
||||
PaperlessShareLink,
|
||||
} from 'src/app/data/paperless-share-link'
|
||||
import { FileVersion, ShareLink } from 'src/app/data/share-link'
|
||||
import { ShareLinkService } from 'src/app/services/rest/share-link.service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { environment } from 'src/environments/environment'
|
||||
@@ -60,7 +57,7 @@ describe('ShareLinksDropdownComponent', () => {
|
||||
slug: '1234slug',
|
||||
created: now.toISOString(),
|
||||
document: 99,
|
||||
file_version: PaperlessFileVersion.Archive,
|
||||
file_version: FileVersion.Archive,
|
||||
expiration: expiration7days.toISOString(),
|
||||
},
|
||||
{
|
||||
@@ -68,7 +65,7 @@ describe('ShareLinksDropdownComponent', () => {
|
||||
slug: '1234slug',
|
||||
created: now.toISOString(),
|
||||
document: 99,
|
||||
file_version: PaperlessFileVersion.Original,
|
||||
file_version: FileVersion.Original,
|
||||
expiration: null,
|
||||
},
|
||||
])
|
||||
@@ -152,7 +149,7 @@ describe('ShareLinksDropdownComponent', () => {
|
||||
deleteSpy.mockReturnValue(of(true))
|
||||
const refreshSpy = jest.spyOn(component, 'refresh')
|
||||
|
||||
component.delete({ id: 12 } as PaperlessShareLink)
|
||||
component.delete({ id: 12 } as ShareLink)
|
||||
fixture.detectChanges()
|
||||
expect(deleteSpy).toHaveBeenCalledWith({ id: 12 })
|
||||
expect(refreshSpy).toHaveBeenCalled()
|
||||
@@ -178,18 +175,18 @@ describe('ShareLinksDropdownComponent', () => {
|
||||
expect(
|
||||
component.getDaysRemaining({
|
||||
expiration: expiration7days.toISOString(),
|
||||
} as PaperlessShareLink)
|
||||
} as ShareLink)
|
||||
).toEqual('7 days')
|
||||
expect(
|
||||
component.getDaysRemaining({
|
||||
expiration: expiration1day.toISOString(),
|
||||
} as PaperlessShareLink)
|
||||
} as ShareLink)
|
||||
).toEqual('1 day')
|
||||
})
|
||||
|
||||
// coverage
|
||||
it('should support share', () => {
|
||||
const link = { slug: '12345slug' } as PaperlessShareLink
|
||||
const link = { slug: '12345slug' } as ShareLink
|
||||
if (!('share' in navigator))
|
||||
Object.defineProperty(navigator, 'share', { value: (obj: any) => {} })
|
||||
// const navigatorSpy = jest.spyOn(navigator, 'share')
|
||||
|
@@ -1,9 +1,6 @@
|
||||
import { Component, Input, OnInit } from '@angular/core'
|
||||
import { first } from 'rxjs'
|
||||
import {
|
||||
PaperlessShareLink,
|
||||
PaperlessFileVersion,
|
||||
} from 'src/app/data/paperless-share-link'
|
||||
import { ShareLink, FileVersion } from 'src/app/data/share-link'
|
||||
import { ShareLinkService } from 'src/app/services/rest/share-link.service'
|
||||
import { ToastService } from 'src/app/services/toast.service'
|
||||
import { environment } from 'src/environments/environment'
|
||||
@@ -41,7 +38,7 @@ export class ShareLinksDropdownComponent implements OnInit {
|
||||
@Input()
|
||||
hasArchiveVersion: boolean = true
|
||||
|
||||
shareLinks: PaperlessShareLink[]
|
||||
shareLinks: ShareLink[]
|
||||
|
||||
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)
|
||||
return `${apiURL.origin}${apiURL.pathname.replace(/\/api\/$/, '/share/')}${
|
||||
link.slug
|
||||
}`
|
||||
}
|
||||
|
||||
getDaysRemaining(link: PaperlessShareLink): string {
|
||||
getDaysRemaining(link: ShareLink): string {
|
||||
const days: number = Math.round(
|
||||
(Date.parse(link.expiration) - Date.now()) / (1000 * 60 * 60 * 24)
|
||||
)
|
||||
return days === 1 ? $localize`1 day` : $localize`${days} days`
|
||||
}
|
||||
|
||||
copy(link: PaperlessShareLink) {
|
||||
copy(link: ShareLink) {
|
||||
const success = this.clipboard.copy(this.getShareUrl(link))
|
||||
if (success) {
|
||||
this.copied = link.id
|
||||
@@ -107,17 +104,17 @@ export class ShareLinksDropdownComponent implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
canShare(link: PaperlessShareLink): boolean {
|
||||
canShare(link: ShareLink): boolean {
|
||||
return (
|
||||
navigator?.canShare && navigator.canShare({ url: this.getShareUrl(link) })
|
||||
)
|
||||
}
|
||||
|
||||
share(link: PaperlessShareLink) {
|
||||
share(link: ShareLink) {
|
||||
navigator.share({ url: this.getShareUrl(link) })
|
||||
}
|
||||
|
||||
delete(link: PaperlessShareLink) {
|
||||
delete(link: ShareLink) {
|
||||
this.shareLinkService.delete(link).subscribe({
|
||||
next: () => {
|
||||
this.refresh()
|
||||
@@ -138,9 +135,7 @@ export class ShareLinksDropdownComponent implements OnInit {
|
||||
this.shareLinkService
|
||||
.createLinkForDocument(
|
||||
this._documentId,
|
||||
this.useArchiveVersion
|
||||
? PaperlessFileVersion.Archive
|
||||
: PaperlessFileVersion.Original,
|
||||
this.useArchiveVersion ? FileVersion.Archive : FileVersion.Original,
|
||||
expiration
|
||||
)
|
||||
.subscribe({
|
||||
|
@@ -1,9 +1,9 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing'
|
||||
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'
|
||||
|
||||
const tag: PaperlessTag = {
|
||||
const tag: Tag = {
|
||||
id: 1,
|
||||
color: '#ff0000',
|
||||
name: 'Tag1',
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { Component, Input } from '@angular/core'
|
||||
import { PaperlessTag } from 'src/app/data/paperless-tag'
|
||||
import { Tag } from 'src/app/data/tag'
|
||||
|
||||
@Component({
|
||||
selector: 'pngx-tag',
|
||||
@@ -10,7 +10,7 @@ export class TagComponent {
|
||||
constructor() {}
|
||||
|
||||
@Input()
|
||||
tag: PaperlessTag
|
||||
tag: Tag
|
||||
|
||||
@Input()
|
||||
linkTitle: string = ''
|
||||
|
Reference in New Issue
Block a user