Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
5446f49f
Unverified
Commit
5446f49f
authored
Jan 22, 2019
by
Torkel Ödegaard
Committed by
GitHub
Jan 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14977 from grafana/explore-fix-datasource-selector
Fixed data source selection in explore
parents
9c8dea06
79bd7f40
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
13 additions
and
11 deletions
+13
-11
public/app/features/explore/state/actionTypes.ts
+1
-1
public/app/features/explore/state/actions.ts
+9
-8
public/app/features/explore/state/reducers.ts
+2
-1
public/app/types/explore.ts
+1
-1
No files found.
public/app/features/explore/state/actionTypes.ts
View file @
5446f49f
...
@@ -123,7 +123,7 @@ export interface LoadDatasourcePendingAction {
...
@@ -123,7 +123,7 @@ export interface LoadDatasourcePendingAction {
type
:
ActionTypes
.
LoadDatasourcePending
;
type
:
ActionTypes
.
LoadDatasourcePending
;
payload
:
{
payload
:
{
exploreId
:
ExploreId
;
exploreId
:
ExploreId
;
datasource
Id
:
number
;
datasource
Name
:
string
;
};
};
}
}
...
...
public/app/features/explore/state/actions.ts
View file @
5446f49f
...
@@ -33,7 +33,7 @@ import {
...
@@ -33,7 +33,7 @@ import {
}
from
'app/types/explore'
;
}
from
'app/types/explore'
;
import
{
Emitter
}
from
'app/core/core'
;
import
{
Emitter
}
from
'app/core/core'
;
import
{
RawTimeRange
,
TimeRange
}
from
'@grafana/ui'
;
import
{
RawTimeRange
,
TimeRange
,
DataSourceApi
}
from
'@grafana/ui'
;
import
{
import
{
Action
as
ThunkableAction
,
Action
as
ThunkableAction
,
ActionTypes
,
ActionTypes
,
...
@@ -216,11 +216,11 @@ export const loadDatasourceMissing = (exploreId: ExploreId): LoadDatasourceMissi
...
@@ -216,11 +216,11 @@ export const loadDatasourceMissing = (exploreId: ExploreId): LoadDatasourceMissi
/**
/**
* Start the async process of loading a datasource to display a loading indicator
* Start the async process of loading a datasource to display a loading indicator
*/
*/
export
const
loadDatasourcePending
=
(
exploreId
:
ExploreId
,
datasource
Id
:
number
):
LoadDatasourcePendingAction
=>
({
export
const
loadDatasourcePending
=
(
exploreId
:
ExploreId
,
datasource
Name
:
string
):
LoadDatasourcePendingAction
=>
({
type
:
ActionTypes
.
LoadDatasourcePending
,
type
:
ActionTypes
.
LoadDatasourcePending
,
payload
:
{
payload
:
{
exploreId
,
exploreId
,
datasource
Id
,
datasource
Name
,
},
},
});
});
...
@@ -266,12 +266,12 @@ export const loadDatasourceSuccess = (
...
@@ -266,12 +266,12 @@ export const loadDatasourceSuccess = (
/**
/**
* Main action to asynchronously load a datasource. Dispatches lots of smaller actions for feedback.
* Main action to asynchronously load a datasource. Dispatches lots of smaller actions for feedback.
*/
*/
export
function
loadDatasource
(
exploreId
:
ExploreId
,
instance
:
any
):
ThunkResult
<
void
>
{
export
function
loadDatasource
(
exploreId
:
ExploreId
,
instance
:
DataSourceApi
):
ThunkResult
<
void
>
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
const
datasource
Id
=
instance
.
meta
.
id
;
const
datasource
Name
=
instance
.
name
;
// Keep ID to track selection
// Keep ID to track selection
dispatch
(
loadDatasourcePending
(
exploreId
,
datasource
Id
));
dispatch
(
loadDatasourcePending
(
exploreId
,
datasource
Name
));
let
datasourceError
=
null
;
let
datasourceError
=
null
;
try
{
try
{
...
@@ -280,12 +280,13 @@ export function loadDatasource(exploreId: ExploreId, instance: any): ThunkResult
...
@@ -280,12 +280,13 @@ export function loadDatasource(exploreId: ExploreId, instance: any): ThunkResult
}
catch
(
error
)
{
}
catch
(
error
)
{
datasourceError
=
(
error
&&
error
.
statusText
)
||
'Network error'
;
datasourceError
=
(
error
&&
error
.
statusText
)
||
'Network error'
;
}
}
if
(
datasourceError
)
{
if
(
datasourceError
)
{
dispatch
(
loadDatasourceFailure
(
exploreId
,
datasourceError
));
dispatch
(
loadDatasourceFailure
(
exploreId
,
datasourceError
));
return
;
return
;
}
}
if
(
datasource
Id
!==
getState
().
explore
[
exploreId
].
requestedDatasourceId
)
{
if
(
datasource
Name
!==
getState
().
explore
[
exploreId
].
requestedDatasourceName
)
{
// User already changed datasource again, discard results
// User already changed datasource again, discard results
return
;
return
;
}
}
...
@@ -311,7 +312,7 @@ export function loadDatasource(exploreId: ExploreId, instance: any): ThunkResult
...
@@ -311,7 +312,7 @@ export function loadDatasource(exploreId: ExploreId, instance: any): ThunkResult
}
}
}
}
if
(
datasource
Id
!==
getState
().
explore
[
exploreId
].
requestedDatasourceId
)
{
if
(
datasource
Name
!==
getState
().
explore
[
exploreId
].
requestedDatasourceName
)
{
// User already changed datasource again, discard results
// User already changed datasource again, discard results
return
;
return
;
}
}
...
...
public/app/features/explore/state/reducers.ts
View file @
5446f49f
...
@@ -185,7 +185,7 @@ const itemReducer = (state, action: Action): ExploreItemState => {
...
@@ -185,7 +185,7 @@ const itemReducer = (state, action: Action): ExploreItemState => {
}
}
case
ActionTypes
.
LoadDatasourcePending
:
{
case
ActionTypes
.
LoadDatasourcePending
:
{
return
{
...
state
,
datasourceLoading
:
true
,
requestedDatasource
Id
:
action
.
payload
.
datasourceId
};
return
{
...
state
,
datasourceLoading
:
true
,
requestedDatasource
Name
:
action
.
payload
.
datasourceName
};
}
}
case
ActionTypes
.
LoadDatasourceSuccess
:
{
case
ActionTypes
.
LoadDatasourceSuccess
:
{
...
@@ -217,6 +217,7 @@ const itemReducer = (state, action: Action): ExploreItemState => {
...
@@ -217,6 +217,7 @@ const itemReducer = (state, action: Action): ExploreItemState => {
supportsTable
,
supportsTable
,
datasourceLoading
:
false
,
datasourceLoading
:
false
,
datasourceMissing
:
false
,
datasourceMissing
:
false
,
datasourceError
:
null
,
logsHighlighterExpressions
:
undefined
,
logsHighlighterExpressions
:
undefined
,
modifiedQueries
:
initialQueries
.
slice
(),
modifiedQueries
:
initialQueries
.
slice
(),
queryTransactions
:
[],
queryTransactions
:
[],
...
...
public/app/types/explore.ts
View file @
5446f49f
...
@@ -186,7 +186,7 @@ export interface ExploreItemState {
...
@@ -186,7 +186,7 @@ export interface ExploreItemState {
* Allows the selection to be discarded if something went wrong during the asynchronous
* Allows the selection to be discarded if something went wrong during the asynchronous
* loading of the datasource.
* loading of the datasource.
*/
*/
requestedDatasource
Id
?:
number
;
requestedDatasource
Name
?:
string
;
/**
/**
* Time range for this Explore. Managed by the time picker and used by all query runs.
* Time range for this Explore. Managed by the time picker and used by all query runs.
*/
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment