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
2672b922
Unverified
Commit
2672b922
authored
Sep 02, 2019
by
Ivana Huckova
Committed by
GitHub
Sep 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Open new window when exploring panel metrics (#18802)
parent
6690b519
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
22 deletions
+18
-22
public/app/features/panel/metrics_panel_ctrl.ts
+2
-9
public/app/features/panel/panel_ctrl.ts
+3
-3
public/app/features/panel/panel_header.ts
+4
-4
public/app/features/panel/specs/metrics_panel_ctrl.test.ts
+9
-6
No files found.
public/app/features/panel/metrics_panel_ctrl.ts
View file @
2672b922
...
...
@@ -248,25 +248,18 @@ class MetricsPanelCtrl extends PanelCtrl {
}
}
getAdditionalMenuItems
()
{
async
getAdditionalMenuItems
()
{
const
items
=
[];
if
(
this
.
contextSrv
.
hasAccessToExplore
()
&&
this
.
datasource
)
{
items
.
push
({
text
:
'Explore'
,
click
:
'ctrl.explore();'
,
icon
:
'gicon gicon-explore'
,
shortcut
:
'x'
,
href
:
await
getExploreUrl
(
this
.
panel
.
targets
,
this
.
datasource
,
this
.
datasourceSrv
,
this
.
timeSrv
),
});
}
return
items
;
}
async
explore
()
{
const
url
=
await
getExploreUrl
(
this
.
panel
.
targets
,
this
.
datasource
,
this
.
datasourceSrv
,
this
.
timeSrv
);
if
(
url
)
{
this
.
$timeout
(()
=>
this
.
$location
.
url
(
url
));
}
}
}
export
{
MetricsPanelCtrl
};
public/app/features/panel/panel_ctrl.ts
View file @
2672b922
...
...
@@ -120,7 +120,7 @@ export class PanelCtrl {
}
}
getMenu
()
{
async
getMenu
()
{
const
menu
=
[];
menu
.
push
({
text
:
'View'
,
...
...
@@ -147,7 +147,7 @@ export class PanelCtrl {
});
// Additional items from sub-class
menu
.
push
(...
this
.
getAdditionalMenuItems
(
));
menu
.
push
(...
(
await
this
.
getAdditionalMenuItems
()
));
const
extendedMenu
=
this
.
getExtendedMenu
();
menu
.
push
({
...
...
@@ -198,7 +198,7 @@ export class PanelCtrl {
}
// Override in sub-class to add items before extended menu
getAdditionalMenuItems
():
any
[]
{
async
getAdditionalMenuItems
():
Promise
<
any
[]
>
{
return
[];
}
...
...
public/app/features/panel/panel_header.ts
View file @
2672b922
...
...
@@ -55,10 +55,10 @@ function renderMenuItem(item: AngularPanelMenuItem, ctrl: any) {
return
html
;
}
function
createMenuTemplate
(
ctrl
:
any
)
{
async
function
createMenuTemplate
(
ctrl
:
any
)
{
let
html
=
''
;
for
(
const
item
of
ctrl
.
getMenu
())
{
for
(
const
item
of
await
ctrl
.
getMenu
())
{
html
+=
renderMenuItem
(
item
,
ctrl
);
}
...
...
@@ -75,7 +75,7 @@ function panelHeader($compile: any) {
let
menuScope
:
any
;
let
isDragged
:
boolean
;
elem
.
click
((
evt
:
any
)
=>
{
elem
.
click
(
async
(
evt
:
any
)
=>
{
const
targetClass
=
evt
.
target
.
className
;
// remove existing scope
...
...
@@ -84,7 +84,7 @@ function panelHeader($compile: any) {
}
menuScope
=
scope
.
$new
();
const
menuHtml
=
createMenuTemplate
(
scope
.
ctrl
);
const
menuHtml
=
await
createMenuTemplate
(
scope
.
ctrl
);
menuElem
.
html
(
menuHtml
);
$compile
(
menuElem
)(
menuScope
);
...
...
public/app/features/panel/specs/metrics_panel_ctrl.test.ts
View file @
2672b922
...
...
@@ -21,28 +21,28 @@ import { MetricsPanelCtrl } from '../metrics_panel_ctrl';
describe
(
'MetricsPanelCtrl'
,
()
=>
{
describe
(
'when getting additional menu items'
,
()
=>
{
describe
(
'and has no datasource set but user has access to explore'
,
()
=>
{
it
(
'should not return any items'
,
()
=>
{
it
(
'should not return any items'
,
async
()
=>
{
const
ctrl
=
setupController
({
hasAccessToExplore
:
true
});
expect
(
ctrl
.
getAdditionalMenuItems
(
).
length
).
toBe
(
0
);
expect
(
(
await
ctrl
.
getAdditionalMenuItems
()
).
length
).
toBe
(
0
);
});
});
describe
(
'and has datasource set that supports explore and user does not have access to explore'
,
()
=>
{
it
(
'should not return any items'
,
()
=>
{
it
(
'should not return any items'
,
async
()
=>
{
const
ctrl
=
setupController
({
hasAccessToExplore
:
false
});
ctrl
.
datasource
=
{
meta
:
{
explore
:
true
}
}
as
any
;
expect
(
ctrl
.
getAdditionalMenuItems
(
).
length
).
toBe
(
0
);
expect
(
(
await
ctrl
.
getAdditionalMenuItems
()
).
length
).
toBe
(
0
);
});
});
describe
(
'and has datasource set that supports explore and user has access to explore'
,
()
=>
{
it
(
'should return one item'
,
()
=>
{
it
(
'should return one item'
,
async
()
=>
{
const
ctrl
=
setupController
({
hasAccessToExplore
:
true
});
ctrl
.
datasource
=
{
meta
:
{
explore
:
true
}
}
as
any
;
expect
(
ctrl
.
getAdditionalMenuItems
(
).
length
).
toBe
(
1
);
expect
(
(
await
ctrl
.
getAdditionalMenuItems
()
).
length
).
toBe
(
1
);
});
});
});
...
...
@@ -58,6 +58,9 @@ function setupController({ hasAccessToExplore } = { hasAccessToExplore: false })
case
'contextSrv'
:
{
return
{
hasAccessToExplore
:
()
=>
hasAccessToExplore
};
}
case
'timeSrv'
:
{
return
{
timeRangeForUrl
:
()
=>
{}
};
}
default
:
{
return
jest
.
fn
();
}
...
...
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