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 { TranslateModule } from '@ngx-translate/core';
import { BlocklyPage } from './blockly'; import { BlocklyPage } from './blockly';
import { LoggingProvider } from '../../providers/logging/logging';
@NgModule({ @NgModule({
declarations: [ declarations: [
@ -12,5 +13,8 @@ import { BlocklyPage } from './blockly';
TranslateModule, TranslateModule,
IonicPageModule.forChild(BlocklyPage) IonicPageModule.forChild(BlocklyPage)
], ],
providers: [
LoggingProvider,
]
}) })
export class BlocklyPageModule {} export class BlocklyPageModule {}

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

Loading…
Cancel
Save