diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 41cf3f2f..19a6ecf2 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -56,6 +56,7 @@ import { ChartService } from './services/chart.service'; import { DataExportService } from './services/data-export.service'; import { ImageExportService } from './services/image-export.service'; import { ClimateModelService } from './services/climate-model.service'; +import { HistoricRangeService } from './services/historic-range.service'; import { IndicatorService } from './services/indicator.service'; import { ScenarioService } from './services/scenario.service'; import { ProjectService } from './services/project.service'; @@ -116,6 +117,7 @@ const locationStrategyProvider = { DataExportService, ImageExportService, ClimateModelService, + HistoricRangeService, IndicatorService, ScenarioService, ProjectService diff --git a/src/app/models/historic-range.model.ts b/src/app/models/historic-range.model.ts new file mode 100644 index 00000000..e70de4a0 --- /dev/null +++ b/src/app/models/historic-range.model.ts @@ -0,0 +1,4 @@ +export interface HistoricRange { + start_year: string; + end_year: string; +} diff --git a/src/app/services/historic-range.service.ts b/src/app/services/historic-range.service.ts new file mode 100644 index 00000000..2c9b229d --- /dev/null +++ b/src/app/services/historic-range.service.ts @@ -0,0 +1,21 @@ +import { Injectable } from '@angular/core'; +import { Observable } from 'rxjs/Rx'; + +import { HistoricRange } from '../models/historic-range.model'; +import { ApiHttp } from '../auth/api-http.service'; +import { apiHost } from '../constants'; + +/* + * Historic Range Service + * Returns available historic ranges from API + */ +@Injectable() +export class HistoricRangeService { + + constructor(private apiHttp: ApiHttp) {} + + public list(): Observable { + const url = apiHost + '/api/historic-range/'; + return this.apiHttp.get(url).map(resp => resp.json() || [] as HistoricRange[]); + } +}