From 6457bc62c8006ca7a7db8a2822a6a13e41d97b0f Mon Sep 17 00:00:00 2001 From: Daniel Haselhan Date: Tue, 10 Oct 2023 14:28:48 -0700 Subject: [PATCH] Public Fixes * Fix Sorting for Notifications on the backend * Set default sorting to all tables * Fix routing for decisions for signed in users --- .../application-search-table.component.html | 2 +- .../application-search-table.component.ts | 5 +++-- .../notice-of-intent-search-table.component.html | 2 +- .../notice-of-intent-search-table.component.ts | 7 +++---- .../notification-search-table.component.html | 2 +- .../notification-search-table.component.ts | 5 +++-- .../application-decision.service.ts | 2 +- .../notice-of-intent-decision.service.ts | 2 +- .../application-decision.controller.spec.ts | 13 ++----------- .../application/application-decision.controller.ts | 9 +++------ .../notice-of-intent-decision.controller.spec.ts | 13 ++----------- .../notice-of-intent-decision.controller.ts | 9 +++------ .../public-notification-search.service.ts | 2 +- 13 files changed, 25 insertions(+), 48 deletions(-) diff --git a/portal-frontend/src/app/features/public/search/application-search-table/application-search-table.component.html b/portal-frontend/src/app/features/public/search/application-search-table/application-search-table.component.html index 0dab4c158a..251efa1ad2 100644 --- a/portal-frontend/src/app/features/public/search/application-search-table/application-search-table.component.html +++ b/portal-frontend/src/app/features/public/search/application-search-table/application-search-table.component.html @@ -4,7 +4,7 @@ [dataSource]="dataSource" class="mat-elevation-z2 table" matSort - matSortActive="dateSubmitted" + matSortActive="lastUpdate" matSortDirection="desc" matSortDisableClear > diff --git a/portal-frontend/src/app/features/public/search/application-search-table/application-search-table.component.ts b/portal-frontend/src/app/features/public/search/application-search-table/application-search-table.component.ts index a6096dd2eb..f27ff2e611 100644 --- a/portal-frontend/src/app/features/public/search/application-search-table/application-search-table.component.ts +++ b/portal-frontend/src/app/features/public/search/application-search-table/application-search-table.component.ts @@ -1,6 +1,7 @@ import { Component, EventEmitter, Input, OnDestroy, Output, ViewChild } from '@angular/core'; import { MatPaginator, PageEvent } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; +import { MatTableDataSource } from '@angular/material/table'; import { Router } from '@angular/router'; import { Subject, takeUntil } from 'rxjs'; import { ApplicationStatusDto } from '../../../../services/application-submission/application-submission.dto'; @@ -21,7 +22,7 @@ export class ApplicationSearchTableComponent implements OnDestroy { _applications: ApplicationSearchResultDto[] = []; @Input() set applications(applications: ApplicationSearchResultDto[]) { this._applications = applications; - this.dataSource = this.mapApplications(applications); + this.dataSource = new MatTableDataSource(this.mapApplications(applications)); } _totalCount = 0; @@ -36,7 +37,7 @@ export class ApplicationSearchTableComponent implements OnDestroy { @Output() tableChange = new EventEmitter(); displayedColumns = ['fileId', 'ownerName', 'type', 'portalStatus', 'lastUpdate', 'government']; - dataSource: SearchResult[] = []; + dataSource = new MatTableDataSource(); pageIndex = 0; itemsPerPage = 20; total = 0; diff --git a/portal-frontend/src/app/features/public/search/notice-of-intent-search-table/notice-of-intent-search-table.component.html b/portal-frontend/src/app/features/public/search/notice-of-intent-search-table/notice-of-intent-search-table.component.html index f55336deb9..ff1d44f83a 100644 --- a/portal-frontend/src/app/features/public/search/notice-of-intent-search-table/notice-of-intent-search-table.component.html +++ b/portal-frontend/src/app/features/public/search/notice-of-intent-search-table/notice-of-intent-search-table.component.html @@ -4,7 +4,7 @@ [dataSource]="dataSource" class="mat-elevation-z2 table" matSort - matSortActive="dateSubmitted" + matSortActive="lastUpdate" matSortDirection="desc" matSortDisableClear > diff --git a/portal-frontend/src/app/features/public/search/notice-of-intent-search-table/notice-of-intent-search-table.component.ts b/portal-frontend/src/app/features/public/search/notice-of-intent-search-table/notice-of-intent-search-table.component.ts index b4ae375be1..6c79df48fd 100644 --- a/portal-frontend/src/app/features/public/search/notice-of-intent-search-table/notice-of-intent-search-table.component.ts +++ b/portal-frontend/src/app/features/public/search/notice-of-intent-search-table/notice-of-intent-search-table.component.ts @@ -1,11 +1,10 @@ import { Component, EventEmitter, Input, OnDestroy, Output, ViewChild } from '@angular/core'; import { MatPaginator, PageEvent } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; +import { MatTableDataSource } from '@angular/material/table'; import { Router } from '@angular/router'; import { Subject, takeUntil } from 'rxjs'; import { ApplicationStatusDto } from '../../../../services/application-submission/application-submission.dto'; -import { ApplicationRegionDto, NoticeOfIntentTypeDto } from '../../../../services/code/code.dto'; -import { NoticeOfIntentSubmissionStatusDto } from '../../../../services/notice-of-intent-submission/notice-of-intent-submission.dto'; import { NoticeOfIntentSearchResultDto } from '../../../../services/search/search.dto'; import { SearchResult, TableChange } from '../search.interface'; @@ -23,7 +22,7 @@ export class NoticeOfIntentSearchTableComponent implements OnDestroy { _noticeOfIntents: NoticeOfIntentSearchResultDto[] = []; @Input() set noticeOfIntents(noticeOfIntents: NoticeOfIntentSearchResultDto[]) { this._noticeOfIntents = noticeOfIntents; - this.dataSource = this.mapNoticeOfIntent(noticeOfIntents); + this.dataSource = new MatTableDataSource(this.mapNoticeOfIntent(noticeOfIntents)); } _totalCount = 0; @@ -36,7 +35,7 @@ export class NoticeOfIntentSearchTableComponent implements OnDestroy { @Output() tableChange = new EventEmitter(); displayedColumns = ['fileId', 'ownerName', 'type', 'portalStatus', 'lastUpdate', 'government']; - dataSource: SearchResult[] = []; + dataSource = new MatTableDataSource(); pageIndex = 0; itemsPerPage = 20; total = 0; diff --git a/portal-frontend/src/app/features/public/search/notification-search-table/notification-search-table.component.html b/portal-frontend/src/app/features/public/search/notification-search-table/notification-search-table.component.html index 58b5b5053f..09f24b0881 100644 --- a/portal-frontend/src/app/features/public/search/notification-search-table/notification-search-table.component.html +++ b/portal-frontend/src/app/features/public/search/notification-search-table/notification-search-table.component.html @@ -4,7 +4,7 @@ [dataSource]="dataSource" class="mat-elevation-z2 table" matSort - matSortActive="dateSubmitted" + matSortActive="lastUpdate" matSortDirection="desc" matSortDisableClear > diff --git a/portal-frontend/src/app/features/public/search/notification-search-table/notification-search-table.component.ts b/portal-frontend/src/app/features/public/search/notification-search-table/notification-search-table.component.ts index 18c8e67acd..8682840657 100644 --- a/portal-frontend/src/app/features/public/search/notification-search-table/notification-search-table.component.ts +++ b/portal-frontend/src/app/features/public/search/notification-search-table/notification-search-table.component.ts @@ -1,6 +1,7 @@ import { Component, EventEmitter, Input, OnDestroy, Output, ViewChild } from '@angular/core'; import { MatPaginator, PageEvent } from '@angular/material/paginator'; import { MatSort } from '@angular/material/sort'; +import { MatTableDataSource } from '@angular/material/table'; import { Router } from '@angular/router'; import { Subject, takeUntil } from 'rxjs'; import { ApplicationStatusDto } from '../../../../services/application-submission/application-submission.dto'; @@ -24,7 +25,7 @@ export class NotificationSearchTableComponent implements OnDestroy { @Input() set notifications(notifications: NotificationSearchResultDto[]) { this._notifications = notifications; - this.dataSource = this.mapNotifications(notifications); + this.dataSource = new MatTableDataSource(this.mapNotifications(notifications)); } _totalCount = 0; @@ -35,7 +36,7 @@ export class NotificationSearchTableComponent implements OnDestroy { @Output() tableChange = new EventEmitter(); displayedColumns = ['fileId', 'ownerName', 'type', 'portalStatus', 'lastUpdate', 'government']; - dataSource: SearchResult[] = []; + dataSource = new MatTableDataSource(); pageIndex = 0; itemsPerPage = 20; total = 0; diff --git a/portal-frontend/src/app/services/application-decision/application-decision.service.ts b/portal-frontend/src/app/services/application-decision/application-decision.service.ts index 2e0806934f..5fdf82ca1f 100644 --- a/portal-frontend/src/app/services/application-decision/application-decision.service.ts +++ b/portal-frontend/src/app/services/application-decision/application-decision.service.ts @@ -9,7 +9,7 @@ import { ApplicationPortalDecisionDto } from './application-decision.dto'; providedIn: 'root', }) export class ApplicationDecisionService { - private serviceUrl = `${environment.apiUrl}/public/application/decision`; + private serviceUrl = `${environment.authUrl}/public/application/decision`; constructor(private httpClient: HttpClient, private toastService: ToastService) {} diff --git a/portal-frontend/src/app/services/notice-of-intent-decision/notice-of-intent-decision.service.ts b/portal-frontend/src/app/services/notice-of-intent-decision/notice-of-intent-decision.service.ts index c145a744ba..477914a2b3 100644 --- a/portal-frontend/src/app/services/notice-of-intent-decision/notice-of-intent-decision.service.ts +++ b/portal-frontend/src/app/services/notice-of-intent-decision/notice-of-intent-decision.service.ts @@ -9,7 +9,7 @@ import { NoticeOfIntentPortalDecisionDto } from './notice-of-intent-decision.dto providedIn: 'root', }) export class NoticeOfIntentDecisionService { - private serviceUrl = `${environment.apiUrl}/public/notice-of-intent/decision`; + private serviceUrl = `${environment.authUrl}/public/notice-of-intent/decision`; constructor(private httpClient: HttpClient, private toastService: ToastService) {} diff --git a/services/apps/alcs/src/portal/public/application/application-decision.controller.spec.ts b/services/apps/alcs/src/portal/public/application/application-decision.controller.spec.ts index b7745058dc..24623cbed8 100644 --- a/services/apps/alcs/src/portal/public/application/application-decision.controller.spec.ts +++ b/services/apps/alcs/src/portal/public/application/application-decision.controller.spec.ts @@ -7,7 +7,6 @@ import { mockKeyCloakProviders } from '../../../../test/mocks/mockTypes'; import { ApplicationDecisionV2Service } from '../../../alcs/application-decision/application-decision-v2/application-decision/application-decision-v2.service'; import { ApplicationDecision } from '../../../alcs/application-decision/application-decision.entity'; import { ApplicationDecisionProfile } from '../../../common/automapper/application-decision-v2.automapper.profile'; -import { User } from '../../../user/user.entity'; import { ApplicationSubmissionService } from '../../application-submission/application-submission.service'; import { ApplicationDecisionController } from './application-decision.controller'; @@ -58,11 +57,7 @@ describe('ApplicationDecisionController', () => { new ApplicationDecision(), ]); - const res = await controller.listDecisions('', { - user: { - entity: new User(), - }, - }); + const res = await controller.listDecisions(''); expect(res.length).toEqual(1); expect(mockDecisionService.getForPortal).toHaveBeenCalledTimes(1); @@ -71,11 +66,7 @@ describe('ApplicationDecisionController', () => { it('should call through for loading files', async () => { mockDecisionService.getDownloadUrl.mockResolvedValue('Mock Url'); - const res = await controller.openFile('', { - user: { - entity: new User(), - }, - }); + const res = await controller.openFile(''); expect(res.url).toBeTruthy(); expect(mockDecisionService.getDownloadUrl).toHaveBeenCalledTimes(1); diff --git a/services/apps/alcs/src/portal/public/application/application-decision.controller.ts b/services/apps/alcs/src/portal/public/application/application-decision.controller.ts index 73d23dc4b4..fc7df0afde 100644 --- a/services/apps/alcs/src/portal/public/application/application-decision.controller.ts +++ b/services/apps/alcs/src/portal/public/application/application-decision.controller.ts @@ -8,7 +8,7 @@ import { ApplicationSubmissionService } from '../../application-submission/appli import { ApplicationPortalDecisionDto } from './application-decision.dto'; @Public() -@Controller('application/decision') +@Controller('public/application/decision') export class ApplicationDecisionController { constructor( private applicationSubmissionService: ApplicationSubmissionService, @@ -16,10 +16,9 @@ export class ApplicationDecisionController { @InjectMapper() private mapper: Mapper, ) {} - @Get('/application/:fileNumber') + @Get('/:fileNumber') async listDecisions( @Param('fileNumber') fileNumber: string, - @Req() req, ): Promise { const decisions = await this.decisionService.getForPortal(fileNumber); @@ -31,11 +30,9 @@ export class ApplicationDecisionController { } @Get('/:uuid/open') - async openFile(@Param('uuid') fileUuid: string, @Req() req) { + async openFile(@Param('uuid') fileUuid: string) { const url = await this.decisionService.getDownloadUrl(fileUuid); - //TODO: How do we know which documents applicant can access? - return { url }; } } diff --git a/services/apps/alcs/src/portal/public/notice-of-intent/notice-of-intent-decision.controller.spec.ts b/services/apps/alcs/src/portal/public/notice-of-intent/notice-of-intent-decision.controller.spec.ts index 15925bf226..530fcdd3bf 100644 --- a/services/apps/alcs/src/portal/public/notice-of-intent/notice-of-intent-decision.controller.spec.ts +++ b/services/apps/alcs/src/portal/public/notice-of-intent/notice-of-intent-decision.controller.spec.ts @@ -7,7 +7,6 @@ import { mockKeyCloakProviders } from '../../../../test/mocks/mockTypes'; import { NoticeOfIntentDecisionV2Service } from '../../../alcs/notice-of-intent-decision/notice-of-intent-decision-v2/notice-of-intent-decision-v2.service'; import { NoticeOfIntentDecision } from '../../../alcs/notice-of-intent-decision/notice-of-intent-decision.entity'; import { NoticeOfIntentDecisionProfile } from '../../../common/automapper/notice-of-intent-decision.automapper.profile'; -import { User } from '../../../user/user.entity'; import { NoticeOfIntentSubmission } from '../../notice-of-intent-submission/notice-of-intent-submission.entity'; import { NoticeOfIntentSubmissionService } from '../../notice-of-intent-submission/notice-of-intent-submission.service'; import { NoticeOfIntentDecisionController } from './notice-of-intent-decision.controller'; @@ -63,11 +62,7 @@ describe('NoticeOfIntentDecisionController', () => { new NoticeOfIntentDecision(), ]); - const res = await controller.listDecisions('', { - user: { - entity: new User(), - }, - }); + const res = await controller.listDecisions(''); expect(res.length).toEqual(1); expect(mockDecisionService.getForPortal).toHaveBeenCalledTimes(1); @@ -76,11 +71,7 @@ describe('NoticeOfIntentDecisionController', () => { it('should call through for loading files', async () => { mockDecisionService.getDownloadUrl.mockResolvedValue('Mock Url'); - const res = await controller.openFile('', { - user: { - entity: new User(), - }, - }); + const res = await controller.openFile(''); expect(res.url).toBeTruthy(); expect(mockDecisionService.getDownloadUrl).toHaveBeenCalledTimes(1); diff --git a/services/apps/alcs/src/portal/public/notice-of-intent/notice-of-intent-decision.controller.ts b/services/apps/alcs/src/portal/public/notice-of-intent/notice-of-intent-decision.controller.ts index d10b67fe08..37e669c45b 100644 --- a/services/apps/alcs/src/portal/public/notice-of-intent/notice-of-intent-decision.controller.ts +++ b/services/apps/alcs/src/portal/public/notice-of-intent/notice-of-intent-decision.controller.ts @@ -1,6 +1,6 @@ import { Mapper } from '@automapper/core'; import { InjectMapper } from '@automapper/nestjs'; -import { Controller, Get, Param, Req } from '@nestjs/common'; +import { Controller, Get, Param } from '@nestjs/common'; import { Public } from 'nest-keycloak-connect'; import { NoticeOfIntentDecisionV2Service } from '../../../alcs/notice-of-intent-decision/notice-of-intent-decision-v2/notice-of-intent-decision-v2.service'; import { NoticeOfIntentDecision } from '../../../alcs/notice-of-intent-decision/notice-of-intent-decision.entity'; @@ -8,7 +8,7 @@ import { NoticeOfIntentSubmissionService } from '../../notice-of-intent-submissi import { NoticeOfIntentPortalDecisionDto } from './notice-of-intent-decision.dto'; @Public() -@Controller('notice-of-intent/decision') +@Controller('public/notice-of-intent/decision') export class NoticeOfIntentDecisionController { constructor( private noticeOfIntentSubmissionService: NoticeOfIntentSubmissionService, @@ -19,7 +19,6 @@ export class NoticeOfIntentDecisionController { @Get('/:fileNumber') async listDecisions( @Param('fileNumber') fileNumber: string, - @Req() req, ): Promise { const decisions = await this.decisionService.getForPortal(fileNumber); @@ -31,11 +30,9 @@ export class NoticeOfIntentDecisionController { } @Get('/:uuid/open') - async openFile(@Param('uuid') fileUuid: string, @Req() req) { + async openFile(@Param('uuid') fileUuid: string) { const url = await this.decisionService.getDownloadUrl(fileUuid); - //TODO: How do we know which documents applicant can access? - return { url }; } } diff --git a/services/apps/alcs/src/portal/public/search/notification/public-notification-search.service.ts b/services/apps/alcs/src/portal/public/search/notification/public-notification-search.service.ts index 904aa27469..e3140ed66c 100644 --- a/services/apps/alcs/src/portal/public/search/notification/public-notification-search.service.ts +++ b/services/apps/alcs/src/portal/public/search/notification/public-notification-search.service.ts @@ -63,7 +63,7 @@ export class PublicNotificationSearchService { default: case 'lastUpdate': - return `"notificationSearch"."status" ->> 'effectiveDate' `; + return `"notificationSearch"."status" ->> 'effective_date' `; } }