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

43 lines
964 B
TypeScript
Raw Normal View History

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) {
return this.http.get(this.config.apiWarPath + '/' + warId)
2017-07-08 21:56:11 +02:00
.map(res => res.json())
}
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)
2017-07-08 21:56:11 +02:00
.map(res => res.json())
}
2017-07-14 23:50:58 +02:00
deleteWar(id: string) {
return this.http.delete(this.config.apiWarPath + '/' + id)
2017-07-14 23:50:58 +02:00
.map(res => res.json())
}
2017-07-08 21:56:11 +02:00
}