diff --git a/src/scheduler/schedule.module.ts b/src/scheduler/schedule.module.ts index b7e7649..5d2b435 100644 --- a/src/scheduler/schedule.module.ts +++ b/src/scheduler/schedule.module.ts @@ -3,9 +3,8 @@ 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 { RestangularModule } from 'ngx-restangular'; import { NgLoggerModule, Level } from '@nsalaun/ng-logger'; import { NgbModule } from '@ng-bootstrap/ng-bootstrap'; import { ToastrModule } from 'ngx-toastr'; @@ -24,11 +23,10 @@ export function accountIdServiceFactory(i: any) { @NgModule({ imports: [ - HttpModule, + HttpClientModule, CommonModule, FormsModule, NgLoggerModule, - RestangularModule, ToastrModule, NgbModule, TextMaskModule diff --git a/src/scheduler/schedule.service.ts b/src/scheduler/schedule.service.ts index d29036b..1d6ced2 100644 --- a/src/scheduler/schedule.service.ts +++ b/src/scheduler/schedule.service.ts @@ -1,49 +1,47 @@ // 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 { Schedule } from './schedule'; @Injectable() export class ScheduleService { constructor( - private restangular: Restangular + private http: HttpClient ) {} - private all() { - //return this.accountService.one(accountId).all('scheduled_operation'); - return this.restangular.all('scheduled_operation'); - } + private url(id?: number): string { + if(id) { + return `/api/scheduled_operation/${id}`; + } - private one(id: number) { - //return this.accountService.one(accountId).one('scheduled_operation', id); - return this.restangular.one('scheduled_operation', id); + return `/api/scheduled_operation`; } query(accountId: number): Observable { - return this.all().getList({ - account_id: accountId - }); + let params = new HttpParams().set('account_id', `${accountId}`); + + return this.http.get(this.url(), { params: params }); } get(accountId: number, id: number): Observable { - return this.one(id).get({ - account_id: accountId - }); + let params = new HttpParams().set('account_id', `${accountId}`); + + return this.http.get(this.url(id), { params: params }); } create(schedule: Schedule): Observable { - return this.all().post(schedule); + return this.http.post(this.url(), schedule); } update(schedule: Schedule): Observable { - return this.one(schedule.id).post(null, schedule); + return this.http.post(this.url(schedule.id), schedule); } delete(schedule: Schedule): Observable { - return this.one(schedule.id).remove(); + return this.http.delete(this.url(schedule.id)); } }