Skip to content
This repository has been archived by the owner on Aug 21, 2023. It is now read-only.

Commit

Permalink
Add historic range query service
Browse files Browse the repository at this point in the history
To discover the available historic ranges.
  • Loading branch information
flibbertigibbet committed Sep 2, 2017
1 parent 18b28b9 commit 9dcaa51
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -116,6 +117,7 @@ const locationStrategyProvider = {
DataExportService,
ImageExportService,
ClimateModelService,
HistoricRangeService,
IndicatorService,
ScenarioService,
ProjectService
Expand Down
4 changes: 4 additions & 0 deletions src/app/models/historic-range.model.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface HistoricRange {
start_year: string;
end_year: string;
}
21 changes: 21 additions & 0 deletions src/app/services/historic-range.service.ts
Original file line number Diff line number Diff line change
@@ -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<HistoricRange[]> {
const url = apiHost + '/api/historic-range/';
return this.apiHttp.get(url).map(resp => resp.json() || [] as HistoricRange[]);
}
}

0 comments on commit 9dcaa51

Please sign in to comment.