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
b0451dc1
Commit
b0451dc1
authored
Jun 01, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More refinements of tag selection and state restoration after dashboard load
parent
b5a84615
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
18 deletions
+33
-18
public/app/directives/variableValueSelect.js
+32
-16
public/test/specs/selectDropdownCtrl-specs.js
+1
-2
No files found.
public/app/directives/variableValueSelect.js
View file @
b0451dc1
...
...
@@ -27,7 +27,6 @@ function (angular, app, _) {
});
vm
.
selectedValues
=
_
.
filter
(
vm
.
options
,
{
selected
:
true
});
vm
.
selectedTags
=
vm
.
selectedTags
||
[];
if
(
!
vm
.
tags
)
{
vm
.
tags
=
_
.
map
(
vm
.
variable
.
tags
,
function
(
value
)
{
...
...
@@ -40,21 +39,37 @@ function (angular, app, _) {
};
vm
.
updateLinkText
=
function
()
{
// var currentValues = vm.variable.current.text;
//
// if (vm.variable.current.tags) {
// selectedOptions = _.filter(selectedOptions, function(test) {
// for (var i = 0; i < vm.variable.current.tags; i++) {
// var tag = vm.selectedTags[i];
// if (_.indexOf(tag.values, test.text) !== -1) {
// return false;
// }
// }
// return true;
// });
// }
//
vm
.
linkText
=
vm
.
variable
.
current
.
text
;
var
current
=
vm
.
variable
.
current
;
var
currentValues
=
current
.
value
;
if
(
_
.
isArray
(
currentValues
)
&&
current
.
tags
.
length
)
{
// filer out values that are in selected tags
currentValues
=
_
.
filter
(
currentValues
,
function
(
test
)
{
for
(
var
i
=
0
;
i
<
current
.
tags
.
length
;
i
++
)
{
if
(
_
.
indexOf
(
current
.
tags
[
i
].
values
,
test
)
!==
-
1
)
{
return
false
;
}
}
return
true
;
});
// convert values to text
var
currentTexts
=
_
.
map
(
currentValues
,
function
(
value
)
{
for
(
var
i
=
0
;
i
<
vm
.
variable
.
options
.
length
;
i
++
)
{
var
option
=
vm
.
variable
.
options
[
i
];
if
(
option
.
value
===
value
)
{
return
option
.
text
;
}
}
return
value
;
});
// join texts
vm
.
linkText
=
currentTexts
.
join
(
' + '
);
if
(
vm
.
linkText
.
length
>
0
)
{
vm
.
linkText
+=
' + '
;
}
}
else
{
vm
.
linkText
=
vm
.
variable
.
current
.
text
;
}
};
vm
.
clearSelections
=
function
()
{
...
...
@@ -202,6 +217,7 @@ function (angular, app, _) {
};
vm
.
init
=
function
()
{
vm
.
selectedTags
=
vm
.
variable
.
current
.
tags
||
[];
vm
.
updateLinkText
();
};
...
...
public/test/specs/selectDropdownCtrl-specs.js
View file @
b0451dc1
...
...
@@ -94,11 +94,10 @@ function () {
it
(
"should select values"
,
function
()
{
expect
(
ctrl
.
options
[
0
].
selected
).
to
.
be
(
true
);
expect
(
ctrl
.
options
[
2
].
selected
).
to
.
be
(
true
);
expect
(
ctrl
.
linkText
).
to
.
be
(
'server-1 + server-2'
);
});
it
(
"link text should not include tag values"
,
function
()
{
expect
(
ctrl
.
linkText
).
to
.
not
.
contain
(
'server-1
'
);
expect
(
ctrl
.
linkText
).
to
.
be
(
'
'
);
});
describe
(
'and then dropdown is opened and closed without changes'
,
function
()
{
...
...
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