-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
32abf9b
commit 7abd6f8
Showing
14 changed files
with
386 additions
and
126 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# TODO | ||
* Run | ||
* Sync with db | ||
* SqlAlchemy Editor? Security? | ||
|
||
# Questions | ||
* Ok to use objects in ADD_TABLE? | ||
* Ok to mix state / redux? | ||
* Ok to keep async out of redux? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,39 @@ | ||
export const ADD_QUERY = 'ADD_QUERY' | ||
export const ADD_TABLE = 'ADD_TABLE' | ||
export const ADD_QUERY_EDITOR = 'ADD_QUERY_EDITOR'; | ||
export const REMOVE_QUERY_EDITOR = 'REMOVE_QUERY_EDITOR'; | ||
export const ADD_TABLE = 'ADD_TABLE'; | ||
export const REMOVE_TABLE = 'REMOVE_TABLE'; | ||
export const HIDE_TABLE_POPUP = 'HIDE_TABLE_POPUP'; | ||
export const SHOW_TABLE_POPUP = 'SHOW_TABLE_POPUP'; | ||
export const START_QUERY = 'START_QUERY'; | ||
export const END_QUERY = 'END_QUERY'; | ||
|
||
export function addQuery(title, sql) { | ||
return { type: ADD_QUERY, title, sql } | ||
export function addQueryEditor(id, title, sql) { | ||
return { type: ADD_QUERY_EDITOR, id, title, sql }; | ||
} | ||
|
||
export function addTable(dbId, tableName) { | ||
return { type: ADD_TABLE, dbId, tableName } | ||
export function removeQueryEditor(id) { | ||
return { type: REMOVE_QUERY_EDITOR, id }; | ||
} | ||
|
||
export function addTable(id, dbId, name, columns = [], showPopup = true) { | ||
return { | ||
type: ADD_TABLE, | ||
id, dbId, name, showPopup, columns | ||
}; | ||
} | ||
|
||
export function hideTablePopup(id) { | ||
return { type: HIDE_TABLE_POPUP, id }; | ||
} | ||
|
||
export function showTablePopup(id) { | ||
return { type: SHOW_TABLE_POPUP, id }; | ||
} | ||
|
||
export function removeTable(id) { | ||
return { type: REMOVE_TABLE, id }; | ||
} | ||
|
||
export function startQuery(id, sqlEditorId, sql, startDttm) { | ||
return { type: START_QUERY, id, sqlEditorId, sql, startDttm }; | ||
} |
25 changes: 25 additions & 0 deletions
25
caravel/assets/javascripts/SqlAnvil/components/ButtonWithTooltip.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import React, { PropTypes } from 'react' | ||
import { OverlayTrigger, Tooltip } from 'react-bootstrap' | ||
import { Button } from 'react-bootstrap' | ||
|
||
|
||
const ButtonWithTooltip = React.createClass({ | ||
render() { | ||
let tooltip = ( | ||
<Tooltip id="tooltip"> | ||
{this.props.tooltip} | ||
</Tooltip> | ||
); | ||
return ( | ||
<OverlayTrigger overlay={tooltip} delayShow={300} delayHide={150}> | ||
<Button | ||
onClick={this.props.onClick} | ||
className={this.props.className}> | ||
{this.props.children} | ||
</Button> | ||
</OverlayTrigger> | ||
); | ||
} | ||
}); | ||
|
||
export default ButtonWithTooltip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
caravel/assets/javascripts/SqlAnvil/components/TabbedSqlEditors.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React from 'react' | ||
import { Button, Tab, Tabs } from 'react-bootstrap'; | ||
import { connect } from 'react-redux'; | ||
import { bindActionCreators } from 'redux'; | ||
import * as Actions from '../actions'; | ||
import SqlEditor from './SqlEditor' | ||
import shortid from 'shortid' | ||
|
||
var queryCount = 1; | ||
|
||
const QueryEditors = React.createClass({ | ||
getInitialState: function() { | ||
return {tabkey: 0}; | ||
}, | ||
newQueryEditor: function () { | ||
var id = shortid.generate(); | ||
queryCount++; | ||
this.props.actions.addQueryEditor(id, `Query ${queryCount}`, "SELECT..."); | ||
}, | ||
handleSelect(key) { | ||
this.setState({tabkey: key}); | ||
}, | ||
render: function () { | ||
var editors = this.props.queryEditors.map(function (qe, i) { | ||
return ( | ||
<Tab | ||
key={qe.id} | ||
title={qe.title} | ||
eventKey={i}> | ||
<SqlEditor name={qe.id} queryEditor={qe}/> | ||
</Tab>); | ||
}); | ||
return ( | ||
<Tabs activeKey={this.state.tabkey} onSelect={this.handleSelect}> | ||
{editors} | ||
<Tab title="+" eventKey={this.props.queryEditors.length}> | ||
<Button onClick={this.newQueryEditor}> | ||
Add Tab | ||
</Button> | ||
</Tab> | ||
</Tabs> | ||
); | ||
} | ||
}); | ||
|
||
function mapStateToProps(state) { | ||
return { | ||
queryEditors: state.queryEditors | ||
}; | ||
} | ||
function mapDispatchToProps(dispatch) { | ||
return { | ||
actions: bindActionCreators(Actions, dispatch) | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(QueryEditors) | ||
|
66 changes: 31 additions & 35 deletions
66
caravel/assets/javascripts/SqlAnvil/components/TableOverlay.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,42 @@ | ||
import React from 'react'; | ||
import Draggable from 'react-draggable'; | ||
import { Table } from 'reactable'; | ||
import { connect } from 'react-redux'; | ||
import { bindActionCreators } from 'redux'; | ||
import * as Actions from '../actions'; | ||
|
||
const TableOverlay = React.createClass({ | ||
getInitialState() { | ||
return { | ||
visible: this.props.visible, | ||
}; | ||
}, | ||
close() { | ||
this.setState({ visible: false }); | ||
this.props.closeCallback(); | ||
this.render(); | ||
}, | ||
render() { | ||
if (this.state.visible) { | ||
return <Draggable | ||
defaultPosition={this.props.defaultPosition} | ||
position={null} | ||
handle=".handle" | ||
zIndex={500}> | ||
<div className="window panel panel-default"> | ||
<div className="panel-heading handle"> | ||
<strong>{this.props.data.name}</strong> | ||
<div className="pull-right"> | ||
<a onClick={this.close} href="#"><i className="fa fa-close"/></a> | ||
</div> | ||
</div> | ||
<div className="panel-body nopadding"> | ||
<Table | ||
className="table table-condensed table-striped small table-bordered" | ||
sortable={true} | ||
columns={['name', 'type']} | ||
data={this.props.data.columns}/> | ||
return <Draggable | ||
defaultPosition={this.props.defaultPosition} | ||
position={null} | ||
handle=".handle" | ||
zIndex={500}> | ||
<div className="window panel panel-default"> | ||
<div className="panel-heading handle"> | ||
<strong>{this.props.table.name}</strong> | ||
<div className="pull-right"> | ||
<a onClick={this.props.actions.hideTablePopup.bind(this, this.props.table.id) } href="#"> | ||
<i className="fa fa-close"/> | ||
</a> | ||
</div> | ||
</div> | ||
</Draggable>; | ||
} | ||
else { | ||
return <div/>; | ||
} | ||
<div className="panel-body nopadding"> | ||
<Table | ||
className="table table-condensed table-striped small table-bordered" | ||
sortable={true} | ||
columns={['name', 'type']} | ||
data={this.props.table.columns}/> | ||
</div> | ||
</div> | ||
</Draggable>; | ||
} | ||
}); | ||
|
||
export default TableOverlay | ||
function mapDispatchToProps(dispatch) { | ||
return { | ||
actions: bindActionCreators(Actions, dispatch) | ||
}; | ||
} | ||
|
||
export default connect(null, mapDispatchToProps)(TableOverlay) |
Oops, something went wrong.