From 629a5dd61edf5e954f1e11a30055a7e168dc61da Mon Sep 17 00:00:00 2001 From: Michael Shamoon <4887959+shamoon@users.noreply.github.com> Date: Mon, 5 Dec 2022 12:28:44 -0800 Subject: [PATCH] Fix some merge errors, integrate permissions for frontend mail --- src-ui/src/app/app-routing.module.ts | 7 + .../manage/settings/settings.component.html | 140 ++++++++++-------- .../manage/settings/settings.component.ts | 10 +- 3 files changed, 91 insertions(+), 66 deletions(-) diff --git a/src-ui/src/app/app-routing.module.ts b/src-ui/src/app/app-routing.module.ts index d0b3acd0e..c95d1ea7e 100644 --- a/src-ui/src/app/app-routing.module.ts +++ b/src-ui/src/app/app-routing.module.ts @@ -158,6 +158,13 @@ const routes: Routes = [ path: 'settings/:section', component: SettingsComponent, canDeactivate: [DirtyFormGuard], + canActivate: [PermissionsGuard], + data: { + requiredPermission: { + action: PermissionAction.View, + type: PermissionType.UISettings, + }, + }, }, { path: 'tasks', component: TasksComponent }, ], diff --git a/src-ui/src/app/components/manage/settings/settings.component.html b/src-ui/src/app/components/manage/settings/settings.component.html index dd3ada296..b557f687a 100644 --- a/src-ui/src/app/components/manage/settings/settings.component.html +++ b/src-ui/src/app/components/manage/settings/settings.component.html @@ -1,6 +1,6 @@ - + Open Django Admin @@ -227,80 +227,84 @@ -
  • +
  • Mail -

    - Mail accounts - -

    -
      + +

      + Mail accounts + +

      +
        -
      • -
        -
        Name
        -
        Server
        -
        Actions
        -
        -
      • +
      • +
        +
        Name
        +
        Server
        +
        Actions
        +
        +
      • -
      • -
        -
        -
        {{account.imap_server}}
        -
        -
        - - +
      • +
        +
        +
        {{account.imap_server}}
        +
        +
        + + +
        - -
      • + -
        No mail accounts defined.
        -
      +
      No mail accounts defined.
      +
    +
    -

    - Mail rules - -

    -
      + +

      + Mail rules + +

      +
        -
      • -
        -
        Name
        -
        Account
        -
        Actions
        -
        -
      • +
      • +
        +
        Name
        +
        Account
        +
        Actions
        +
        +
      • -
      • -
        -
        -
        {{(mailAccountService.getCached(rule.account) | async)?.name}}
        -
        -
        - - +
      • +
        +
        +
        {{(mailAccountService.getCached(rule.account) | async)?.name}}
        +
        +
        + + +
        - -
      • + -
        No mail rules defined.
        -
      +
      No mail rules defined.
      +
    +
    @@ -318,7 +322,12 @@

    Users - +

      @@ -335,7 +344,7 @@
      {{user.first_name}} {{user.last_name}}
      -
      {{user.groups}}
      +
      {{user.groups?.map(getGroupName, this)}}
      @@ -348,7 +357,12 @@

      Groups - +

        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 8c7df6edc..917dbf4a0 100644 --- a/src-ui/src/app/components/manage/settings/settings.component.ts +++ b/src-ui/src/app/components/manage/settings/settings.component.ts @@ -246,14 +246,14 @@ export class SettingsComponent this.initialize(false) }) } else if ( - (navID == SettingsNavIDs.UsersGroups && !this.users) || - !this.groups + navID == SettingsNavIDs.UsersGroups && + (!this.users || !this.groups) ) { this.usersService.listAll().subscribe((r) => { this.users = r.results this.groupsService.listAll().subscribe((r) => { this.groups = r.results - this.initialize() + this.initialize(false) }) }) } else if ( @@ -724,6 +724,10 @@ export class SettingsComponent }) } + getGroupName(id: number): string { + return this.groups?.find((g) => g.id === id)?.name ?? '' + } + editMailAccount(account: PaperlessMailAccount) { const modal = this.modalService.open(MailAccountEditDialogComponent, { backdrop: 'static',