add logging to BlocklyPage

ios
Norwin 6 years ago
parent 48da9819f7
commit 4fc0dbaa89

@ -3,6 +3,7 @@ import { IonicPageModule } from 'ionic-angular';
import { TranslateModule } from '@ngx-translate/core';
import { BlocklyPage } from './blockly';
import { LoggingProvider } from '../../providers/logging/logging';
@NgModule({
declarations: [
@ -12,5 +13,8 @@ import { BlocklyPage } from './blockly';
TranslateModule,
IonicPageModule.forChild(BlocklyPage)
],
providers: [
LoggingProvider,
]
})
export class BlocklyPageModule {}

@ -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', '*')
}

Loading…
Cancel
Save