Commit 90f0a050 authored by RenanMontenegro3's avatar RenanMontenegro3

"feat:adição do environment.ts"

parent 33475603
......@@ -4,16 +4,16 @@ import { catchError, tap } from 'rxjs/operators';
import { AsyncValidatorFn, AbstractControl, ValidationErrors, Validators } from '@angular/forms';
import { map } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { environment } from '../../../environments/environment'; // Importa o environment
@Injectable({
providedIn: 'root'
})
export class BlackListService {
users:any[]=[];
private apiUrl = 'http://localhost:8080/api/black-list';
private apiUrl_verifica_imo = 'http://localhost:8080/api/vdatas';
users: any[] = [];
private apiUrl = environment.API_URL + '/api/black-list';
private apiUrl_verifica_imo = environment.API_URL + '/api/vdatas';
constructor(private _http: HttpClient) {}
......@@ -23,7 +23,7 @@ export class BlackListService {
this.users = res;
}),
catchError(error => {
return throwError(error);
return throwError(error);
}));
}
......@@ -33,16 +33,15 @@ export class BlackListService {
this.users = res;
}),
catchError(error => {
return throwError(error);
return throwError(error);
}));
}
getEmployeeList(pageIndex: number, pageSize: number): Observable<any> {
let params = new HttpParams()
.set('page', pageIndex.toString())
.set('size', pageSize.toString());
return this._http.get<any>(this.apiUrl, { params }).pipe(
tap((res: any) => {
this.users = res;
......@@ -60,7 +59,7 @@ export class BlackListService {
this.users = res;
}),
catchError(error => {
return throwError(error);
return throwError(error);
})
);
}
......@@ -73,7 +72,7 @@ export class BlackListService {
}),
catchError(error => {
console.log(error)
return throwError(error);
return throwError(error);
})
);
}
......@@ -84,7 +83,7 @@ export class BlackListService {
this.users = res;
}),
catchError(error => {
return throwError(error);
return throwError(error);
}));
}
}
\ No newline at end of file
}
......@@ -5,19 +5,20 @@ import { AsyncValidatorFn, AbstractControl, ValidationErrors, Validators } from
import { map } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { of } from 'rxjs';
import { environment } from '../../../environments/environment'; // Importa o environment
@Injectable({
providedIn: 'root'
})
export class AceiteService {
users: any[] = [];
private apiUrl = 'http://localhost:8080/api/accepts';
private apiUrl_verifica_imo = 'http://localhost:8080/api/vdatas';
private apiUrl = environment.API_URL + '/api/accepts';
private apiUrl_verifica_imo = environment.API_URL + '/api/vdatas';
constructor(private _http: HttpClient) { }
addAceite(data: any, foto: File | null): Observable<any> {
console.log(JSON.stringify(JSON.stringify(data)));
......
......@@ -5,6 +5,7 @@ import { AsyncValidatorFn, AbstractControl, ValidationErrors, Validators } from
import { map} from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { of } from 'rxjs';
import { environment } from '../../../environments/environment'; // Importa o environment
@Injectable({
providedIn: 'root'
......@@ -12,12 +13,12 @@ import { of } from 'rxjs';
export class BercosService {
users:any[]=[];
private apiUrl = 'http://localhost:8080/api/bercos';
private apiUrl = environment.API_URL + '/api/bercos';
constructor(private _http: HttpClient) {}
addEmployee(data: any): Observable<any> {
return this._http.post(this.apiUrl, data).pipe(
......@@ -36,7 +37,7 @@ export class BercosService {
this.users = res;
}),
catchError(error => {
return throwError(error);
return throwError(error);
}));
}
......@@ -62,7 +63,7 @@ export class BercosService {
this.users = res;
}),
catchError(error => {
return throwError(error);
return throwError(error);
})
);
}
......@@ -73,7 +74,7 @@ export class BercosService {
this.users = res;
}),
catchError(error => {
return throwError(error);
return throwError(error);
}));
}
......@@ -90,7 +91,7 @@ export class BercosService {
searchBerco(data: any): Observable<any> {
let params = new HttpParams();
// Adiciona os parâmetros de forma condicional (apenas se existirem)
if (data.categoria) {
params = params.set('categoria', data.categoria);
......@@ -98,7 +99,7 @@ export class BercosService {
if (data.nome) {
params = params.set('nome', data.nome);
}
// Faz a requisição GET com os parâmetros
return this._http.get<any>(`${this.apiUrl}/custom`, { params }).pipe(
tap((res: any) => {
......@@ -107,7 +108,7 @@ export class BercosService {
}),
catchError(error => {
console.error('Erro ao buscar dados:', error);
return throwError(error);
return throwError(error);
})
);
}
......
......@@ -2,12 +2,13 @@ import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { LoginResponse } from '../types/login-response.type';
import { tap } from 'rxjs';
import { environment } from '../../environments/environment'; // Importa o environment
@Injectable({
providedIn: 'root'
})
export class LoginService {
apiUrl: string = "http://localhost:8080/api/auth"
apiUrl: string = environment.API_URL + "/api/auth"; // Usa a variável do environment
constructor(private httpClient: HttpClient) { }
......@@ -29,4 +30,4 @@ export class LoginService {
})
);
}
}
\ No newline at end of file
}
......@@ -6,14 +6,15 @@ import {
} from '@angular/common/http';
import { Observable, throwError } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
import { environment } from '../../environments/environment'; // Importa o environment
@Injectable({
providedIn: 'root',
})
export class NavioService {
users: any[] = [];
private apiUrl = 'http://localhost:8080/api/vessels';
private apiUrlDash = 'http://localhost:8080/statistics/all';
private apiUrl = environment.API_URL + '/api/vessels';
private apiUrlDash = environment.API_URL + '/statistics/all';
constructor(private _http: HttpClient) {}
addEmployee1(data: any, foto: File): Observable<any> {
......@@ -172,5 +173,5 @@ export class NavioService {
);
}
}
import { HttpClient, HttpParams } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { catchError, Observable, tap, throwError } from 'rxjs';
import { environment } from '../../../environments/environment'; // Importa o environment
@Injectable({
providedIn: 'root'
})
export class UserService {
private apiUrl = 'http://localhost:8080/api/users'; // Certifique-se de que a URL está correta
private apiUrl = environment.API_URL + '/api/users'; // Usa a variável do environment
private users: any; // Adicione a propriedade users
constructor(private _http: HttpClient) {}
......@@ -30,7 +31,7 @@ export class UserService {
sendEmail(userId: number, sendEmail: boolean): Observable<any> {
const url = `${this.apiUrl}/${userId}`; // Monta a URL para o usuário específico
const body = { sendEmail: sendEmail ? 1 : 0 }; // Envia 1 para true e 0 para false
return this._http.put<any>(url, body).pipe(
tap(() => {
console.log(`Email status atualizado para o usuário com ID: ${userId}`);
......
export const environment = {
production: false,
API_URL: 'http://aceite-tecnico-back:9090'
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment