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
52800844
Unverified
Commit
52800844
authored
Jun 25, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
set correct text in drop down when variable is present in url using key/values
parent
7797a66b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
1 deletions
+52
-1
public/app/features/templating/specs/variable_srv_init_specs.ts
+34
-0
public/app/features/templating/variable_srv.ts
+18
-1
No files found.
public/app/features/templating/specs/variable_srv_init_specs.ts
View file @
52800844
...
@@ -179,4 +179,38 @@ describe('VariableSrv init', function() {
...
@@ -179,4 +179,38 @@ describe('VariableSrv init', function() {
expect
(
variable
.
options
[
2
].
selected
).
to
.
be
(
false
);
expect
(
variable
.
options
[
2
].
selected
).
to
.
be
(
false
);
});
});
});
});
describeInitScenario
(
'when template variable is present in url multiple times using key/values'
,
scenario
=>
{
scenario
.
setup
(()
=>
{
scenario
.
variables
=
[
{
name
:
'apps'
,
type
:
'query'
,
multi
:
true
,
current
:
{
text
:
'Val1'
,
value
:
'val1'
},
options
:
[
{
text
:
'Val1'
,
value
:
'val1'
},
{
text
:
'Val2'
,
value
:
'val2'
},
{
text
:
'Val3'
,
value
:
'val3'
,
selected
:
true
},
],
},
];
scenario
.
urlParams
[
'var-apps'
]
=
[
'val2'
,
'val1'
];
});
it
(
'should update current value'
,
function
()
{
var
variable
=
ctx
.
variableSrv
.
variables
[
0
];
expect
(
variable
.
current
.
value
.
length
).
to
.
be
(
2
);
expect
(
variable
.
current
.
value
[
0
]).
to
.
be
(
'val2'
);
expect
(
variable
.
current
.
value
[
1
]).
to
.
be
(
'val1'
);
expect
(
variable
.
current
.
text
).
to
.
be
(
'Val2 + Val1'
);
expect
(
variable
.
options
[
0
].
selected
).
to
.
be
(
true
);
expect
(
variable
.
options
[
1
].
selected
).
to
.
be
(
true
);
});
it
(
'should set options that are not in value to selected false'
,
function
()
{
var
variable
=
ctx
.
variableSrv
.
variables
[
0
];
expect
(
variable
.
options
[
2
].
selected
).
to
.
be
(
false
);
});
});
});
});
public/app/features/templating/variable_srv.ts
View file @
52800844
...
@@ -209,7 +209,24 @@ export class VariableSrv {
...
@@ -209,7 +209,24 @@ export class VariableSrv {
return
op
.
text
===
urlValue
||
op
.
value
===
urlValue
;
return
op
.
text
===
urlValue
||
op
.
value
===
urlValue
;
});
});
option
=
option
||
{
text
:
urlValue
,
value
:
urlValue
};
let
defaultText
=
urlValue
;
let
defaultValue
=
urlValue
;
if
(
!
option
&&
_
.
isArray
(
urlValue
))
{
defaultText
=
[];
for
(
let
n
=
0
;
n
<
urlValue
.
length
;
n
++
)
{
let
t
=
_
.
find
(
variable
.
options
,
op
=>
{
return
op
.
value
===
urlValue
[
n
];
});
if
(
t
)
{
defaultText
.
push
(
t
.
text
);
}
}
}
option
=
option
||
{
text
:
defaultText
,
value
:
defaultValue
};
return
variable
.
setValue
(
option
);
return
variable
.
setValue
(
option
);
});
});
}
}
...
...
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