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
5bc936d2
Unverified
Commit
5bc936d2
authored
Apr 10, 2019
by
Ryan McKinley
Committed by
GitHub
Apr 10, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DataSourceApi: add getCollapsedText(query) to DataSourceApi (#16482)
Add getQueryDisplayText() to DataSourceApi
parent
23d461af
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
22 additions
and
5 deletions
+22
-5
packages/grafana-ui/src/types/datasource.ts
+5
-0
public/app/features/dashboard/panel_editor/QueryEditorRow.tsx
+5
-1
public/app/plugins/datasource/prometheus/datasource.ts
+4
-0
public/app/plugins/datasource/prometheus/query_ctrl.ts
+0
-4
public/app/plugins/datasource/testdata/datasource.ts
+7
-0
public/app/plugins/datasource/testdata/types.ts
+1
-0
No files found.
packages/grafana-ui/src/types/datasource.ts
View file @
5bc936d2
...
...
@@ -107,6 +107,11 @@ export interface DataSourceApi<TQuery extends DataQuery = DataQuery> {
getQueryHints
?(
query
:
TQuery
,
results
:
any
[],
...
rest
:
any
):
QueryHint
[];
/**
* Convert a query to a simple text string
*/
getQueryDisplayText
?(
query
:
TQuery
):
string
;
/**
* Set after constructor is called by Grafana
*/
name
?:
string
;
...
...
public/app/features/dashboard/panel_editor/QueryEditorRow.tsx
View file @
5bc936d2
...
...
@@ -225,10 +225,14 @@ export class QueryEditorRow extends PureComponent<Props, State> {
};
renderCollapsedText
():
string
|
null
{
const
{
datasource
}
=
this
.
state
;
if
(
datasource
.
getQueryDisplayText
)
{
return
datasource
.
getQueryDisplayText
(
this
.
props
.
query
);
}
if
(
this
.
angularScope
&&
this
.
angularScope
.
getCollapsedText
)
{
return
this
.
angularScope
.
getCollapsedText
();
}
return
null
;
}
...
...
public/app/plugins/datasource/prometheus/datasource.ts
View file @
5bc936d2
...
...
@@ -55,6 +55,10 @@ export class PrometheusDatasource implements DataSourceApi<PromQuery> {
this
.
loadRules
();
}
getQueryDisplayText
(
query
:
PromQuery
)
{
return
query
.
expr
;
}
_request
(
url
,
data
?,
options
?:
any
)
{
options
=
_
.
defaults
(
options
||
{},
{
url
:
this
.
url
+
url
,
...
...
public/app/plugins/datasource/prometheus/query_ctrl.ts
View file @
5bc936d2
...
...
@@ -89,10 +89,6 @@ class PrometheusQueryCtrl extends QueryCtrl {
}).
join
(
'&'
);
this
.
linkToPrometheus
=
this
.
datasource
.
directUrl
+
'/graph?'
+
args
;
}
getCollapsedText
()
{
return
this
.
target
.
expr
;
}
}
export
{
PrometheusQueryCtrl
};
public/app/plugins/datasource/testdata/datasource.ts
View file @
5bc936d2
...
...
@@ -90,6 +90,13 @@ export class TestDataDatasource implements DataSourceApi<TestDataQuery> {
return
this
.
$q
.
when
(
events
);
}
getQueryDisplayText
(
query
:
TestDataQuery
)
{
if
(
query
.
alias
)
{
return
query
.
scenarioId
+
' as '
+
query
.
alias
;
}
return
query
.
scenarioId
;
}
testDatasource
()
{
return
Promise
.
resolve
({
status
:
'success'
,
...
...
public/app/plugins/datasource/testdata/types.ts
View file @
5bc936d2
import
{
DataQuery
}
from
'@grafana/ui/src/types'
;
export
interface
TestDataQuery
extends
DataQuery
{
alias
?:
string
;
scenarioId
:
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