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
e81614b9
Commit
e81614b9
authored
May 24, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v3.0.x'
parents
366baea0
6f094ef2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
2 deletions
+53
-2
public/app/features/templating/templateValuesSrv.js
+13
-2
public/test/specs/templateValuesSrv-specs.js
+40
-0
No files found.
public/app/features/templating/templateValuesSrv.js
View file @
e81614b9
...
...
@@ -244,15 +244,26 @@ function (angular, _, kbn) {
this
.
validateVariableSelectionState
=
function
(
variable
)
{
if
(
!
variable
.
current
)
{
if
(
!
variable
.
options
.
length
)
{
return
;
}
return
self
.
setVariableValue
(
variable
,
variable
.
options
[
0
],
tru
e
);
return
self
.
setVariableValue
(
variable
,
variable
.
options
[
0
],
fals
e
);
}
if
(
_
.
isArray
(
variable
.
current
.
value
))
{
self
.
selectOptionsForCurrentValue
(
variable
);
// updated selected value
var
selected
=
{
value
:
_
.
map
(
_
.
filter
(
variable
.
options
,
{
selected
:
true
}),
function
(
op
)
{
return
op
.
value
;
})
};
// if none pick first
if
(
selected
.
value
.
length
===
0
)
{
selected
=
variable
.
options
[
0
];
}
return
self
.
setVariableValue
(
variable
,
selected
,
false
);
}
else
{
var
currentOption
=
_
.
findWhere
(
variable
.
options
,
{
text
:
variable
.
current
.
text
});
if
(
currentOption
)
{
return
self
.
setVariableValue
(
variable
,
currentOption
,
tru
e
);
return
self
.
setVariableValue
(
variable
,
currentOption
,
fals
e
);
}
else
{
if
(
!
variable
.
options
.
length
)
{
return
;
}
return
self
.
setVariableValue
(
variable
,
variable
.
options
[
0
]);
...
...
public/test/specs/templateValuesSrv-specs.js
View file @
e81614b9
...
...
@@ -126,6 +126,46 @@ define([
});
});
describeUpdateVariable
(
'query variable with multi select and new options does not contain some selected values'
,
function
(
scenario
)
{
scenario
.
setup
(
function
()
{
scenario
.
variable
=
{
type
:
'query'
,
query
:
''
,
name
:
'test'
,
current
:
{
value
:
[
'val1'
,
'val2'
,
'val3'
],
text
:
'val1 + val2 + val3'
}
};
scenario
.
queryResult
=
[{
text
:
'val2'
},
{
text
:
'val3'
}];
});
it
(
'should update current value'
,
function
()
{
expect
(
scenario
.
variable
.
current
.
value
).
to
.
eql
([
'val2'
,
'val3'
]);
expect
(
scenario
.
variable
.
current
.
text
).
to
.
eql
(
'val2 + val3'
);
});
});
describeUpdateVariable
(
'query variable with multi select and new options does not contain any selected values'
,
function
(
scenario
)
{
scenario
.
setup
(
function
()
{
scenario
.
variable
=
{
type
:
'query'
,
query
:
''
,
name
:
'test'
,
current
:
{
value
:
[
'val1'
,
'val2'
,
'val3'
],
text
:
'val1 + val2 + val3'
}
};
scenario
.
queryResult
=
[{
text
:
'val5'
},
{
text
:
'val6'
}];
});
it
(
'should update current value with first one'
,
function
()
{
expect
(
scenario
.
variable
.
current
.
value
).
to
.
eql
(
'val5'
);
expect
(
scenario
.
variable
.
current
.
text
).
to
.
eql
(
'val5'
);
});
});
describeUpdateVariable
(
'query variable with numeric results'
,
function
(
scenario
)
{
scenario
.
setup
(
function
()
{
scenario
.
variable
=
{
type
:
'query'
,
query
:
''
,
name
:
'test'
,
current
:
{}
};
...
...
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