mirror of
https://github.com/sensebox/blockly-app
synced 2025-12-03 14:47:55 +01:00
improve error message on compilation
This commit is contained in:
parent
3c1b9d1044
commit
b1fa8eca0a
2 changed files with 22 additions and 32 deletions
|
|
@ -156,7 +156,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
|||
private async handleUpload () {
|
||||
this.state.upload = 'uploading'
|
||||
try {
|
||||
const res = await this.otaWifi.uploadFirmware(this.sketch)
|
||||
const res = await this.otaWifi.uploadFirmware(this.compiledSketch)
|
||||
console.log(JSON.stringify(res, null, 2))
|
||||
|
||||
this.state.upload = 'done'
|
||||
|
|
@ -169,13 +169,9 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
|||
}
|
||||
|
||||
private async compileSketch () {
|
||||
// TODO: implement. use this.sketch
|
||||
|
||||
this.state.compilation = 'compiling'
|
||||
try {
|
||||
this.compiledSketch = await this.compilerprovider.callcompiler(this.sketch)
|
||||
console.log((this.compiledSketch))
|
||||
|
||||
this.state.compilation = 'done'
|
||||
this.slides.lockSwipeToNext(false)
|
||||
} catch (err) {
|
||||
|
|
|
|||
|
|
@ -1,38 +1,32 @@
|
|||
import { HttpClient,HttpHeaders } from '@angular/common/http';
|
||||
import { Http, Headers, RequestOptions } from '@angular/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { BindingFlags } from '@angular/core/src/view';
|
||||
|
||||
/*
|
||||
Generated class for the CompilerProvider provider.
|
||||
|
||||
See https://angular.io/guide/dependency-injection for more info on providers
|
||||
and Angular DI.
|
||||
*/
|
||||
const url = "https://compiler.sensebox.de"
|
||||
const URL = "https://compiler.sensebox.de"
|
||||
|
||||
@Injectable()
|
||||
export class CompilerProvider {
|
||||
|
||||
|
||||
constructor(public http: HttpClient) {
|
||||
console.log('Hello CompilerProvider Provider');
|
||||
}
|
||||
|
||||
async callcompiler(sketch : string): Promise<any> {
|
||||
let Headers = new HttpHeaders({'Content-Type': 'application/json'} );
|
||||
|
||||
/*let options = new RequestOptions({ headers: headers });*/
|
||||
|
||||
let data ={"board":"sensebox-mcu", "sketch":sketch}
|
||||
return this.http.post(`${url}/compile`, data,{ headers:new HttpHeaders({'Content-Type': 'application/json'} ) })
|
||||
.toPromise()
|
||||
.then((response:any) =>{
|
||||
console.log('API Response : ', response.data.id);
|
||||
return this.http.get(`${url}/download?id=${response.data.id}&board=sensebox-mcu`,{
|
||||
responseType: 'text',
|
||||
|
||||
async callcompiler(sketch : string): Promise<any> {
|
||||
const headers = new HttpHeaders({'Content-Type': 'application/json'} );
|
||||
const data = { board: 'sensebox-mcu', sketch }
|
||||
|
||||
// send compilation request, returning a job ID
|
||||
return this.http.post(`${URL}/compile`, data, { headers }).toPromise()
|
||||
.catch(err => {
|
||||
let msg = ''
|
||||
try { msg = JSON.parse(err.error.message).process } catch (err) {}
|
||||
throw new Error(msg || err)
|
||||
})
|
||||
.toPromise()
|
||||
|
||||
});
|
||||
.then((response:any) =>{
|
||||
// download the resulting sketch binary
|
||||
return this.http.get(`${URL}/download?id=${response.data.id}&board=sensebox-mcu`, {
|
||||
responseType: 'text',
|
||||
}).toPromise()
|
||||
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue