2018-03-07 11:56:50 +01:00
|
|
|
import {Injectable} from '@angular/core';
|
|
|
|
import {War} from '../../models/model-interfaces';
|
|
|
|
import {AppConfig} from '../../app.config';
|
|
|
|
import {HttpClient} from '../http-client';
|
2017-07-08 21:56:11 +02:00
|
|
|
|
|
|
|
@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-03-07 11:56:50 +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-03-07 11:56:50 +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-03-07 11:56:50 +01:00
|
|
|
.map(res => res.json());
|
2017-07-14 23:50:58 +02:00
|
|
|
}
|
|
|
|
|
2017-07-08 21:56:11 +02:00
|
|
|
}
|
|
|
|
|