Browse Source

web-ui: Add the AddressesService

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
e2e9b205f4
  1. 2
      web-ui/src/app/app.module.ts
  2. 6
      web-ui/src/app/models/address.ts
  3. 24
      web-ui/src/app/services/addresses.service.ts

2
web-ui/src/app/app.module.ts

@ -12,6 +12,7 @@ import { ToastrModule } from 'ngx-toastr';
import { NgHttpLoaderModule } from 'ng-http-loader/ng-http-loader.module'
import { AddressesService } from './services/addresses.service';
import { ErrorService } from './services/error.service';
import { LanguageService } from './services/language.service';
import { NavigatorService } from './services/navigator.service';
@ -54,6 +55,7 @@ import { AddressDetailsComponent } from './components/address-details/address-de
TranslateModule.forRoot(),
],
providers: [
AddressesService,
ErrorService,
LanguageService,
NavigatorService,

6
web-ui/src/app/models/address.ts

@ -0,0 +1,6 @@
export class Address {
balance: number;
received: number;
transactionCount: number;
}

24
web-ui/src/app/services/addresses.service.ts

@ -0,0 +1,24 @@
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
import { environment } from '../../environments/environment';
import { Address } from '../models/address';
const httpOptions = {
headers: new HttpHeaders({ 'Content-Type': 'application/json' })
};
@Injectable()
export class AddressesService {
private baseUrl = environment.api.url + '/addresses';
constructor(private http: HttpClient) { }
get(address: string): Observable<Address> {
const url = `${this.baseUrl}/${address}`;
return this.http.get<Address>(url);
}
}
Loading…
Cancel
Save