2017-07-08 21:56:11 +02:00
|
|
|
import {Injectable} from "@angular/core";
|
2017-09-12 15:02:35 +02:00
|
|
|
import {War} from "../../models/model-interfaces";
|
2017-07-08 21:56:11 +02:00
|
|
|
import {AppConfig} from "../../app.config";
|
|
|
|
import {HttpClient} from "../http-client";
|
|
|
|
|
|
|
|
@Injectable()
|
|
|
|
export class WarService {
|
|
|
|
|
|
|
|
constructor(private http: HttpClient,
|
|
|
|
private config: AppConfig) {
|
|
|
|
}
|
|
|
|
|
|
|
|
getWar(warId: string) {
|
2017-08-01 23:52:10 +02:00
|
|
|
return this.http.get(this.config.apiWarPath + '/' + warId)
|
2018-02-26 09:04:27 +01:00
|
|
|
.map(res => res.json())
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-14 23:33:17 +02:00
|
|
|
submitWar(war: War, logFile?) {
|
2017-07-08 21:56:11 +02:00
|
|
|
let body;
|
|
|
|
|
|
|
|
if (logFile) {
|
|
|
|
body = new FormData();
|
|
|
|
Object.keys(war).map((objectKey) => {
|
|
|
|
if (war[objectKey] !== undefined) {
|
|
|
|
body.append(objectKey, war[objectKey]);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
body.append('log', logFile, logFile.name);
|
|
|
|
}
|
|
|
|
|
2017-08-01 23:52:10 +02:00
|
|
|
return this.http.post(this.config.apiWarPath, body)
|
2018-02-26 09:04:27 +01:00
|
|
|
.map(res => res.json())
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|
|
|
|
|
2017-07-14 23:50:58 +02:00
|
|
|
deleteWar(id: string) {
|
2017-08-01 23:52:10 +02:00
|
|
|
return this.http.delete(this.config.apiWarPath + '/' + id)
|
2018-02-26 09:04:27 +01:00
|
|
|
.map(res => res.json())
|
2017-07-14 23:50:58 +02:00
|
|
|
}
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|
|
|
|
|