import React from 'react'; import { Alert, Modal } from 'react-bootstrap'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import * as Actions from '../actions'; import Select from 'react-select'; import moment from 'moment'; import { Table } from 'reactable'; import SyntaxHighlighter from 'react-syntax-highlighter'; import { github } from 'react-syntax-highlighter/dist/styles'; import Link from './Link'; // TODO move to CSS const STATE_COLOR_MAP = { failed: 'red', running: 'lime', success: 'green', }; class QueryTable extends React.Component { constructor(props) { super(props); this.state = { showVisualizeModal: false, activeQuery: null, }; } hideVisualizeModal() { this.setState({ showVisualizeModal: false }); } showVisualizeModal(query) { this.setState({ showVisualizeModal: true }); this.state.activeQuery = query; } changeChartType(event) { } render() { const data = this.props.queries.map((query) => { const q = Object.assign({}, query); const since = (q.endDttm) ? q.endDttm : new Date(); let duration = since.valueOf() - q.startDttm.valueOf(); duration = moment.utc(duration); if (q.endDttm) { q.duration = duration.format('HH:mm:ss.SS'); } q.started = moment(q.startDttm).format('HH:mm:ss'); q.sql = {q.sql}; q.state = ( {q.state} ); q.actions = (
); return q; }).reverse(); let visualizeModalBody; if (this.state.activeQuery) { const cols = this.state.activeQuery.results.columns; visualizeModalBody = (
, is_date: , agg_func: (