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
1060eeb1
Commit
1060eeb1
authored
May 25, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(dashboard): include org id query parameter in dashboard url, #1613
parent
f923edc4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
33 deletions
+49
-33
public/app/features/dashboard/submenu/submenu.ts
+0
-17
public/app/features/dashboard/timeSrv.js
+1
-8
public/app/features/dashboard/viewStateSrv.js
+33
-5
public/test/specs/dashboardViewStateSrv-specs.js
+15
-3
No files found.
public/app/features/dashboard/submenu/submenu.ts
View file @
1060eeb1
...
...
@@ -27,25 +27,8 @@ export class SubmenuCtrl {
return
this
.
templateValuesSrv
.
getValuesForTag
(
variable
,
tagKey
);
}
updateUrlParamsWithCurrentVariables
()
{
// update url
var
params
=
this
.
$location
.
search
();
// remove variable params
_
.
each
(
params
,
function
(
value
,
key
)
{
if
(
key
.
indexOf
(
'var-'
)
===
0
)
{
delete
params
[
key
];
}
});
// add new values
this
.
templateSrv
.
fillVariableValuesForUrl
(
params
);
// update url
this
.
$location
.
search
(
params
);
}
variableUpdated
(
variable
)
{
this
.
templateValuesSrv
.
variableUpdated
(
variable
).
then
(()
=>
{
this
.
updateUrlParamsWithCurrentVariables
();
this
.
dynamicDashboardSrv
.
update
(
this
.
dashboard
);
this
.
$rootScope
.
$emit
(
'template-variable-value-updated'
);
this
.
$rootScope
.
$broadcast
(
'refresh'
);
...
...
public/app/features/dashboard/timeSrv.js
View file @
1060eeb1
...
...
@@ -10,7 +10,7 @@ define([
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
service
(
'timeSrv'
,
function
(
$rootScope
,
$timeout
,
$routeParams
,
timer
,
$location
)
{
module
.
service
(
'timeSrv'
,
function
(
$rootScope
,
$timeout
,
$routeParams
,
timer
)
{
var
self
=
this
;
this
.
init
=
function
(
dashboard
)
{
...
...
@@ -108,13 +108,6 @@ define([
this
.
old_refresh
=
null
;
}
// update url params
var
urlParams
=
$location
.
search
();
var
urlRange
=
this
.
timeRangeForUrl
();
urlParams
.
from
=
urlRange
.
from
;
urlParams
.
to
=
urlRange
.
to
;
$location
.
search
(
urlParams
);
$rootScope
.
appEvent
(
'time-range-changed'
,
this
.
time
);
$timeout
(
this
.
refreshDashboard
,
0
);
};
...
...
public/app/features/dashboard/viewStateSrv.js
View file @
1060eeb1
...
...
@@ -8,7 +8,7 @@ function (angular, _, $) {
var
module
=
angular
.
module
(
'grafana.services'
);
module
.
factory
(
'dashboardViewStateSrv'
,
function
(
$location
,
$timeout
)
{
module
.
factory
(
'dashboardViewStateSrv'
,
function
(
$location
,
$timeout
,
templateSrv
,
contextSrv
,
timeSrv
)
{
// represents the transient view state
// like fullscreen panel & edit
...
...
@@ -25,6 +25,19 @@ function (angular, _, $) {
}
};
// update url on time range change
$scope
.
onAppEvent
(
'time-range-changed'
,
function
()
{
var
urlParams
=
$location
.
search
();
var
urlRange
=
timeSrv
.
timeRangeForUrl
();
urlParams
.
from
=
urlRange
.
from
;
urlParams
.
to
=
urlRange
.
to
;
$location
.
search
(
urlParams
);
});
$scope
.
onAppEvent
(
'template-variable-value-updated'
,
function
()
{
self
.
updateUrlParamsWithCurrentVariables
();
});
$scope
.
onAppEvent
(
'$routeUpdate'
,
function
()
{
var
urlState
=
self
.
getQueryStringState
();
if
(
self
.
needsSync
(
urlState
))
{
...
...
@@ -44,6 +57,22 @@ function (angular, _, $) {
this
.
expandRowForPanel
();
}
DashboardViewState
.
prototype
.
updateUrlParamsWithCurrentVariables
=
function
()
{
// update url
var
params
=
$location
.
search
();
// remove variable params
_
.
each
(
params
,
function
(
value
,
key
)
{
if
(
key
.
indexOf
(
'var-'
)
===
0
)
{
delete
params
[
key
];
}
});
// add new values
templateSrv
.
fillVariableValuesForUrl
(
params
);
// update url
$location
.
search
(
params
);
};
DashboardViewState
.
prototype
.
expandRowForPanel
=
function
()
{
if
(
!
this
.
state
.
panelId
)
{
return
;
}
...
...
@@ -63,6 +92,7 @@ function (angular, _, $) {
state
.
fullscreen
=
state
.
fullscreen
?
true
:
null
;
state
.
edit
=
(
state
.
edit
===
"true"
||
state
.
edit
===
true
)
||
null
;
state
.
editview
=
state
.
editview
||
null
;
state
.
org
=
contextSrv
.
user
.
orgId
;
return
state
;
};
...
...
@@ -70,10 +100,11 @@ function (angular, _, $) {
var
urlState
=
_
.
clone
(
this
.
state
);
urlState
.
fullscreen
=
this
.
state
.
fullscreen
?
true
:
null
;
urlState
.
edit
=
this
.
state
.
edit
?
true
:
null
;
urlState
.
org
=
contextSrv
.
user
.
orgId
;
return
urlState
;
};
DashboardViewState
.
prototype
.
update
=
function
(
state
,
skipUrlSync
)
{
DashboardViewState
.
prototype
.
update
=
function
(
state
)
{
_
.
extend
(
this
.
state
,
state
);
this
.
dashboard
.
meta
.
fullscreen
=
this
.
state
.
fullscreen
;
...
...
@@ -83,10 +114,7 @@ function (angular, _, $) {
this
.
state
.
edit
=
null
;
}
if
(
!
skipUrlSync
)
{
$location
.
search
(
this
.
serializeToUrl
());
}
this
.
syncState
();
};
...
...
public/test/specs/dashboardViewStateSrv-specs.js
View file @
1060eeb1
...
...
@@ -5,8 +5,20 @@ define([
describe
(
'when updating view state'
,
function
()
{
var
viewState
,
location
;
var
timeSrv
=
{};
var
templateSrv
=
{};
var
contextSrv
=
{
user
:
{
orgId
:
19
}
};
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
module
(
function
(
$provide
)
{
$provide
.
value
(
'timeSrv'
,
timeSrv
);
$provide
.
value
(
'templateSrv'
,
templateSrv
);
$provide
.
value
(
'contextSrv'
,
contextSrv
);
}));
beforeEach
(
inject
(
function
(
dashboardViewStateSrv
,
$location
,
$rootScope
)
{
$rootScope
.
onAppEvent
=
function
()
{};
...
...
@@ -17,9 +29,9 @@ define([
describe
(
'to fullscreen true and edit true'
,
function
()
{
it
(
'should update querystring and view state'
,
function
()
{
var
updateState
=
{
fullscreen
:
true
,
edit
:
true
,
panelId
:
1
};
var
updateState
=
{
fullscreen
:
true
,
edit
:
true
,
panelId
:
1
};
viewState
.
update
(
updateState
);
expect
(
location
.
search
()).
to
.
eql
(
updateState
);
expect
(
location
.
search
()).
to
.
eql
(
{
fullscreen
:
true
,
edit
:
true
,
panelId
:
1
,
org
:
19
}
);
expect
(
viewState
.
dashboard
.
meta
.
fullscreen
).
to
.
be
(
true
);
expect
(
viewState
.
state
.
fullscreen
).
to
.
be
(
true
);
});
...
...
@@ -29,7 +41,7 @@ define([
it
(
'should remove params from query string'
,
function
()
{
viewState
.
update
({
fullscreen
:
true
,
panelId
:
1
,
edit
:
true
});
viewState
.
update
({
fullscreen
:
false
});
expect
(
location
.
search
()).
to
.
eql
({});
expect
(
location
.
search
()).
to
.
eql
({
org
:
19
});
expect
(
viewState
.
dashboard
.
meta
.
fullscreen
).
to
.
be
(
false
);
expect
(
viewState
.
state
.
fullscreen
).
to
.
be
(
null
);
});
...
...
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