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
54a3e2d1
Commit
54a3e2d1
authored
Oct 24, 2018
by
David Kaltschmidt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added types to query rows
parent
3a1ece53
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
8 deletions
+55
-8
public/app/features/explore/QueryRows.tsx
+34
-6
public/app/plugins/datasource/prometheus/query_hints.ts
+3
-1
public/app/types/explore.ts
+18
-1
No files found.
public/app/features/explore/QueryRows.tsx
View file @
54a3e2d1
import
React
,
{
PureComponent
}
from
'react'
;
import
{
QueryTransaction
}
from
'app/types/explore'
;
import
{
QueryTransaction
,
HistoryItem
,
Query
,
QueryHint
}
from
'app/types/explore'
;
// TODO make this datasource-plugin-dependent
import
QueryField
from
'./PromQueryField'
;
import
QueryTransactions
from
'./QueryTransactions'
;
function
getFirstHintFromTransactions
(
transactions
:
QueryTransaction
[])
{
function
getFirstHintFromTransactions
(
transactions
:
QueryTransaction
[])
:
QueryHint
{
const
transaction
=
transactions
.
find
(
qt
=>
qt
.
hints
&&
qt
.
hints
.
length
>
0
);
if
(
transaction
)
{
return
transaction
.
hints
[
0
];
...
...
@@ -14,7 +14,30 @@ function getFirstHintFromTransactions(transactions: QueryTransaction[]) {
return
undefined
;
}
class
QueryRow
extends
PureComponent
<
any
,
{}
>
{
interface
QueryRowEventHandlers
{
onAddQueryRow
:
(
index
:
number
)
=>
void
;
onChangeQuery
:
(
value
:
string
,
index
:
number
,
override
?:
boolean
)
=>
void
;
onClickHintFix
:
(
action
:
object
,
index
?:
number
)
=>
void
;
onExecuteQuery
:
()
=>
void
;
onRemoveQueryRow
:
(
index
:
number
)
=>
void
;
}
interface
QueryRowCommonProps
{
className
?:
string
;
history
:
HistoryItem
[];
request
:
(
url
:
string
)
=>
Promise
<
any
>
;
// Temporarily
supportsLogs
?:
boolean
;
transactions
:
QueryTransaction
[];
}
type
QueryRowProps
=
QueryRowCommonProps
&
QueryRowEventHandlers
&
{
index
:
number
;
query
:
string
;
};
class
QueryRow
extends
PureComponent
<
QueryRowProps
>
{
onChangeQuery
=
(
value
,
override
?:
boolean
)
=>
{
const
{
index
,
onChangeQuery
}
=
this
.
props
;
if
(
onChangeQuery
)
{
...
...
@@ -56,7 +79,7 @@ class QueryRow extends PureComponent<any, {}> {
render
()
{
const
{
history
,
query
,
request
,
supportsLogs
,
transactions
}
=
this
.
props
;
const
transactionWithError
=
transactions
.
find
(
t
=>
t
.
error
);
const
transactionWithError
=
transactions
.
find
(
t
=>
t
.
error
!==
undefined
);
const
hint
=
getFirstHintFromTransactions
(
transactions
);
const
queryError
=
transactionWithError
?
transactionWithError
.
error
:
null
;
return
(
...
...
@@ -93,9 +116,14 @@ class QueryRow extends PureComponent<any, {}> {
}
}
export
default
class
QueryRows
extends
PureComponent
<
any
,
{}
>
{
type
QueryRowsProps
=
QueryRowCommonProps
&
QueryRowEventHandlers
&
{
queries
:
Query
[];
};
export
default
class
QueryRows
extends
PureComponent
<
QueryRowsProps
>
{
render
()
{
const
{
className
=
''
,
queries
,
queryHints
,
transactions
,
...
handlers
}
=
this
.
props
;
const
{
className
=
''
,
queries
,
transactions
,
...
handlers
}
=
this
.
props
;
return
(
<
div
className=
{
className
}
>
{
queries
.
map
((
q
,
index
)
=>
(
...
...
public/app/plugins/datasource/prometheus/query_hints.ts
View file @
54a3e2d1
import
_
from
'lodash'
;
export
function
getQueryHints
(
query
:
string
,
series
?:
any
[],
datasource
?:
any
):
any
[]
{
import
{
QueryHint
}
from
'app/types/explore'
;
export
function
getQueryHints
(
query
:
string
,
series
?:
any
[],
datasource
?:
any
):
QueryHint
[]
{
const
hints
=
[];
// ..._bucket metric needs a histogram_quantile()
...
...
public/app/types/explore.ts
View file @
54a3e2d1
...
...
@@ -18,11 +18,28 @@ export interface Query {
key
?:
string
;
}
export
interface
QueryFix
{
type
:
string
;
label
:
string
;
action
?:
QueryFixAction
;
}
export
interface
QueryFixAction
{
type
:
string
;
query
?:
string
;
}
export
interface
QueryHint
{
type
:
string
;
label
:
string
;
fix
?:
QueryFix
;
}
export
interface
QueryTransaction
{
id
:
string
;
done
:
boolean
;
error
?:
string
;
hints
?:
any
[];
hints
?:
QueryHint
[];
latency
:
number
;
options
:
any
;
query
:
string
;
...
...
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