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
94e5001c
Commit
94e5001c
authored
Sep 15, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat(templating): making progress on adhoc template variable, #6038
parent
83b9db51
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
18 deletions
+38
-18
public/app/features/dashboard/ad_hoc_filters.ts
+2
-2
public/app/features/templating/templateValuesSrv.js
+1
-0
public/app/plugins/datasource/influxdb/datasource.ts
+1
-1
public/test/specs/templateValuesSrv-specs.js
+34
-15
No files found.
public/app/features/dashboard/ad_hoc_filters.ts
View file @
94e5001c
...
...
@@ -21,7 +21,7 @@ export class AdHocFiltersCtrl {
if
(
this
.
variable
.
value
&&
!
_
.
isArray
(
this
.
variable
.
value
))
{
}
for
(
let
tag
of
this
.
variable
.
value
)
{
for
(
let
tag
of
this
.
variable
.
tags
)
{
if
(
this
.
segments
.
length
>
0
)
{
this
.
segments
.
push
(
this
.
uiSegmentSrv
.
newCondition
(
'AND'
));
}
...
...
@@ -130,7 +130,7 @@ export class AdHocFiltersCtrl {
});
this
.
$rootScope
.
$broadcast
(
'refresh'
);
this
.
variable
.
value
=
tags
;
this
.
variable
.
tags
=
tags
;
}
}
...
...
public/app/features/templating/templateValuesSrv.js
View file @
94e5001c
...
...
@@ -189,6 +189,7 @@ function (angular, _, $, kbn) {
}
if
(
variable
.
type
===
'adhoc'
)
{
variable
.
current
=
{};
variable
.
options
=
[];
return
;
}
...
...
public/app/plugins/datasource/influxdb/datasource.ts
View file @
94e5001c
...
...
@@ -56,7 +56,7 @@ export default class InfluxDatasource {
// apply add hoc filters
for
(
let
variable
of
this
.
templateSrv
.
variables
)
{
if
(
variable
.
type
===
'adhoc'
&&
variable
.
datasource
===
this
.
name
)
{
for
(
let
tag
of
variable
.
value
)
{
for
(
let
tag
of
variable
.
tags
)
{
if
(
tag
.
key
!==
undefined
&&
tag
.
value
!==
undefined
)
{
target
.
tags
.
push
({
key
:
tag
.
key
,
value
:
tag
.
value
,
condition
:
'AND'
});
}
...
...
public/test/specs/templateValuesSrv-specs.js
View file @
94e5001c
...
...
@@ -28,24 +28,43 @@ define([
});
describe
(
'when template variable is present in url'
,
function
()
{
var
variable
=
{
name
:
'apps'
,
current
:
{
text
:
"test"
,
value
:
"test"
},
options
:
[{
text
:
"test"
,
value
:
"test"
}]
};
describe
(
'and setting simple variable'
,
function
()
{
var
variable
=
{
name
:
'apps'
,
current
:
{
text
:
"test"
,
value
:
"test"
},
options
:
[{
text
:
"test"
,
value
:
"test"
}]
};
beforeEach
(
function
(
done
)
{
var
dashboard
=
{
templating
:
{
list
:
[
variable
]
}
};
var
urlParams
=
{};
urlParams
[
"var-apps"
]
=
"new"
;
ctx
.
$location
.
search
=
sinon
.
stub
().
returns
(
urlParams
);
ctx
.
service
.
init
(
dashboard
).
then
(
function
()
{
done
();
});
ctx
.
$rootScope
.
$digest
();
beforeEach
(
function
(
done
)
{
var
dashboard
=
{
templating
:
{
list
:
[
variable
]
}
};
var
urlParams
=
{};
urlParams
[
"var-apps"
]
=
"new"
;
ctx
.
$location
.
search
=
sinon
.
stub
().
returns
(
urlParams
);
ctx
.
service
.
init
(
dashboard
).
then
(
function
()
{
done
();
});
ctx
.
$rootScope
.
$digest
();
});
it
(
'should update current value'
,
function
()
{
expect
(
variable
.
current
.
value
).
to
.
be
(
"new"
);
expect
(
variable
.
current
.
text
).
to
.
be
(
"new"
);
});
});
it
(
'should update current value'
,
function
()
{
expect
(
variable
.
current
.
value
).
to
.
be
(
"new"
);
expect
(
variable
.
current
.
text
).
to
.
be
(
"new"
);
describe
(
'and setting adhoc variable'
,
function
()
{
var
variable
=
{
name
:
'filters'
,
type
:
'adhoc'
};
beforeEach
(
function
(
done
)
{
var
dashboard
=
{
templating
:
{
list
:
[
variable
]
}
};
var
urlParams
=
{};
urlParams
[
"var-filters"
]
=
"hostname|gt|server2"
;
ctx
.
$location
.
search
=
sinon
.
stub
().
returns
(
urlParams
);
ctx
.
service
.
init
(
dashboard
).
then
(
function
()
{
done
();
});
ctx
.
$rootScope
.
$digest
();
});
it
(
'should update current value'
,
function
()
{
expect
(
variable
.
tags
[
0
]).
to
.
eq
({
tag
:
'hostname'
,
value
:
'server2'
});
});
});
});
...
...
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