diff --git a/docs/setup.rst b/docs/setup.rst index d3290b432..80874820d 100644 --- a/docs/setup.rst +++ b/docs/setup.rst @@ -332,6 +332,12 @@ writing. Windows is not and will never be supported. 3. Optional. Install ``postgresql`` and configure a database, user and password for paperless. If you do not wish to use PostgreSQL, SQLite is available as well. + .. note:: + + On bare-metal installations using SQLite, ensure the + `JSON1 extension `_ is enabled. This is + usually the case, but not always. + 4. Get the release archive from ``_. If you clone the git repo as it is, you also have to compile the front end by yourself. Extract the archive to a place from where you wish to execute it, such as ``/opt/paperless``. diff --git a/src-ui/cypress/fixtures/ui_settings/settings.json b/src-ui/cypress/fixtures/ui_settings/settings.json new file mode 100644 index 000000000..0e844b5e1 --- /dev/null +++ b/src-ui/cypress/fixtures/ui_settings/settings.json @@ -0,0 +1,34 @@ +{ + "user_id": 1, + "username": "admin", + "display_name": "Admin", + "settings": { + "language": "", + "bulk_edit": { + "confirmation_dialogs": true, + "apply_on_close": false + }, + "documentListSize": 50, + "dark_mode": { + "use_system": true, + "enabled": "false", + "thumb_inverted": "true" + }, + "theme": { + "color": "#b198e5" + }, + "document_details": { + "native_pdf_viewer": false + }, + "date_display": { + "date_locale": "", + "date_format": "mediumDate" + }, + "notifications": { + "consumer_new_documents": true, + "consumer_success": true, + "consumer_failed": true, + "consumer_suppress_on_dashboard": true + } + } +} diff --git a/src-ui/cypress/integration/document-detail.spec.ts b/src-ui/cypress/integration/document-detail.spec.ts index 9ff566760..8faf2412c 100644 --- a/src-ui/cypress/integration/document-detail.spec.ts +++ b/src-ui/cypress/integration/document-detail.spec.ts @@ -2,6 +2,9 @@ describe('document-detail', () => { beforeEach(() => { this.modifiedDocuments = [] + cy.intercept('http://localhost:8000/api/ui_settings/', { + fixture: 'ui_settings/settings.json', + }) cy.fixture('documents/documents.json').then((documentsJson) => { cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => { let response = { ...documentsJson } diff --git a/src-ui/cypress/integration/documents-list.spec.ts b/src-ui/cypress/integration/documents-list.spec.ts index 5b923ed2f..169bd333b 100644 --- a/src-ui/cypress/integration/documents-list.spec.ts +++ b/src-ui/cypress/integration/documents-list.spec.ts @@ -3,6 +3,9 @@ describe('documents-list', () => { this.bulkEdits = {} // mock API methods + cy.intercept('http://localhost:8000/api/ui_settings/', { + fixture: 'ui_settings/settings.json', + }) cy.fixture('documents/documents.json').then((documentsJson) => { // bulk edit cy.intercept( diff --git a/src-ui/cypress/integration/manage.spec.ts b/src-ui/cypress/integration/manage.spec.ts index e28556a24..ef7e12723 100644 --- a/src-ui/cypress/integration/manage.spec.ts +++ b/src-ui/cypress/integration/manage.spec.ts @@ -1,5 +1,8 @@ describe('manage', () => { beforeEach(() => { + cy.intercept('http://localhost:8000/api/ui_settings/', { + fixture: 'ui_settings/settings.json', + }) cy.intercept('http://localhost:8000/api/correspondents/*', { fixture: 'correspondents/correspondents.json', }) diff --git a/src-ui/cypress/integration/settings.spec.ts b/src-ui/cypress/integration/settings.spec.ts index 72f9835f2..16e706b63 100644 --- a/src-ui/cypress/integration/settings.spec.ts +++ b/src-ui/cypress/integration/settings.spec.ts @@ -3,45 +3,53 @@ describe('settings', () => { this.modifiedViews = [] // mock API methods - cy.fixture('saved_views/savedviews.json').then((savedViewsJson) => { - // saved views PATCH - cy.intercept( - 'PATCH', - 'http://localhost:8000/api/saved_views/*', - (req) => { - this.modifiedViews.push(req.body) // store this for later - req.reply({ result: 'OK' }) - } - ) + cy.intercept('http://localhost:8000/api/ui_settings/', { + fixture: 'ui_settings/settings.json', + }).then(() => { + cy.fixture('saved_views/savedviews.json').then((savedViewsJson) => { + // saved views PATCH + cy.intercept( + 'PATCH', + 'http://localhost:8000/api/saved_views/*', + (req) => { + this.modifiedViews.push(req.body) // store this for later + req.reply({ result: 'OK' }) + } + ) - cy.intercept('GET', 'http://localhost:8000/api/saved_views/*', (req) => { - let response = { ...savedViewsJson } - if (this.modifiedViews.length) { - response.results = response.results.map((v) => { - if (this.modifiedViews.find((mv) => mv.id == v.id)) - v = this.modifiedViews.find((mv) => mv.id == v.id) - return v - }) - } + cy.intercept( + 'GET', + 'http://localhost:8000/api/saved_views/*', + (req) => { + let response = { ...savedViewsJson } + if (this.modifiedViews.length) { + response.results = response.results.map((v) => { + if (this.modifiedViews.find((mv) => mv.id == v.id)) + v = this.modifiedViews.find((mv) => mv.id == v.id) + return v + }) + } - req.reply(response) - }).as('savedViews') - }) - - cy.fixture('documents/documents.json').then((documentsJson) => { - cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => { - let response = { ...documentsJson } - response = response.results.find((d) => d.id == 1) - req.reply(response) + req.reply(response) + } + ).as('savedViews') }) - }) - cy.intercept('http://localhost:8000/api/documents/1/metadata/', { - fixture: 'documents/1/metadata.json', - }) + cy.fixture('documents/documents.json').then((documentsJson) => { + cy.intercept('GET', 'http://localhost:8000/api/documents/1/', (req) => { + let response = { ...documentsJson } + response = response.results.find((d) => d.id == 1) + req.reply(response) + }) + }) - cy.intercept('http://localhost:8000/api/documents/1/suggestions/', { - fixture: 'documents/1/suggestions.json', + cy.intercept('http://localhost:8000/api/documents/1/metadata/', { + fixture: 'documents/1/metadata.json', + }) + + cy.intercept('http://localhost:8000/api/documents/1/suggestions/', { + fixture: 'documents/1/suggestions.json', + }) }) cy.viewport(1024, 1024) diff --git a/src-ui/messages.xlf b/src-ui/messages.xlf index 0c9ca23e0..ddd284ce4 100644 --- a/src-ui/messages.xlf +++ b/src-ui/messages.xlf @@ -256,21 +256,21 @@ Document added src/app/app.component.ts - 71 + 72 Document was added to paperless. src/app/app.component.ts - 73 + 74 Open document src/app/app.component.ts - 74 + 75 src/app/components/dashboard/widgets/upload-file-widget/upload-file-widget.component.html @@ -281,28 +281,28 @@ Could not add : src/app/app.component.ts - 89 + 90 New document detected src/app/app.component.ts - 103 + 104 Document is being processed by paperless. src/app/app.component.ts - 105 + 106 Initiating upload... src/app/app.component.ts - 140 + 141 @@ -321,7 +321,7 @@ - Logged in as + Logged in as src/app/components/app-frame/app-frame.component.html 34 @@ -368,7 +368,7 @@ src/app/components/document-list/document-list.component.ts - 68 + 69 src/app/components/manage/management-list/management-list.component.html @@ -551,15 +551,15 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 217 + 215 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 255 + 253 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 291 + 289 @@ -942,17 +942,17 @@ - Hello , welcome to Paperless-ngx! + Hello , welcome to Paperless-ngx! src/app/components/dashboard/dashboard.component.ts - 27 + 19 Welcome to Paperless-ngx! src/app/components/dashboard/dashboard.component.ts - 29 + 21 @@ -1095,7 +1095,7 @@ src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 162 + 160 this string is used to separate processing, failed and added on the file upload widget @@ -1458,7 +1458,7 @@ Confirm delete src/app/components/document-detail/document-detail.component.ts - 423 + 421 src/app/components/manage/management-list/management-list.component.ts @@ -1469,28 +1469,28 @@ Do you really want to delete document ""? src/app/components/document-detail/document-detail.component.ts - 424 + 422 The files for this document will be deleted permanently. This operation cannot be undone. src/app/components/document-detail/document-detail.component.ts - 425 + 423 Delete document src/app/components/document-detail/document-detail.component.ts - 427 + 425 Error deleting document: src/app/components/document-detail/document-detail.component.ts - 443 + 441 @@ -1560,25 +1560,25 @@ )"/> src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 97,99 + 95,97 "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 154 + 152 src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 160 + 158 "" and "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 156 + 154 This is for messages like 'modify "tag1" and "tag2"' @@ -1586,7 +1586,7 @@ and "" src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 164,166 + 162,164 this is for messages like 'modify "tag1", "tag2" and "tag3"' @@ -1594,14 +1594,14 @@ Confirm tags assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 181 + 179 This operation will add the tag "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 187 + 185 @@ -1610,14 +1610,14 @@ )"/> to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 192,194 + 190,192 This operation will remove the tag "" from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 200 + 198 @@ -1626,7 +1626,7 @@ )"/> from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 205,207 + 203,205 @@ -1637,77 +1637,77 @@ )"/> on selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 209,213 + 207,211 Confirm correspondent assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 248 + 246 This operation will assign the correspondent "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 250 + 248 This operation will remove the correspondent from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 252 + 250 Confirm document type assignment src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 284 + 282 This operation will assign the document type "" to selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 286 + 284 This operation will remove the document type from selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 288 + 286 Delete confirm src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 309 + 307 This operation will permanently delete selected document(s). src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 310 + 308 This operation cannot be undone. src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 311 + 309 Delete document(s) src/app/components/document-list/bulk-editor/bulk-editor.component.ts - 313 + 311 @@ -1913,14 +1913,14 @@ View "" saved successfully. src/app/components/document-list/document-list.component.ts - 197 + 198 View "" created successfully. src/app/components/document-list/document-list.component.ts - 227 + 228 @@ -2512,21 +2512,28 @@ Settings saved successfully. src/app/components/manage/settings/settings.component.ts - 233 + 238 + + + + An error occurred while saving settings. + + src/app/components/manage/settings/settings.component.ts + 242 Use system language src/app/components/manage/settings/settings.component.ts - 237 + 250 Use date format of display language src/app/components/manage/settings/settings.component.ts - 244 + 257 @@ -2535,7 +2542,7 @@ )"/> src/app/components/manage/settings/settings.component.ts - 264,266 + 277,279 @@ -2853,154 +2860,168 @@ English (US) src/app/services/settings.service.ts - 184 + 136 Belarusian src/app/services/settings.service.ts - 190 + 142 Czech src/app/services/settings.service.ts - 196 + 148 Danish src/app/services/settings.service.ts - 202 + 154 German src/app/services/settings.service.ts - 208 + 160 English (GB) src/app/services/settings.service.ts - 214 + 166 Spanish src/app/services/settings.service.ts - 220 + 172 French src/app/services/settings.service.ts - 226 + 178 Italian src/app/services/settings.service.ts - 232 + 184 Luxembourgish src/app/services/settings.service.ts - 238 + 190 Dutch src/app/services/settings.service.ts - 244 + 196 Polish src/app/services/settings.service.ts - 250 + 202 Portuguese (Brazil) src/app/services/settings.service.ts - 256 + 208 Portuguese src/app/services/settings.service.ts - 262 + 214 Romanian src/app/services/settings.service.ts - 268 + 220 Russian src/app/services/settings.service.ts - 274 + 226 Slovenian src/app/services/settings.service.ts - 280 + 232 Serbian src/app/services/settings.service.ts - 286 + 238 Swedish src/app/services/settings.service.ts - 292 + 244 Turkish src/app/services/settings.service.ts - 298 + 250 Chinese Simplified src/app/services/settings.service.ts - 304 + 256 ISO 8601 src/app/services/settings.service.ts - 321 + 273 + + + + Successfully completed one-time migratration of settings to the database! + + src/app/services/settings.service.ts + 368 + + + + Unable to migrate settings to the database, please try saving manually. + + src/app/services/settings.service.ts + 369 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/app.module.ts b/src-ui/src/app/app.module.ts index e891d217d..0c9d628d0 100644 --- a/src-ui/src/app/app.module.ts +++ b/src-ui/src/app/app.module.ts @@ -1,5 +1,5 @@ import { BrowserModule } from '@angular/platform-browser' -import { NgModule } from '@angular/core' +import { APP_INITIALIZER, NgModule } from '@angular/core' import { AppRoutingModule } from './app-routing.module' import { AppComponent } from './app.component' import { @@ -87,6 +87,7 @@ import localeSr from '@angular/common/locales/sr' import localeSv from '@angular/common/locales/sv' import localeTr from '@angular/common/locales/tr' import localeZh from '@angular/common/locales/zh' +import { SettingsService } from './services/settings.service' registerLocaleData(localeBe) registerLocaleData(localeCs) @@ -109,6 +110,12 @@ registerLocaleData(localeSv) registerLocaleData(localeTr) registerLocaleData(localeZh) +function initializeApp(settings: SettingsService) { + return () => { + return settings.initializeSettings() + } +} + @NgModule({ declarations: [ AppComponent, @@ -174,6 +181,12 @@ registerLocaleData(localeZh) ColorSliderModule, ], providers: [ + { + provide: APP_INITIALIZER, + useFactory: initializeApp, + deps: [SettingsService], + multi: true, + }, DatePipe, CookieService, { diff --git a/src-ui/src/app/components/app-frame/app-frame.component.html b/src-ui/src/app/components/app-frame/app-frame.component.html index 718e2a242..ce9c8993b 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.html +++ b/src-ui/src/app/components/app-frame/app-frame.component.html @@ -21,17 +21,17 @@