Fix for delete error

This commit is contained in:
piotrpekala7
2020-08-20 00:32:54 +02:00
parent 72418a1a9f
commit a0073e1d23
3 changed files with 6 additions and 11 deletions

View File

@ -33,11 +33,9 @@ export class DeleteTemplateComponent {
dialogRef.afterClosed().subscribe((answer: boolean) => { dialogRef.afterClosed().subscribe((answer: boolean) => {
if (answer) { if (answer) {
this.templateService.deleteTemplate(this.server, templateId).subscribe((answer: boolean) => { this.templateService.deleteTemplate(this.server, templateId).subscribe((answer) => {
if(answer) { this.deleteEvent.emit(templateId);
this.deleteEvent.emit(templateId); this.toasterService.success(`Template ${templateName} deleted.`);
this.toasterService.success(`Template ${templateName} deleted.`);
}
}); });
} }
}); });

View File

@ -146,7 +146,7 @@ export class AddQemuVmTemplateComponent implements OnInit {
addTemplate() { addTemplate() {
if (!this.nameForm.invalid && !this.memoryForm.invalid && (this.selectedImage || this.chosenImage)) { if (!this.nameForm.invalid && !this.memoryForm.invalid && (this.selectedImage || this.chosenImage)) {
this.qemuTemplate.ram = this.memoryForm.get("ramMemory").value; this.qemuTemplate.ram = +this.memoryForm.get("ramMemory").value;
this.qemuTemplate.qemu_path = this.selectedBinary.path; this.qemuTemplate.qemu_path = this.selectedBinary.path;
if (this.newImageSelected) { if (this.newImageSelected) {
this.qemuTemplate.hda_disk_image = this.diskForm.get("fileName").value; this.qemuTemplate.hda_disk_image = this.diskForm.get("fileName").value;

View File

@ -17,10 +17,7 @@ export class TemplateService {
return this.httpServer.get<Template[]>(server, '/templates') as Observable<Template[]>; return this.httpServer.get<Template[]>(server, '/templates') as Observable<Template[]>;
} }
deleteTemplate(server: Server, templateId: string): Observable<boolean> { deleteTemplate(server: Server, templateId: string): Observable<any> {
return this.httpServer.delete(server, `/templates/${templateId}`, { observe: 'body' }).map(response => { return this.httpServer.delete(server, `/templates/${templateId}`, { observe: 'body' });
return true;
})
.catch((response) => { return Observable.throw(false)});
} }
} }