From 3cf8e0c7d5d78185747b4cb9ba545488c425d416 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Thu, 11 May 2017 12:16:43 -0700 Subject: [PATCH 1/6] New version clears local storage. --- ui/src/localStorage.js | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/ui/src/localStorage.js b/ui/src/localStorage.js index f660294a4..7e10eab98 100644 --- a/ui/src/localStorage.js +++ b/ui/src/localStorage.js @@ -2,9 +2,22 @@ export const loadLocalStorage = () => { try { const serializedState = localStorage.getItem('state') - return JSON.parse(serializedState) || {} + const state = JSON.parse(serializedState) + + // eslint-disable-next-line no-undef + if (state.VERSION !== VERSION) { + // eslint-disable-next-line no-console + console.log('New version detected. Clearing old settings.') + window.localStorage.removeItem('state') + return {} + } + + delete state.VERSION + + return state || {} } catch (err) { - console.error(`Loading persisted state failed: ${err}`) // eslint-disable-line no-console + // eslint-disable-line no-console + console.error(`Loading persisted state failed: ${err}`) return {} } } @@ -25,6 +38,7 @@ export const saveToLocalStorage = ({ queryConfigs, timeRange, dataExplorer, + VERSION, // eslint-disable-line no-undef }) ) } catch (err) { From b1b6cd09cf7863ddf7bd76dbdbff08c915f01f59 Mon Sep 17 00:00:00 2001 From: Hunter Trujillo Date: Mon, 15 May 2017 11:41:23 -0600 Subject: [PATCH 2/6] Update CHANGELOG. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0d9a70075..03bf4f262 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ### Bug Fixes 1. [#1450](https://github.com/influxdata/chronograf/pull/1450): Fix infinite spinner when using "/chronograf" as a basepath + 1. [#1458](https://github.com/influxdata/chronograf/pull/1458): New versions of Chronograf will automatically clear localStorage settings until further notice. ### Features From 0120cd5e502d5e6a9f689ff6328b54feeb05d381 Mon Sep 17 00:00:00 2001 From: Chris Goller Date: Mon, 15 May 2017 17:11:20 -0500 Subject: [PATCH 3/6] Fix queryEditor error handling to not allow objects. The local storage was getting corrupted with an object instead of a string if the queryEditor had a problem. As a result, the application would stop working altogether. --- ui/src/shared/actions/timeSeries.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/src/shared/actions/timeSeries.js b/ui/src/shared/actions/timeSeries.js index d6d78d24a..a18741932 100644 --- a/ui/src/shared/actions/timeSeries.js +++ b/ui/src/shared/actions/timeSeries.js @@ -32,7 +32,7 @@ export const handleSuccess = (data, query, editQueryStatus) => { } export const handleError = (error, query, editQueryStatus) => { - const message = _.get(error, ['data', 'message'], error) + const message = _.get(error, ['data', 'message'], error.toString()) // 400 from chrono server = fail editQueryStatus(query.id, {error: message}) From 843ee32c72ba24676d64d00874e00b2dec5ce200 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Wed, 17 May 2017 10:58:07 -0700 Subject: [PATCH 4/6] Fix bug on selecting single-stat Visualization Type when no queries (#1484) * Fix single-stat bug when no queries yet * Bupdate changebog --- CHANGELOG.md | 3 ++- ui/src/data_explorer/components/VisView.js | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae9542d10..bb363195b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,8 @@ 1. [#1455](https://github.com/influxdata/chronograf/issues/1455): Fix backwards sort arrows in tables 1. [#1423](https://github.com/influxdata/chronograf/issues/1423): Make logout nav item consistent with design 1. [#1426](https://github.com/influxdata/chronograf/issues/1426): Fix graph loading spinner - 1. [#1485](https://github.com/influxdata/chronograf/issues/1485): Filter out any template variable values that are empty, whitespace, or duplicates + 1. [#1485](https://github.com/influxdata/chronograf/pull/1485): Filter out any template variable values that are empty, whitespace, or duplicates + 1. [#1484](https://github.com/influxdata/chronograf/pull/1484): Allow user to select SingleStat as Visualization Type before adding any queries and continue to be able to click Add Query ### Features 1. [#1477](https://github.com/influxdata/chronograf/pull/1477): Add ability to log alerts diff --git a/ui/src/data_explorer/components/VisView.js b/ui/src/data_explorer/components/VisView.js index 76282fac6..987ab279f 100644 --- a/ui/src/data_explorer/components/VisView.js +++ b/ui/src/data_explorer/components/VisView.js @@ -43,7 +43,7 @@ const VisView = ({ if (cellType === 'single-stat') { return ( From d7dcb0652918b24e1dec850dddc5265a1c3a0027 Mon Sep 17 00:00:00 2001 From: Jared Scheib Date: Wed, 17 May 2017 16:21:20 -0700 Subject: [PATCH 5/6] Notify user via UI if their local storage is cleared (#1499) * Notify user via UI if their local storage is cleared * Upbate changebog --- CHANGELOG.md | 1 + ui/src/index.js | 13 ++++++++++++- ui/src/localStorage.js | 19 +++++++++++++------ ui/src/shared/actions/errors.js | 3 ++- ui/src/shared/middleware/errors.js | 8 ++++---- 5 files changed, 32 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb363195b..ed2f7f15d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ 1. [#1477](https://github.com/influxdata/chronograf/pull/1477): Add ability to log alerts 1. [#1474](https://github.com/influxdata/chronograf/pull/1474): Change behavior of template variable autocomplete to filter by exact match from front of string 1. [#1491](https://github.com/influxdata/chronograf/pull/1491): Update go vendoring to dep and committed vendor directory + 1. [#1498](https://github.com/influxdata/chronograf/pull/1498): Notify user via UI when local settings are cleared ### UI Improvements 1. [#1451](https://github.com/influxdata/chronograf/pull/1451): Refactor scrollbars to support non-webkit browsers diff --git a/ui/src/index.js b/ui/src/index.js index de18a7338..646b7490b 100644 --- a/ui/src/index.js +++ b/ui/src/index.js @@ -40,6 +40,8 @@ import 'src/style/chronograf.scss' import {HEARTBEAT_INTERVAL} from 'shared/constants' +const errorsQueue = [] + const rootNode = document.getElementById('react-root') const basepath = rootNode.dataset.basepath || '' @@ -48,7 +50,7 @@ const browserHistory = useRouterHistory(createHistory)({ basename: basepath, // this is written in when available by the URL prefixer middleware }) -const store = configureStore(loadLocalStorage(), browserHistory) +const store = configureStore(loadLocalStorage(errorsQueue), browserHistory) const {dispatch} = store browserHistory.listen(() => { @@ -67,6 +69,7 @@ const history = syncHistoryWithStore(browserHistory, store) const Root = React.createClass({ componentWillMount() { + this.flushErrorsQueue() this.checkAuth() }, @@ -99,6 +102,14 @@ const Root = React.createClass({ } }, + flushErrorsQueue() { + if (errorsQueue.length) { + errorsQueue.forEach(errorText => { + dispatch(errorThrown({status: 0, auth: null}, errorText, 'warning')) + }) + } + }, + render() { return ( diff --git a/ui/src/localStorage.js b/ui/src/localStorage.js index 7e10eab98..4ae1e4557 100644 --- a/ui/src/localStorage.js +++ b/ui/src/localStorage.js @@ -1,4 +1,4 @@ -export const loadLocalStorage = () => { +export const loadLocalStorage = errorsQueue => { try { const serializedState = localStorage.getItem('state') @@ -6,8 +6,12 @@ export const loadLocalStorage = () => { // eslint-disable-next-line no-undef if (state.VERSION !== VERSION) { - // eslint-disable-next-line no-console - console.log('New version detected. Clearing old settings.') + const errorText = + 'New version of Chronograf detected. Local settings cleared.' + + console.log(errorText) // eslint-disable-line no-console + errorsQueue.push(errorText) + window.localStorage.removeItem('state') return {} } @@ -15,9 +19,12 @@ export const loadLocalStorage = () => { delete state.VERSION return state || {} - } catch (err) { - // eslint-disable-line no-console - console.error(`Loading persisted state failed: ${err}`) + } catch (error) { + const errorText = `Loading local settings failed: ${error}` + + console.error(errorText) // eslint-disable-line no-console + errorsQueue.push(errorText) + return {} } } diff --git a/ui/src/shared/actions/errors.js b/ui/src/shared/actions/errors.js index 3a522d34e..7e19a4537 100644 --- a/ui/src/shared/actions/errors.js +++ b/ui/src/shared/actions/errors.js @@ -1,5 +1,6 @@ -export const errorThrown = (error, altText) => ({ +export const errorThrown = (error, altText, alertType) => ({ type: 'ERROR_THROWN', error, altText, + alertType, }) diff --git a/ui/src/shared/middleware/errors.js b/ui/src/shared/middleware/errors.js index ec3a15489..56d64dd03 100644 --- a/ui/src/shared/middleware/errors.js +++ b/ui/src/shared/middleware/errors.js @@ -17,7 +17,7 @@ const errorsMiddleware = store => next => action => { const {auth: {me}} = store.getState() if (action.type === 'ERROR_THROWN') { - const {error: {status, auth}, altText} = action + const {error: {status, auth}, altText, alertType = 'error'} = action if (status === HTTP_FORBIDDEN) { const wasSessionTimeout = me !== null @@ -26,7 +26,7 @@ const errorsMiddleware = store => next => action => { if (wasSessionTimeout) { store.dispatch( - notify('error', 'Session timed out. Please login again.') + notify(alertType, 'Session timed out. Please login again.') ) allowNotifications = false @@ -35,9 +35,9 @@ const errorsMiddleware = store => next => action => { }, notificationsBlackoutDuration) } } else if (altText) { - store.dispatch(notify('error', altText)) + store.dispatch(notify(alertType, altText)) } else { - store.dispatch(notify('error', 'Cannot communicate with server.')) + store.dispatch(notify(alertType, 'Cannot communicate with server.')) } } From ea413941051e20c89a76964609d2d7a89c382efd Mon Sep 17 00:00:00 2001 From: Luke Morris Date: Thu, 18 May 2017 11:43:34 -0700 Subject: [PATCH 6/6] After the query is parsed, return to :dashboardTime: --- influx/query.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/influx/query.go b/influx/query.go index dc40a91d9..b8c358920 100644 --- a/influx/query.go +++ b/influx/query.go @@ -21,6 +21,10 @@ func Convert(influxQL string) (chronograf.QueryConfig, error) { return chronograf.QueryConfig{}, err } + if itsDashboardTime { + influxQL = strings.Replace(influxQL, "now() - 15m", ":dashboardTime:", 1) + } + raw := chronograf.QueryConfig{ RawText: &influxQL, Fields: []chronograf.Field{},