add dashboard service
This commit is contained in:
parent
7c1612f8da
commit
281fb3ae40
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { DashboardService } from './dashboard.service';
|
||||
|
||||
describe('DashboardService', () => {
|
||||
let service: DashboardService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(DashboardService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,27 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {IDashboardCommonBikePoint} from './domain/dashboard-common-bike-point';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {environment} from '../../environments/environment';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class DashboardService {
|
||||
public station: IDashboardCommonBikePoint;
|
||||
|
||||
constructor(private client: HttpClient) {
|
||||
}
|
||||
|
||||
setBikeStation(id: string): void {
|
||||
this.initialDashboardStationFetch(id).then((data) => {
|
||||
this.station = data;
|
||||
console.log(this.station);
|
||||
}).catch((error) => {
|
||||
console.log('something went wrong: ' + JSON.stringify(error));
|
||||
});
|
||||
}
|
||||
|
||||
private async initialDashboardStationFetch(id: string): Promise<any> {
|
||||
return await this.client.get(environment.apiUrl + 'latest/dashboard/' + id + '/').toPromise();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user