Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added geia service, pull XA list from backend.
  • Loading branch information
dds14002 committed Mar 30, 2020
1 parent 966d1b8 commit 0b9cae7
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/app/main/dropdown/dropdown.component.ts
@@ -1,26 +1,29 @@
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({
selector: 'app-dropdown',
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);
Expand Down
52 changes: 52 additions & 0 deletions 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<T>(endpoint: string) {
return super._get(`${this.baseEndpoint}/${endpoint}`, { responseType: 'json' }) as unknown as Observable<T>;
}

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<any[]>('XAList');
}

getXA(eiac: string) {
return this.get<any>(`XA/${eiac}`);
}

getTopLevelXBs(eiac: string) {
return this.get<any[]>(`XA/${eiac}/XBChildren`);
}

getXBs(eiac: string, lcn: string) {
return this.get<any[]>(`XB/${eiac}/${lcn}/XBChildren`);
}

getCAs(eiac: string, lcn: string) {
return this.get<any[]>(`XB/${eiac}/${lcn}/CAChildren`);
}


}

0 comments on commit 0b9cae7

Please sign in to comment.