diff --git a/Frontend Angular 4/angular.json b/Frontend Angular 4/angular.json index 44c4fc7e280a97bf6d883d3853200486dfd84683..105f7599bcc25fc3fc8bbb45c025fab93aaf7dc6 100644 --- a/Frontend Angular 4/angular.json +++ b/Frontend Angular 4/angular.json @@ -57,7 +57,8 @@ "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { - "browserTarget": "cli-stable:build" + "browserTarget": "cli-stable:build", + "proxyConfig": "proxy.conf.json" }, "configurations": { "production": { diff --git a/Frontend Angular 4/proxy.conf.json b/Frontend Angular 4/proxy.conf.json new file mode 100644 index 0000000000000000000000000000000000000000..50eaf9b54c10f902b76920763d0c911152eec9ba --- /dev/null +++ b/Frontend Angular 4/proxy.conf.json @@ -0,0 +1,15 @@ +{ + "/servicios/": { + "target": "http://localhost:8080/matefun", + "secure": false, + "changeOrigin": true, + "logLevel": "debug" + }, + "/servicios/*": { + "target": "http://localhost:8080/matefun", + "secure": false, + "changeOrigin": true, + "logLevel": "debug", + "ws": true + } +} diff --git a/Frontend Angular 4/src/app/shared/services/haskell.service.ts b/Frontend Angular 4/src/app/shared/services/haskell.service.ts index c33c13b53301e21fa6e253f55fb95494daf5f9aa..1cd7ff9e6022ce0b7a4404b55424d73398c42cec 100755 --- a/Frontend Angular 4/src/app/shared/services/haskell.service.ts +++ b/Frontend Angular 4/src/app/shared/services/haskell.service.ts @@ -28,11 +28,15 @@ export class HaskellService { this.translateService = translate; } - getArchivos(cedula: string): Observable<Archivo[]> { - let headers = new HttpHeaders({ + private getHeaders() { + return new HttpHeaders({ "Content-Type": "application/json", Authorization: "Bearer " + this.authService.getToken(), }); + } + + getArchivos(cedula: string): Observable<Archivo[]> { + let headers = this.getHeaders(); let params: HttpParams = new HttpParams(); params.set("cedula", cedula); let httpOptions = { headers: headers, params: params }; @@ -43,10 +47,7 @@ export class HaskellService { } getArchivosCompartidosAlumno(cedula: string): Observable<Archivo[]> { - let headers = new HttpHeaders({ - "Content-Type": "application/json", - Authorization: "Bearer " + this.authService.getToken(), - }); + let headers = this.getHeaders(); let params: HttpParams = new HttpParams(); params.set("cedula", cedula); params.set("compartidos", "true"); @@ -58,10 +59,7 @@ export class HaskellService { } crearArchivo(archivo: Archivo): Observable<Archivo> { - let headers = new HttpHeaders({ - "Content-Type": "application/json", - Authorization: "Bearer " + this.authService.getToken(), - }); + let headers = this.getHeaders(); let httpOptions = { headers: headers }; @@ -71,10 +69,7 @@ export class HaskellService { } editarArchivo(archivoId, archivo: Archivo): Observable<Archivo> { - let headers = new HttpHeaders({ - "Content-Type": "application/json", - Authorization: "Bearer " + this.authService.getToken(), - }); + let headers = this.getHeaders(); let httpOptions = { headers: headers }; return this.http @@ -87,10 +82,7 @@ export class HaskellService { } eliminarArchivo(archivoId): Observable<Response> { - let headers = new HttpHeaders({ - "Content-Type": "application/json", - Authorization: "Bearer " + this.authService.getToken(), - }); + let headers = this.getHeaders(); let httpOptions = { headers: headers }; return this.http @@ -99,10 +91,7 @@ export class HaskellService { } getCopiaArchivoCompartidoGrupo(cedula, archivoId): Observable<Archivo> { - let headers = new HttpHeaders({ - "Content-Type": "application/json", - Authorization: "Bearer " + this.authService.getToken(), - }); + let headers = this.getHeaders(); let params: HttpParams = new HttpParams(); params.set("cedula", cedula); let httpOptions = { headers: headers, params: params }; @@ -116,10 +105,7 @@ export class HaskellService { } compartirArchivoGrupo(grupo, archivoId): Observable<Archivo> { - let headers = new HttpHeaders({ - "Content-Type": "application/json", - Authorization: "Bearer " + this.authService.getToken(), - }); + let headers = this.getHeaders(); let httpOptions = { headers: headers }; var archId = { id: archivoId, @@ -143,10 +129,7 @@ export class HaskellService { } calificarArchivo(archivoId, estado, evaluacion): Observable<Evaluacion> { - let headers = new HttpHeaders({ - "Content-Type": "application/json", - Authorization: "Bearer " + this.authService.getToken(), - }); + let headers = this.getHeaders(); let httpOptions = { headers: headers }; return this.http .post<Evaluacion>( @@ -163,10 +146,7 @@ export class HaskellService { } getGrupos(cedula: string): Observable<Grupo[]> { - let headers = new HttpHeaders({ - "Content-Type": "application/json", - Authorization: "Bearer " + this.authService.getToken(), - }); + let headers = this.getHeaders(); let params: HttpParams = new HttpParams(); params.set("cedula", cedula); let httpOptions = { headers: headers, params: params };