|
|
|
@ -4,6 +4,7 @@ import { IonicPage, NavController, NavParams } from 'ionic-angular';
|
|
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
|
|
|
|
|
|
|
|
|
import { OtaWizardPage } from '../ota-wizard/ota-wizard';
|
|
|
|
|
import { LoggingProvider } from '../../providers/logging/logging';
|
|
|
|
|
|
|
|
|
|
@IonicPage()
|
|
|
|
|
@Component({
|
|
|
|
@ -15,13 +16,16 @@ export class BlocklyPage {
|
|
|
|
|
blocklyUrl: SafeResourceUrl
|
|
|
|
|
|
|
|
|
|
private messageHandler: (ev: IframePostMessageEvent) => void
|
|
|
|
|
private log: LoggingProvider
|
|
|
|
|
|
|
|
|
|
constructor(
|
|
|
|
|
public navCtrl: NavController,
|
|
|
|
|
public navParams: NavParams,
|
|
|
|
|
private sanitizer: DomSanitizer,
|
|
|
|
|
logger: LoggingProvider,
|
|
|
|
|
translate: TranslateService,
|
|
|
|
|
) {
|
|
|
|
|
this.log = logger.createChild('BlocklyPage')
|
|
|
|
|
this.blocklyUrl = this.buildBlocklyUrl(translate.currentLang)
|
|
|
|
|
|
|
|
|
|
// need to assign it here to keep the function reference for unsubscribing again
|
|
|
|
@ -30,6 +34,7 @@ export class BlocklyPage {
|
|
|
|
|
const { type, data } = ev.data;
|
|
|
|
|
switch (type) {
|
|
|
|
|
case 'sketch':
|
|
|
|
|
this.log.debug('sketch received, launching ota wizard page', { sketch: data })
|
|
|
|
|
this.navCtrl.push(OtaWizardPage, { sketch: data })
|
|
|
|
|
break
|
|
|
|
|
default:
|
|
|
|
@ -44,10 +49,12 @@ export class BlocklyPage {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
launchOtaWizard () {
|
|
|
|
|
this.log.debug('clicked launch ota')
|
|
|
|
|
this.blocklyFrame.nativeElement.contentWindow.postMessage('getSketch', '*')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
toggleView () {
|
|
|
|
|
this.log.debug('clicked toggle view')
|
|
|
|
|
this.blocklyFrame.nativeElement.contentWindow.postMessage('toggleView', '*')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|