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
05f9eb07
Commit
05f9eb07
authored
Jan 28, 2019
by
Dominik Prokop
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update datasource before the loading has started
parent
c7b556c0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
4 deletions
+39
-4
public/app/features/explore/state/actionTypes.ts
+12
-2
public/app/features/explore/state/actions.ts
+19
-2
public/app/features/explore/state/reducers.ts
+8
-0
No files found.
public/app/features/explore/state/actionTypes.ts
View file @
05f9eb07
// Types
import
{
Emitter
}
from
'app/core/core'
;
import
{
RawTimeRange
,
TimeRange
,
DataQuery
,
DataSourceSelectItem
}
from
'@grafana/ui/src/types'
;
import
{
RawTimeRange
,
TimeRange
,
DataQuery
,
DataSourceSelectItem
,
DataSourceApi
}
from
'@grafana/ui/src/types'
;
import
{
ExploreId
,
ExploreItemState
,
...
...
@@ -41,6 +41,7 @@ export enum ActionTypes {
ToggleGraph
=
'explore/TOGGLE_GRAPH'
,
ToggleLogs
=
'explore/TOGGLE_LOGS'
,
ToggleTable
=
'explore/TOGGLE_TABLE'
,
UpdateDatasourceInstance
=
'explore/UPDATE_DATASOURCE_INSTANCE'
,
}
export
interface
AddQueryRowAction
{
...
...
@@ -270,6 +271,14 @@ export interface ToggleLogsAction {
};
}
export
interface
UpdateDatasourceInstanceAction
{
type
:
ActionTypes
.
UpdateDatasourceInstance
;
payload
:
{
exploreId
:
ExploreId
;
datasourceInstance
:
DataSourceApi
;
};
}
export
type
Action
=
|
AddQueryRowAction
|
ChangeQueryAction
...
...
@@ -297,4 +306,5 @@ export type Action =
|
SplitOpenAction
|
ToggleGraphAction
|
ToggleLogsAction
|
ToggleTableAction
;
|
ToggleTableAction
|
UpdateDatasourceInstanceAction
;
public/app/features/explore/state/actions.ts
View file @
05f9eb07
...
...
@@ -21,7 +21,7 @@ import { updateLocation } from 'app/core/actions';
// Types
import
{
StoreState
}
from
'app/types'
;
import
{
DataQuery
,
DataSourceSelectItem
,
QueryHint
}
from
'@grafana/ui/src/types'
;
import
{
DataQuery
,
DataSourceSelectItem
,
QueryHint
}
from
'@grafana/ui/src/types'
;
import
{
getDatasourceSrv
}
from
'app/features/plugins/datasource_srv'
;
import
{
ExploreId
,
...
...
@@ -46,9 +46,9 @@ import {
LoadDatasourceSuccessAction
,
QueryTransactionStartAction
,
ScanStopAction
,
UpdateDatasourceInstanceAction
,
}
from
'./actionTypes'
;
type
ThunkResult
<
R
>
=
ThunkAction
<
R
,
StoreState
,
undefined
,
ThunkableAction
>
;
/**
...
...
@@ -65,6 +65,7 @@ export function addQueryRow(exploreId: ExploreId, index: number): AddQueryRowAct
export
function
changeDatasource
(
exploreId
:
ExploreId
,
datasource
:
string
):
ThunkResult
<
void
>
{
return
async
dispatch
=>
{
const
instance
=
await
getDatasourceSrv
().
get
(
datasource
);
dispatch
(
updateDatasourceInstance
(
exploreId
,
instance
));
dispatch
(
loadDatasource
(
exploreId
,
instance
));
};
}
...
...
@@ -264,6 +265,22 @@ export const loadDatasourceSuccess = (
};
/**
* Updates datasource instance before datasouce loading has started
*/
export
function
updateDatasourceInstance
(
exploreId
:
ExploreId
,
instance
:
DataSourceApi
):
UpdateDatasourceInstanceAction
{
return
{
type
:
ActionTypes
.
UpdateDatasourceInstance
,
payload
:
{
exploreId
,
datasourceInstance
:
instance
,
},
};
}
/**
* Main action to asynchronously load a datasource. Dispatches lots of smaller actions for feedback.
*/
export
function
loadDatasource
(
exploreId
:
ExploreId
,
instance
:
DataSourceApi
):
ThunkResult
<
void
>
{
...
...
public/app/features/explore/state/reducers.ts
View file @
05f9eb07
...
...
@@ -176,6 +176,14 @@ export const itemReducer = (state, action: Action): ExploreItemState => {
};
}
case
ActionTypes
.
UpdateDatasourceInstance
:
{
const
{
datasourceInstance
}
=
action
.
payload
;
return
{
...
state
,
datasourceInstance
,
};
}
case
ActionTypes
.
LoadDatasourceFailure
:
{
return
{
...
state
,
datasourceError
:
action
.
payload
.
error
,
datasourceLoading
:
false
};
}
...
...
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