Fix typing errors
parent
debfff5050
commit
ae707ac283
|
@ -1,66 +0,0 @@
|
||||||
const webpack = require('webpack')
|
|
||||||
const path = require('path')
|
|
||||||
|
|
||||||
module.exports = function(config) {
|
|
||||||
config.set({
|
|
||||||
browsers: ['PhantomJS'],
|
|
||||||
frameworks: ['mocha'],
|
|
||||||
files: [
|
|
||||||
'node_modules/babel-polyfill/dist/polyfill.js',
|
|
||||||
'spec/spec-helper.js',
|
|
||||||
'spec/index.js',
|
|
||||||
],
|
|
||||||
preprocessors: {
|
|
||||||
'spec/spec-helper.js': ['webpack', 'sourcemap'],
|
|
||||||
'spec/index.js': ['webpack', 'sourcemap'],
|
|
||||||
},
|
|
||||||
// For more detailed reporting on tests, you can add 'verbose' and/or 'progress'.
|
|
||||||
// This can also be done via the command line with `yarn test -- --reporters=verbose`.
|
|
||||||
reporters: ['dots'],
|
|
||||||
webpack: {
|
|
||||||
devtool: 'inline-source-map',
|
|
||||||
module: {
|
|
||||||
loaders: [
|
|
||||||
{
|
|
||||||
test: /\.js$/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader: 'babel-loader',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.css/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader: 'style-loader!css-loader!postcss-loader',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
test: /\.scss/,
|
|
||||||
exclude: /node_modules/,
|
|
||||||
loader: 'style-loader!css-loader!sass-loader',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
// Sinon behaves weirdly with webpack, see https://github.com/webpack/webpack/issues/304
|
|
||||||
test: /sinon\/pkg\/sinon\.js/,
|
|
||||||
loader: 'imports?define=>false,require=>false',
|
|
||||||
},
|
|
||||||
],
|
|
||||||
},
|
|
||||||
externals: {
|
|
||||||
'react/addons': true,
|
|
||||||
'react/lib/ExecutionEnvironment': true,
|
|
||||||
'react/lib/ReactContext': true,
|
|
||||||
},
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
app: path.resolve(__dirname, 'app'),
|
|
||||||
src: path.resolve(__dirname, 'src'),
|
|
||||||
chronograf: path.resolve(__dirname, 'src', 'chronograf'),
|
|
||||||
shared: path.resolve(__dirname, 'src', 'shared'),
|
|
||||||
style: path.resolve(__dirname, 'src', 'style'),
|
|
||||||
utils: path.resolve(__dirname, 'src', 'utils'),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
webpackServer: {
|
|
||||||
noInfo: true, // please don't spam the console when running in karma!
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
|
@ -20,7 +20,6 @@ interface ASTRequest {
|
||||||
|
|
||||||
export const getAST = async (request: ASTRequest) => {
|
export const getAST = async (request: ASTRequest) => {
|
||||||
const {url, body} = request
|
const {url, body} = request
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const {data} = await AJAX({
|
const {data} = await AJAX({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import 'babel-polyfill'
|
import 'babel-polyfill'
|
||||||
|
|
||||||
import React from 'react'
|
import React, {PureComponent} from 'react'
|
||||||
import {render} from 'react-dom'
|
import {render} from 'react-dom'
|
||||||
import {Provider} from 'react-redux'
|
import {Provider} from 'react-redux'
|
||||||
import {Router, Route, useRouterHistory} from 'react-router'
|
import {Router, Route, useRouterHistory} from 'react-router'
|
||||||
|
@ -32,27 +32,34 @@ import {
|
||||||
} from 'src/kapacitor'
|
} from 'src/kapacitor'
|
||||||
import {AdminChronografPage, AdminInfluxDBPage} from 'src/admin'
|
import {AdminChronografPage, AdminInfluxDBPage} from 'src/admin'
|
||||||
import {SourcePage, ManageSources} from 'src/sources'
|
import {SourcePage, ManageSources} from 'src/sources'
|
||||||
import {IFQLPage} from 'src/ifql/index.ts'
|
import {IFQLPage} from 'src/ifql/index'
|
||||||
import NotFound from 'shared/components/NotFound'
|
import NotFound from 'src/shared/components/NotFound'
|
||||||
|
|
||||||
import {getLinksAsync} from 'shared/actions/links'
|
import {getLinksAsync} from 'src/shared/actions/links'
|
||||||
import {getMeAsync} from 'shared/actions/auth'
|
import {getMeAsync} from 'src/shared/actions/auth'
|
||||||
|
|
||||||
import {disablePresentationMode} from 'shared/actions/app'
|
import {disablePresentationMode} from 'src/shared/actions/app'
|
||||||
import {errorThrown} from 'shared/actions/errors'
|
import {errorThrown} from 'src/shared/actions/errors'
|
||||||
import {notify} from 'shared/actions/notifications'
|
import {notify} from 'src/shared/actions/notifications'
|
||||||
|
|
||||||
import 'src/style/chronograf.scss'
|
import 'src/style/chronograf.scss'
|
||||||
|
|
||||||
import {HEARTBEAT_INTERVAL} from 'shared/constants'
|
import {HEARTBEAT_INTERVAL} from 'src/shared/constants'
|
||||||
|
|
||||||
const errorsQueue = []
|
const errorsQueue = []
|
||||||
|
|
||||||
const rootNode = document.getElementById('react-root')
|
const rootNode = document.getElementById('react-root')
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
basepath: string
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Older method used for pre-IE 11 compatibility
|
// Older method used for pre-IE 11 compatibility
|
||||||
const basepath = rootNode.getAttribute('data-basepath') || ''
|
const basepath = rootNode.getAttribute('data-basepath') || ''
|
||||||
window.basepath = basepath
|
window.basepath = basepath
|
||||||
|
|
||||||
const browserHistory = useRouterHistory(createHistory)({
|
const browserHistory = useRouterHistory(createHistory)({
|
||||||
basename: basepath, // this is written in when available by the URL prefixer middleware
|
basename: basepath, // this is written in when available by the URL prefixer middleware
|
||||||
})
|
})
|
||||||
|
@ -74,14 +81,22 @@ window.addEventListener('keyup', event => {
|
||||||
|
|
||||||
const history = syncHistoryWithStore(browserHistory, store)
|
const history = syncHistoryWithStore(browserHistory, store)
|
||||||
|
|
||||||
const Root = React.createClass({
|
interface State {
|
||||||
getInitialState() {
|
ready: boolean
|
||||||
return {
|
}
|
||||||
|
|
||||||
|
class Root extends PureComponent<{}, State> {
|
||||||
|
private getLinks = bindActionCreators(getLinksAsync, dispatch)
|
||||||
|
private getMe = bindActionCreators(getMeAsync, dispatch)
|
||||||
|
|
||||||
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
this.state = {
|
||||||
ready: false,
|
ready: false,
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
async componentWillMount() {
|
public async componentWillMount() {
|
||||||
this.flushErrorsQueue()
|
this.flushErrorsQueue()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -91,45 +106,10 @@ const Root = React.createClass({
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
dispatch(errorThrown(error))
|
dispatch(errorThrown(error))
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
getLinks: bindActionCreators(getLinksAsync, dispatch),
|
|
||||||
getMe: bindActionCreators(getMeAsync, dispatch),
|
|
||||||
|
|
||||||
async checkAuth() {
|
|
||||||
try {
|
|
||||||
await this.performHeartbeat({shouldResetMe: true})
|
|
||||||
} catch (error) {
|
|
||||||
dispatch(errorThrown(error))
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
|
|
||||||
async performHeartbeat({shouldResetMe = false} = {}) {
|
public render() {
|
||||||
await this.getMe({shouldResetMe})
|
return this.state.ready ? (
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
if (store.getState().auth.me !== null) {
|
|
||||||
this.performHeartbeat()
|
|
||||||
}
|
|
||||||
}, HEARTBEAT_INTERVAL)
|
|
||||||
},
|
|
||||||
|
|
||||||
flushErrorsQueue() {
|
|
||||||
if (errorsQueue.length) {
|
|
||||||
errorsQueue.forEach(error => {
|
|
||||||
if (typeof error === 'object') {
|
|
||||||
dispatch(notify(error))
|
|
||||||
} else {
|
|
||||||
dispatch(errorThrown({status: 0, auth: null}, error, 'warning'))
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return !this.state.ready ? ( // eslint-disable-line no-negated-condition
|
|
||||||
<div className="page-spinner" />
|
|
||||||
) : (
|
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Router history={history}>
|
<Router history={history}>
|
||||||
<Route path="/" component={UserIsAuthenticated(CheckSources)} />
|
<Route path="/" component={UserIsAuthenticated(CheckSources)} />
|
||||||
|
@ -170,9 +150,41 @@ const Root = React.createClass({
|
||||||
<Route path="*" component={NotFound} />
|
<Route path="*" component={NotFound} />
|
||||||
</Router>
|
</Router>
|
||||||
</Provider>
|
</Provider>
|
||||||
|
) : (
|
||||||
|
<div className="page-spinner" />
|
||||||
)
|
)
|
||||||
},
|
}
|
||||||
})
|
|
||||||
|
private async performHeartbeat({shouldResetMe = false} = {}) {
|
||||||
|
await this.getMe({shouldResetMe})
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (store.getState().auth.me !== null) {
|
||||||
|
this.performHeartbeat()
|
||||||
|
}
|
||||||
|
}, HEARTBEAT_INTERVAL)
|
||||||
|
}
|
||||||
|
|
||||||
|
private flushErrorsQueue() {
|
||||||
|
if (errorsQueue.length) {
|
||||||
|
errorsQueue.forEach(error => {
|
||||||
|
if (typeof error === 'object') {
|
||||||
|
dispatch(notify(error))
|
||||||
|
} else {
|
||||||
|
dispatch(errorThrown({status: 0, auth: null}, error, 'warning'))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async checkAuth() {
|
||||||
|
try {
|
||||||
|
await this.performHeartbeat({shouldResetMe: true})
|
||||||
|
} catch (error) {
|
||||||
|
dispatch(errorThrown(error))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (rootNode) {
|
if (rootNode) {
|
||||||
render(<Root />, rootNode)
|
render(<Root />, rootNode)
|
|
@ -1,4 +1,4 @@
|
||||||
import AJAX from 'utils/ajax'
|
import AJAX from 'src/utils/ajax'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import {buildInfluxUrl, proxy} from 'utils/queryUrlGenerator'
|
import {buildInfluxUrl, proxy} from 'utils/queryUrlGenerator'
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
import AJAX from 'utils/ajax'
|
import AJAX from 'src/utils/ajax'
|
||||||
|
|
||||||
|
const excludeBasepath = true // don't prefix route of external link with basepath/
|
||||||
|
|
||||||
export const fetchJSONFeed = url =>
|
export const fetchJSONFeed = url =>
|
||||||
AJAX(
|
AJAX(
|
||||||
|
@ -9,5 +11,5 @@ export const fetchJSONFeed = url =>
|
||||||
// https://stackoverflow.com/questions/22968406/how-to-skip-the-options-preflight-request-in-angularjs
|
// https://stackoverflow.com/questions/22968406/how-to-skip-the-options-preflight-request-in-angularjs
|
||||||
headers: {'Content-Type': 'text/plain; charset=UTF-8'},
|
headers: {'Content-Type': 'text/plain; charset=UTF-8'},
|
||||||
},
|
},
|
||||||
{excludeBasepath: true} // don't prefix route of external link with basepath
|
excludeBasepath // don't prefix route of external link with basepath
|
||||||
)
|
)
|
|
@ -42,6 +42,16 @@ const generateResponseWithLinks = (response, newLinks) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface RequestParams {
|
||||||
|
url: string
|
||||||
|
resource?: string | null
|
||||||
|
id?: string | null
|
||||||
|
method?: string
|
||||||
|
data?: object
|
||||||
|
params?: object
|
||||||
|
headers?: object
|
||||||
|
}
|
||||||
|
|
||||||
const AJAX = async (
|
const AJAX = async (
|
||||||
{
|
{
|
||||||
url,
|
url,
|
||||||
|
@ -51,8 +61,8 @@ const AJAX = async (
|
||||||
data = {},
|
data = {},
|
||||||
params = {},
|
params = {},
|
||||||
headers = {},
|
headers = {},
|
||||||
},
|
}: RequestParams,
|
||||||
{excludeBasepath} = {}
|
excludeBasepath = false
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
if (!links) {
|
if (!links) {
|
||||||
|
@ -91,7 +101,7 @@ export const getAJAX = async url => {
|
||||||
try {
|
try {
|
||||||
return await axios({
|
return await axios({
|
||||||
method: 'GET',
|
method: 'GET',
|
||||||
url: addBasepath(url),
|
url: addBasepath(url, false),
|
||||||
})
|
})
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
|
@ -5,8 +5,8 @@ import TimeMachine from 'src/ifql/components/TimeMachine'
|
||||||
const setup = () => {
|
const setup = () => {
|
||||||
const props = {
|
const props = {
|
||||||
funcs: [],
|
funcs: [],
|
||||||
ast: {},
|
|
||||||
nodes: [],
|
nodes: [],
|
||||||
|
onAddNode: () => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapper = shallow(<TimeMachine {...props} />)
|
const wrapper = shallow(<TimeMachine {...props} />)
|
||||||
|
|
|
@ -11,6 +11,7 @@ const setup = () => {
|
||||||
links: {
|
links: {
|
||||||
self: '',
|
self: '',
|
||||||
suggestions: '',
|
suggestions: '',
|
||||||
|
ast: '',
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ module.exports = {
|
||||||
cache: true,
|
cache: true,
|
||||||
devtool: 'inline-eval-cheap-source-map',
|
devtool: 'inline-eval-cheap-source-map',
|
||||||
entry: {
|
entry: {
|
||||||
app: path.resolve(__dirname, '..', 'src', 'index.js'),
|
app: path.resolve(__dirname, '..', 'src', 'index.tsx'),
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
publicPath: '/',
|
publicPath: '/',
|
||||||
|
|
|
@ -25,7 +25,7 @@ const config = {
|
||||||
bail: true,
|
bail: true,
|
||||||
devtool: false,
|
devtool: false,
|
||||||
entry: {
|
entry: {
|
||||||
app: path.resolve(__dirname, '..', 'src', 'index.js'),
|
app: path.resolve(__dirname, '..', 'src', 'index.tsx'),
|
||||||
vendor: Object.keys(dependencies),
|
vendor: Object.keys(dependencies),
|
||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
|
|
Loading…
Reference in New Issue