Prettier code cleanup for .ts files

See #182
This commit is contained in:
Michael Shamoon
2022-03-11 10:53:32 -08:00
parent f8c8161a3e
commit f34202a82a
159 changed files with 3882 additions and 2716 deletions

View File

@@ -27,40 +27,160 @@ export const FILTER_FULLTEXT_QUERY = 20
export const FILTER_FULLTEXT_MORELIKE = 21
export const FILTER_RULE_TYPES: FilterRuleType[] = [
{
id: FILTER_TITLE,
filtervar: 'title__icontains',
datatype: 'string',
multi: false,
default: '',
},
{
id: FILTER_CONTENT,
filtervar: 'content__icontains',
datatype: 'string',
multi: false,
default: '',
},
{id: FILTER_TITLE, filtervar: "title__icontains", datatype: "string", multi: false, default: ""},
{id: FILTER_CONTENT, filtervar: "content__icontains", datatype: "string", multi: false, default: ""},
{
id: FILTER_ASN,
filtervar: 'archive_serial_number',
datatype: 'number',
multi: false,
},
{id: FILTER_ASN, filtervar: "archive_serial_number", datatype: "number", multi: false},
{
id: FILTER_CORRESPONDENT,
filtervar: 'correspondent__id',
isnull_filtervar: 'correspondent__isnull',
datatype: 'correspondent',
multi: false,
},
{
id: FILTER_DOCUMENT_TYPE,
filtervar: 'document_type__id',
isnull_filtervar: 'document_type__isnull',
datatype: 'document_type',
multi: false,
},
{id: FILTER_CORRESPONDENT, filtervar: "correspondent__id", isnull_filtervar: "correspondent__isnull", datatype: "correspondent", multi: false},
{id: FILTER_DOCUMENT_TYPE, filtervar: "document_type__id", isnull_filtervar: "document_type__isnull", datatype: "document_type", multi: false},
{
id: FILTER_IS_IN_INBOX,
filtervar: 'is_in_inbox',
datatype: 'boolean',
multi: false,
default: true,
},
{
id: FILTER_HAS_TAGS_ALL,
filtervar: 'tags__id__all',
datatype: 'tag',
multi: true,
},
{
id: FILTER_HAS_TAGS_ANY,
filtervar: 'tags__id__in',
datatype: 'tag',
multi: true,
},
{
id: FILTER_DOES_NOT_HAVE_TAG,
filtervar: 'tags__id__none',
datatype: 'tag',
multi: true,
},
{
id: FILTER_HAS_ANY_TAG,
filtervar: 'is_tagged',
datatype: 'boolean',
multi: false,
default: true,
},
{id: FILTER_IS_IN_INBOX, filtervar: "is_in_inbox", datatype: "boolean", multi: false, default: true},
{id: FILTER_HAS_TAGS_ALL, filtervar: "tags__id__all", datatype: "tag", multi: true},
{id: FILTER_HAS_TAGS_ANY, filtervar: "tags__id__in", datatype: "tag", multi: true},
{id: FILTER_DOES_NOT_HAVE_TAG, filtervar: "tags__id__none", datatype: "tag", multi: true},
{id: FILTER_HAS_ANY_TAG, filtervar: "is_tagged", datatype: "boolean", multi: false, default: true},
{
id: FILTER_CREATED_BEFORE,
filtervar: 'created__date__lt',
datatype: 'date',
multi: false,
},
{
id: FILTER_CREATED_AFTER,
filtervar: 'created__date__gt',
datatype: 'date',
multi: false,
},
{id: FILTER_CREATED_BEFORE, filtervar: "created__date__lt", datatype: "date", multi: false},
{id: FILTER_CREATED_AFTER, filtervar: "created__date__gt", datatype: "date", multi: false},
{
id: FILTER_CREATED_YEAR,
filtervar: 'created__year',
datatype: 'number',
multi: false,
},
{
id: FILTER_CREATED_MONTH,
filtervar: 'created__month',
datatype: 'number',
multi: false,
},
{
id: FILTER_CREATED_DAY,
filtervar: 'created__day',
datatype: 'number',
multi: false,
},
{id: FILTER_CREATED_YEAR, filtervar: "created__year", datatype: "number", multi: false},
{id: FILTER_CREATED_MONTH, filtervar: "created__month", datatype: "number", multi: false},
{id: FILTER_CREATED_DAY, filtervar: "created__day", datatype: "number", multi: false},
{
id: FILTER_ADDED_BEFORE,
filtervar: 'added__date__lt',
datatype: 'date',
multi: false,
},
{
id: FILTER_ADDED_AFTER,
filtervar: 'added__date__gt',
datatype: 'date',
multi: false,
},
{id: FILTER_ADDED_BEFORE, filtervar: "added__date__lt", datatype: "date", multi: false},
{id: FILTER_ADDED_AFTER, filtervar: "added__date__gt", datatype: "date", multi: false},
{
id: FILTER_MODIFIED_BEFORE,
filtervar: 'modified__date__lt',
datatype: 'date',
multi: false,
},
{
id: FILTER_MODIFIED_AFTER,
filtervar: 'modified__date__gt',
datatype: 'date',
multi: false,
},
{
id: FILTER_ASN_ISNULL,
filtervar: 'archive_serial_number__isnull',
datatype: 'boolean',
multi: false,
},
{id: FILTER_MODIFIED_BEFORE, filtervar: "modified__date__lt", datatype: "date", multi: false},
{id: FILTER_MODIFIED_AFTER, filtervar: "modified__date__gt", datatype: "date", multi: false},
{id: FILTER_ASN_ISNULL, filtervar: "archive_serial_number__isnull", datatype: "boolean", multi: false},
{
id: FILTER_TITLE_CONTENT,
filtervar: 'title_content',
datatype: 'string',
multi: false,
},
{id: FILTER_TITLE_CONTENT, filtervar: "title_content", datatype: "string", multi: false},
{
id: FILTER_FULLTEXT_QUERY,
filtervar: 'query',
datatype: 'string',
multi: false,
},
{id: FILTER_FULLTEXT_QUERY, filtervar: "query", datatype: "string", multi: false},
{id: FILTER_FULLTEXT_MORELIKE, filtervar: "more_like_id", datatype: "number", multi: false},
{
id: FILTER_FULLTEXT_MORELIKE,
filtervar: 'more_like_id',
datatype: 'number',
multi: false,
},
]
export interface FilterRuleType {

View File

@@ -1,10 +1,13 @@
import { FILTER_FULLTEXT_MORELIKE, FILTER_FULLTEXT_QUERY } from "./filter-rule-type"
import {
FILTER_FULLTEXT_MORELIKE,
FILTER_FULLTEXT_QUERY,
} from './filter-rule-type'
export function cloneFilterRules(filterRules: FilterRule[]): FilterRule[] {
if (filterRules) {
let newRules: FilterRule[] = []
for (let rule of filterRules) {
newRules.push({rule_type: rule.rule_type, value: rule.value})
newRules.push({ rule_type: rule.rule_type, value: rule.value })
}
return newRules
} else {
@@ -13,7 +16,13 @@ export function cloneFilterRules(filterRules: FilterRule[]): FilterRule[] {
}
export function isFullTextFilterRule(filterRules: FilterRule[]): boolean {
return filterRules.find(r => r.rule_type == FILTER_FULLTEXT_QUERY || r.rule_type == FILTER_FULLTEXT_MORELIKE) != null
return (
filterRules.find(
(r) =>
r.rule_type == FILTER_FULLTEXT_QUERY ||
r.rule_type == FILTER_FULLTEXT_MORELIKE
) != null
)
}
export interface FilterRule {

View File

@@ -1,5 +1,4 @@
import { ObjectWithId } from './object-with-id';
import { ObjectWithId } from './object-with-id'
export const MATCH_ANY = 1
export const MATCH_ALL = 2
@@ -9,26 +8,48 @@ export const MATCH_FUZZY = 5
export const MATCH_AUTO = 6
export const MATCHING_ALGORITHMS = [
{id: MATCH_ANY, shortName: $localize`Any word`, name: $localize`Any: Document contains any of these words (space separated)`},
{id: MATCH_ALL, shortName: $localize`All words`, name: $localize`All: Document contains all of these words (space separated)`},
{id: MATCH_LITERAL, shortName: $localize`Exact match`, name: $localize`Exact: Document contains this string`},
{id: MATCH_REGEX, shortName: $localize`Regular expression`, name: $localize`Regular expression: Document matches this regular expression`},
{id: MATCH_FUZZY, shortName: $localize`Fuzzy word`, name: $localize`Fuzzy: Document contains a word similar to this word`},
{id: MATCH_AUTO, shortName: $localize`Automatic`, name: $localize`Auto: Learn matching automatically`},
{
id: MATCH_ANY,
shortName: $localize`Any word`,
name: $localize`Any: Document contains any of these words (space separated)`,
},
{
id: MATCH_ALL,
shortName: $localize`All words`,
name: $localize`All: Document contains all of these words (space separated)`,
},
{
id: MATCH_LITERAL,
shortName: $localize`Exact match`,
name: $localize`Exact: Document contains this string`,
},
{
id: MATCH_REGEX,
shortName: $localize`Regular expression`,
name: $localize`Regular expression: Document matches this regular expression`,
},
{
id: MATCH_FUZZY,
shortName: $localize`Fuzzy word`,
name: $localize`Fuzzy: Document contains a word similar to this word`,
},
{
id: MATCH_AUTO,
shortName: $localize`Automatic`,
name: $localize`Auto: Learn matching automatically`,
},
]
export interface MatchingModel extends ObjectWithId {
name?: string
name?: string
slug?: string
slug?: string
match?: string
match?: string
matching_algorithm?: number
matching_algorithm?: number
is_insensitive?: boolean
document_count?: number
is_insensitive?: boolean
document_count?: number
}

View File

@@ -1,5 +1,3 @@
export interface ObjectWithId {
id?: number
id?: number
}

View File

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

View File

@@ -1,5 +1,4 @@
export interface PaperlessDocumentMetadata {
original_checksum?: string
archived_checksum?: string
@@ -9,5 +8,4 @@ export interface PaperlessDocumentMetadata {
media_filename?: string
has_archive_version?: boolean
}

View File

@@ -1,9 +1,7 @@
export interface PaperlessDocumentSuggestions {
tags?: number[]
correspondents?: number[]
document_types?: number[]
}

View File

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

View File

@@ -5,50 +5,46 @@ import { PaperlessDocumentType } from './paperless-document-type'
import { Observable } from 'rxjs'
export interface SearchHit {
score?: number
rank?: number
highlights?: string
}
export interface PaperlessDocument extends ObjectWithId {
correspondent$?: Observable<PaperlessCorrespondent>
correspondent$?: Observable<PaperlessCorrespondent>
correspondent?: number
correspondent?: number
document_type$?: Observable<PaperlessDocumentType>
document_type$?: Observable<PaperlessDocumentType>
document_type?: number
document_type?: number
title?: string
title?: string
content?: string
content?: string
file_type?: string
file_type?: string
tags$?: Observable<PaperlessTag[]>
tags$?: Observable<PaperlessTag[]>
tags?: number[]
tags?: number[]
checksum?: string
checksum?: string
created?: Date
created?: Date
modified?: Date
modified?: Date
added?: Date
added?: Date
file_name?: string
file_name?: string
download_url?: string
download_url?: string
thumbnail_url?: string
thumbnail_url?: string
archive_serial_number?: number
__search_hit__?: SearchHit
archive_serial_number?: number
__search_hit__?: SearchHit
}

View File

@@ -1,8 +1,7 @@
import { FilterRule } from './filter-rule';
import { ObjectWithId } from './object-with-id';
import { FilterRule } from './filter-rule'
import { ObjectWithId } from './object-with-id'
export interface PaperlessSavedView extends ObjectWithId {
name?: string
show_on_dashboard?: boolean
@@ -14,5 +13,4 @@ export interface PaperlessSavedView extends ObjectWithId {
sort_reverse: boolean
filter_rules: FilterRule[]
}

View File

@@ -1,11 +1,9 @@
import { MatchingModel } from "./matching-model";
import { MatchingModel } from './matching-model'
export interface PaperlessTag extends MatchingModel {
color?: string
color?: string
text_color?: string
is_inbox_tag?: boolean
text_color?: string
is_inbox_tag?: boolean
}

View File

@@ -1,7 +1,5 @@
export interface Results<T> {
count: number
results: T[]
}

View File

@@ -1,7 +1,7 @@
export const OPEN_DOCUMENT_SERVICE = {
DOCUMENTS: 'open-documents-service:openDocuments'
DOCUMENTS: 'open-documents-service:openDocuments',
}
export const DOCUMENT_LIST_SERVICE = {
CURRENT_VIEW_CONFIG: 'document-list-service:currentViewConfig'
CURRENT_VIEW_CONFIG: 'document-list-service:currentViewConfig',
}

View File

@@ -1,5 +1,4 @@
export interface WebsocketConsumerStatusMessage {
filename?: string
task_id?: string
current_progress?: number
@@ -7,5 +6,4 @@ export interface WebsocketConsumerStatusMessage {
status?: string
message?: string
document_id: number
}