diff --git a/src/app/main/dropdown/dropdown.component.ts b/src/app/main/dropdown/dropdown.component.ts index 35db625..bc99b6d 100644 --- a/src/app/main/dropdown/dropdown.component.ts +++ b/src/app/main/dropdown/dropdown.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { EndItemService } from 'src/app/services/enditem.service'; +import { GeiaService } from 'src/app/services/api/geia.service'; import { SelectItem } from 'primeng/api'; @Component({ @@ -7,20 +8,22 @@ import { SelectItem } from 'primeng/api'; templateUrl: './dropdown.component.html', styleUrls: ['./dropdown.component.css'] }) -export class DropdownComponent { +export class DropdownComponent implements OnInit { constructor( - private endItemService: EndItemService + private endItemService: EndItemService, + private geiaService: GeiaService ) {} - // TODO replace with backend. - xaList: SelectItem[] = [ - { label: 'None selected', value: null }, - { label: 'UConn', value: 'Uconn' }, - { label: 'Test', value: 'Test' } - ]; + xaList: SelectItem[]; - selectedEndItem = ''; + selectedEndItem; + + async ngOnInit() { + const xas = await this.geiaService.getXAs().toPromise(); + this.xaList = xas.map(xa => ({ label: xa.endItemAcronymCode, value: xa.endItemAcronymCode })); + this.xaList.unshift({ label: 'None selected', value: null }); + } onChange(event: any) { this.endItemService.setEndItem(this.selectedEndItem); diff --git a/src/app/services/api/geia.service.ts b/src/app/services/api/geia.service.ts new file mode 100644 index 0000000..ca6068d --- /dev/null +++ b/src/app/services/api/geia.service.ts @@ -0,0 +1,52 @@ +import { APIService } from './api.service'; +import { Injectable } from '@angular/core'; +import { HttpClient } from '@angular/common/http'; +import { Observable } from 'rxjs'; + +@Injectable({ + providedIn: 'root' +}) +export class GeiaService extends APIService { + + baseEndpoint = 'geia'; + + constructor( + http: HttpClient + ) { + super(http); + } + + get(endpoint: string) { + return super._get(`${this.baseEndpoint}/${endpoint}`, { responseType: 'json' }) as unknown as Observable; + } + + post(endpoint: string, body: any) { + return super._post(`${this.baseEndpoint}/${endpoint}`, body); + } + + put(endpoint: string, body: any) { + return super._put(`${this.baseEndpoint}/${endpoint}`, body); + } + + getXAs() { + return this.get('XAList'); + } + + getXA(eiac: string) { + return this.get(`XA/${eiac}`); + } + + getTopLevelXBs(eiac: string) { + return this.get(`XA/${eiac}/XBChildren`); + } + + getXBs(eiac: string, lcn: string) { + return this.get(`XB/${eiac}/${lcn}/XBChildren`); + } + + getCAs(eiac: string, lcn: string) { + return this.get(`XB/${eiac}/${lcn}/CAChildren`); + } + + +}