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
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
50 additions
and
34 deletions
+50
-34
public/app/features/dashboard/submenu/submenu.ts
+0
-17
public/app/features/dashboard/timeSrv.js
+1
-8
public/app/features/dashboard/viewStateSrv.js
+34
-6
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 {
...
@@ -27,25 +27,8 @@ export class SubmenuCtrl {
return
this
.
templateValuesSrv
.
getValuesForTag
(
variable
,
tagKey
);
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
)
{
variableUpdated
(
variable
)
{
this
.
templateValuesSrv
.
variableUpdated
(
variable
).
then
(()
=>
{
this
.
templateValuesSrv
.
variableUpdated
(
variable
).
then
(()
=>
{
this
.
updateUrlParamsWithCurrentVariables
();
this
.
dynamicDashboardSrv
.
update
(
this
.
dashboard
);
this
.
dynamicDashboardSrv
.
update
(
this
.
dashboard
);
this
.
$rootScope
.
$emit
(
'template-variable-value-updated'
);
this
.
$rootScope
.
$emit
(
'template-variable-value-updated'
);
this
.
$rootScope
.
$broadcast
(
'refresh'
);
this
.
$rootScope
.
$broadcast
(
'refresh'
);
...
...
public/app/features/dashboard/timeSrv.js
View file @
1060eeb1
...
@@ -10,7 +10,7 @@ define([
...
@@ -10,7 +10,7 @@ define([
var
module
=
angular
.
module
(
'grafana.services'
);
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
;
var
self
=
this
;
this
.
init
=
function
(
dashboard
)
{
this
.
init
=
function
(
dashboard
)
{
...
@@ -108,13 +108,6 @@ define([
...
@@ -108,13 +108,6 @@ define([
this
.
old_refresh
=
null
;
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
);
$rootScope
.
appEvent
(
'time-range-changed'
,
this
.
time
);
$timeout
(
this
.
refreshDashboard
,
0
);
$timeout
(
this
.
refreshDashboard
,
0
);
};
};
...
...
public/app/features/dashboard/viewStateSrv.js
View file @
1060eeb1
...
@@ -8,7 +8,7 @@ function (angular, _, $) {
...
@@ -8,7 +8,7 @@ function (angular, _, $) {
var
module
=
angular
.
module
(
'grafana.services'
);
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
// represents the transient view state
// like fullscreen panel & edit
// like fullscreen panel & edit
...
@@ -25,6 +25,19 @@ function (angular, _, $) {
...
@@ -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
()
{
$scope
.
onAppEvent
(
'$routeUpdate'
,
function
()
{
var
urlState
=
self
.
getQueryStringState
();
var
urlState
=
self
.
getQueryStringState
();
if
(
self
.
needsSync
(
urlState
))
{
if
(
self
.
needsSync
(
urlState
))
{
...
@@ -44,6 +57,22 @@ function (angular, _, $) {
...
@@ -44,6 +57,22 @@ function (angular, _, $) {
this
.
expandRowForPanel
();
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
()
{
DashboardViewState
.
prototype
.
expandRowForPanel
=
function
()
{
if
(
!
this
.
state
.
panelId
)
{
return
;
}
if
(
!
this
.
state
.
panelId
)
{
return
;
}
...
@@ -63,6 +92,7 @@ function (angular, _, $) {
...
@@ -63,6 +92,7 @@ function (angular, _, $) {
state
.
fullscreen
=
state
.
fullscreen
?
true
:
null
;
state
.
fullscreen
=
state
.
fullscreen
?
true
:
null
;
state
.
edit
=
(
state
.
edit
===
"true"
||
state
.
edit
===
true
)
||
null
;
state
.
edit
=
(
state
.
edit
===
"true"
||
state
.
edit
===
true
)
||
null
;
state
.
editview
=
state
.
editview
||
null
;
state
.
editview
=
state
.
editview
||
null
;
state
.
org
=
contextSrv
.
user
.
orgId
;
return
state
;
return
state
;
};
};
...
@@ -70,10 +100,11 @@ function (angular, _, $) {
...
@@ -70,10 +100,11 @@ function (angular, _, $) {
var
urlState
=
_
.
clone
(
this
.
state
);
var
urlState
=
_
.
clone
(
this
.
state
);
urlState
.
fullscreen
=
this
.
state
.
fullscreen
?
true
:
null
;
urlState
.
fullscreen
=
this
.
state
.
fullscreen
?
true
:
null
;
urlState
.
edit
=
this
.
state
.
edit
?
true
:
null
;
urlState
.
edit
=
this
.
state
.
edit
?
true
:
null
;
urlState
.
org
=
contextSrv
.
user
.
orgId
;
return
urlState
;
return
urlState
;
};
};
DashboardViewState
.
prototype
.
update
=
function
(
state
,
skipUrlSync
)
{
DashboardViewState
.
prototype
.
update
=
function
(
state
)
{
_
.
extend
(
this
.
state
,
state
);
_
.
extend
(
this
.
state
,
state
);
this
.
dashboard
.
meta
.
fullscreen
=
this
.
state
.
fullscreen
;
this
.
dashboard
.
meta
.
fullscreen
=
this
.
state
.
fullscreen
;
...
@@ -83,10 +114,7 @@ function (angular, _, $) {
...
@@ -83,10 +114,7 @@ function (angular, _, $) {
this
.
state
.
edit
=
null
;
this
.
state
.
edit
=
null
;
}
}
if
(
!
skipUrlSync
)
{
$location
.
search
(
this
.
serializeToUrl
());
$location
.
search
(
this
.
serializeToUrl
());
}
this
.
syncState
();
this
.
syncState
();
};
};
...
...
public/test/specs/dashboardViewStateSrv-specs.js
View file @
1060eeb1
...
@@ -5,8 +5,20 @@ define([
...
@@ -5,8 +5,20 @@ define([
describe
(
'when updating view state'
,
function
()
{
describe
(
'when updating view state'
,
function
()
{
var
viewState
,
location
;
var
viewState
,
location
;
var
timeSrv
=
{};
var
templateSrv
=
{};
var
contextSrv
=
{
user
:
{
orgId
:
19
}
};
beforeEach
(
module
(
'grafana.services'
));
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
)
{
beforeEach
(
inject
(
function
(
dashboardViewStateSrv
,
$location
,
$rootScope
)
{
$rootScope
.
onAppEvent
=
function
()
{};
$rootScope
.
onAppEvent
=
function
()
{};
...
@@ -17,9 +29,9 @@ define([
...
@@ -17,9 +29,9 @@ define([
describe
(
'to fullscreen true and edit true'
,
function
()
{
describe
(
'to fullscreen true and edit true'
,
function
()
{
it
(
'should update querystring and view state'
,
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
);
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
.
dashboard
.
meta
.
fullscreen
).
to
.
be
(
true
);
expect
(
viewState
.
state
.
fullscreen
).
to
.
be
(
true
);
expect
(
viewState
.
state
.
fullscreen
).
to
.
be
(
true
);
});
});
...
@@ -29,7 +41,7 @@ define([
...
@@ -29,7 +41,7 @@ define([
it
(
'should remove params from query string'
,
function
()
{
it
(
'should remove params from query string'
,
function
()
{
viewState
.
update
({
fullscreen
:
true
,
panelId
:
1
,
edit
:
true
});
viewState
.
update
({
fullscreen
:
true
,
panelId
:
1
,
edit
:
true
});
viewState
.
update
({
fullscreen
:
false
});
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
.
dashboard
.
meta
.
fullscreen
).
to
.
be
(
false
);
expect
(
viewState
.
state
.
fullscreen
).
to
.
be
(
null
);
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