diff --git a/src/accounts/account.module.ts b/src/accounts/account.module.ts index bdb5bf4..c2c5e59 100644 --- a/src/accounts/account.module.ts +++ b/src/accounts/account.module.ts @@ -3,10 +3,9 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; -import { HttpModule } from '@angular/http'; +import { HttpClientModule } from '@angular/common/http'; import { NgLoggerModule, Level } from '@nsalaun/ng-logger'; -import { RestangularModule } from 'ngx-restangular'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { ToastrModule } from 'ngx-toastr'; @@ -21,11 +20,10 @@ import { DailyBalanceService } from './dailyBalance.service'; @NgModule({ imports: [ - HttpModule, + HttpClientModule, CommonModule, FormsModule, NgLoggerModule, - RestangularModule, ToastrModule, NgbModule ], diff --git a/src/accounts/account.service.ts b/src/accounts/account.service.ts index 5003350..f183fbb 100644 --- a/src/accounts/account.service.ts +++ b/src/accounts/account.service.ts @@ -1,42 +1,41 @@ // vim: set tw=80 ts=2 sw=2 sts=2 : import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs/Rx'; +import { HttpClient } from '@angular/common/http'; -import { Restangular } from "ngx-restangular"; +import { Observable } from 'rxjs/Rx'; import { Account } from './account'; @Injectable() export class AccountService { constructor( - private restangular: Restangular + private http: HttpClient ) {} - private all() { - return this.restangular.all('account'); - } + url(id?: Number): string { + if(id) { + return `/api/account/${id}`; + } - private one(id: number) { - return this.restangular.one('account', id); + return `/api/account`; } - query(): Observable { - return this.all().getList(); + return this.http.get(this.url()); } get(id: number): Observable { - return this.one(id).get(); + return this.http.get(this.url(id)); } create(account: Account): Observable { - return this.all().post(account); + return this.http.post(this.url(), account); } update(account: Account): Observable { - return this.one(account.id).post(null, account); + return this.http.post(this.url(account.id), account); } delete(account: Account): Observable { - return this.one(account.id).remove(); + return this.http.delete(this.url(account.id)); } } diff --git a/src/accounts/accountBalances.service.ts b/src/accounts/accountBalances.service.ts index 77b99fa..020b4c3 100644 --- a/src/accounts/accountBalances.service.ts +++ b/src/accounts/accountBalances.service.ts @@ -2,17 +2,17 @@ import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Rx'; -import { Restangular } from "ngx-restangular"; +import { HttpClient, HttpParams } from "@angular/common/http"; import { AccountBalances } from './accountBalances'; @Injectable() export class AccountBalancesService { constructor( - private restangular: Restangular + private http: HttpClient ) {} get(id: number): Observable { - return this.restangular.one('account', id).one('balances').get(); + return this.http.get(`/api/account/${id}/balances`); } } diff --git a/src/accounts/dailyBalance.service.ts b/src/accounts/dailyBalance.service.ts index 8c41dcf..774c8ea 100644 --- a/src/accounts/dailyBalance.service.ts +++ b/src/accounts/dailyBalance.service.ts @@ -1,19 +1,19 @@ // vim: set tw=80 ts=2 sw=2 sts=2: import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs/Rx'; +import { HttpClient, HttpParams } from '@angular/common/http'; -import { Restangular } from "ngx-restangular"; +import { Observable } from 'rxjs/Rx'; import { DailyBalance } from './dailyBalance'; @Injectable() export class DailyBalanceService { constructor( - private restangular: Restangular + private http: HttpClient ) {} query(id: number): Observable { - return this.restangular.one('account', id).one('daily_balances').getList(); + return this.http.get(`/api/account/${id}/daily_balances`); } }