license import { Classes , Dialog } from "@blueprintjs/core" ; import React from "react" ; import RPCClient from "../RPCClient" ; interface Props { rpc : RPCClient ; onHide ( ) : void ; } export default class MusicXML2LyModal extends React . PureComponent < Props > { render ( ) { return ( < Dialog title = "Import MusicXML" isOpen = { true } onClose = { this . props . onHide } > < div className = { Classes . DIALOG_BODY } > < p > Select a MusicXML file to import into Hacklily . < /p> < input type = "file" value = "" onChange = { this . convert } / > < /div> < /Dialog>); } convert = ( ev ) => { if ( ! ev . target . files ) { return ; } const reader = new FileReader ( ) ; reader . onload = ( ) => { this . doLoad ( reader . result as any ) ; reader . onload = null ; } ; reader . readAsText ( ev . target . files [ 0 ] ) ; } ; doLoad = async ( src ) => { console . log ( src ) ; const rendered = await this . props . rpc . call ( "render" , { backend : "musicxml2ly" , version : "stable" , src , } ) ; const file = rendered . result . files [ 0 ] ; alert ( rendered . result . logs ) ; location . href = `/#src=${ encodeURIComponent ( file ) }` ; } ; }