-
+
@@ -71,4 +84,4 @@
-
\ No newline at end of file
+
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 bec85e039..acb456f1c 100644
--- a/src-ui/src/app/components/manage/settings/settings.component.ts
+++ b/src-ui/src/app/components/manage/settings/settings.component.ts
@@ -1,10 +1,11 @@
-import { Component, OnInit } from '@angular/core';
+import { Component, OnInit, Renderer2 } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { PaperlessSavedView } from 'src/app/data/paperless-saved-view';
import { GENERAL_SETTINGS } from 'src/app/data/storage-keys';
import { DocumentListViewService } from 'src/app/services/document-list-view.service';
import { SavedViewService } from 'src/app/services/rest/saved-view.service';
import { Toast, ToastService } from 'src/app/services/toast.service';
+import { AppViewService } from 'src/app/services/app-view.service';
@Component({
selector: 'app-settings',
@@ -17,17 +18,24 @@ export class SettingsComponent implements OnInit {
settingsForm = new FormGroup({
'documentListItemPerPage': new FormControl(+localStorage.getItem(GENERAL_SETTINGS.DOCUMENT_LIST_SIZE) || GENERAL_SETTINGS.DOCUMENT_LIST_SIZE_DEFAULT),
+ 'darkModeUseSystem': new FormControl(
+ localStorage.getItem(GENERAL_SETTINGS.DARK_MODE_USE_SYSTEM) == undefined ? GENERAL_SETTINGS.DARK_MODE_USE_SYSTEM_DEFAULT : JSON.parse(localStorage.getItem(GENERAL_SETTINGS.DARK_MODE_USE_SYSTEM))
+ ),
+ 'darkModeEnabled': new FormControl(
+ localStorage.getItem(GENERAL_SETTINGS.DARK_MODE_ENABLED) == undefined ? GENERAL_SETTINGS.DARK_MODE_ENABLED_DEFAULT : JSON.parse(localStorage.getItem(GENERAL_SETTINGS.DARK_MODE_ENABLED))
+ ),
'savedViews': this.savedViewGroup
})
+ savedViews: PaperlessSavedView[]
+
constructor(
public savedViewService: SavedViewService,
private documentListViewService: DocumentListViewService,
- private toastService: ToastService
+ private toastService: ToastService,
+ private appViewService: AppViewService
) { }
- savedViews: PaperlessSavedView[]
-
ngOnInit() {
this.savedViewService.listAll().subscribe(r => {
this.savedViews = r.results
@@ -50,9 +58,20 @@ export class SettingsComponent implements OnInit {
})
}
+ toggleDarkModeSetting() {
+ if (this.settingsForm.value.darkModeUseSystem) {
+ (this.settingsForm.controls.darkModeEnabled as FormControl).disable()
+ } else {
+ (this.settingsForm.controls.darkModeEnabled as FormControl).enable()
+ }
+ }
+
private saveLocalSettings() {
localStorage.setItem(GENERAL_SETTINGS.DOCUMENT_LIST_SIZE, this.settingsForm.value.documentListItemPerPage)
+ localStorage.setItem(GENERAL_SETTINGS.DARK_MODE_USE_SYSTEM, this.settingsForm.value.darkModeUseSystem)
+ localStorage.setItem(GENERAL_SETTINGS.DARK_MODE_ENABLED, (this.settingsForm.value.darkModeEnabled == true).toString())
this.documentListViewService.updatePageSize()
+ this.appViewService.updateDarkModeSettings()
this.toastService.showToast(Toast.make("Information", $localize`Settings saved successfully.`))
}
diff --git a/src-ui/src/app/data/storage-keys.ts b/src-ui/src/app/data/storage-keys.ts
index 13b41d4a7..057d68d70 100644
--- a/src-ui/src/app/data/storage-keys.ts
+++ b/src-ui/src/app/data/storage-keys.ts
@@ -8,5 +8,9 @@ export const DOCUMENT_LIST_SERVICE = {
export const GENERAL_SETTINGS = {
DOCUMENT_LIST_SIZE: 'general-settings:documentListSize',
- DOCUMENT_LIST_SIZE_DEFAULT: 50
-}
\ No newline at end of file
+ DOCUMENT_LIST_SIZE_DEFAULT: 50,
+ DARK_MODE_USE_SYSTEM: 'general-settings:darkModeUseSystem',
+ DARK_MODE_USE_SYSTEM_DEFAULT: true,
+ DARK_MODE_ENABLED: 'general-settings:darkModeEnabled',
+ DARK_MODE_ENABLED_DEFAULT: false
+}
diff --git a/src-ui/src/app/services/app-view.service.spec.ts b/src-ui/src/app/services/app-view.service.spec.ts
new file mode 100644
index 000000000..fc44ed3a4
--- /dev/null
+++ b/src-ui/src/app/services/app-view.service.spec.ts
@@ -0,0 +1,16 @@
+import { TestBed } from '@angular/core/testing';
+
+import { AppViewService } from './app-view.service';
+
+describe('AppViewService', () => {
+ let service: AppViewService;
+
+ beforeEach(() => {
+ TestBed.configureTestingModule({});
+ service = TestBed.inject(AppViewService);
+ });
+
+ it('should be created', () => {
+ expect(service).toBeTruthy();
+ });
+});
diff --git a/src-ui/src/app/services/app-view.service.ts b/src-ui/src/app/services/app-view.service.ts
new file mode 100644
index 000000000..c6faa5603
--- /dev/null
+++ b/src-ui/src/app/services/app-view.service.ts
@@ -0,0 +1,29 @@
+import { Inject, Injectable, Renderer2, RendererFactory2 } from '@angular/core';
+import { DOCUMENT } from '@angular/common';
+import { GENERAL_SETTINGS } from 'src/app/data/storage-keys';
+
+@Injectable({
+ providedIn: 'root'
+})
+export class AppViewService {
+ private renderer: Renderer2;
+
+ constructor(rendererFactory: RendererFactory2, @Inject(DOCUMENT) private document) {
+ this.renderer = rendererFactory.createRenderer(null, null);
+ }
+
+ updateDarkModeSettings() {
+ let darkModeUseSystem = JSON.parse(localStorage.getItem(GENERAL_SETTINGS.DARK_MODE_USE_SYSTEM)) && GENERAL_SETTINGS.DARK_MODE_USE_SYSTEM_DEFAULT
+ let darkModeEnabled = JSON.parse(localStorage.getItem(GENERAL_SETTINGS.DARK_MODE_ENABLED)) || GENERAL_SETTINGS.DARK_MODE_ENABLED_DEFAULT
+
+ if (darkModeUseSystem) {
+ this.renderer.addClass(this.document.body, 'dark-mode-preferred')
+ this.renderer.removeClass(this.document.body, 'dark-mode')
+ } else {
+ this.renderer.removeClass(this.document.body, 'dark-mode-preferred')
+ darkModeEnabled ? this.renderer.addClass(this.document.body, 'dark-mode') : this.renderer.removeClass(this.document.body, 'dark-mode')
+ }
+
+ }
+
+}
From 28b7c3c20867e97eae9a3d9ff4fc04a66d1cef7a Mon Sep 17 00:00:00 2001
From: Michael Shamoon <4887959+nikonratm@users.noreply.github.com>
Date: Sun, 27 Dec 2020 23:05:34 -0800
Subject: [PATCH 002/199] Logo svg inline
---
.../app-frame/app-frame.component.html | 4 +-
src-ui/src/assets/logo-dark-notext.svg | 86 ++++---------------
src-ui/src/assets/logo-white-notext.svg | 69 +++++++++++++++
3 files changed, 90 insertions(+), 69 deletions(-)
create mode 100644 src-ui/src/assets/logo-white-notext.svg
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 d191ec0de..6fd2a579e 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
@@ -1,6 +1,8 @@