import { IMinemeldConfigService , IMinemeldCandidateConfigNode } from '../../app/services/config' ; declare var jsyaml ; export class ConfigureExportController { $modalInstance : angular . ui . bootstrap . IModalServiceInstance ; MinemeldConfigService : IMinemeldConfigService ; config : string ; editor : any ; ngInject constructor ( $modalInstance , MinemeldConfigService ) { var vm = this ; this . $modalInstance = $modalInstance ; this . MinemeldConfigService = MinemeldConfigService ; this . dumpYaml ( ) ; vm . editorLoaded = ( editor_ ) => { vm . editor = editor_ ; editor_ . setShowInvisibles ( false ) ; angular . element ( '.ace_text-input' ) . on ( 'focus' , ( event ) => { angular . element ( event . currentTarget . parentNode ) . addClass ( 'ace-focus' ) ; } ) ; angular . element ( '.ace_text-input' ) . on ( 'blur' , ( event ) => { angular . element ( event . currentTarget . parentNode ) . removeClass ( 'ace-focus' ) ; } ) ; } ; } copyToClipboard ( ) { this . editor . selectAll ( ) ; this . editor . focus ( ) ; document . execCommand ( 'copy' ) ; } ok ( ) { this . $modalInstance . dismiss ( ) ; } private dumpYaml ( ) { var oconfig = { } ; this . MinemeldConfigService . nodesConfig . forEach ( ( currentNode ) => { if ( currentNode . deleted ) { return ; } oconfig [ currentNode . name ] = angular . copy ( currentNode . properties ) ; delete oconfig [ currentNode . name ] [ 'node_type' ] ; delete oconfig [ currentNode . name ] [ 'indicator_types' ] ; if ( typeof oconfig [ currentNode . name ] . inputs !== 'undefined' && ! ( oconfig [ currentNode . name ] . inputs instanceof Array ) ) { delete oconfig [ currentNode . name ] [ 'inputs' ] ; } } ) ; this . config = jsyaml . safeDump ( { nodes : oconfig } ) ; } }