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
2c255fd8
Commit
2c255fd8
authored
Feb 05, 2019
by
Hugo Häggmark
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed initialQueries to queries
parent
f74ebdad
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
54 additions
and
68 deletions
+54
-68
packages/grafana-ui/src/types/plugin.ts
+1
-1
public/app/features/explore/QueryRow.tsx
+7
-7
public/app/features/explore/state/actions.ts
+8
-19
public/app/features/explore/state/reducers.ts
+25
-22
public/app/plugins/datasource/loki/components/LokiQueryEditor.tsx
+1
-1
public/app/plugins/datasource/loki/components/LokiQueryField.tsx
+5
-8
public/app/plugins/datasource/prometheus/components/PromQueryField.tsx
+5
-8
public/app/types/explore.ts
+2
-2
No files found.
packages/grafana-ui/src/types/plugin.ts
View file @
2c255fd8
...
@@ -56,7 +56,7 @@ export interface QueryEditorProps<DSType extends DataSourceApi, TQuery extends D
...
@@ -56,7 +56,7 @@ export interface QueryEditorProps<DSType extends DataSourceApi, TQuery extends D
export
interface
ExploreQueryFieldProps
<
DSType
extends
DataSourceApi
,
TQuery
extends
DataQuery
>
{
export
interface
ExploreQueryFieldProps
<
DSType
extends
DataSourceApi
,
TQuery
extends
DataQuery
>
{
datasource
:
DSType
;
datasource
:
DSType
;
initialQ
uery
:
TQuery
;
q
uery
:
TQuery
;
error
?:
string
|
JSX
.
Element
;
error
?:
string
|
JSX
.
Element
;
hint
?:
QueryHint
;
hint
?:
QueryHint
;
history
:
any
[];
history
:
any
[];
...
...
public/app/features/explore/QueryRow.tsx
View file @
2c255fd8
...
@@ -35,7 +35,7 @@ interface QueryRowProps {
...
@@ -35,7 +35,7 @@ interface QueryRowProps {
highlightLogsExpressionAction
:
typeof
highlightLogsExpressionAction
;
highlightLogsExpressionAction
:
typeof
highlightLogsExpressionAction
;
history
:
HistoryItem
[];
history
:
HistoryItem
[];
index
:
number
;
index
:
number
;
initialQ
uery
:
DataQuery
;
q
uery
:
DataQuery
;
modifyQueries
:
typeof
modifyQueries
;
modifyQueries
:
typeof
modifyQueries
;
queryTransactions
:
QueryTransaction
[];
queryTransactions
:
QueryTransaction
[];
exploreEvents
:
Emitter
;
exploreEvents
:
Emitter
;
...
@@ -95,7 +95,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
...
@@ -95,7 +95,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
},
500
);
},
500
);
render
()
{
render
()
{
const
{
datasourceInstance
,
history
,
index
,
initialQ
uery
,
queryTransactions
,
exploreEvents
,
range
}
=
this
.
props
;
const
{
datasourceInstance
,
history
,
index
,
q
uery
,
queryTransactions
,
exploreEvents
,
range
}
=
this
.
props
;
const
transactions
=
queryTransactions
.
filter
(
t
=>
t
.
rowIndex
===
index
);
const
transactions
=
queryTransactions
.
filter
(
t
=>
t
.
rowIndex
===
index
);
const
transactionWithError
=
transactions
.
find
(
t
=>
t
.
error
!==
undefined
);
const
transactionWithError
=
transactions
.
find
(
t
=>
t
.
error
!==
undefined
);
const
hint
=
getFirstHintFromTransactions
(
transactions
);
const
hint
=
getFirstHintFromTransactions
(
transactions
);
...
@@ -110,7 +110,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
...
@@ -110,7 +110,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
{
QueryField
?
(
{
QueryField
?
(
<
QueryField
<
QueryField
datasource=
{
datasourceInstance
}
datasource=
{
datasourceInstance
}
initialQuery=
{
initialQ
uery
}
query=
{
q
uery
}
error=
{
queryError
}
error=
{
queryError
}
hint=
{
hint
}
hint=
{
hint
}
history=
{
history
}
history=
{
history
}
...
@@ -124,7 +124,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
...
@@ -124,7 +124,7 @@ export class QueryRow extends PureComponent<QueryRowProps> {
error=
{
queryError
}
error=
{
queryError
}
onQueryChange=
{
this
.
onChangeQuery
}
onQueryChange=
{
this
.
onChangeQuery
}
onExecuteQuery=
{
this
.
onExecuteQuery
}
onExecuteQuery=
{
this
.
onExecuteQuery
}
initialQuery=
{
initialQ
uery
}
initialQuery=
{
q
uery
}
exploreEvents=
{
exploreEvents
}
exploreEvents=
{
exploreEvents
}
range=
{
range
}
range=
{
range
}
/>
/>
...
@@ -155,9 +155,9 @@ export class QueryRow extends PureComponent<QueryRowProps> {
...
@@ -155,9 +155,9 @@ export class QueryRow extends PureComponent<QueryRowProps> {
function
mapStateToProps
(
state
:
StoreState
,
{
exploreId
,
index
})
{
function
mapStateToProps
(
state
:
StoreState
,
{
exploreId
,
index
})
{
const
explore
=
state
.
explore
;
const
explore
=
state
.
explore
;
const
item
:
ExploreItemState
=
explore
[
exploreId
];
const
item
:
ExploreItemState
=
explore
[
exploreId
];
const
{
datasourceInstance
,
history
,
initialQ
ueries
,
queryTransactions
,
range
}
=
item
;
const
{
datasourceInstance
,
history
,
q
ueries
,
queryTransactions
,
range
}
=
item
;
const
initialQuery
=
initialQ
ueries
[
index
];
const
query
=
q
ueries
[
index
];
return
{
datasourceInstance
,
history
,
initialQ
uery
,
queryTransactions
,
range
};
return
{
datasourceInstance
,
history
,
q
uery
,
queryTransactions
,
range
};
}
}
const
mapDispatchToProps
=
{
const
mapDispatchToProps
=
{
...
...
public/app/features/explore/state/actions.ts
View file @
2c255fd8
...
@@ -87,7 +87,7 @@ export function changeDatasource(exploreId: ExploreId, datasource: string): Thun
...
@@ -87,7 +87,7 @@ export function changeDatasource(exploreId: ExploreId, datasource: string): Thun
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
const
newDataSourceInstance
=
await
getDatasourceSrv
().
get
(
datasource
);
const
newDataSourceInstance
=
await
getDatasourceSrv
().
get
(
datasource
);
const
currentDataSourceInstance
=
getState
().
explore
[
exploreId
].
datasourceInstance
;
const
currentDataSourceInstance
=
getState
().
explore
[
exploreId
].
datasourceInstance
;
const
queries
=
getState
().
explore
[
exploreId
].
initialQ
ueries
;
const
queries
=
getState
().
explore
[
exploreId
].
q
ueries
;
await
dispatch
(
importQueries
(
exploreId
,
queries
,
currentDataSourceInstance
,
newDataSourceInstance
));
await
dispatch
(
importQueries
(
exploreId
,
queries
,
currentDataSourceInstance
,
newDataSourceInstance
));
...
@@ -494,7 +494,7 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false) {
...
@@ -494,7 +494,7 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false) {
return
(
dispatch
,
getState
)
=>
{
return
(
dispatch
,
getState
)
=>
{
const
{
const
{
datasourceInstance
,
datasourceInstance
,
initialQ
ueries
,
q
ueries
,
showingLogs
,
showingLogs
,
showingGraph
,
showingGraph
,
showingTable
,
showingTable
,
...
@@ -503,7 +503,7 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false) {
...
@@ -503,7 +503,7 @@ export function runQueries(exploreId: ExploreId, ignoreUIState = false) {
supportsTable
,
supportsTable
,
}
=
getState
().
explore
[
exploreId
];
}
=
getState
().
explore
[
exploreId
];
if
(
!
hasNonEmptyQuery
(
initialQ
ueries
))
{
if
(
!
hasNonEmptyQuery
(
q
ueries
))
{
dispatch
(
runQueriesEmptyAction
({
exploreId
}));
dispatch
(
runQueriesEmptyAction
({
exploreId
}));
dispatch
(
stateSave
());
// Remember to saves to state and update location
dispatch
(
stateSave
());
// Remember to saves to state and update location
return
;
return
;
...
@@ -565,14 +565,7 @@ function runQueriesForType(
...
@@ -565,14 +565,7 @@ function runQueriesForType(
resultGetter
?:
any
resultGetter
?:
any
)
{
)
{
return
async
(
dispatch
,
getState
)
=>
{
return
async
(
dispatch
,
getState
)
=>
{
const
{
const
{
datasourceInstance
,
eventBridge
,
queries
,
queryIntervals
,
range
,
scanning
}
=
getState
().
explore
[
exploreId
];
datasourceInstance
,
eventBridge
,
initialQueries
:
queries
,
queryIntervals
,
range
,
scanning
,
}
=
getState
().
explore
[
exploreId
];
const
datasourceId
=
datasourceInstance
.
meta
.
id
;
const
datasourceId
=
datasourceInstance
.
meta
.
id
;
// Run all queries concurrently
// Run all queries concurrently
...
@@ -653,7 +646,7 @@ export function splitOpen(): ThunkResult<void> {
...
@@ -653,7 +646,7 @@ export function splitOpen(): ThunkResult<void> {
const
itemState
=
{
const
itemState
=
{
...
leftState
,
...
leftState
,
queryTransactions
:
[],
queryTransactions
:
[],
initialQueries
:
leftState
.
initialQ
ueries
.
slice
(),
queries
:
leftState
.
q
ueries
.
slice
(),
};
};
dispatch
(
splitOpenAction
({
itemState
}));
dispatch
(
splitOpenAction
({
itemState
}));
dispatch
(
stateSave
());
dispatch
(
stateSave
());
...
@@ -670,7 +663,7 @@ export function stateSave() {
...
@@ -670,7 +663,7 @@ export function stateSave() {
const
urlStates
:
{
[
index
:
string
]:
string
}
=
{};
const
urlStates
:
{
[
index
:
string
]:
string
}
=
{};
const
leftUrlState
:
ExploreUrlState
=
{
const
leftUrlState
:
ExploreUrlState
=
{
datasource
:
left
.
datasourceInstance
.
name
,
datasource
:
left
.
datasourceInstance
.
name
,
queries
:
left
.
initialQ
ueries
.
map
(
clearQueryKeys
),
queries
:
left
.
q
ueries
.
map
(
clearQueryKeys
),
range
:
left
.
range
,
range
:
left
.
range
,
ui
:
{
ui
:
{
showingGraph
:
left
.
showingGraph
,
showingGraph
:
left
.
showingGraph
,
...
@@ -682,13 +675,9 @@ export function stateSave() {
...
@@ -682,13 +675,9 @@ export function stateSave() {
if
(
split
)
{
if
(
split
)
{
const
rightUrlState
:
ExploreUrlState
=
{
const
rightUrlState
:
ExploreUrlState
=
{
datasource
:
right
.
datasourceInstance
.
name
,
datasource
:
right
.
datasourceInstance
.
name
,
queries
:
right
.
initialQ
ueries
.
map
(
clearQueryKeys
),
queries
:
right
.
q
ueries
.
map
(
clearQueryKeys
),
range
:
right
.
range
,
range
:
right
.
range
,
ui
:
{
ui
:
{
showingGraph
:
right
.
showingGraph
,
showingLogs
:
right
.
showingLogs
,
showingTable
:
right
.
showingTable
},
showingGraph
:
right
.
showingGraph
,
showingLogs
:
right
.
showingLogs
,
showingTable
:
right
.
showingTable
,
},
};
};
urlStates
.
right
=
serializeStateToUrlParam
(
rightUrlState
,
true
);
urlStates
.
right
=
serializeStateToUrlParam
(
rightUrlState
,
true
);
...
...
public/app/features/explore/state/reducers.ts
View file @
2c255fd8
...
@@ -60,7 +60,7 @@ export const makeExploreItemState = (): ExploreItemState => ({
...
@@ -60,7 +60,7 @@ export const makeExploreItemState = (): ExploreItemState => ({
datasourceMissing
:
false
,
datasourceMissing
:
false
,
exploreDatasources
:
[],
exploreDatasources
:
[],
history
:
[],
history
:
[],
initialQ
ueries
:
[],
q
ueries
:
[],
initialized
:
false
,
initialized
:
false
,
queryTransactions
:
[],
queryTransactions
:
[],
queryIntervals
:
{
interval
:
'15s'
,
intervalMs
:
DEFAULT_GRAPH_INTERVAL
},
queryIntervals
:
{
interval
:
'15s'
,
intervalMs
:
DEFAULT_GRAPH_INTERVAL
},
...
@@ -92,23 +92,26 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -92,23 +92,26 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
.
addMapper
({
.
addMapper
({
filter
:
addQueryRowAction
,
filter
:
addQueryRowAction
,
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
const
{
initialQ
ueries
,
queryTransactions
}
=
state
;
const
{
q
ueries
,
queryTransactions
}
=
state
;
const
{
index
,
query
}
=
action
.
payload
;
const
{
index
,
query
}
=
action
.
payload
;
// Add to
initialQ
ueries, which will cause a new row to be rendered
// Add to
q
ueries, which will cause a new row to be rendered
const
nextQueries
=
[...
initialQueries
.
slice
(
0
,
index
+
1
),
{
...
query
},
...
initialQ
ueries
.
slice
(
index
+
1
)];
const
nextQueries
=
[...
queries
.
slice
(
0
,
index
+
1
),
{
...
query
},
...
q
ueries
.
slice
(
index
+
1
)];
// Ongoing transactions need to update their row indices
// Ongoing transactions need to update their row indices
const
nextQueryTransactions
=
queryTransactions
.
map
(
qt
=>
{
const
nextQueryTransactions
=
queryTransactions
.
map
(
qt
=>
{
if
(
qt
.
rowIndex
>
index
)
{
if
(
qt
.
rowIndex
>
index
)
{
return
{
...
qt
,
rowIndex
:
qt
.
rowIndex
+
1
};
return
{
...
qt
,
rowIndex
:
qt
.
rowIndex
+
1
,
};
}
}
return
qt
;
return
qt
;
});
});
return
{
return
{
...
state
,
...
state
,
initialQ
ueries
:
nextQueries
,
q
ueries
:
nextQueries
,
logsHighlighterExpressions
:
undefined
,
logsHighlighterExpressions
:
undefined
,
queryTransactions
:
nextQueryTransactions
,
queryTransactions
:
nextQueryTransactions
,
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
...
@@ -118,12 +121,12 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -118,12 +121,12 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
.
addMapper
({
.
addMapper
({
filter
:
changeQueryAction
,
filter
:
changeQueryAction
,
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
const
{
initialQ
ueries
,
queryTransactions
}
=
state
;
const
{
q
ueries
,
queryTransactions
}
=
state
;
const
{
query
,
index
}
=
action
.
payload
;
const
{
query
,
index
}
=
action
.
payload
;
// Override path: queries are completely reset
// Override path: queries are completely reset
const
nextQuery
:
DataQuery
=
{
...
query
,
...
generateEmptyQuery
(
index
)
};
const
nextQuery
:
DataQuery
=
{
...
query
,
...
generateEmptyQuery
(
index
)
};
const
nextQueries
=
[...
initialQ
ueries
];
const
nextQueries
=
[...
q
ueries
];
nextQueries
[
index
]
=
nextQuery
;
nextQueries
[
index
]
=
nextQuery
;
// Discard ongoing transaction related to row query
// Discard ongoing transaction related to row query
...
@@ -131,7 +134,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -131,7 +134,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
return
{
return
{
...
state
,
...
state
,
initialQ
ueries
:
nextQueries
,
q
ueries
:
nextQueries
,
queryTransactions
:
nextQueryTransactions
,
queryTransactions
:
nextQueryTransactions
,
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
};
};
...
@@ -162,7 +165,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -162,7 +165,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
const
queries
=
ensureQueries
();
const
queries
=
ensureQueries
();
return
{
return
{
...
state
,
...
state
,
initialQ
ueries
:
queries
.
slice
(),
q
ueries
:
queries
.
slice
(),
queryTransactions
:
[],
queryTransactions
:
[],
showingStartPage
:
Boolean
(
state
.
StartPage
),
showingStartPage
:
Boolean
(
state
.
StartPage
),
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
...
@@ -186,7 +189,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -186,7 +189,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
eventBridge
,
eventBridge
,
exploreDatasources
,
exploreDatasources
,
range
,
range
,
initialQueries
:
queries
,
queries
,
initialized
:
true
,
initialized
:
true
,
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
...
ui
,
...
ui
,
...
@@ -197,7 +200,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -197,7 +200,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
,
queryKeys
:
getQueryKeys
(
state
.
initialQ
ueries
,
datasourceInstance
)
};
return
{
...
state
,
datasourceInstance
,
queryKeys
:
getQueryKeys
(
state
.
q
ueries
,
datasourceInstance
)
};
},
},
})
})
.
addMapper
({
.
addMapper
({
...
@@ -254,13 +257,13 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -254,13 +257,13 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
.
addMapper
({
.
addMapper
({
filter
:
modifyQueriesAction
,
filter
:
modifyQueriesAction
,
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
const
{
initialQ
ueries
,
queryTransactions
}
=
state
;
const
{
q
ueries
,
queryTransactions
}
=
state
;
const
{
modification
,
index
,
modifier
}
=
action
.
payload
;
const
{
modification
,
index
,
modifier
}
=
action
.
payload
;
let
nextQueries
:
DataQuery
[];
let
nextQueries
:
DataQuery
[];
let
nextQueryTransactions
;
let
nextQueryTransactions
;
if
(
index
===
undefined
)
{
if
(
index
===
undefined
)
{
// Modify all queries
// Modify all queries
nextQueries
=
initialQ
ueries
.
map
((
query
,
i
)
=>
({
nextQueries
=
q
ueries
.
map
((
query
,
i
)
=>
({
...
modifier
({
...
query
},
modification
),
...
modifier
({
...
query
},
modification
),
...
generateEmptyQuery
(
i
),
...
generateEmptyQuery
(
i
),
}));
}));
...
@@ -268,7 +271,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -268,7 +271,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
nextQueryTransactions
=
[];
nextQueryTransactions
=
[];
}
else
{
}
else
{
// Modify query only at index
// Modify query only at index
nextQueries
=
initialQ
ueries
.
map
((
query
,
i
)
=>
{
nextQueries
=
q
ueries
.
map
((
query
,
i
)
=>
{
// Synchronize all queries with local query cache to ensure consistency
// Synchronize all queries with local query cache to ensure consistency
// TODO still needed?
// TODO still needed?
return
i
===
index
?
{
...
modifier
({
...
query
},
modification
),
...
generateEmptyQuery
(
i
)
}
:
query
;
return
i
===
index
?
{
...
modifier
({
...
query
},
modification
),
...
generateEmptyQuery
(
i
)
}
:
query
;
...
@@ -286,7 +289,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -286,7 +289,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
}
}
return
{
return
{
...
state
,
...
state
,
initialQ
ueries
:
nextQueries
,
q
ueries
:
nextQueries
,
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
queryKeys
:
getQueryKeys
(
nextQueries
,
state
.
datasourceInstance
),
queryTransactions
:
nextQueryTransactions
,
queryTransactions
:
nextQueryTransactions
,
};
};
...
@@ -332,14 +335,14 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -332,14 +335,14 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
.
addMapper
({
.
addMapper
({
filter
:
removeQueryRowAction
,
filter
:
removeQueryRowAction
,
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
mapper
:
(
state
,
action
):
ExploreItemState
=>
{
const
{
datasourceInstance
,
initialQ
ueries
,
queryIntervals
,
queryTransactions
,
queryKeys
}
=
state
;
const
{
datasourceInstance
,
q
ueries
,
queryIntervals
,
queryTransactions
,
queryKeys
}
=
state
;
const
{
index
}
=
action
.
payload
;
const
{
index
}
=
action
.
payload
;
if
(
initialQ
ueries
.
length
<=
1
)
{
if
(
q
ueries
.
length
<=
1
)
{
return
state
;
return
state
;
}
}
const
nextQueries
=
[...
initialQueries
.
slice
(
0
,
index
),
...
initialQ
ueries
.
slice
(
index
+
1
)];
const
nextQueries
=
[...
queries
.
slice
(
0
,
index
),
...
q
ueries
.
slice
(
index
+
1
)];
const
nextQueryKeys
=
[...
queryKeys
.
slice
(
0
,
index
),
...
queryKeys
.
slice
(
index
+
1
)];
const
nextQueryKeys
=
[...
queryKeys
.
slice
(
0
,
index
),
...
queryKeys
.
slice
(
index
+
1
)];
// Discard transactions related to row query
// Discard transactions related to row query
...
@@ -353,7 +356,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -353,7 +356,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
return
{
return
{
...
state
,
...
state
,
...
results
,
...
results
,
initialQ
ueries
:
nextQueries
,
q
ueries
:
nextQueries
,
logsHighlighterExpressions
:
undefined
,
logsHighlighterExpressions
:
undefined
,
queryTransactions
:
nextQueryTransactions
,
queryTransactions
:
nextQueryTransactions
,
queryKeys
:
nextQueryKeys
,
queryKeys
:
nextQueryKeys
,
...
@@ -398,7 +401,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -398,7 +401,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
const
{
queries
}
=
action
.
payload
;
const
{
queries
}
=
action
.
payload
;
return
{
return
{
...
state
,
...
state
,
initialQ
ueries
:
queries
.
slice
(),
q
ueries
:
queries
.
slice
(),
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
};
};
},
},
...
@@ -452,7 +455,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
...
@@ -452,7 +455,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
const
{
queries
}
=
action
.
payload
;
const
{
queries
}
=
action
.
payload
;
return
{
return
{
...
state
,
...
state
,
initialQueries
:
queries
,
queries
,
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
queryKeys
:
getQueryKeys
(
queries
,
state
.
datasourceInstance
),
};
};
},
},
...
...
public/app/plugins/datasource/loki/components/LokiQueryEditor.tsx
View file @
2c255fd8
...
@@ -59,7 +59,7 @@ export class LokiQueryEditor extends PureComponent<Props> {
...
@@ -59,7 +59,7 @@ export class LokiQueryEditor extends PureComponent<Props> {
<
div
>
<
div
>
<
LokiQueryField
<
LokiQueryField
datasource=
{
datasource
}
datasource=
{
datasource
}
initialQ
uery=
{
query
}
q
uery=
{
query
}
onQueryChange=
{
this
.
onFieldChange
}
onQueryChange=
{
this
.
onFieldChange
}
onExecuteQuery=
{
this
.
onRunQuery
}
onExecuteQuery=
{
this
.
onRunQuery
}
history=
{
[]
}
history=
{
[]
}
...
...
public/app/plugins/datasource/loki/components/LokiQueryField.tsx
View file @
2c255fd8
...
@@ -162,13 +162,10 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
...
@@ -162,13 +162,10 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
onChangeQuery
=
(
value
:
string
,
override
?:
boolean
)
=>
{
onChangeQuery
=
(
value
:
string
,
override
?:
boolean
)
=>
{
// Send text change to parent
// Send text change to parent
const
{
initialQ
uery
,
onQueryChange
,
onExecuteQuery
}
=
this
.
props
;
const
{
q
uery
,
onQueryChange
,
onExecuteQuery
}
=
this
.
props
;
if
(
onQueryChange
)
{
if
(
onQueryChange
)
{
const
query
=
{
const
nextQuery
=
{
...
query
,
expr
:
value
};
...
initialQuery
,
onQueryChange
(
nextQuery
);
expr
:
value
,
};
onQueryChange
(
query
);
if
(
override
&&
onExecuteQuery
)
{
if
(
override
&&
onExecuteQuery
)
{
onExecuteQuery
();
onExecuteQuery
();
...
@@ -217,7 +214,7 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
...
@@ -217,7 +214,7 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
};
};
render
()
{
render
()
{
const
{
error
,
hint
,
initialQ
uery
}
=
this
.
props
;
const
{
error
,
hint
,
q
uery
}
=
this
.
props
;
const
{
logLabelOptions
,
syntaxLoaded
}
=
this
.
state
;
const
{
logLabelOptions
,
syntaxLoaded
}
=
this
.
state
;
const
cleanText
=
this
.
languageProvider
?
this
.
languageProvider
.
cleanText
:
undefined
;
const
cleanText
=
this
.
languageProvider
?
this
.
languageProvider
.
cleanText
:
undefined
;
const
hasLogLabels
=
logLabelOptions
&&
logLabelOptions
.
length
>
0
;
const
hasLogLabels
=
logLabelOptions
&&
logLabelOptions
.
length
>
0
;
...
@@ -237,7 +234,7 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
...
@@ -237,7 +234,7 @@ export class LokiQueryField extends React.PureComponent<LokiQueryFieldProps, Lok
<
QueryField
<
QueryField
additionalPlugins=
{
this
.
plugins
}
additionalPlugins=
{
this
.
plugins
}
cleanText=
{
cleanText
}
cleanText=
{
cleanText
}
initialQuery=
{
initialQ
uery
.
expr
}
initialQuery=
{
q
uery
.
expr
}
onTypeahead=
{
this
.
onTypeahead
}
onTypeahead=
{
this
.
onTypeahead
}
onWillApplySuggestion=
{
willApplySuggestion
}
onWillApplySuggestion=
{
willApplySuggestion
}
onQueryChange=
{
this
.
onChangeQuery
}
onQueryChange=
{
this
.
onChangeQuery
}
...
...
public/app/plugins/datasource/prometheus/components/PromQueryField.tsx
View file @
2c255fd8
...
@@ -168,13 +168,10 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
...
@@ -168,13 +168,10 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
onChangeQuery
=
(
value
:
string
,
override
?:
boolean
)
=>
{
onChangeQuery
=
(
value
:
string
,
override
?:
boolean
)
=>
{
// Send text change to parent
// Send text change to parent
const
{
initialQ
uery
,
onQueryChange
,
onExecuteQuery
}
=
this
.
props
;
const
{
q
uery
,
onQueryChange
,
onExecuteQuery
}
=
this
.
props
;
if
(
onQueryChange
)
{
if
(
onQueryChange
)
{
const
query
:
PromQuery
=
{
const
nextQuery
:
PromQuery
=
{
...
query
,
expr
:
value
};
...
initialQuery
,
onQueryChange
(
nextQuery
);
expr
:
value
,
};
onQueryChange
(
query
);
if
(
override
&&
onExecuteQuery
)
{
if
(
override
&&
onExecuteQuery
)
{
onExecuteQuery
();
onExecuteQuery
();
...
@@ -240,7 +237,7 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
...
@@ -240,7 +237,7 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
};
};
render
()
{
render
()
{
const
{
error
,
hint
,
initialQ
uery
}
=
this
.
props
;
const
{
error
,
hint
,
q
uery
}
=
this
.
props
;
const
{
metricsOptions
,
syntaxLoaded
}
=
this
.
state
;
const
{
metricsOptions
,
syntaxLoaded
}
=
this
.
state
;
const
cleanText
=
this
.
languageProvider
?
this
.
languageProvider
.
cleanText
:
undefined
;
const
cleanText
=
this
.
languageProvider
?
this
.
languageProvider
.
cleanText
:
undefined
;
const
chooserText
=
syntaxLoaded
?
'Metrics'
:
'Loading metrics...'
;
const
chooserText
=
syntaxLoaded
?
'Metrics'
:
'Loading metrics...'
;
...
@@ -259,7 +256,7 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
...
@@ -259,7 +256,7 @@ class PromQueryField extends React.PureComponent<PromQueryFieldProps, PromQueryF
<
QueryField
<
QueryField
additionalPlugins=
{
this
.
plugins
}
additionalPlugins=
{
this
.
plugins
}
cleanText=
{
cleanText
}
cleanText=
{
cleanText
}
initialQuery=
{
initialQ
uery
.
expr
}
initialQuery=
{
q
uery
.
expr
}
onTypeahead=
{
this
.
onTypeahead
}
onTypeahead=
{
this
.
onTypeahead
}
onWillApplySuggestion=
{
willApplySuggestion
}
onWillApplySuggestion=
{
willApplySuggestion
}
onQueryChange=
{
this
.
onChangeQuery
}
onQueryChange=
{
this
.
onChangeQuery
}
...
...
public/app/types/explore.ts
View file @
2c255fd8
...
@@ -153,10 +153,10 @@ export interface ExploreItemState {
...
@@ -153,10 +153,10 @@ export interface ExploreItemState {
*/
*/
history
:
HistoryItem
[];
history
:
HistoryItem
[];
/**
/**
*
Initial q
ueries for this Explore, e.g., set via URL. Each query will be
*
Q
ueries for this Explore, e.g., set via URL. Each query will be
* converted to a query row.
* converted to a query row.
*/
*/
initialQ
ueries
:
DataQuery
[];
q
ueries
:
DataQuery
[];
/**
/**
* True if this Explore area has been initialized.
* True if this Explore area has been initialized.
* Used to distinguish URL state injection versus split view state injection.
* Used to distinguish URL state injection versus split view state injection.
...
...
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