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
c2686781
Commit
c2686781
authored
Sep 17, 2018
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'text_variable-3173' of
https://github.com/daldoyle/grafana
parents
742d2041
f0e905f3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
70 additions
and
1 deletions
+70
-1
public/app/features/dashboard/submenu/submenu.html
+2
-1
public/app/features/templating/all.ts
+2
-0
public/app/features/templating/partials/editor.html
+8
-0
public/app/features/templating/text_variable.ts
+58
-0
No files found.
public/app/features/dashboard/submenu/submenu.html
View file @
c2686781
...
...
@@ -4,7 +4,8 @@
<label
class=
"gf-form-label template-variable"
ng-hide=
"variable.hide === 1"
>
{{variable.label || variable.name}}
</label>
<value-select-dropdown
ng-if=
"variable.type !== 'adhoc'"
variable=
"variable"
on-updated=
"ctrl.variableUpdated(variable)"
></value-select-dropdown>
<value-select-dropdown
ng-if=
"variable.type !== 'adhoc' && variable.type !== 'text'"
variable=
"variable"
on-updated=
"ctrl.variableUpdated(variable)"
></value-select-dropdown>
<input
type=
"text"
ng-if=
"variable.type === 'text'"
ng-model=
"variable.query"
class=
"gf-form-input width-9"
ng-blur=
"variable.current.value != variable.query && variable.updateOptions() && ctrl.variableUpdated(variable);"
ng-keydown=
"$event.keyCode === 13 && variable.current.value != variable.query && variable.updateOptions() && ctrl.variableUpdated(variable);"
></input>
</div>
<ad-hoc-filters
ng-if=
"variable.type === 'adhoc'"
variable=
"variable"
></ad-hoc-filters>
</div>
...
...
public/app/features/templating/all.ts
View file @
c2686781
...
...
@@ -9,6 +9,7 @@ import { DatasourceVariable } from './datasource_variable';
import
{
CustomVariable
}
from
'./custom_variable'
;
import
{
ConstantVariable
}
from
'./constant_variable'
;
import
{
AdhocVariable
}
from
'./adhoc_variable'
;
import
{
TextVariable
}
from
'./text_variable'
;
coreModule
.
factory
(
'templateSrv'
,
()
=>
{
return
templateSrv
;
...
...
@@ -22,4 +23,5 @@ export {
CustomVariable
,
ConstantVariable
,
AdhocVariable
,
TextVariable
};
public/app/features/templating/partials/editor.html
View file @
c2686781
...
...
@@ -155,6 +155,14 @@
</div>
</div>
<div
ng-if=
"current.type === 'text'"
class=
"gf-form-group"
>
<h5
class=
"section-heading"
>
Text options
</h5>
<div
class=
"gf-form"
>
<span
class=
"gf-form-label"
>
Value
</span>
<input
type=
"text"
class=
"gf-form-input"
ng-model=
'current.query'
ng-blur=
"runQuery()"
placeholder=
"default value, if any"
></input>
</div>
</div>
<div
ng-if=
"current.type === 'query'"
class=
"gf-form-group"
>
<h5
class=
"section-heading"
>
Query Options
</h5>
...
...
public/app/features/templating/text_variable.ts
0 → 100644
View file @
c2686781
import
{
Variable
,
assignModelProperties
,
variableTypes
}
from
'./variable'
;
export
class
TextVariable
implements
Variable
{
query
:
string
;
current
:
any
;
options
:
any
[];
skipUrlSync
:
boolean
;
defaults
=
{
type
:
'text'
,
name
:
''
,
hide
:
2
,
label
:
''
,
query
:
''
,
current
:
{},
options
:
[],
skipUrlSync
:
false
,
};
/** @ngInject */
constructor
(
private
model
,
private
variableSrv
)
{
assignModelProperties
(
this
,
model
,
this
.
defaults
);
}
getSaveModel
()
{
assignModelProperties
(
this
.
model
,
this
,
this
.
defaults
);
return
this
.
model
;
}
setValue
(
option
)
{
this
.
variableSrv
.
setOptionAsCurrent
(
this
,
option
);
}
updateOptions
()
{
this
.
options
=
[{
text
:
this
.
query
.
trim
(),
value
:
this
.
query
.
trim
()
}];
this
.
current
=
this
.
options
[
0
];
return
Promise
.
resolve
();
}
dependsOn
(
variable
)
{
return
false
;
}
setValueFromUrl
(
urlValue
)
{
this
.
query
=
urlValue
;
return
this
.
variableSrv
.
setOptionFromUrl
(
this
,
urlValue
);
}
getValueForUrl
()
{
return
this
.
current
.
value
;
}
}
variableTypes
[
'text'
]
=
{
name
:
'Text'
,
ctor
:
TextVariable
,
description
:
'Define a textbox variable, where users can enter any arbitrary string'
,
};
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