Added: Alembic for migrations
Moving from Pyramid to FastAPI
This commit is contained in:
@ -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 {Role} from './role';
|
||||
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 { Role } from './role';
|
||||
|
||||
const httpOptions = {
|
||||
headers: new HttpHeaders({'Content-Type': 'application/json'})
|
||||
};
|
||||
const url = '/v1/roles';
|
||||
const url = '/api/roles';
|
||||
const serviceName = 'RoleService';
|
||||
|
||||
@Injectable({
|
||||
@ -19,7 +19,7 @@ export class RoleService {
|
||||
}
|
||||
|
||||
get(id: string): Observable<Role> {
|
||||
const getUrl: string = (id === null) ? `${url}/new` : `${url}/${id}`;
|
||||
const getUrl: string = (id === null) ? `${url}` : `${url}/${id}`;
|
||||
return <Observable<Role>>this.http.get<Role>(getUrl)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, `get id=${id}`))
|
||||
@ -27,23 +27,14 @@ export class RoleService {
|
||||
}
|
||||
|
||||
list(): Observable<Role[]> {
|
||||
const options = {params: new HttpParams().set('l', '')};
|
||||
return <Observable<Role[]>>this.http.get<Role[]>(url, options)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
}
|
||||
|
||||
listOfNames(): Observable<string[]> {
|
||||
const options = {params: new HttpParams().set('n', '')};
|
||||
return <Observable<string[]>>this.http.get<string[]>(url, options)
|
||||
return <Observable<Role[]>>this.http.get<Role[]>(`${url}/list`)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'list'))
|
||||
);
|
||||
}
|
||||
|
||||
save(role: Role): Observable<Role> {
|
||||
return <Observable<Role>>this.http.post<Role>(`${url}/new`, role, httpOptions)
|
||||
return <Observable<Role>>this.http.post<Role>(`${url}`, role, httpOptions)
|
||||
.pipe(
|
||||
catchError(this.log.handleError(serviceName, 'save'))
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user