import LogContent from '../components/LogContent' ; import * as actions from '../actions/' ; import { StoreState } from '../types' ; import { connect , Dispatch } from 'react-redux' ; import { Settings , DownloadJob } from '../common-interfaces' ; import { mergeFilters } from '../utils' ; import { createUuid , currentDate , connectCloudWatchLogs , getCloudWatchLogsEvents , showSaveDialog } from '../side-effect-functions' ; export function mapStateToProps ( { logGroups , logStreams , dateRange , settings , logText } ) { return { settings : settings . settings , logGroupName : logGroups . selectedName , logStreamName : logStreams . selectedName , startDate : dateRange . startDate , endDate : dateRange . endDate , logText : logText . text , } ; } export function mapDispatchToProps ( dispatch ) { return { SetDateRange : ( startDate , endDate ) => dispatch ( actions . setDateRange ( startDate , endDate ) ) , DownloadLogs : ( settings , logGroupName , logStreamName , startDate , endDate ) => { let filter = mergeFilters ( settings . filters ) ; let job = { id : createUuid ( ) , logGroupName : logGroupName , logStreamName : logStreamName , startTime : currentDate ( ) . getTime ( ) , progress : 0 , } ; dispatch ( actions . downloadLogs ( settings , ( ) => showSaveDialog ( logStreamName ) , job , ( callbackData , callbackError , callbackEnd ) => getCloudWatchLogsEvents ( connectCloudWatchLogs ( settings ) , logGroupName , logStreamName , startDate , endDate , callbackData , callbackError , callbackEnd ) , filter ) ) ; } , } ; } export default connect ( mapStateToProps , mapDispatchToProps ) ( LogContent as any ) ;