opt-cc/static/src/app/services/logs/war.service.ts

43 lines
994 B
TypeScript
Raw Normal View History

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) {
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);
}
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) {
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
}