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