diff --git a/public/i18n/en_US.json b/public/i18n/en_US.json index 5fff9761..995c52ca 100644 --- a/public/i18n/en_US.json +++ b/public/i18n/en_US.json @@ -875,6 +875,7 @@ "INVALID_XML_ZIP_EXTENSION_ALERT": "Sorry!<\/strong> SEED doesn't currently support that file format. Only .xml<\/strong> and .zip<\/strong> files are supported.", "IRREVERSIBLE_OPERATION_WARNING": "This operation is irreversible.", "ITEMS_WILL_NOT_CHANGE": "these will not change", + "I agree with the": "I agree with the", "If Enabled": "If Enabled", "If you are unable to scan the QR code, select a different method below.": "If you are unable to scan the QR code, select a different method below.", "If you wish to generate stub Audit Template reports from SEED data, select which Audit Template Report Type SEED should generate.": "If you wish to generate stub Audit Template reports from SEED data, select which Audit Template Report Type SEED should generate.", diff --git a/src/@seed/api/audit-template/audit-template.service.ts b/src/@seed/api/audit-template/audit-template.service.ts index 15e194a2..903f2de4 100644 --- a/src/@seed/api/audit-template/audit-template.service.ts +++ b/src/@seed/api/audit-template/audit-template.service.ts @@ -10,7 +10,7 @@ import type { AuditTemplateConfig, AuditTemplateConfigCreateResponse, AuditTemplateConfigResponse, - AuditTemplateReportType, + AuditTemplateReportTypesResponse, } from './audit-template.types' @Injectable({ providedIn: 'root' }) @@ -18,41 +18,31 @@ export class AuditTemplateService { private _httpClient = inject(HttpClient) private _userService = inject(UserService) private _errorService = inject(ErrorService) - private _reportTypes = new ReplaySubject(1) + private _reportTypes = new ReplaySubject(1) private _auditTemplateConfig = new ReplaySubject(1) reportTypes$ = this._reportTypes.asObservable() auditTemplateConfig$ = this._auditTemplateConfig.asObservable() constructor() { - this._reportTypes.next([ - { name: 'ASHRAE Level 2 Report' }, - { name: 'Atlanta Report' }, - { name: 'Baltimore Energy Audit Report' }, - { name: 'Berkeley Report' }, - { name: 'BRICR Phase 0/1' }, - { name: 'Brisbane Energy Audit Report' }, - { name: 'DC BEPS Energy Audit Report' }, - { name: 'DC BEPS RCx Report' }, - { name: 'Demo City Report' }, - { name: 'Denver Energy Audit Report' }, - { name: 'EE-RLF Template' }, - { name: 'Energy Trust of Oregon Report' }, - { name: 'Los Angeles Report' }, - { name: 'Minneapolis Energy Evaluation Report' }, - { name: 'New York City Energy Efficiency Report' }, - { name: 'Office of Recapitalization Energy Audit Report' }, - { name: 'Open Efficiency Report' }, - { name: 'San Francisco Report' }, - { name: 'St. Louis RCx Report' }, - { name: 'St. Louis Report' }, - { name: 'WA Commerce Clean Buildings - Form D Report' }, - { name: 'WA Commerce Grants Report' }, - ]) + this.getReportTypes().subscribe() this._userService.currentOrganizationId$.subscribe((organizationId) => { this.getConfigs(organizationId).subscribe() }) } + getReportTypes(): Observable { + const url = '/api/v3/audit_template/report_types/' + return this._httpClient.get(url).pipe( + map((response) => { + this._reportTypes.next(response.data) + return response.data + }), + catchError((error: HttpErrorResponse) => { + return this._errorService.handleError(error, 'Error fetching Audit Template report types') + }), + ) + } + getConfigs(organizationId: number): Observable { const url = `/api/v3/audit_template_configs/?organization_id=${organizationId}` return this._httpClient.get(url).pipe( diff --git a/src/@seed/api/audit-template/audit-template.types.ts b/src/@seed/api/audit-template/audit-template.types.ts index 4707a859..230f377e 100644 --- a/src/@seed/api/audit-template/audit-template.types.ts +++ b/src/@seed/api/audit-template/audit-template.types.ts @@ -1,5 +1,6 @@ -export type AuditTemplateReportType = { - name: string; +export type AuditTemplateReportTypesResponse = { + status: string; + data: string[]; } export type AuditTemplateConfig = { diff --git a/src/app/modules/organizations/settings/audit-template/audit-template.component.html b/src/app/modules/organizations/settings/audit-template/audit-template.component.html index 2d3a8326..a2437d2f 100644 --- a/src/app/modules/organizations/settings/audit-template/audit-template.component.html +++ b/src/app/modules/organizations/settings/audit-template/audit-template.component.html @@ -156,8 +156,8 @@ {{ t('Audit Template Report Type') }} None - @for (atrt of auditTemplateReportTypes; track atrt.name) { - {{ atrt.name }} + @for (atrt of auditTemplateReportTypes; track atrt) { + {{ atrt }} } diff --git a/src/app/modules/organizations/settings/audit-template/audit-template.component.ts b/src/app/modules/organizations/settings/audit-template/audit-template.component.ts index 010da54e..ab39248c 100644 --- a/src/app/modules/organizations/settings/audit-template/audit-template.component.ts +++ b/src/app/modules/organizations/settings/audit-template/audit-template.component.ts @@ -3,7 +3,7 @@ import type { OnDestroy, OnInit } from '@angular/core' import { Component, inject } from '@angular/core' import { FormControl, FormGroup, ReactiveFormsModule, Validators } from '@angular/forms' import { Subject, takeUntil } from 'rxjs' -import type { AuditTemplateConfig, AuditTemplateReportType, Organization } from '@seed/api' +import type { AuditTemplateConfig, Organization } from '@seed/api' import { AuditTemplateService, OrganizationService } from '@seed/api' import { PageComponent } from '@seed/components' import { SharedImports } from '@seed/directives' @@ -28,7 +28,7 @@ export class AuditTemplateComponent implements OnDestroy, OnInit { id: null, organization: null, } - auditTemplateReportTypes: AuditTemplateReportType[] + auditTemplateReportTypes: string[] auditTemplateForm = new FormGroup({ at_organization_token: new FormControl(''), audit_template_user: new FormControl('', Validators.email),