mirror of
https://github.com/sensebox/blockly-app
synced 2025-04-19 16:07:33 +02:00
ota-wizard fixes
This commit is contained in:
parent
cd923084f3
commit
b9a0a91a70
3 changed files with 21 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
page-blockly {
|
page-blockly {
|
||||||
ion-fab {
|
ion-fab {
|
||||||
margin-right: 25px;
|
margin-right: 15px;
|
||||||
ion-icon {
|
ion-icon {
|
||||||
font-size: 35px !important;
|
font-size: 35px !important;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,11 +11,15 @@ import { OtaWizardPage } from '../ota-wizard/ota-wizard';
|
||||||
export class BlocklyPage {
|
export class BlocklyPage {
|
||||||
@ViewChild('blocklyFrame') blocklyFrame: ElementRef
|
@ViewChild('blocklyFrame') blocklyFrame: ElementRef
|
||||||
|
|
||||||
|
messageHandler: (ev: IframePostMessageEvent) => void
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
public navCtrl: NavController,
|
public navCtrl: NavController,
|
||||||
public navParams: NavParams
|
public navParams: NavParams
|
||||||
) {
|
) {
|
||||||
window.addEventListener('message', ev => {
|
// need to assign it here to keep the function reference for unsubscribing again
|
||||||
|
// and to maintain the this scope properly
|
||||||
|
this.messageHandler = (ev: IframePostMessageEvent) => {
|
||||||
const { type, data } = ev.data;
|
const { type, data } = ev.data;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'sketch':
|
case 'sketch':
|
||||||
|
@ -23,10 +27,23 @@ export class BlocklyPage {
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
})
|
}
|
||||||
|
|
||||||
|
window.addEventListener('message', this.messageHandler)
|
||||||
|
}
|
||||||
|
|
||||||
|
ionViewWillUnload () {
|
||||||
|
window.removeEventListener('message', this.messageHandler)
|
||||||
}
|
}
|
||||||
|
|
||||||
launchOtaWizard () {
|
launchOtaWizard () {
|
||||||
this.blocklyFrame.nativeElement.contentWindow.postMessage('getSketch', '*')
|
this.blocklyFrame.nativeElement.contentWindow.postMessage('getSketch', '*')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface IframePostMessageEvent extends MessageEvent {
|
||||||
|
data: {
|
||||||
|
type: 'sketch',
|
||||||
|
data: any,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -145,7 +145,7 @@
|
||||||
<ng-container *ngIf="state.upload == 'done'">
|
<ng-container *ngIf="state.upload == 'done'">
|
||||||
<ion-icon name="checkmark" style="font-size: 160px"></ion-icon>
|
<ion-icon name="checkmark" style="font-size: 160px"></ion-icon>
|
||||||
<h2>Done!</h2>
|
<h2>Done!</h2>
|
||||||
<button ion-button large clear icon-end color="primary" (click)="slides.slideNext()">
|
<button ion-button large clear icon-end color="primary" (click)="onClose()">
|
||||||
Close
|
Close
|
||||||
</button>
|
</button>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
Loading…
Add table
Reference in a new issue