From a720c57a26490226bc7dd03f6d28a0fd6020e407 Mon Sep 17 00:00:00 2001 From: Alexis Hernandez Date: Sun, 8 Apr 2018 00:25:23 -0500 Subject: [PATCH] web-ui: Add TickerService --- web-ui/src/app/app.module.ts | 2 ++ web-ui/src/app/models/ticker.ts | 6 ++++++ web-ui/src/app/services/ticker.service.ts | 24 +++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 web-ui/src/app/models/ticker.ts create mode 100644 web-ui/src/app/services/ticker.service.ts diff --git a/web-ui/src/app/app.module.ts b/web-ui/src/app/app.module.ts index 076287c..62cfbbc 100644 --- a/web-ui/src/app/app.module.ts +++ b/web-ui/src/app/app.module.ts @@ -18,6 +18,7 @@ import { ErrorService } from './services/error.service'; import { LanguageService } from './services/language.service'; import { NavigatorService } from './services/navigator.service'; import { NotificationService } from './services/notification.service'; +import { TickerService } from './services/ticker.service'; import { TransactionsService } from './services/transactions.service'; import { AppComponent } from './app.component'; @@ -66,6 +67,7 @@ import { LatestBlocksComponent } from './components/latest-blocks/latest-blocks. LanguageService, NavigatorService, NotificationService, + TickerService, TransactionsService ], bootstrap: [AppComponent] diff --git a/web-ui/src/app/models/ticker.ts b/web-ui/src/app/models/ticker.ts new file mode 100644 index 0000000..a44159a --- /dev/null +++ b/web-ui/src/app/models/ticker.ts @@ -0,0 +1,6 @@ + +export class ServerStats { + totalSupply: number; + transactions: number; + height: number; +} diff --git a/web-ui/src/app/services/ticker.service.ts b/web-ui/src/app/services/ticker.service.ts new file mode 100644 index 0000000..1d5b89b --- /dev/null +++ b/web-ui/src/app/services/ticker.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 { ServerStats } from '../models/ticker'; + +const httpOptions = { + headers: new HttpHeaders({ 'Content-Type': 'application/json' }) +}; + +@Injectable() +export class TickerService { + + private baseUrl = environment.api.url + '/stats'; + + constructor(private http: HttpClient) { } + + get(): Observable { + const url = this.baseUrl; + return this.http.get(url); + } +}