Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,7 @@
"INVALID_XML_ZIP_EXTENSION_ALERT": "<strong>Sorry!<\/strong> SEED doesn't currently support that file format. Only <strong>.xml<\/strong> and <strong>.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.",
Expand Down
42 changes: 16 additions & 26 deletions src/@seed/api/audit-template/audit-template.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,39 @@ import type {
AuditTemplateConfig,
AuditTemplateConfigCreateResponse,
AuditTemplateConfigResponse,
AuditTemplateReportType,
AuditTemplateReportTypesResponse,
} from './audit-template.types'

@Injectable({ providedIn: 'root' })
export class AuditTemplateService {
private _httpClient = inject(HttpClient)
private _userService = inject(UserService)
private _errorService = inject(ErrorService)
private _reportTypes = new ReplaySubject<AuditTemplateReportType[]>(1)
private _reportTypes = new ReplaySubject<string[]>(1)
private _auditTemplateConfig = new ReplaySubject<AuditTemplateConfig>(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<string[]> {
const url = '/api/v3/audit_template/report_types/'
return this._httpClient.get<AuditTemplateReportTypesResponse>(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<AuditTemplateConfig> {
const url = `/api/v3/audit_template_configs/?organization_id=${organizationId}`
return this._httpClient.get<AuditTemplateConfigResponse>(url).pipe(
Expand Down
5 changes: 3 additions & 2 deletions src/@seed/api/audit-template/audit-template.types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export type AuditTemplateReportType = {
name: string;
export type AuditTemplateReportTypesResponse = {
status: string;
data: string[];
}

export type AuditTemplateConfig = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,8 @@
<mat-label>{{ t('Audit Template Report Type') }}</mat-label>
<mat-select formControlName="audit_template_report_type">
<mat-option value="">None</mat-option>
@for (atrt of auditTemplateReportTypes; track atrt.name) {
<mat-option [value]="atrt.name">{{ atrt.name }}</mat-option>
@for (atrt of auditTemplateReportTypes; track atrt) {
<mat-option [value]="atrt">{{ atrt }}</mat-option>
}
</mat-select>
</mat-form-field>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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),
Expand Down
Loading