mirror of
https://github.com/sensebox/blockly-app
synced 2026-01-03 10:31:29 +01:00
Merge remote-tracking branch 'origin/compiler-service' into development_norwin
This commit is contained in:
commit
ab19194acd
8 changed files with 72 additions and 10 deletions
|
|
@ -4,6 +4,7 @@ import { StatusBar } from '@ionic-native/status-bar';
|
||||||
import { SplashScreen } from '@ionic-native/splash-screen';
|
import { SplashScreen } from '@ionic-native/splash-screen';
|
||||||
|
|
||||||
import { HomePage } from '../pages/home/home';
|
import { HomePage } from '../pages/home/home';
|
||||||
|
import { BlocklyPage } from '../pages/Blockly/blockly';
|
||||||
import { OtaWizardPage } from '../pages/ota-wizard/ota-wizard';
|
import { OtaWizardPage } from '../pages/ota-wizard/ota-wizard';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ import { ApiProvider } from '../providers/api/api';
|
||||||
import { HttpClientModule } from '@angular/common/http';
|
import { HttpClientModule } from '@angular/common/http';
|
||||||
import { OtaWizardPage } from '../pages/ota-wizard/ota-wizard';
|
import { OtaWizardPage } from '../pages/ota-wizard/ota-wizard';
|
||||||
import { OtaWizardPageModule } from '../pages/ota-wizard/ota-wizard.module';
|
import { OtaWizardPageModule } from '../pages/ota-wizard/ota-wizard.module';
|
||||||
|
import { CompilerProvider } from '../providers/compiler/compiler';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
|
|
@ -33,6 +34,7 @@ import { OtaWizardPageModule } from '../pages/ota-wizard/ota-wizard.module';
|
||||||
SplashScreen,
|
SplashScreen,
|
||||||
{provide: ErrorHandler, useClass: IonicErrorHandler},
|
{provide: ErrorHandler, useClass: IonicErrorHandler},
|
||||||
ApiProvider,
|
ApiProvider,
|
||||||
|
CompilerProvider,
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
export class AppModule {}
|
export class AppModule {}
|
||||||
|
|
|
||||||
|
|
@ -19,11 +19,18 @@
|
||||||
|
|
||||||
<!-- Real floating action button, fixed. It will not scroll with the content -->
|
<!-- Real floating action button, fixed. It will not scroll with the content -->
|
||||||
<ion-fab top right edge>
|
<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>
|
</ion-fab>
|
||||||
<div>
|
<div>
|
||||||
Blockly should be displayed here !
|
Blockly should be displayed here !
|
||||||
</div>
|
</div>
|
||||||
|
<ion-item>
|
||||||
|
<ion-textarea placeholder="Enter your text here" #sketchtext>
|
||||||
|
<ion-input>id = "sketchtext" </ion-input>
|
||||||
|
|
||||||
|
</ion-textarea>
|
||||||
|
</ion-item>
|
||||||
|
|
||||||
</ion-content>
|
</ion-content>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
page-blockly {
|
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
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,18 +15,20 @@ import { OtaWizardPage } from '../ota-wizard/ota-wizard';
|
||||||
templateUrl: 'blockly.html',
|
templateUrl: 'blockly.html',
|
||||||
})
|
})
|
||||||
export class BlocklyPage {
|
export class BlocklyPage {
|
||||||
|
sketchtext = ""
|
||||||
constructor(
|
constructor(
|
||||||
public navCtrl: NavController,
|
public navCtrl: NavController,
|
||||||
public navParams: NavParams) {
|
public navParams: NavParams) {
|
||||||
}
|
}
|
||||||
|
goTo(sketch) {
|
||||||
|
this.sketchtext = '' || 'No text Entered';}
|
||||||
ionViewDidLoad() {
|
ionViewDidLoad() {
|
||||||
console.log('ionViewDidLoad SenseBoxPage');
|
console.log('ionViewDidLoad SenseBoxPage');
|
||||||
}
|
}
|
||||||
|
|
||||||
launchOtaWizard() {
|
launchOtaWizard() {
|
||||||
this.navCtrl.setRoot(OtaWizardPage)
|
this.navCtrl.setRoot(OtaWizardPage,{sketch : this.sketchtext})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import {
|
||||||
IonicPage,
|
IonicPage,
|
||||||
Slides,
|
Slides,
|
||||||
NavController,
|
NavController,
|
||||||
|
NavParams,
|
||||||
} from 'ionic-angular'
|
} from 'ionic-angular'
|
||||||
import { Network } from '@ionic-native/network'
|
import { Network } from '@ionic-native/network'
|
||||||
import { Subscription } from 'rxjs/Subscription';
|
import { Subscription } from 'rxjs/Subscription';
|
||||||
|
|
@ -24,7 +25,8 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
onlineSub: Subscription
|
onlineSub: Subscription
|
||||||
offlineSub: Subscription
|
offlineSub: Subscription
|
||||||
|
|
||||||
filterSsids = false // TODO: add toggle to UI?
|
sketch = ''
|
||||||
|
filterSsids = true
|
||||||
availableSenseboxes: string[] = [] // list of SSIDs
|
availableSenseboxes: string[] = [] // list of SSIDs
|
||||||
compiledSketch = undefined
|
compiledSketch = undefined
|
||||||
errorMsg = ''
|
errorMsg = ''
|
||||||
|
|
@ -40,7 +42,9 @@ export class OtaWizardPage implements OnInit, OnDestroy {
|
||||||
private network: Network,
|
private network: Network,
|
||||||
private otaWifi: OtaWifiProvider,
|
private otaWifi: OtaWifiProvider,
|
||||||
private navCtrl : NavController,
|
private navCtrl : NavController,
|
||||||
|
navParams : NavParams,
|
||||||
) {
|
) {
|
||||||
|
this.sketch = navParams.get('sketch')
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
|
||||||
39
src/providers/compiler/compiler.ts
Normal file
39
src/providers/compiler/compiler.ts
Normal 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()); */
|
||||||
Loading…
Add table
Reference in a new issue