7 changed files with 79 additions and 20 deletions
@ -1,19 +1,22 @@ |
|||||
import { Injectable } from '@angular/core'; |
import { Injectable } from '@angular/core'; |
||||
import { HttpClient, HttpHeaders } from "@angular/common/http"; |
import { HttpClient, HttpHeaders } from "@angular/common/http"; |
||||
import { Observable } from "rxjs"; |
import { Observable } from "rxjs"; |
||||
|
import { ServerEndpointService } from './server-endpoint.service'; |
||||
|
|
||||
@Injectable({ |
@Injectable({ |
||||
providedIn: 'root' |
providedIn: 'root' |
||||
}) |
}) |
||||
export class ReplaysService { |
export class ReplaysService { |
||||
server_route: string = "http://172.16.40.146:3000/" |
|
||||
|
|
||||
constructor(private httpClient: HttpClient) { |
constructor( |
||||
|
private httpClient: HttpClient, |
||||
|
private serverEndpointService: ServerEndpointService |
||||
|
) { |
||||
} |
} |
||||
|
|
||||
uploadReplay(newReplay: FormData) { |
uploadReplay(newReplay: FormData) { |
||||
const headers = new HttpHeaders(); |
const headers = new HttpHeaders(); |
||||
headers.append('Content-Type', 'multipart/form-data'); |
headers.append('Content-Type', 'multipart/form-data'); |
||||
return this.httpClient.post(this.server_route+'upload/replay', newReplay, { headers }); |
return this.httpClient.post(this.serverEndpointService.getCurrentEndpoint()+"upload/replay", newReplay, { headers }); |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,16 @@ |
|||||
|
import { TestBed } from '@angular/core/testing'; |
||||
|
|
||||
|
import { ServerEndpointService } from './server-endpoint.service'; |
||||
|
|
||||
|
describe('ServerEndpointService', () => { |
||||
|
let service: ServerEndpointService; |
||||
|
|
||||
|
beforeEach(() => { |
||||
|
TestBed.configureTestingModule({}); |
||||
|
service = TestBed.inject(ServerEndpointService); |
||||
|
}); |
||||
|
|
||||
|
it('should be created', () => { |
||||
|
expect(service).toBeTruthy(); |
||||
|
}); |
||||
|
}); |
||||
@ -0,0 +1,24 @@ |
|||||
|
import { Injectable } from '@angular/core'; |
||||
|
|
||||
|
@Injectable({ |
||||
|
providedIn: 'root' |
||||
|
}) |
||||
|
export class ServerEndpointService { |
||||
|
|
||||
|
currentHost: string; |
||||
|
currentPort: string; |
||||
|
|
||||
|
constructor() |
||||
|
{ |
||||
|
this.currentHost = "localhost"; |
||||
|
this.currentPort = "3000"; |
||||
|
} |
||||
|
|
||||
|
testAndSetEndpoint() { |
||||
|
|
||||
|
} |
||||
|
|
||||
|
getCurrentEndpoint(): string { |
||||
|
return "http://" + this.currentHost + ":" + this.currentPort + "/"; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue