1
0
Fork 0
mirror of https://github.com/sensebox/blockly-app synced 2026-01-03 10:31:29 +01:00

compilerservice

This commit is contained in:
Kirubamoh 2018-11-19 12:42:55 +01:00
parent 657db355ec
commit 0e02f71fce
8 changed files with 74 additions and 11 deletions

View file

@ -4,6 +4,7 @@ import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { HomePage } from '../pages/home/home';
import { BlocklyPage } from '../pages/Blockly/blockly';
import { OtaWizardPage } from '../pages/ota-wizard/ota-wizard';
@Component({

View file

@ -10,6 +10,7 @@ import { ApiProvider } from '../providers/api/api';
import { HttpClientModule } from '@angular/common/http';
import { OtaWizardPage } from '../pages/ota-wizard/ota-wizard';
import { OtaWizardPageModule } from '../pages/ota-wizard/ota-wizard.module';
import { CompilerProvider } from '../providers/compiler/compiler';
@NgModule({
declarations: [
@ -33,6 +34,7 @@ import { OtaWizardPageModule } from '../pages/ota-wizard/ota-wizard.module';
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
ApiProvider,
CompilerProvider,
]
})
export class AppModule {}

View file

@ -19,11 +19,18 @@
<!-- Real floating action button, fixed. It will not scroll with the content -->
<ion-fab top right edge>
<button ion-fab mini (click)="launchOtaWizard()" color ="light"><ion-icon name="wifi"></ion-icon></button>
<button ion-fab mini (click)="launchOtaWizard() " color ="light"><ion-icon name="wifi"></ion-icon></button>
</ion-fab>
<div>
Blockly should be displayed here !
</div>
<ion-item>
<ion-textarea placeholder="Enter your text here" #sketchtext>
<ion-input>id = "sketchtext" </ion-input>
</ion-textarea>
</ion-item>
</ion-content>

View file

@ -1,3 +1,10 @@
page-blockly {
$text-input-highlight-color-valid : #32db64
Color of the input highlight when valid
$text-input-highlight-color-invalid #f53d3d
Color of the input highlight when invalid
$text-input-placeholder-color #999
Color of the input placeholder
}

View file

@ -15,18 +15,20 @@ import { OtaWizardPage } from '../ota-wizard/ota-wizard';
templateUrl: 'blockly.html',
})
export class BlocklyPage {
sketchtext = ""
constructor(
public navCtrl: NavController,
public navParams: NavParams) {
}
goTo(sketch) {
this.sketchtext = '' || 'No text Entered';}
ionViewDidLoad() {
console.log('ionViewDidLoad SenseBoxPage');
}
launchOtaWizard () {
this.navCtrl.setRoot(OtaWizardPage)
launchOtaWizard() {
this.navCtrl.setRoot(OtaWizardPage,{sketch : this.sketchtext})
}
}

View file

@ -22,7 +22,7 @@
We will help you connect to your senseBox via <b>WiFi</b>.
</p>
</ion-col>
<ion-col col-12 col-md-6>
<p>First, please make sure that your senseBox...</p>
<ul style="text-align: left">

View file

@ -7,6 +7,8 @@ import {
import {
IonicPage,
Slides,
NavController,
NavParams,
} from 'ionic-angular'
import { Network } from '@ionic-native/network'
import { Subscription } from 'rxjs/Subscription';
@ -23,7 +25,7 @@ export class OtaWizardPage implements OnInit, OnDestroy {
onlineSub: Subscription
offlineSub: Subscription
filterSsids = false // TODO: add toggle to UI?
sketch = ""
filterSsids = true
availableSenseboxes: string[] = [] // list of SSIDs
compiledSketch = undefined
@ -39,8 +41,11 @@ export class OtaWizardPage implements OnInit, OnDestroy {
constructor(
private network: Network,
private otaWifi: OtaWifiProvider,
) {
}
private navCtrl : NavController,
navParams : NavParams,
)
{ this.sketch = navParams.get("sketch")
}
ngOnInit() {
// try to start compilation already in the background

View file

@ -0,0 +1,39 @@
import { HttpClient,HttpHeaders } from '@angular/common/http';
import { Http, Headers, RequestOptions } from '@angular/http';
import { Injectable } from '@angular/core';
/*
Generated class for the CompilerProvider provider.
See https://angular.io/guide/dependency-injection for more info on providers
and Angular DI.
*/
@Injectable()
export class CompilerProvider {
constructor(public http: HttpClient) {
console.log('Hello CompilerProvider Provider');
}
async callcompiler(Binary : string): Promise<any> {
let Headers = new HttpHeaders({'Content-Type': 'application/json'} );
/*let options = new RequestOptions({ headers: headers });*/
let data ='{"board":"sensebox-mcu", "sketch":"void setup() {\nSerial.begin(9600);\nSerial.println(\"Hello World\");\n}\nvoid loop() {}"}'
return this.http.post('url', data,{ headers:new HttpHeaders({'Content-Type': 'application/json'} ) })
.toPromise()
.then((response) =>
{
console.log('API Response : ', response.json());
return response.json();
})
};
};
/* .catch((error) =>
{
console.error('API Error : ', error.status);
console.error('API Error : ', JSON.stringify(error));
reject(error.json()); */