diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..21ab057 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "src/assets/blockly"] + path = src/assets/blockly + url = https://github.com/sensebox/ardublockly-1 diff --git a/README.md b/README.md index 35ce3c6..b1f29db 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ - please fork this repository to develop your apps ### Prequesites +- Git Installation + - use + `git clone https://github.com/AppDevelopmentAtsenseBox/openSenseApp --recursive` + because the ardublockly submodule is used to implememt blockly - Node + NPM (nvm) - https://www.npmjs.com/get-npm diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 420381a..434aa26 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -5,7 +5,6 @@ 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({ templateUrl: 'app.html' diff --git a/src/assets/blockly b/src/assets/blockly new file mode 160000 index 0000000..60674aa --- /dev/null +++ b/src/assets/blockly @@ -0,0 +1 @@ +Subproject commit 60674aa95849ab75e60c04d74ea29339b856473b diff --git a/src/assets/blockly.html b/src/assets/blockly.html new file mode 100644 index 0000000..ce36b5d --- /dev/null +++ b/src/assets/blockly.html @@ -0,0 +1,381 @@ + + + + + + + + Blockly for senseBox + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+ + + + + +
+
+
+
+
+
+ +
+
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/pages/Blockly/blockly.html b/src/pages/Blockly/blockly.html index d042643..317b41e 100644 --- a/src/pages/Blockly/blockly.html +++ b/src/pages/Blockly/blockly.html @@ -5,28 +5,18 @@ Ionic pages and navigation. --> - + - Blockly + Blockly for SenseBox - - - - - - - - + + -
- Blockly should be displayed here ! -
- - +
diff --git a/src/pages/Blockly/blockly.module.ts b/src/pages/Blockly/blockly.module.ts index 73e4e5b..332227b 100644 --- a/src/pages/Blockly/blockly.module.ts +++ b/src/pages/Blockly/blockly.module.ts @@ -7,7 +7,7 @@ import { BlocklyPage } from './blockly'; BlocklyPage, ], imports: [ - IonicPageModule.forChild(BlocklyPage), + IonicPageModule.forChild(BlocklyPage) ], }) export class BlocklyPageModule {} diff --git a/src/pages/Blockly/blockly.scss b/src/pages/Blockly/blockly.scss index 940c7be..534367c 100644 --- a/src/pages/Blockly/blockly.scss +++ b/src/pages/Blockly/blockly.scss @@ -1,8 +1,9 @@ page-blockly { - textarea { + iframe { + height: 100%; width: 100%; - height: 90%; - resize: none; - margin-top: 20px; + border: 0; + margin: 0; + padding: 0; } } diff --git a/src/pages/Blockly/blockly.ts b/src/pages/Blockly/blockly.ts index 333a8f4..5a60dcd 100644 --- a/src/pages/Blockly/blockly.ts +++ b/src/pages/Blockly/blockly.ts @@ -1,13 +1,7 @@ -import { Component } from '@angular/core'; +import { Component, ViewChild, ElementRef } from '@angular/core'; import { IonicPage, NavController, NavParams } from 'ionic-angular'; import { OtaWizardPage } from '../ota-wizard/ota-wizard'; -/** - * Generated class for the SenseBoxPage page. - * - * See https://ionicframework.com/docs/components/#navigation for more info on - * Ionic pages and navigation. - */ @IonicPage() @Component({ @@ -15,14 +9,24 @@ import { OtaWizardPage } from '../ota-wizard/ota-wizard'; templateUrl: 'blockly.html', }) export class BlocklyPage { - sketchtext = 'void setup() {\n Serial.begin(9600);\n Serial.println(\"Hello World\");\n}\n\nvoid loop() {\n\n}' + @ViewChild('blocklyFrame') blocklyFrame: ElementRef constructor( public navCtrl: NavController, - public navParams: NavParams) { } - - launchOtaWizard() { - this.navCtrl.push(OtaWizardPage,{ sketch : this.sketchtext }) + public navParams: NavParams + ) { + window.addEventListener('message', ev => { + const { type, data } = ev.data; + switch (type) { + case 'sketch': + this.navCtrl.push(OtaWizardPage, { sketch: data }) + break + default: + } + }) } + launchOtaWizard () { + this.blocklyFrame.nativeElement.contentWindow.postMessage('getSketch', '*') + } }