From 9daa6ba463ac9a9746f9e33095b6de6ce3a790ce Mon Sep 17 00:00:00 2001 From: Sasha Dresden Date: Wed, 4 Dec 2024 18:06:20 -0500 Subject: [PATCH] Fix api links missing '/' as well as clean up services --- .../manage-committee/manage-committee.component.ts | 5 +---- .../submission-workflow/submit-report-step2.component.ts | 4 ++-- .../src/app/shared/resolvers/report.resolver.spec.ts | 2 +- .../src/app/shared/services/contact.service.spec.ts | 2 +- front-end/src/app/shared/services/contact.service.ts | 4 ++-- front-end/src/app/shared/services/form-1m.service.ts | 9 --------- front-end/src/app/shared/services/form-24.service.ts | 9 --------- .../src/app/shared/services/form-3x.service.spec.ts | 2 +- front-end/src/app/shared/services/form-3x.service.ts | 8 ++++---- front-end/src/app/shared/services/form-99.service.ts | 9 --------- front-end/src/app/shared/services/login.service.ts | 2 -- .../src/app/shared/services/memo-text.service.spec.ts | 4 ++-- front-end/src/app/shared/services/memo-text.service.ts | 4 ++-- front-end/src/app/shared/services/report.service.spec.ts | 2 +- front-end/src/app/shared/services/report.service.ts | 4 ++-- .../src/app/shared/services/transaction-schA.service.ts | 9 --------- .../src/app/shared/services/transaction-schB.service.ts | 9 +-------- .../src/app/shared/services/transaction-schC.service.ts | 9 +-------- .../src/app/shared/services/transaction-schC2.service.ts | 9 --------- front-end/src/app/shared/services/web-print.service.ts | 2 -- 20 files changed, 21 insertions(+), 87 deletions(-) diff --git a/front-end/src/app/committee/manage-committee/manage-committee.component.ts b/front-end/src/app/committee/manage-committee/manage-committee.component.ts index 4de267590b..2599b85471 100644 --- a/front-end/src/app/committee/manage-committee/manage-committee.component.ts +++ b/front-end/src/app/committee/manage-committee/manage-committee.component.ts @@ -5,7 +5,7 @@ import { TableAction, TableListBaseComponent } from 'app/shared/components/table import { CommitteeMember, CommitteeMemberRoles } from 'app/shared/models/committee-member.model'; import { Store } from '@ngrx/store'; import { selectUserLoginData } from '../../store/user-login-data.selectors'; -import { firstValueFrom, lastValueFrom } from 'rxjs'; +import { firstValueFrom, lastValueFrom, map } from 'rxjs'; import { CommitteeMemberService } from '../../shared/services/committee-member.service'; @Component({ @@ -22,8 +22,6 @@ export class ManageCommitteeComponent extends TableListBaseComponent; - sortableHeaders: { field: string; label: string }[] = [ { field: 'name', label: 'Name' }, { field: 'email', label: 'Email' }, @@ -39,7 +37,6 @@ export class ManageCommitteeComponent extends TableListBaseComponent { expect(response).toEqual(form3X); }); - const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/${form3X.id}`); + const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/${form3X.id}/`); expect(req.request.method).toEqual('GET'); req.flush(form3X); httpTestingController.verify(); diff --git a/front-end/src/app/shared/services/contact.service.spec.ts b/front-end/src/app/shared/services/contact.service.spec.ts index 04e5d6d66b..bd83910e31 100644 --- a/front-end/src/app/shared/services/contact.service.spec.ts +++ b/front-end/src/app/shared/services/contact.service.spec.ts @@ -105,7 +105,7 @@ describe('ContactService', () => { expect(response).toEqual(mockResponse); }); - const req = httpTestingController.expectOne(`${environment.apiUrl}/contacts/1`); + const req = httpTestingController.expectOne(`${environment.apiUrl}/contacts/1/`); expect(req.request.method).toEqual('DELETE'); req.flush(mockResponse); httpTestingController.verify(); diff --git a/front-end/src/app/shared/services/contact.service.ts b/front-end/src/app/shared/services/contact.service.ts index 30cee66e70..ec1998a73d 100644 --- a/front-end/src/app/shared/services/contact.service.ts +++ b/front-end/src/app/shared/services/contact.service.ts @@ -60,7 +60,7 @@ export class ContactService implements TableListService { } public get(id: string): Observable { - return this.apiService.get(`/contacts/${id}`).pipe(map((response) => Contact.fromJSON(response))); + return this.apiService.get(`/contacts/${id}/`).pipe(map((response) => Contact.fromJSON(response))); } public create(contact: Contact): Observable { @@ -75,7 +75,7 @@ export class ContactService implements TableListService { } public delete(contact: Contact): Observable { - return this.apiService.delete(`/contacts/${contact.id}`); + return this.apiService.delete(`/contacts/${contact.id}/`); } /** diff --git a/front-end/src/app/shared/services/form-1m.service.ts b/front-end/src/app/shared/services/form-1m.service.ts index 11696e47ec..44a8376415 100644 --- a/front-end/src/app/shared/services/form-1m.service.ts +++ b/front-end/src/app/shared/services/form-1m.service.ts @@ -1,18 +1,9 @@ import { Injectable } from '@angular/core'; -import { Store } from '@ngrx/store'; import { ReportService } from './report.service'; -import { ApiService } from './api.service'; @Injectable({ providedIn: 'root', }) export class Form1MService extends ReportService { override apiEndpoint = '/reports/form-1m'; - - constructor( - override apiService: ApiService, - override store: Store, - ) { - super(apiService, store); - } } diff --git a/front-end/src/app/shared/services/form-24.service.ts b/front-end/src/app/shared/services/form-24.service.ts index ff07be6317..dbb07448c5 100644 --- a/front-end/src/app/shared/services/form-24.service.ts +++ b/front-end/src/app/shared/services/form-24.service.ts @@ -1,18 +1,9 @@ import { Injectable } from '@angular/core'; -import { Store } from '@ngrx/store'; import { ReportService } from './report.service'; -import { ApiService } from './api.service'; @Injectable({ providedIn: 'root', }) export class Form24Service extends ReportService { override apiEndpoint = '/reports/form-24'; - - constructor( - override apiService: ApiService, - override store: Store, - ) { - super(apiService, store); - } } diff --git a/front-end/src/app/shared/services/form-3x.service.spec.ts b/front-end/src/app/shared/services/form-3x.service.spec.ts index 73e772908c..eb9c1e0407 100644 --- a/front-end/src/app/shared/services/form-3x.service.spec.ts +++ b/front-end/src/app/shared/services/form-3x.service.spec.ts @@ -59,7 +59,7 @@ describe('Form3XService', () => { expect(response).toBeNull(); }); - const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/form-3x/999`); + const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/form-3x/999/`); expect(req.request.method).toEqual('DELETE'); req.flush(null); httpTestingController.verify(); diff --git a/front-end/src/app/shared/services/form-3x.service.ts b/front-end/src/app/shared/services/form-3x.service.ts index 9d8075797d..a1d4f50696 100644 --- a/front-end/src/app/shared/services/form-3x.service.ts +++ b/front-end/src/app/shared/services/form-3x.service.ts @@ -26,7 +26,7 @@ export class Form3XService extends ReportService { public async getF3xCoverageDates(): Promise { const [response, reportCodeLabelMap] = await Promise.all([ - firstValueFrom(this.apiService.get(`${this.apiEndpoint}/coverage_dates`)), + firstValueFrom(this.apiService.get(`${this.apiEndpoint}/coverage_dates/`)), this.getReportCodeLabelMap(), ]); return response.map((fx3CoverageDate) => @@ -38,7 +38,7 @@ export class Form3XService extends ReportService { let map = this.f3xReportCodeLabelMap$.getValue(); if (!map) { map = await firstValueFrom( - this.apiService.get<{ [key in F3xReportCodes]: string }>(`${this.apiEndpoint}/report_code_map`), + this.apiService.get<{ [key in F3xReportCodes]: string }>(`${this.apiEndpoint}/report_code_map/`), ); this.f3xReportCodeLabelMap$.next(map); } @@ -47,12 +47,12 @@ export class Form3XService extends ReportService { public getFutureReports(coverage_through_date: string): Observable { return this.apiService - .get(`${this.apiEndpoint}/future?after=${coverage_through_date}`) + .get(`${this.apiEndpoint}/future/?after=${coverage_through_date}`) .pipe(map((response) => response.map((r) => Form3X.fromJSON(r)))); } public getFinalReport(year: number): Promise { - return firstValueFrom(this.apiService.get(`${this.apiEndpoint}/final?year=${year}`)); + return firstValueFrom(this.apiService.get(`${this.apiEndpoint}/final/?year=${year}`)); } public override fecUpdate(report: Form3X, committeeAccount?: CommitteeAccount): Observable { diff --git a/front-end/src/app/shared/services/form-99.service.ts b/front-end/src/app/shared/services/form-99.service.ts index 99e7fadc50..b2601dabeb 100644 --- a/front-end/src/app/shared/services/form-99.service.ts +++ b/front-end/src/app/shared/services/form-99.service.ts @@ -1,18 +1,9 @@ import { Injectable } from '@angular/core'; -import { Store } from '@ngrx/store'; import { ReportService } from './report.service'; -import { ApiService } from './api.service'; @Injectable({ providedIn: 'root', }) export class Form99Service extends ReportService { override apiEndpoint = '/reports/form-99'; - - constructor( - override apiService: ApiService, - override store: Store, - ) { - super(apiService, store); - } } diff --git a/front-end/src/app/shared/services/login.service.ts b/front-end/src/app/shared/services/login.service.ts index 227be6c373..670661f3d3 100644 --- a/front-end/src/app/shared/services/login.service.ts +++ b/front-end/src/app/shared/services/login.service.ts @@ -10,7 +10,6 @@ import { DestroyerComponent } from '../components/app-destroyer.component'; import { UserLoginData } from '../models/user.model'; import { UsersService } from '../services/users.service'; import { DateUtils } from '../utils/date.utils'; -import { ApiService } from './api.service'; @Injectable({ providedIn: 'root', @@ -20,7 +19,6 @@ export class LoginService extends DestroyerComponent { constructor( private store: Store, private router: Router, - private apiService: ApiService, private cookieService: CookieService, private usersService: UsersService, ) { diff --git a/front-end/src/app/shared/services/memo-text.service.spec.ts b/front-end/src/app/shared/services/memo-text.service.spec.ts index 28b611c579..803649f3c7 100644 --- a/front-end/src/app/shared/services/memo-text.service.spec.ts +++ b/front-end/src/app/shared/services/memo-text.service.spec.ts @@ -31,7 +31,7 @@ describe('MemoTextService', () => { expect(response).toEqual(memoText); }); - const req = httpTestingController.expectOne(`${environment.apiUrl}/memo-text/${memoText.id}`); + const req = httpTestingController.expectOne(`${environment.apiUrl}/memo-text/${memoText.id}/`); expect(req.request.method).toEqual('GET'); req.flush(memoText); httpTestingController.verify(); @@ -84,7 +84,7 @@ describe('MemoTextService', () => { expect(response).toBeNull(); }); - const req = httpTestingController.expectOne(`${environment.apiUrl}/memo-text/999`); + const req = httpTestingController.expectOne(`${environment.apiUrl}/memo-text/999/`); expect(req.request.method).toEqual('DELETE'); req.flush(null); httpTestingController.verify(); diff --git a/front-end/src/app/shared/services/memo-text.service.ts b/front-end/src/app/shared/services/memo-text.service.ts index 45c8880d3f..039d4d10bb 100644 --- a/front-end/src/app/shared/services/memo-text.service.ts +++ b/front-end/src/app/shared/services/memo-text.service.ts @@ -11,7 +11,7 @@ export class MemoTextService { constructor(private apiService: ApiService) {} public get(id: string): Observable { - return this.apiService.get(`/memo-text/${id}`).pipe(map((response) => MemoText.fromJSON(response))); + return this.apiService.get(`/memo-text/${id}/`).pipe(map((response) => MemoText.fromJSON(response))); } public getForReportId(reportId: string): Observable { @@ -35,6 +35,6 @@ export class MemoTextService { } public delete(memoText: MemoText): Observable { - return this.apiService.delete(`/memo-text/${memoText.id}`); + return this.apiService.delete(`/memo-text/${memoText.id}/`); } } diff --git a/front-end/src/app/shared/services/report.service.spec.ts b/front-end/src/app/shared/services/report.service.spec.ts index 2b554ecde2..0ded7c4274 100644 --- a/front-end/src/app/shared/services/report.service.spec.ts +++ b/front-end/src/app/shared/services/report.service.spec.ts @@ -64,7 +64,7 @@ describe('ReportService', () => { expect(response).toEqual(mockResponse); }); - const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/1`); + const req = httpTestingController.expectOne(`${environment.apiUrl}/reports/1/`); expect(req.request.method).toEqual('DELETE'); req.flush(mockResponse); httpTestingController.verify(); diff --git a/front-end/src/app/shared/services/report.service.ts b/front-end/src/app/shared/services/report.service.ts index ad3efafc5d..ae17e95407 100644 --- a/front-end/src/app/shared/services/report.service.ts +++ b/front-end/src/app/shared/services/report.service.ts @@ -53,7 +53,7 @@ export class ReportService implements TableListService { public get(reportId: string): Observable { return this.apiService - .get(`${this.apiEndpoint}/${reportId}`) + .get(`${this.apiEndpoint}/${reportId}/`) .pipe(map((response) => getReportFromJSON(response))); } @@ -72,7 +72,7 @@ export class ReportService implements TableListService { } public delete(report: Report): Observable { - return this.apiService.delete(`${this.apiEndpoint}/${report.id}`); + return this.apiService.delete(`${this.apiEndpoint}/${report.id}/`); } /** diff --git a/front-end/src/app/shared/services/transaction-schA.service.ts b/front-end/src/app/shared/services/transaction-schA.service.ts index d2ccf1f028..889cc2ea3b 100644 --- a/front-end/src/app/shared/services/transaction-schA.service.ts +++ b/front-end/src/app/shared/services/transaction-schA.service.ts @@ -1,6 +1,4 @@ -import { DatePipe } from '@angular/common'; import { Injectable } from '@angular/core'; -import { ApiService } from './api.service'; import { TransactionService } from './transaction.service'; import { Observable } from 'rxjs'; import { ListRestResponse } from '../models/rest-api.model'; @@ -18,11 +16,4 @@ export class TransactionSchAService extends TransactionService { ): Observable { return super.getTableData(pageNumber, ordering, { ...params, schedules: 'A' }); } - - constructor( - override apiService: ApiService, - override datePipe: DatePipe, - ) { - super(apiService, datePipe); - } } diff --git a/front-end/src/app/shared/services/transaction-schB.service.ts b/front-end/src/app/shared/services/transaction-schB.service.ts index edd811d743..55ed38c639 100644 --- a/front-end/src/app/shared/services/transaction-schB.service.ts +++ b/front-end/src/app/shared/services/transaction-schB.service.ts @@ -1,7 +1,6 @@ -import { DatePipe } from '@angular/common'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { ApiService, QueryParams } from './api.service'; +import { QueryParams } from './api.service'; import { TransactionService } from './transaction.service'; import { ListRestResponse } from '../models/rest-api.model'; @@ -10,12 +9,6 @@ import { ListRestResponse } from '../models/rest-api.model'; }) export class TransactionSchBService extends TransactionService { override tableDataEndpoint = '/transactions'; - constructor( - override apiService: ApiService, - override datePipe: DatePipe, - ) { - super(apiService, datePipe); - } override getTableData(pageNumber = 1, ordering = '', params: QueryParams = {}): Observable { // The table data for the Schedule B disbursements also includes the Schedule E expenditures. diff --git a/front-end/src/app/shared/services/transaction-schC.service.ts b/front-end/src/app/shared/services/transaction-schC.service.ts index fb975c837f..a80a8a0833 100644 --- a/front-end/src/app/shared/services/transaction-schC.service.ts +++ b/front-end/src/app/shared/services/transaction-schC.service.ts @@ -1,7 +1,6 @@ -import { DatePipe } from '@angular/common'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; -import { ApiService, QueryParams } from './api.service'; +import { QueryParams } from './api.service'; import { TransactionService } from './transaction.service'; import { ListRestResponse } from '../models/rest-api.model'; @@ -10,12 +9,6 @@ import { ListRestResponse } from '../models/rest-api.model'; }) export class TransactionSchCService extends TransactionService { override tableDataEndpoint = '/transactions'; - constructor( - override apiService: ApiService, - override datePipe: DatePipe, - ) { - super(apiService, datePipe); - } override getTableData(pageNumber = 1, ordering = '', params: QueryParams = {}): Observable { // The table data for the Schedule C loans also includes the Schedule D debts. diff --git a/front-end/src/app/shared/services/transaction-schC2.service.ts b/front-end/src/app/shared/services/transaction-schC2.service.ts index d78c001a4e..ec261ce948 100644 --- a/front-end/src/app/shared/services/transaction-schC2.service.ts +++ b/front-end/src/app/shared/services/transaction-schC2.service.ts @@ -1,6 +1,4 @@ -import { DatePipe } from '@angular/common'; import { Injectable } from '@angular/core'; -import { ApiService } from './api.service'; import { TransactionService } from './transaction.service'; import { Observable } from 'rxjs'; import { ListRestResponse } from '../models/rest-api.model'; @@ -20,11 +18,4 @@ export class TransactionSchC2Service extends TransactionService { ): Observable { return super.getTableData(pageNumber, ordering, { ...params, schedules: 'C2' }); } - - constructor( - override apiService: ApiService, - override datePipe: DatePipe, - ) { - super(apiService, datePipe); - } } diff --git a/front-end/src/app/shared/services/web-print.service.ts b/front-end/src/app/shared/services/web-print.service.ts index 8205dd5f8c..4eca16221d 100644 --- a/front-end/src/app/shared/services/web-print.service.ts +++ b/front-end/src/app/shared/services/web-print.service.ts @@ -1,5 +1,4 @@ import { Injectable } from '@angular/core'; -import { Store } from '@ngrx/store'; import { ApiService } from './api.service'; import { ReportService } from './report.service'; import { firstValueFrom } from 'rxjs'; @@ -11,7 +10,6 @@ export class WebPrintService { constructor( private apiService: ApiService, private reportService: ReportService, - private store: Store, ) {} /**