import { Component , OnInit } from '@angular/core' ; import { ModalController } from '@ionic/angular' ; import { ReferenceDataManager } from '../../services/ReferenceDataManager' ; @ Component ( { selector : 'app-layer-editor' , templateUrl : './layer-editor.page.html' , styleUrls : [ './layer-editor.page.css' ] , } ) export class LayerEditorPage implements OnInit { fileData : any [ ] ; constructor ( private modalController , private refData ) { } ngOnInit ( ) { } async previewFile ( ) { await this . loadFile ( false ) ; } async cancel ( ) { await this . modalController . dismiss ( this . fileData ) ; } async loadFile ( dismissOnLoad = true ) { const reader = new FileReader ( ) ; reader . onload = ( ) => { let dat = reader . result as string ; let parsedList = JSON . parse ( dat ) ; for ( let p of parsedList ) { p . ID = "imp_" + p . ID ; } this . fileData = this . refData . hydrateCompactPOIList ( < Array < any > > parsedList ) ; if ( dismissOnLoad ) { this . modalController . dismiss ( this . fileData ) ; } } ; reader . onerror = ( ) => { } ; reader . readAsText ( ( < any > document . getElementById ( 'file-upload' ) ) . files [ 0 ] ) ; } async add ( ) { this . modalController . dismiss ( this . fileData ) ; } }