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 {
|
||||
ion-fab {
|
||||
margin-right: 25px;
|
||||
margin-right: 15px;
|
||||
ion-icon {
|
||||
font-size: 35px !important;
|
||||
}
|
||||
|
|
|
@ -11,11 +11,15 @@ import { OtaWizardPage } from '../ota-wizard/ota-wizard';
|
|||
export class BlocklyPage {
|
||||
@ViewChild('blocklyFrame') blocklyFrame: ElementRef
|
||||
|
||||
messageHandler: (ev: IframePostMessageEvent) => void
|
||||
|
||||
constructor(
|
||||
public navCtrl: NavController,
|
||||
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;
|
||||
switch (type) {
|
||||
case 'sketch':
|
||||
|
@ -23,10 +27,23 @@ export class BlocklyPage {
|
|||
break
|
||||
default:
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
window.addEventListener('message', this.messageHandler)
|
||||
}
|
||||
|
||||
ionViewWillUnload () {
|
||||
window.removeEventListener('message', this.messageHandler)
|
||||
}
|
||||
|
||||
launchOtaWizard () {
|
||||
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'">
|
||||
<ion-icon name="checkmark" style="font-size: 160px"></ion-icon>
|
||||
<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
|
||||
</button>
|
||||
</ng-container>
|
||||
|
|
Loading…
Add table
Reference in a new issue