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
96aef3ba
Commit
96aef3ba
authored
Feb 04, 2019
by
Hugo Häggmark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replaced intialQueris with queryKeys
parent
efa48390
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
16 deletions
+43
-16
public/app/core/utils/explore.ts
+10
-1
public/app/features/explore/Explore.tsx
+5
-5
public/app/features/explore/QueryRows.tsx
+3
-6
public/app/features/explore/state/reducers.ts
+20
-4
public/app/types/explore.ts
+5
-0
No files found.
public/app/core/utils/explore.ts
View file @
96aef3ba
...
@@ -11,7 +11,7 @@ import { colors } from '@grafana/ui';
...
@@ -11,7 +11,7 @@ import { colors } from '@grafana/ui';
import
TableModel
,
{
mergeTablesIntoModel
}
from
'app/core/table_model'
;
import
TableModel
,
{
mergeTablesIntoModel
}
from
'app/core/table_model'
;
// Types
// Types
import
{
RawTimeRange
,
IntervalValues
,
DataQuery
}
from
'@grafana/ui/src/types'
;
import
{
RawTimeRange
,
IntervalValues
,
DataQuery
,
DataSourceApi
}
from
'@grafana/ui/src/types'
;
import
TimeSeries
from
'app/core/time_series2'
;
import
TimeSeries
from
'app/core/time_series2'
;
import
{
import
{
ExploreUrlState
,
ExploreUrlState
,
...
@@ -304,3 +304,12 @@ export function clearHistory(datasourceId: string) {
...
@@ -304,3 +304,12 @@ export function clearHistory(datasourceId: string) {
const
historyKey
=
`grafana.explore.history.
${
datasourceId
}
`
;
const
historyKey
=
`grafana.explore.history.
${
datasourceId
}
`
;
store
.
delete
(
historyKey
);
store
.
delete
(
historyKey
);
}
}
export
const
getQueryKeys
=
(
queries
:
DataQuery
[],
datasourceInstance
:
DataSourceApi
):
string
[]
=>
{
const
queryKeys
=
queries
.
reduce
((
newQueryKeys
,
query
,
index
)
=>
{
const
primaryKey
=
datasourceInstance
&&
datasourceInstance
.
name
?
datasourceInstance
.
name
:
query
.
key
;
return
newQueryKeys
.
concat
(
`
${
primaryKey
}
-
${
index
}
`
);
},
[]);
return
queryKeys
;
};
public/app/features/explore/Explore.tsx
View file @
96aef3ba
...
@@ -38,7 +38,6 @@ interface ExploreProps {
...
@@ -38,7 +38,6 @@ interface ExploreProps {
datasourceLoading
:
boolean
|
null
;
datasourceLoading
:
boolean
|
null
;
datasourceMissing
:
boolean
;
datasourceMissing
:
boolean
;
exploreId
:
ExploreId
;
exploreId
:
ExploreId
;
initialQueries
:
DataQuery
[];
initializeExplore
:
typeof
initializeExplore
;
initializeExplore
:
typeof
initializeExplore
;
initialized
:
boolean
;
initialized
:
boolean
;
modifyQueries
:
typeof
modifyQueries
;
modifyQueries
:
typeof
modifyQueries
;
...
@@ -55,6 +54,7 @@ interface ExploreProps {
...
@@ -55,6 +54,7 @@ interface ExploreProps {
supportsLogs
:
boolean
|
null
;
supportsLogs
:
boolean
|
null
;
supportsTable
:
boolean
|
null
;
supportsTable
:
boolean
|
null
;
urlState
:
ExploreUrlState
;
urlState
:
ExploreUrlState
;
queryKeys
:
string
[];
}
}
/**
/**
...
@@ -175,12 +175,12 @@ export class Explore extends React.PureComponent<ExploreProps> {
...
@@ -175,12 +175,12 @@ export class Explore extends React.PureComponent<ExploreProps> {
datasourceLoading
,
datasourceLoading
,
datasourceMissing
,
datasourceMissing
,
exploreId
,
exploreId
,
initialQueries
,
showingStartPage
,
showingStartPage
,
split
,
split
,
supportsGraph
,
supportsGraph
,
supportsLogs
,
supportsLogs
,
supportsTable
,
supportsTable
,
queryKeys
,
}
=
this
.
props
;
}
=
this
.
props
;
const
exploreClass
=
split
?
'explore explore-split'
:
'explore'
;
const
exploreClass
=
split
?
'explore explore-split'
:
'explore'
;
...
@@ -201,7 +201,7 @@ export class Explore extends React.PureComponent<ExploreProps> {
...
@@ -201,7 +201,7 @@ export class Explore extends React.PureComponent<ExploreProps> {
{
datasourceInstance
&&
{
datasourceInstance
&&
!
datasourceError
&&
(
!
datasourceError
&&
(
<
div
className=
"explore-container"
>
<
div
className=
"explore-container"
>
<
QueryRows
exploreEvents=
{
this
.
exploreEvents
}
exploreId=
{
exploreId
}
initialQueries=
{
initialQuerie
s
}
/>
<
QueryRows
exploreEvents=
{
this
.
exploreEvents
}
exploreId=
{
exploreId
}
queryKeys=
{
queryKey
s
}
/>
<
AutoSizer
onResize=
{
this
.
onResize
}
disableHeight
>
<
AutoSizer
onResize=
{
this
.
onResize
}
disableHeight
>
{
({
width
})
=>
(
{
({
width
})
=>
(
<
main
className=
"m-t-2"
style=
{
{
width
}
}
>
<
main
className=
"m-t-2"
style=
{
{
width
}
}
>
...
@@ -243,13 +243,13 @@ function mapStateToProps(state: StoreState, { exploreId }) {
...
@@ -243,13 +243,13 @@ function mapStateToProps(state: StoreState, { exploreId }) {
datasourceInstance
,
datasourceInstance
,
datasourceLoading
,
datasourceLoading
,
datasourceMissing
,
datasourceMissing
,
initialQueries
,
initialized
,
initialized
,
range
,
range
,
showingStartPage
,
showingStartPage
,
supportsGraph
,
supportsGraph
,
supportsLogs
,
supportsLogs
,
supportsTable
,
supportsTable
,
queryKeys
,
}
=
item
;
}
=
item
;
return
{
return
{
StartPage
,
StartPage
,
...
@@ -257,7 +257,6 @@ function mapStateToProps(state: StoreState, { exploreId }) {
...
@@ -257,7 +257,6 @@ function mapStateToProps(state: StoreState, { exploreId }) {
datasourceInstance
,
datasourceInstance
,
datasourceLoading
,
datasourceLoading
,
datasourceMissing
,
datasourceMissing
,
initialQueries
,
initialized
,
initialized
,
range
,
range
,
showingStartPage
,
showingStartPage
,
...
@@ -265,6 +264,7 @@ function mapStateToProps(state: StoreState, { exploreId }) {
...
@@ -265,6 +264,7 @@ function mapStateToProps(state: StoreState, { exploreId }) {
supportsGraph
,
supportsGraph
,
supportsLogs
,
supportsLogs
,
supportsTable
,
supportsTable
,
queryKeys
,
};
};
}
}
...
...
public/app/features/explore/QueryRows.tsx
View file @
96aef3ba
...
@@ -6,24 +6,21 @@ import QueryRow from './QueryRow';
...
@@ -6,24 +6,21 @@ import QueryRow from './QueryRow';
// Types
// Types
import
{
Emitter
}
from
'app/core/utils/emitter'
;
import
{
Emitter
}
from
'app/core/utils/emitter'
;
import
{
DataQuery
}
from
'@grafana/ui/src/types'
;
import
{
ExploreId
}
from
'app/types/explore'
;
import
{
ExploreId
}
from
'app/types/explore'
;
interface
QueryRowsProps
{
interface
QueryRowsProps
{
className
?:
string
;
className
?:
string
;
exploreEvents
:
Emitter
;
exploreEvents
:
Emitter
;
exploreId
:
ExploreId
;
exploreId
:
ExploreId
;
initialQueries
:
DataQuery
[];
queryKeys
:
string
[];
}
}
export
default
class
QueryRows
extends
PureComponent
<
QueryRowsProps
>
{
export
default
class
QueryRows
extends
PureComponent
<
QueryRowsProps
>
{
render
()
{
render
()
{
const
{
className
=
''
,
exploreEvents
,
exploreId
,
initialQuerie
s
}
=
this
.
props
;
const
{
className
=
''
,
exploreEvents
,
exploreId
,
queryKey
s
}
=
this
.
props
;
return
(
return
(
<
div
className=
{
className
}
>
<
div
className=
{
className
}
>
{
initialQueries
.
map
((
query
,
index
)
=>
{
{
queryKeys
.
map
((
key
,
index
)
=>
{
// using query.key will introduce infinite loop because QueryEditor#53
const
key
=
query
.
datasource
?
`${query.datasource}-${index}`
:
query
.
key
;
return
<
QueryRow
key=
{
key
}
exploreEvents=
{
exploreEvents
}
exploreId=
{
exploreId
}
index=
{
index
}
/>;
return
<
QueryRow
key=
{
key
}
exploreEvents=
{
exploreEvents
}
exploreId=
{
exploreId
}
index=
{
index
}
/>;
})
}
})
}
</
div
>
</
div
>
...
...
public/app/features/explore/state/reducers.ts
View file @
96aef3ba
...
@@ -3,6 +3,7 @@ import {
...
@@ -3,6 +3,7 @@ import {
generateEmptyQuery
,
generateEmptyQuery
,
getIntervals
,
getIntervals
,
ensureQueries
,
ensureQueries
,
getQueryKeys
,
}
from
'app/core/utils/explore'
;
}
from
'app/core/utils/explore'
;
import
{
ExploreItemState
,
ExploreState
,
QueryTransaction
}
from
'app/types/explore'
;
import
{
ExploreItemState
,
ExploreState
,
QueryTransaction
}
from
'app/types/explore'
;
import
{
DataQuery
}
from
'@grafana/ui/src/types'
;
import
{
DataQuery
}
from
'@grafana/ui/src/types'
;
...
@@ -72,6 +73,7 @@ export const makeExploreItemState = (): ExploreItemState => ({
...
@@ -72,6 +73,7 @@ export const makeExploreItemState = (): ExploreItemState => ({
supportsGraph
:
null
,
supportsGraph
:
null
,
supportsLogs
:
null
,
supportsLogs
:
null
,
supportsTable
:
null
,
supportsTable
:
null
,
queryKeys
:
[],
});
});
/**
/**
...
@@ -109,6 +111,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -109,6 +111,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
initialQueries
:
nextQueries
,
initialQueries
:
nextQueries
,
logsHighlighterExpressions
:
undefined
,
logsHighlighterExpressions
:
undefined
,
queryTransactions
:
nextQueryTransactions
,
queryTransactions
:
nextQueryTransactions
,
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
};
};
},
},
})
})
...
@@ -130,6 +133,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -130,6 +133,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
state
,
...
state
,
initialQueries
:
nextQueries
,
initialQueries
:
nextQueries
,
queryTransactions
:
nextQueryTransactions
,
queryTransactions
:
nextQueryTransactions
,
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
};
};
},
},
})
})
...
@@ -161,6 +165,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -161,6 +165,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
initialQueries
:
queries
.
slice
(),
initialQueries
:
queries
.
slice
(),
queryTransactions
:
[],
queryTransactions
:
[],
showingStartPage
:
Boolean
(
state
.
StartPage
),
showingStartPage
:
Boolean
(
state
.
StartPage
),
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
};
};
},
},
})
})
...
@@ -183,6 +188,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -183,6 +188,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
range
,
range
,
initialQueries
:
queries
,
initialQueries
:
queries
,
initialized
:
true
,
initialized
:
true
,
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
};
};
},
},
})
})
...
@@ -190,8 +196,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -190,8 +196,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
filter
:
updateDatasourceInstanceAction
,
filter
:
updateDatasourceInstanceAction
,
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
const
{
datasourceInstance
}
=
action
.
payload
;
const
{
datasourceInstance
}
=
action
.
payload
;
return
{
...
state
,
datasourceInstance
};
return
{
...
state
,
datasourceInstance
,
queryKeys
:
getQueryKeys
(
state
.
initialQueries
,
datasourceInstance
)
};
/*datasourceName: datasourceInstance.name removed after refactor, datasourceName does not exists on ExploreItemState */
},
},
})
})
.
addMapper
({
.
addMapper
({
...
@@ -281,6 +286,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -281,6 +286,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
return
{
return
{
...
state
,
...
state
,
initialQueries
:
nextQueries
,
initialQueries
:
nextQueries
,
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
queryTransactions
:
nextQueryTransactions
,
queryTransactions
:
nextQueryTransactions
,
};
};
},
},
...
@@ -348,6 +354,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -348,6 +354,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
initialQueries
:
nextQueries
,
initialQueries
:
nextQueries
,
logsHighlighterExpressions
:
undefined
,
logsHighlighterExpressions
:
undefined
,
queryTransactions
:
nextQueryTransactions
,
queryTransactions
:
nextQueryTransactions
,
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
};
};
},
},
})
})
...
@@ -387,7 +394,11 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -387,7 +394,11 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
filter
:
setQueriesAction
,
filter
:
setQueriesAction
,
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
const
{
queries
}
=
action
.
payload
;
const
{
queries
}
=
action
.
payload
;
return
{
...
state
,
initialQueries
:
queries
.
slice
()
};
return
{
...
state
,
initialQueries
:
queries
.
slice
(),
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
};
},
},
})
})
.
addMapper
({
.
addMapper
({
...
@@ -436,7 +447,12 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -436,7 +447,12 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
.
addMapper
({
.
addMapper
({
filter
:
queriesImportedAction
,
filter
:
queriesImportedAction
,
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
return
{
...
state
,
initialQueries
:
action
.
payload
.
queries
};
const
{
queries
}
=
action
.
payload
;
return
{
...
state
,
initialQueries
:
queries
,
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
};
},
},
})
})
.
create
();
.
create
();
...
...
public/app/types/explore.ts
View file @
96aef3ba
...
@@ -232,6 +232,11 @@ export interface ExploreItemState {
...
@@ -232,6 +232,11 @@ export interface ExploreItemState {
* Table model that combines all query table results into a single table.
* Table model that combines all query table results into a single table.
*/
*/
tableResult
?:
TableModel
;
tableResult
?:
TableModel
;
/**
* React keys for rendering of QueryRows
*/
queryKeys
:
string
[];
}
}
export
interface
ExploreUrlState
{
export
interface
ExploreUrlState
{
...
...
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