|
|
|
import { Injectable } from '@angular/core'
|
|
|
|
import { HttpClient, HttpHeaders, HttpParams, HttpRequest } from '@angular/common/http'
|
|
|
|
import { Observable, Subject, throwError } from 'rxjs'
|
|
|
|
import { catchError } from 'rxjs/operators'
|
|
|
|
import { BaseService } from './base-service'
|
|
|
|
import { environment } from '../../environments/environment'
|
|
|
|
|
|
|
|
@Injectable({
|
|
|
|
providedIn: 'root'
|
|
|
|
})
|
|
|
|
export class ApisService extends BaseService {
|
|
|
|
|
|
|
|
private restApi = `${environment.API_URL}`
|
|
|
|
|
|
|
|
constructor(private http: HttpClient) {
|
|
|
|
super()
|
|
|
|
}
|
|
|
|
|
|
|
|
getPortfolio(section): Observable<any> {
|
|
|
|
let urlApi = `${this.restApi}?query=${section}`
|
|
|
|
return this.http.get<any>(urlApi).pipe(
|
|
|
|
catchError(this.handleError)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
getDetails(section, id): Observable<any> {
|
|
|
|
let urlApi = `${this.restApi}?query=detail&type=${section}&id=${id}`
|
|
|
|
return this.http.get<any>(urlApi).pipe(
|
|
|
|
catchError(this.handleError)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
// ADMIN SERVICES
|
|
|
|
uploadImage(body): Observable<any> {
|
|
|
|
let urlApi = `${this.restApi}upload.php`
|
|
|
|
return this.http.post<any>(urlApi, body).pipe(
|
|
|
|
catchError(this.handleError)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
removeImage(url): Observable<any> {
|
|
|
|
let urlApi = `${this.restApi}remove.php?url=${url}`
|
|
|
|
return this.http.get<any>(urlApi).pipe(
|
|
|
|
catchError(this.handleError)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|