Skip to content

A community-supported supercharged document management system: scan, index and archive all your documents

PaperlessUiSettings data object

Michael Shamoon96f86adfb87f
diff --git a/src-ui/src/app/app.component.ts b/src-ui/src/app/app.component.ts
index f8c98fbc7..c7954e3a6 100644
--- a/src-ui/src/app/app.component.ts
+++ b/src-ui/src/app/app.component.ts
@@ -1,4 +1,5 @@
-import { SettingsService, SETTINGS_KEYS } from './services/settings.service'
+import { SettingsService } from './services/settings.service'
+import { SETTINGS_KEYS } from './data/paperless-uisettings'
import { Component, OnDestroy, OnInit } from '@angular/core'
import { Router } from '@angular/router'
import { Subscription } from 'rxjs'
diff --git a/src-ui/src/app/components/document-detail/document-detail.component.ts b/src-ui/src/app/components/document-detail/document-detail.component.ts
index 6f1614e5f..992f5ff06 100644
--- a/src-ui/src/app/components/document-detail/document-detail.component.ts
+++ b/src-ui/src/app/components/document-detail/document-detail.component.ts
@@ -18,10 +18,7 @@ import { DocumentTypeEditDialogComponent } from '../common/edit-dialog/document-
import { PDFDocumentProxy } from 'ng2-pdf-viewer'
import { ToastService } from 'src/app/services/toast.service'
import { TextComponent } from '../common/input/text/text.component'
-import {
- SettingsService,
- SETTINGS_KEYS,
-} from 'src/app/services/settings.service'
+import { SettingsService } from 'src/app/services/settings.service'
import { dirtyCheck, DirtyComponent } from '@ngneat/dirty-check-forms'
import { Observable, Subject, BehaviorSubject } from 'rxjs'
import {
@@ -36,6 +33,7 @@ import { PaperlessDocumentSuggestions } from 'src/app/data/paperless-document-su
import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
import { normalizeDateStr } from 'src/app/utils/date'
import { QueryParamsService } from 'src/app/services/query-params.service'
+import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
@Component({
selector: 'app-document-detail',
diff --git a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
index c451f851e..b17af67eb 100644
--- a/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
+++ b/src-ui/src/app/components/document-list/bulk-editor/bulk-editor.component.ts
@@ -19,12 +19,10 @@ import {
} from '../../common/filterable-dropdown/filterable-dropdown.component'
import { ToggleableItemState } from '../../common/filterable-dropdown/toggleable-dropdown-button/toggleable-dropdown-button.component'
import { MatchingModel } from 'src/app/data/matching-model'
-import {
- SettingsService,
- SETTINGS_KEYS,
-} from 'src/app/services/settings.service'
+import { SettingsService } from 'src/app/services/settings.service'
import { ToastService } from 'src/app/services/toast.service'
import { saveAs } from 'file-saver'
+import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
@Component({
selector: 'app-bulk-editor',
diff --git a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts
index 061a0e681..9b9e20b8c 100644
--- a/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts
+++ b/src-ui/src/app/components/document-list/document-card-large/document-card-large.component.ts
@@ -8,12 +8,12 @@ import {
} from '@angular/core'
import { PaperlessDocument } from 'src/app/data/paperless-document'
import { DocumentService } from 'src/app/services/rest/document.service'
-import {
- SettingsService,
- SETTINGS_KEYS,
-} from 'src/app/services/settings.service'
+import { SettingsService } from 'src/app/services/settings.service'
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
+import { DocumentListViewService } from 'src/app/services/document-list-view.service'
+import { FILTER_FULLTEXT_MORELIKE } from 'src/app/data/filter-rule-type'
+import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
@Component({
selector: 'app-document-card-large',
diff --git a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts
index c166b42cb..06e2fe967 100644
--- a/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts
+++ b/src-ui/src/app/components/document-list/document-card-small/document-card-small.component.ts
@@ -9,12 +9,10 @@ import {
import { map } from 'rxjs/operators'
import { PaperlessDocument } from 'src/app/data/paperless-document'
import { DocumentService } from 'src/app/services/rest/document.service'
-import {
- SettingsService,
- SETTINGS_KEYS,
-} from 'src/app/services/settings.service'
+import { SettingsService } from 'src/app/services/settings.service'
import { NgbPopover } from '@ng-bootstrap/ng-bootstrap'
import { OpenDocumentsService } from 'src/app/services/open-documents.service'
+import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
@Component({
selector: 'app-document-card-small',
diff --git a/src-ui/src/app/components/manage/settings/settings.component.ts b/src-ui/src/app/components/manage/settings/settings.component.ts
index ce999c14c..d9877d281 100644
--- a/src-ui/src/app/components/manage/settings/settings.component.ts
+++ b/src-ui/src/app/components/manage/settings/settings.component.ts
@@ -13,11 +13,11 @@ import { SavedViewService } from 'src/app/services/rest/saved-view.service'
import {
LanguageOption,
SettingsService,
- SETTINGS_KEYS,
} from 'src/app/services/settings.service'
import { ToastService } from 'src/app/services/toast.service'
import { dirtyCheck, DirtyComponent } from '@ngneat/dirty-check-forms'
import { Observable, Subscription, BehaviorSubject, first } from 'rxjs'
+import { SETTINGS_KEYS } from 'src/app/data/paperless-uisettings'
@Component({
selector: 'app-settings',
diff --git a/src-ui/src/app/data/paperless-uisettings.ts b/src-ui/src/app/data/paperless-uisettings.ts
new file mode 100644
index 000000000..75aec2a51
--- /dev/null
+++ b/src-ui/src/app/data/paperless-uisettings.ts
@@ -0,0 +1,117 @@
+export interface PaperlessUiSettings {
+ user_id: number
+
+ username: string
+
+ display_name: string
+
+ settings: Object
+}
+
+export interface PaperlessUiSetting {
+ key: string
+ type: string
+ default: any
+}
+
+export const SETTINGS_KEYS = {
+ LANGUAGE: 'language',
+ // maintain old general-settings: for backwards compatibility
+ BULK_EDIT_CONFIRMATION_DIALOGS:
+ 'general-settings:bulk-edit:confirmation-dialogs',
+ BULK_EDIT_APPLY_ON_CLOSE: 'general-settings:bulk-edit:apply-on-close',
+ DOCUMENT_LIST_SIZE: 'general-settings:documentListSize',
+ DARK_MODE_USE_SYSTEM: 'general-settings:dark-mode:use-system',
+ DARK_MODE_ENABLED: 'general-settings:dark-mode:enabled',
+ DARK_MODE_THUMB_INVERTED: 'general-settings:dark-mode:thumb-inverted',
+ THEME_COLOR: 'general-settings:theme:color',
+ USE_NATIVE_PDF_VIEWER: 'general-settings:document-details:native-pdf-viewer',
+ DATE_LOCALE: 'general-settings:date-display:date-locale',
+ DATE_FORMAT: 'general-settings:date-display:date-format',
+ NOTIFICATIONS_CONSUMER_NEW_DOCUMENT:
+ 'general-settings:notifications:consumer-new-documents',
+ NOTIFICATIONS_CONSUMER_SUCCESS:
+ 'general-settings:notifications:consumer-success',
+ NOTIFICATIONS_CONSUMER_FAILED:
+ 'general-settings:notifications:consumer-failed',
+ NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD:
+ 'general-settings:notifications:consumer-suppress-on-dashboard',
+}
+
+export const SETTINGS: PaperlessUiSetting[] = [
+ {
+ key: SETTINGS_KEYS.LANGUAGE,
+ type: 'string',
+ default: '',
+ },
+ {
+ key: SETTINGS_KEYS.BULK_EDIT_CONFIRMATION_DIALOGS,
+ type: 'boolean',
+ default: true,
+ },
+ {
+ key: SETTINGS_KEYS.BULK_EDIT_APPLY_ON_CLOSE,
+ type: 'boolean',
+ default: false,
+ },
+ {
+ key: SETTINGS_KEYS.DOCUMENT_LIST_SIZE,
+ type: 'number',
+ default: 50,
+ },
+ {
+ key: SETTINGS_KEYS.DARK_MODE_USE_SYSTEM,
+ type: 'boolean',
+ default: true,
+ },
+ {
+ key: SETTINGS_KEYS.DARK_MODE_ENABLED,
+ type: 'boolean',
+ default: false,
+ },
+ {
+ key: SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED,
+ type: 'boolean',
+ default: true,
+ },
+ {
+ key: SETTINGS_KEYS.THEME_COLOR,
+ type: 'string',
+ default: '',
+ },
+ {
+ key: SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER,
+ type: 'boolean',
+ default: false,
+ },
+ {
+ key: SETTINGS_KEYS.DATE_LOCALE,
+ type: 'string',
+ default: '',
+ },
+ {
+ key: SETTINGS_KEYS.DATE_FORMAT,
+ type: 'string',
+ default: 'mediumDate',
+ },
+ {
+ key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT,
+ type: 'boolean',
+ default: true,
+ },
+ {
+ key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUCCESS,
+ type: 'boolean',
+ default: true,
+ },
+ {
+ key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED,
+ type: 'boolean',
+ default: true,
+ },
+ {
+ key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD,
+ type: 'boolean',
+ default: true,
+ },
+]
diff --git a/src-ui/src/app/pipes/custom-date.pipe.ts b/src-ui/src/app/pipes/custom-date.pipe.ts
index bd4833d04..c9cfc2876 100644
--- a/src-ui/src/app/pipes/custom-date.pipe.ts
+++ b/src-ui/src/app/pipes/custom-date.pipe.ts
@@ -1,6 +1,7 @@
import { DatePipe } from '@angular/common'
import { Inject, LOCALE_ID, Pipe, PipeTransform } from '@angular/core'
-import { SettingsService, SETTINGS_KEYS } from '../services/settings.service'
+import { SETTINGS_KEYS } from '../data/paperless-uisettings'
+import { SettingsService } from '../services/settings.service'
import { normalizeDateStr } from '../utils/date'
const FORMAT_TO_ISO_FORMAT = {
diff --git a/src-ui/src/app/services/document-list-view.service.ts b/src-ui/src/app/services/document-list-view.service.ts
index 99349d37f..471fc7944 100644
--- a/src-ui/src/app/services/document-list-view.service.ts
+++ b/src-ui/src/app/services/document-list-view.service.ts
@@ -8,9 +8,10 @@ import {
} from '../data/filter-rule'
import { PaperlessDocument } from '../data/paperless-document'
import { PaperlessSavedView } from '../data/paperless-saved-view'
+import { SETTINGS_KEYS } from '../data/paperless-uisettings'
import { DOCUMENT_LIST_SERVICE } from '../data/storage-keys'
import { DocumentService, DOCUMENT_SORT_FIELDS } from './rest/document.service'
-import { SettingsService, SETTINGS_KEYS } from './settings.service'
+import { SettingsService } from './settings.service'
/**
* Captures the current state of the list view.
diff --git a/src-ui/src/app/services/settings.service.ts b/src-ui/src/app/services/settings.service.ts
index 81b15e1b0..aeab14df4 100644
--- a/src-ui/src/app/services/settings.service.ts
+++ b/src-ui/src/app/services/settings.service.ts
@@ -17,15 +17,13 @@ import {
hexToHsl,
} from 'src/app/utils/color'
import { environment } from 'src/environments/environment'
-import { Results } from '../data/results'
+import {
+ PaperlessUiSettings,
+ SETTINGS,
+ SETTINGS_KEYS,
+} from '../data/paperless-uisettings'
import { ToastService } from './toast.service'
-export interface PaperlessSettings {
- key: string
- type: string
- default: any
-}
-
export interface LanguageOption {
code: string
name: string
@@ -37,108 +35,6 @@ export interface LanguageOption {
dateInputFormat?: string
}
-export const SETTINGS_KEYS = {
- LANGUAGE: 'language',
- // maintain old general-settings: for backwards compatibility
- BULK_EDIT_CONFIRMATION_DIALOGS:
- 'general-settings:bulk-edit:confirmation-dialogs',
- BULK_EDIT_APPLY_ON_CLOSE: 'general-settings:bulk-edit:apply-on-close',
- DOCUMENT_LIST_SIZE: 'general-settings:documentListSize',
- DARK_MODE_USE_SYSTEM: 'general-settings:dark-mode:use-system',
- DARK_MODE_ENABLED: 'general-settings:dark-mode:enabled',
- DARK_MODE_THUMB_INVERTED: 'general-settings:dark-mode:thumb-inverted',
- THEME_COLOR: 'general-settings:theme:color',
- USE_NATIVE_PDF_VIEWER: 'general-settings:document-details:native-pdf-viewer',
- DATE_LOCALE: 'general-settings:date-display:date-locale',
- DATE_FORMAT: 'general-settings:date-display:date-format',
- NOTIFICATIONS_CONSUMER_NEW_DOCUMENT:
- 'general-settings:notifications:consumer-new-documents',
- NOTIFICATIONS_CONSUMER_SUCCESS:
- 'general-settings:notifications:consumer-success',
- NOTIFICATIONS_CONSUMER_FAILED:
- 'general-settings:notifications:consumer-failed',
- NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD:
- 'general-settings:notifications:consumer-suppress-on-dashboard',
-}
-
-const SETTINGS: PaperlessSettings[] = [
- {
- key: SETTINGS_KEYS.LANGUAGE,
- type: 'string',
- default: '',
- },
- {
- key: SETTINGS_KEYS.BULK_EDIT_CONFIRMATION_DIALOGS,
- type: 'boolean',
- default: true,
- },
- {
- key: SETTINGS_KEYS.BULK_EDIT_APPLY_ON_CLOSE,
- type: 'boolean',
- default: false,
- },
- {
- key: SETTINGS_KEYS.DOCUMENT_LIST_SIZE,
- type: 'number',
- default: 50,
- },
- {
- key: SETTINGS_KEYS.DARK_MODE_USE_SYSTEM,
- type: 'boolean',
- default: true,
- },
- {
- key: SETTINGS_KEYS.DARK_MODE_ENABLED,
- type: 'boolean',
- default: false,
- },
- {
- key: SETTINGS_KEYS.DARK_MODE_THUMB_INVERTED,
- type: 'boolean',
- default: true,
- },
- {
- key: SETTINGS_KEYS.THEME_COLOR,
- type: 'string',
- default: '',
- },
- {
- key: SETTINGS_KEYS.USE_NATIVE_PDF_VIEWER,
- type: 'boolean',
- default: false,
- },
- {
- key: SETTINGS_KEYS.DATE_LOCALE,
- type: 'string',
- default: '',
- },
- {
- key: SETTINGS_KEYS.DATE_FORMAT,
- type: 'string',
- default: 'mediumDate',
- },
- {
- key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_NEW_DOCUMENT,
- type: 'boolean',
- default: true,
- },
- {
- key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUCCESS,
- type: 'boolean',
- default: true,
- },
- {
- key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_FAILED,
- type: 'boolean',
- default: true,
- },
- {
- key: SETTINGS_KEYS.NOTIFICATIONS_CONSUMER_SUPPRESS_ON_DASHBOARD,
- type: 'boolean',
- default: true,
- },
-]
-
@Injectable({
providedIn: 'root',
})
@@ -161,10 +57,10 @@ export class SettingsService {
}
// this is called by the app initializer in app.module
- public initializeSettings(): Observable<Results<any>> {
- let settings$ = this.http.get<Results<any>>(this.baseUrl)
- settings$.pipe(first()).subscribe((response) => {
- Object.assign(this.settings, response['settings'])
+ public initializeSettings(): Observable<PaperlessUiSettings> {
+ let settings$ = this.http.get<PaperlessUiSettings>(this.baseUrl)
+ settings$.pipe(first()).subscribe((uisettings) => {
+ Object.assign(this.settings, uisettings.settings)
this.maybeMigrateSettings()
})
return settings$