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
c41aa647
Commit
c41aa647
authored
Sep 30, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ShareModal: Added template variables to share url, and an option for it, #864
parent
285d246c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
4 deletions
+30
-4
src/app/controllers/search.js
+1
-0
src/app/controllers/sharePanelCtrl.js
+14
-2
src/app/partials/share-panel.html
+3
-2
src/test/specs/sharePanelCtrl-specs.js
+12
-0
No files found.
src/app/controllers/search.js
View file @
c41aa647
...
...
@@ -62,6 +62,7 @@ function (angular, _, config, $) {
};
$scope
.
goToDashboard
=
function
(
id
)
{
$location
.
search
({});
$location
.
path
(
"/dashboard/db/"
+
id
);
};
...
...
src/app/controllers/sharePanelCtrl.js
View file @
c41aa647
...
...
@@ -7,12 +7,13 @@ function (angular, _) {
var
module
=
angular
.
module
(
'grafana.controllers'
);
module
.
controller
(
'SharePanelCtrl'
,
function
(
$scope
,
$location
,
$timeout
,
timeSrv
,
$element
)
{
module
.
controller
(
'SharePanelCtrl'
,
function
(
$scope
,
$location
,
$timeout
,
timeSrv
,
$element
,
templateSrv
)
{
$scope
.
init
=
function
()
{
$scope
.
editor
=
{
index
:
0
};
$scope
.
forCurrent
=
true
;
$scope
.
toPanel
=
true
;
$scope
.
includeTemplateVars
=
true
;
$scope
.
buildUrl
();
};
...
...
@@ -27,7 +28,7 @@ function (angular, _) {
var
panelId
=
$scope
.
panel
.
id
;
var
range
=
timeSrv
.
timeRange
(
false
);
var
params
=
$location
.
search
(
);
var
params
=
angular
.
copy
(
$location
.
search
()
);
if
(
_
.
isString
(
range
.
to
)
&&
range
.
to
.
indexOf
(
'now'
))
{
range
=
timeSrv
.
timeRange
();
...
...
@@ -39,6 +40,17 @@ function (angular, _) {
if
(
_
.
isDate
(
params
.
from
))
{
params
.
from
=
params
.
from
.
getTime
();
}
if
(
_
.
isDate
(
params
.
to
))
{
params
.
to
=
params
.
to
.
getTime
();
}
if
(
$scope
.
includeTemplateVars
)
{
_
.
each
(
templateSrv
.
variables
,
function
(
variable
)
{
params
[
'var-'
+
variable
.
name
]
=
variable
.
current
.
text
;
});
}
else
{
_
.
each
(
templateSrv
.
variables
,
function
(
variable
)
{
delete
params
[
'var-'
+
variable
.
name
];
});
}
if
(
!
$scope
.
forCurrent
)
{
delete
params
.
from
;
delete
params
.
to
;
...
...
src/app/partials/share-panel.html
View file @
c41aa647
...
...
@@ -17,8 +17,9 @@
<div
class=
"modal-body"
>
<div
class=
"editor-row"
>
<editor-opt-bool
name=
"currentTime"
text=
"Current time range"
model=
"forCurrent"
change=
"buildUrl()"
></editor-opt-bool>
<editor-opt-bool
name=
"toPanel"
text=
"To this panel only"
model=
"toPanel"
change=
"buildUrl()"
></editor-opt-bool>
<editor-opt-bool
text=
"Current time range"
model=
"forCurrent"
change=
"buildUrl()"
></editor-opt-bool>
<editor-opt-bool
text=
"To this panel only"
model=
"toPanel"
change=
"buildUrl()"
></editor-opt-bool>
<editor-opt-bool
text=
"Include template variables"
model=
"includeTemplateVars"
change=
"buildUrl()"
></editor-opt-bool>
</div>
<div
class=
"editor-row"
style=
"margin-top: 20px;"
>
...
...
src/test/specs/sharePanelCtrl-specs.js
View file @
c41aa647
...
...
@@ -51,6 +51,18 @@ define([
expect
(
ctx
.
scope
.
shareUrl
).
to
.
be
(
'http://server/#/test?from=now-1h&to=now'
);
});
it
(
'should include template variables in url'
,
function
()
{
ctx
.
$location
.
path
(
'/test'
);
ctx
.
scope
.
panel
=
{
id
:
22
};
ctx
.
scope
.
includeTemplateVars
=
true
;
ctx
.
scope
.
toPanel
=
false
;
ctx
.
templateSrv
.
variables
=
[{
name
:
'app'
,
current
:
{
text
:
'mupp'
}},
{
name
:
'server'
,
current
:
{
text
:
'srv-01'
}}];
ctx
.
timeSrv
.
time
=
{
from
:
'now-1h'
,
to
:
'now'
};
ctx
.
scope
.
buildUrl
();
expect
(
ctx
.
scope
.
shareUrl
).
to
.
be
(
'http://server/#/test?from=now-1h&to=now&var-app=mupp&var-server=srv-01'
);
});
});
});
...
...
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