Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Add scheduled query browser #472

Merged
merged 34 commits into from
Jul 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
adf348d
Add scheduler
mfix22 Jun 25, 2018
5f338ad
Add sort fns
mfix22 Jun 25, 2018
a7591a4
Move info to props and use defaultProps for mock
mfix22 Jun 25, 2018
72f6fc8
Create scheduled query button
mfix22 Jun 26, 2018
0608d45
Number bug fix
mfix22 Jun 26, 2018
3ddfde1
Fix search and sort
mfix22 Jun 26, 2018
5aa210e
Use rowGetter
mfix22 Jun 26, 2018
c666552
Use selectors
mfix22 Jun 26, 2018
29d7f0a
Remove stage 2 and 3 code
mfix22 Jun 26, 2018
a2fd188
fetch scheduled queries and add to store
briandennis Jun 27, 2018
9bc1a55
Add PropTypes
mfix22 Jun 27, 2018
d96e543
Fix column resize issue
mfix22 Jun 27, 2018
108793b
save all queries in the store and filter by connection in Settings co…
briandennis Jun 27, 2018
96ff033
Use react-click-outside, preview modal
mfix22 Jun 27, 2018
664f395
Create modal factory, lint
mfix22 Jun 28, 2018
c106d88
Extract Modal, Row, Column components to own files
mfix22 Jun 28, 2018
0d73275
add SQL syntax highlighting in schedule tab
briandennis Jun 28, 2018
5b73177
misc style fixes, add modal close button
jakedex Jun 29, 2018
453f04e
add tests for Scheduler, update Scheduler/Modal with fixes found testing
briandennis Jun 29, 2018
cfc1919
Review Comments #1:
mfix22 Jul 2, 2018
bf5f4c6
.js extensions
mfix22 Jul 2, 2018
4c34df3
Word wrap SQL preview
mfix22 Jul 2, 2018
a7089ab
Add Layout description comment
mfix22 Jul 2, 2018
8c2ea91
Comment react-data-grid formatters
mfix22 Jul 2, 2018
567d961
Rename .react.js -> .jsx, import css files
mfix22 Jul 2, 2018
39686d1
Fix indentation
mfix22 Jul 2, 2018
97b206d
Better preview header spacing
mfix22 Jul 2, 2018
95894eb
Bold SQL preview header
mfix22 Jul 2, 2018
d8fb7b2
Move new deps to devDependencies
mfix22 Jul 3, 2018
de9f645
Make SchedulerPreview
mfix22 Jul 3, 2018
2ce012a
test/app/components/Settings/Scheduler/Scheduler.test.js -> test/app…
mfix22 Jul 3, 2018
9f8e97e
adapt scheduler test to additional sql element in query modal
briandennis Jul 3, 2018
10492dd
Fix scheduler-table styling issues
jakedex Jul 3, 2018
428ef5f
add className prop type to SQL
briandennis Jul 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions app/actions/sessions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const mergeTabMap = createAction('MERGE_TAB_MAP');
export const setTab = createAction('SET_TAB');
export const setTable = createAction('SET_TABLE');
export const setIndex = createAction('SET_INDEX');
export const setScheduledQueries = createAction('SET_SCHEDULED_QUERIES');
export const mergeConnections = createAction('MERGE_CONNECTIONS');
export const updateConnection = createAction('UPDATE_CREDENTIAL');
export const deleteConnection = createAction('DELETE_CREDENTIAL');
Expand Down Expand Up @@ -137,6 +138,19 @@ export function editConnections(connectionObject, connectionId) {
);
}

export function getScheduledQueries() {
return dispatch => {
return dispatch(apiThunk(
'queries',
'GET',
'scheduledQueriesRequest'
)).then((json => {
dispatch(setScheduledQueries(json));
return json;
}));
};
}

export function connect(connectionId) {
return apiThunk(
`connections/${connectionId}/connect`,
Expand Down
34 changes: 31 additions & 3 deletions app/components/Settings/Settings.react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, {Component} from 'react';
import PropTypes from 'prop-types';
import {contains, dissoc, flip, head, hasIn, isEmpty, keys, merge, propOr, reduce} from 'ramda';
import {contains, dissoc, flip, head, hasIn, isEmpty, keys, merge, propEq, propOr, reduce} from 'ramda';
import {connect} from 'react-redux';
import ReactToolTip from 'react-tooltip';
import classnames from 'classnames';
Expand All @@ -13,10 +13,10 @@ import DialectSelector from './DialectSelector/DialectSelector.react';
import ConnectButton from './ConnectButton/ConnectButton.react';
import Preview from './Preview/Preview.react';
import {Link} from '../Link.react';
import Scheduler from './scheduler.jsx';
import {DIALECTS, FAQ, PREVIEW_QUERY, SQL_DIALECTS_USING_EDITOR} from '../../constants/constants.js';
import {isElectron, isOnPrem} from '../../utils/utils';


class Settings extends Component {
constructor(props) {
super(props);
Expand Down Expand Up @@ -169,6 +169,7 @@ class Settings extends Component {
getApacheDrillS3Keys,
getElasticsearchMappings,
getTables,
getScheduledQueries,
getS3Keys,
getSettings,
initialize,
Expand All @@ -181,7 +182,8 @@ class Settings extends Component {
s3KeysRequest,
selectedTab,
selectedIndex,
tablesRequest
tablesRequest,
scheduledQueriesRequest
} = this.props;
if (connectionsRequest && !connectionsRequest.status) {
initialize();
Expand All @@ -199,6 +201,10 @@ class Settings extends Component {
getSettings();
}

if (connectRequest.status === 200 && !scheduledQueriesRequest.status) {
getScheduledQueries();
}

const connectionObject = connections[selectedTab] || {};
if (contains(connectionObject.dialect, SQL_DIALECTS_USING_EDITOR)) {
if (connectRequest.status === 200 && !tablesRequest.status) {
Expand Down Expand Up @@ -268,6 +274,8 @@ class Settings extends Component {
setIndex,
setTable,
selectedTable,
selectedScheduledQueries,
getScheduledQueries,
selectedIndex,
setTab,
tablesRequest,
Expand Down Expand Up @@ -327,6 +335,7 @@ class Settings extends Component {
<TabList>
<Tab>Connection</Tab>
<Tab disabled={queryPanelDisabled}>Query</Tab>
<Tab>Schedule</Tab>
{isOnPrem() || <Tab
className="test-ssl-tab react-tabs__tab"
>
Expand Down Expand Up @@ -378,6 +387,10 @@ class Settings extends Component {
)}
</TabPanel>

<TabPanel>
<Scheduler queries={selectedScheduledQueries} refreshQueries={getScheduledQueries} />
</TabPanel>

{isOnPrem() || <TabPanel>
{this.props.connectRequest.status === 200 ? (
<div className="big-whitespace-tab">
Expand Down Expand Up @@ -497,6 +510,8 @@ function mapStateToProps(state) {
deleteConnectionsRequests,
previewTableRequests,
tablesRequests,
scheduledQueries,
scheduledQueriesRequest,
elasticsearchMappingsRequests,
selectedTables,
selectedIndecies,
Expand All @@ -513,6 +528,7 @@ function mapStateToProps(state) {
const connectionsHaveBeenSaved = Boolean(selectedConnectionId);
const selectedTable = selectedTables[selectedConnectionId] || null;
const selectedIndex = selectedIndecies[selectedConnectionId] || null;
const selectedScheduledQueries = scheduledQueries.filter(propEq('connectionId', selectedConnectionId));

let previewTableRequest = {};
if (previewTableRequests[selectedConnectionId] &&
Expand All @@ -533,6 +549,7 @@ function mapStateToProps(state) {
deleteConnectionsRequest: deleteConnectionsRequests[selectedConnectionId] || {},
previewTableRequest,
tablesRequest: tablesRequests[selectedConnectionId] || {},
scheduledQueriesRequest: scheduledQueriesRequest || {},
elasticsearchMappingsRequest: elasticsearchMappingsRequests[selectedConnectionId] || {},
s3KeysRequest: s3KeysRequests[selectedConnectionId] || {},
apacheDrillStorageRequest: apacheDrillStorageRequests[selectedConnectionId] || {},
Expand All @@ -546,6 +563,7 @@ function mapStateToProps(state) {
schemaRequest: schemaRequests[selectedConnectionId],
queryRequest: queryRequests[selectedConnectionId],
selectedTable,
selectedScheduledQueries,
selectedIndex,
selectedConnectionId,
settingsRequest,
Expand Down Expand Up @@ -586,6 +604,9 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
function boundGetTables() {
return dispatch(Actions.getTables(selectedConnectionId));
}
function boundGetScheduledQueries() {
return dispatch(Actions.getScheduledQueries(selectedConnectionId));
}
function boundGetElasticsearchMappings() {
return dispatch(Actions.getElasticsearchMappings(selectedConnectionId));
}
Expand Down Expand Up @@ -679,6 +700,7 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
setConnectionNeedToBeSaved: boundSetConnectionNeedToBeSaved,
updateConnection: boundUpdateConnection,
getTables: boundGetTables,
getScheduledQueries: boundGetScheduledQueries,
getElasticsearchMappings: boundGetElasticsearchMappings,
setTable: boundSetTable,
setIndex: boundSetIndex,
Expand Down Expand Up @@ -733,6 +755,12 @@ Settings.propTypes = {
s3KeysRequest: PropTypes.object,
selectedTab: PropTypes.string,
selectedIndex: PropTypes.any,
selectedScheduledQueries: PropTypes.arrayOf(PropTypes.shape({
query: PropTypes.string,
refreshInterval: PropTypes.number
})),
scheduledQueriesRequest: PropTypes.object,
getScheduledQueries: PropTypes.func,
tablesRequest: PropTypes.object,
deleteTab: PropTypes.func,
getSqlSchema: PropTypes.func,
Expand Down
52 changes: 52 additions & 0 deletions app/components/Settings/scheduler.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/* SQL token highlighting */
.default .hljs-keyword,
.default .hljs-selector-tag {
color: #ab63fa;
}

.default .hljs-number,
.default .hljs-meta,
.default .hljs-built_in,
.default .hljs-builtin-name,
.default .hljs-literal,
.default .hljs-type,
.default .hljs-params {
color: #00cc96;
}

.default .hljs-string,
.default .hljs-symbol,
.default .hljs-bullet {
color: #119DFF;
}

.default .hljs {
color: #585260;
}

.bold .hljs-keyword,
.bold .hljs-selector-tag {
font-weight: bold;
}

/* custom ReactDataGrid styles for scheduled queries table */
.scheduler-table .react-grid-Row--odd .react-grid-Cell {
background: #fff;
}

.scheduler-table .react-grid-Row--odd:hover .react-grid-Cell {
background-color: #f9f9f9;
}

.scheduler-table .react-grid-Row {
border-top: 1px solid #c8d4e3;
cursor: pointer;
}

.scheduler-table .react-grid-Row:first-child {
border-top: none;
}

.sql-preview pre {
white-space: pre-wrap;
}
Loading