dockerfile-build-form component working with promise-based method

This commit is contained in:
alecmerdler 2017-03-10 16:01:41 -08:00
parent 4e913f106d
commit 4303f658e8

View file

@ -15,14 +15,19 @@ export class DockerfileServiceImpl implements DockerfileService {
return new Promise((resolve, reject) => {
var reader: FileReader = this.fileReaderFactory();
reader.onload = (event: any) => {
// FIXME: Debugging
console.log(event.target.result);
this.DataFileService.readDataArrayAsPossibleArchive(event.target.result,
(files: any[]) => {
this.processFiles(files)
.then((dockerfileInfo: DockerfileInfoImpl) => resolve(dockerfileInfo))
.catch((error: string) => reject(error));
if (files.length > 0) {
this.processFiles(files)
.then((dockerfileInfo: DockerfileInfoImpl) => resolve(dockerfileInfo))
.catch((error: string) => reject(error));
}
// Not an archive. Read directly as a single file.
else {
this.processFile(event.target.result)
.then((dockerfileInfo: DockerfileInfoImpl) => resolve(dockerfileInfo))
.catch((error: string) => reject(error));
}
},
() => {
// Not an archive. Read directly as a single file.