All Masters Done!!

This commit is contained in:
2020-06-15 21:40:12 +05:30
parent fdfd3dcbfb
commit 938bb67e0a
33 changed files with 1082 additions and 765 deletions

View File

@ -1,14 +1,14 @@
import {Injectable} from '@angular/core';
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
import {ErrorLoggerService} from '../core/error-logger.service';
import {catchError} from 'rxjs/operators';
import {Observable} from 'rxjs/internal/Observable';
import {Section} from '../core/section';
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { ErrorLoggerService } from '../core/error-logger.service';
import { catchError } from 'rxjs/operators';
import { Observable } from 'rxjs/internal/Observable';
import { Section } from '../core/section';
const httpOptions = {
headers: new HttpHeaders({'Content-Type': 'application/json'})
};
const url = '/v1/sections';
const url = '/api/sections';
const serviceName = 'SectionService';
@Injectable({
@ -19,7 +19,7 @@ export class SectionService {
}
get(id: string): Observable<Section> {
const getUrl: string = (id === null) ? `${url}/new` : `${url}/${id}`;
const getUrl: string = (id === null) ? url : `${url}/${id}`;
return <Observable<Section>>this.http.get<Section>(getUrl)
.pipe(
catchError(this.log.handleError(serviceName, `get id=${id}`))
@ -27,15 +27,14 @@ export class SectionService {
}
list(): Observable<Section[]> {
const options = {params: new HttpParams().set('l', '')};
return <Observable<Section[]>>this.http.get<Section[]>(url, options)
return <Observable<Section[]>>this.http.get<Section[]>(`${url}/list`)
.pipe(
catchError(this.log.handleError(serviceName, 'list'))
);
}
save(section: Section): Observable<Section> {
return <Observable<Section>>this.http.post<Section>(`${url}/new`, section, httpOptions)
return <Observable<Section>>this.http.post<Section>(url, section, httpOptions)
.pipe(
catchError(this.log.handleError(serviceName, 'save'))
);