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
67a256fc
Commit
67a256fc
authored
Apr 20, 2020
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prometheus: Fixed error in PromLink
parent
a78ca939
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
9 deletions
+19
-9
public/app/plugins/datasource/prometheus/components/PromLink.tsx
+19
-9
No files found.
public/app/plugins/datasource/prometheus/components/PromLink.tsx
View file @
67a256fc
...
...
@@ -10,7 +10,7 @@ import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
interface
Props
{
datasource
:
PrometheusDatasource
;
query
:
PromQuery
;
panelData
:
PanelData
;
panelData
?
:
PanelData
;
}
interface
State
{
...
...
@@ -20,29 +20,38 @@ interface State {
export
default
class
PromLink
extends
Component
<
Props
,
State
>
{
state
:
State
=
{
href
:
null
};
async
componentDidUpdate
(
prevProps
:
Props
)
{
if
(
prevProps
.
panelData
!==
this
.
props
.
panelData
&&
this
.
props
.
panelData
.
request
)
{
const
href
=
await
this
.
getExternalLink
();
const
{
panelData
}
=
this
.
props
;
if
(
panelData
&&
panelData
.
request
&&
prevProps
.
panelData
!==
panelData
)
{
const
href
=
await
this
.
getExternalLink
(
panelData
);
this
.
setState
({
href
});
}
}
async
getExternalLink
():
Promise
<
string
>
{
const
{
query
,
panelData
}
=
this
.
props
;
const
target
=
panelData
.
request
.
targets
.
length
>
0
?
panelData
.
request
.
targets
[
0
]
:
({
datasource
:
null
}
as
any
);
async
getExternalLink
(
panelData
:
PanelData
):
Promise
<
string
>
{
const
{
query
}
=
this
.
props
;
const
{
request
}
=
panelData
;
if
(
!
request
)
{
return
''
;
}
const
target
=
request
.
targets
.
length
>
0
?
request
.
targets
[
0
]
:
({
datasource
:
null
}
as
any
);
const
datasourceName
=
target
.
datasource
;
const
datasource
:
PrometheusDatasource
=
datasourceName
?
(((
await
getDatasourceSrv
().
get
(
datasourceName
))
as
any
)
as
PrometheusDatasource
)
:
(
this
.
props
.
datasource
as
PrometheusDatasource
);
const
range
=
panelData
.
request
.
range
;
const
range
=
request
.
range
;
const
start
=
datasource
.
getPrometheusTime
(
range
.
from
,
false
);
const
end
=
datasource
.
getPrometheusTime
(
range
.
to
,
true
);
const
rangeDiff
=
Math
.
ceil
(
end
-
start
);
const
endTime
=
range
.
to
.
utc
().
format
(
'YYYY-MM-DD HH:mm'
);
const
options
=
{
interval
:
panelData
.
request
.
interval
,
interval
:
request
.
interval
,
}
as
DataQueryRequest
<
PromQuery
>
;
const
queryOptions
=
datasource
.
createQuery
(
query
,
options
,
start
,
end
);
const
expr
=
{
'g0.expr'
:
queryOptions
.
expr
,
...
...
@@ -60,9 +69,10 @@ export default class PromLink extends Component<Props, State> {
render
()
{
const
{
href
}
=
this
.
state
;
return
(
<
a
href=
{
href
}
target=
"_blank"
rel=
"noopener"
>
<
Icon
name=
"share-alt"
/>
Prometheus
Prometheus
</
a
>
);
}
...
...
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