From c40b2adad7e42038693e4cb37ca82aa6745185f4 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 12 Feb 2024 10:04:45 -0800 Subject: [PATCH] Move to settings, add celery, updated styling --- src-ui/src/app/app.module.ts | 2 + .../admin/settings/settings.component.html | 12 +- .../admin/settings/settings.component.spec.ts | 15 ++ .../admin/settings/settings.component.ts | 12 +- .../app-frame/app-frame.component.html | 4 - .../app-frame/app-frame.component.spec.ts | 7 - .../app-frame/app-frame.component.ts | 5 - .../system-status-dialog.component.html | 179 +++++++++++------- .../system-status-dialog.component.spec.ts | 9 +- src-ui/src/app/data/system-status.ts | 9 +- src/documents/tests/test_api_status.py | 6 +- src/documents/views.py | 32 +++- 12 files changed, 179 insertions(+), 113 deletions(-) diff --git a/src-ui/src/app/app.module.ts b/src-ui/src/app/app.module.ts index 1f9814a38..a7f8d2f3d 100644 --- a/src-ui/src/app/app.module.ts +++ b/src-ui/src/app/app.module.ts @@ -117,6 +117,7 @@ import { MonetaryComponent } from './components/common/input/monetary/monetary.c import { SystemStatusDialogComponent } from './components/common/system-status-dialog/system-status-dialog.component' import { NgxFilesizeModule } from 'ngx-filesize' import { + airplane, archive, arrowCounterclockwise, arrowDown, @@ -205,6 +206,7 @@ import { } from 'ngx-bootstrap-icons' const icons = { + airplane, archive, arrowCounterclockwise, arrowDown, diff --git a/src-ui/src/app/components/admin/settings/settings.component.html b/src-ui/src/app/components/admin/settings/settings.component.html index 059b233e2..e448de7f8 100644 --- a/src-ui/src/app/components/admin/settings/settings.component.html +++ b/src-ui/src/app/components/admin/settings/settings.component.html @@ -4,10 +4,16 @@ info="Options to customize appearance, notifications, saved views and more. Settings apply to the current user only." i18n-info > - - + + + Open Django Admin - +   diff --git a/src-ui/src/app/components/admin/settings/settings.component.spec.ts b/src-ui/src/app/components/admin/settings/settings.component.spec.ts index 6256f646b..d5b681394 100644 --- a/src-ui/src/app/components/admin/settings/settings.component.spec.ts +++ b/src-ui/src/app/components/admin/settings/settings.component.spec.ts @@ -9,6 +9,8 @@ import { NgbModule, NgbAlertModule, NgbNavLink, + NgbModal, + NgbModalModule, } from '@ng-bootstrap/ng-bootstrap' import { NgSelectModule } from '@ng-select/ng-select' import { of, throwError } from 'rxjs' @@ -39,6 +41,7 @@ import { SettingsComponent } from './settings.component' import { IfOwnerDirective } from 'src/app/directives/if-owner.directive' import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' import { ConfirmButtonComponent } from '../../common/confirm-button/confirm-button.component' +import { SystemStatusDialogComponent } from '../../common/system-status-dialog/system-status-dialog.component' const savedViews = [ { id: 1, name: 'view1', show_in_sidebar: true, show_on_dashboard: true }, @@ -65,6 +68,7 @@ describe('SettingsComponent', () => { let userService: UserService let permissionsService: PermissionsService let groupService: GroupService + let modalService: NgbModal beforeEach(async () => { TestBed.configureTestingModule({ @@ -96,6 +100,7 @@ describe('SettingsComponent', () => { NgbAlertModule, NgSelectModule, NgxBootstrapIconsModule.pick(allIcons), + NgbModalModule, ], }).compileComponents() @@ -107,6 +112,7 @@ describe('SettingsComponent', () => { settingsService.currentUser = users[0] userService = TestBed.inject(UserService) permissionsService = TestBed.inject(PermissionsService) + modalService = TestBed.inject(NgbModal) jest.spyOn(permissionsService, 'currentUserCan').mockReturnValue(true) jest .spyOn(permissionsService, 'currentUserHasObjectPermissions') @@ -372,4 +378,13 @@ describe('SettingsComponent', () => { fixture.detectChanges() expect(toastErrorSpy).toBeCalled() }) + + it('should open system status dialog', () => { + const modalOpenSpy = jest.spyOn(modalService, 'open') + completeSetup() + component.showSystemStatus() + expect(modalOpenSpy).toHaveBeenCalledWith(SystemStatusDialogComponent, { + size: 'xl', + }) + }) }) diff --git a/src-ui/src/app/components/admin/settings/settings.component.ts b/src-ui/src/app/components/admin/settings/settings.component.ts index a77a556bf..053d72ccb 100644 --- a/src-ui/src/app/components/admin/settings/settings.component.ts +++ b/src-ui/src/app/components/admin/settings/settings.component.ts @@ -9,7 +9,7 @@ import { } from '@angular/core' import { FormGroup, FormControl } from '@angular/forms' import { ActivatedRoute, Router } from '@angular/router' -import { NgbNavChangeEvent } from '@ng-bootstrap/ng-bootstrap' +import { NgbModal, NgbNavChangeEvent } from '@ng-bootstrap/ng-bootstrap' import { DirtyComponent, dirtyCheck } from '@ngneat/dirty-check-forms' import { TourService } from 'ngx-ui-tour-ng-bootstrap' import { @@ -40,6 +40,7 @@ import { } from 'src/app/services/settings.service' import { ToastService, Toast } from 'src/app/services/toast.service' import { ComponentWithPermissions } from '../../with-permissions/with-permissions.component' +import { SystemStatusDialogComponent } from '../../common/system-status-dialog/system-status-dialog.component' enum SettingsNavIDs { General = 1, @@ -131,7 +132,8 @@ export class SettingsComponent private usersService: UserService, private groupsService: GroupService, private router: Router, - public permissionsService: PermissionsService + public permissionsService: PermissionsService, + private modalService: NgbModal ) { super() this.settings.settingsSaved.subscribe(() => { @@ -565,4 +567,10 @@ export class SettingsComponent clearThemeColor() { this.settingsForm.get('themeColor').patchValue('') } + + showSystemStatus() { + this.modalService.open(SystemStatusDialogComponent, { + size: 'xl', + }) + } } 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 e7cafa1a4..261c033e0 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 @@ -58,10 +58,6 @@ *pngxIfPermissions="{ action: PermissionAction.Change, type: PermissionType.UISettings }"> Settings - Logout diff --git a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts index 989c2780f..e1a553047 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.spec.ts +++ b/src-ui/src/app/components/app-frame/app-frame.component.spec.ts @@ -38,7 +38,6 @@ import { CdkDragDrop, DragDropModule } from '@angular/cdk/drag-drop' import { SavedView } from 'src/app/data/saved-view' import { ProfileEditDialogComponent } from '../common/profile-edit-dialog/profile-edit-dialog.component' import { NgxBootstrapIconsModule, allIcons } from 'ngx-bootstrap-icons' -import { SystemStatusDialogComponent } from '../common/system-status-dialog/system-status-dialog.component' const saved_views = [ { @@ -416,10 +415,4 @@ describe('AppFrameComponent', () => { expect(toastErrorSpy).toHaveBeenCalledTimes(2) expect(toastInfoSpy).toHaveBeenCalledTimes(3) }) - - it('should open system status dialog', () => { - const modalOpenSpy = jest.spyOn(modalService, 'open') - component.showSystemStatus() - expect(modalOpenSpy).toHaveBeenCalledWith(SystemStatusDialogComponent) - }) }) diff --git a/src-ui/src/app/components/app-frame/app-frame.component.ts b/src-ui/src/app/components/app-frame/app-frame.component.ts index 159781827..ab9322380 100644 --- a/src-ui/src/app/components/app-frame/app-frame.component.ts +++ b/src-ui/src/app/components/app-frame/app-frame.component.ts @@ -46,7 +46,6 @@ import { } from '@angular/cdk/drag-drop' import { NgbModal } from '@ng-bootstrap/ng-bootstrap' import { ProfileEditDialogComponent } from '../common/profile-edit-dialog/profile-edit-dialog.component' -import { SystemStatusDialogComponent } from '../common/system-status-dialog/system-status-dialog.component' @Component({ selector: 'pngx-app-frame', @@ -317,8 +316,4 @@ export class AppFrameComponent onLogout() { this.openDocumentsService.closeAll() } - - showSystemStatus() { - this.modalService.open(SystemStatusDialogComponent) - } } diff --git a/src-ui/src/app/components/common/system-status-dialog/system-status-dialog.component.html b/src-ui/src/app/components/common/system-status-dialog/system-status-dialog.component.html index acdb86b47..8fcec21b0 100644 --- a/src-ui/src/app/components/common/system-status-dialog/system-status-dialog.component.html +++ b/src-ui/src/app/components/common/system-status-dialog/system-status-dialog.component.html @@ -11,81 +11,116 @@ } @else { -
General Info
-
-
Paperless-ngx Version:
-
{{status.pngx_version}}
-
Install Type:
-
{{status.install_type}}
-
Server OS:
-
{{status.server_os}}
-
Media Storage:
-
- - {{status.storage.available | filesize}} available ({{status.storage.total | filesize}} total) -
-
+
+
+
+
+
Environment
+
+
+
+
Paperless-ngx Version
+
{{status.pngx_version}}
+
Install Type
+
{{status.install_type}}
+
Server OS
+
{{status.server_os}}
+
Media Storage
+
+ + {{status.storage.available | filesize}} available ({{status.storage.total | filesize}} total) +
+
+
+
+
-
Database
-
-
Type:
-
{{status.database.type}}
-
URL:
-
{{status.database.url}}
-
Status:
-
- {{status.database.status}} - @if (status.database.status === 'OK') { - - } @else { - - } -
-
Migration Status:
-
- @if (status.database.migration_status.unapplied_migrations.length === 0) { - Up to date - } @else { - {{status.database.migration_status.unapplied_migrations.length}} Pending - } - - Latest Migration: {{status.database.migration_status.latest_migration}}
- @if (status.database.migration_status.unapplied_migrations.length > 0) { - Pending Migrations: -
    - @for (migration of status.database.migration_status.unapplied_migrations; track migration) { -
  • {{migration}}
  • +
    +
    +
    +
    Database
    +
    +
    +
    +
    Type
    +
    {{status.database.type}}
    +
    URL
    +
    {{status.database.url}}
    +
    Status
    +
    + {{status.database.status}} + @if (status.database.status === 'OK') { + + } @else { + + } +
    +
    Migration Status
    +
    + @if (status.database.migration_status.unapplied_migrations.length === 0) { + Up to date + } @else { + {{status.database.migration_status.unapplied_migrations.length}} Pending + } + + Latest Migration: {{status.database.migration_status.latest_migration}}
    + @if (status.database.migration_status.unapplied_migrations.length > 0) { + Pending Migrations: +
      + @for (migration of status.database.migration_status.unapplied_migrations; track migration) { +
    • {{migration}}
    • + } +
    + } +
    +
    + @if (status.database.migration_status.unapplied_migrations.length > 0) { +
    Pending Migrations:
    +
    +
      + @for (migration of status.database.migration_status.unapplied_migrations; track migration) { +
    • {{migration}}
    • + } +
    +
    } -
- } -
-
- @if (status.database.migration_status.unapplied_migrations.length > 0) { -
Pending Migrations:
-
-
    - @for (migration of status.database.migration_status.unapplied_migrations; track migration) { -
  • {{migration}}
  • - } -
-
- } -
+ +
+ + -
Redis
-
-
URL:
-
{{status.redis.url}}
-
Status:
-
- {{status.redis.status}} - @if (status.redis.status === 'OK') { - - } @else { - - } -
-
+
+
+
+
Tasks
+
+
+
+
Redis URL
+
{{status.tasks.redis_url}}
+
Redis Status
+
+ {{status.tasks.redis_status}} + @if (status.tasks.redis_status === 'OK') { + + } @else { + + } +
+
Celery Status
+
+ {{status.tasks.celery_status}} + @if (status.tasks.celery_status === 'OK') { + + } @else { + + } +
+
+
+
+
+ }