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
69e18905
Commit
69e18905
authored
Nov 27, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Templating: added validation to template editor for variable names, Fixes #1133
parent
ac4524cf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
8 deletions
+26
-8
src/app/controllers/templateEditorCtrl.js
+25
-6
src/app/partials/templating_editor.html
+1
-2
No files found.
src/app/controllers/templateEditorCtrl.js
View file @
69e18905
...
@@ -33,8 +33,25 @@ function (angular, _) {
...
@@ -33,8 +33,25 @@ function (angular, _) {
};
};
$scope
.
add
=
function
()
{
$scope
.
add
=
function
()
{
$scope
.
variables
.
push
(
$scope
.
current
);
if
(
$scope
.
isValid
())
{
$scope
.
update
();
$scope
.
variables
.
push
(
$scope
.
current
);
$scope
.
update
();
}
};
$scope
.
isValid
=
function
()
{
if
(
!
$scope
.
current
.
name
)
{
$scope
.
appEvent
(
'alert-warning'
,
[
'Validation'
,
'Template variable requires a name'
]);
return
false
;
}
var
sameName
=
_
.
findWhere
(
$scope
.
variables
,
{
name
:
$scope
.
current
.
name
});
if
(
sameName
&&
sameName
!==
$scope
.
current
)
{
$scope
.
appEvent
(
'alert-warning'
,
[
'Validation'
,
'Variable with the same name already exists'
]);
return
false
;
}
return
true
;
};
};
$scope
.
runQuery
=
function
()
{
$scope
.
runQuery
=
function
()
{
...
@@ -57,10 +74,12 @@ function (angular, _) {
...
@@ -57,10 +74,12 @@ function (angular, _) {
};
};
$scope
.
update
=
function
()
{
$scope
.
update
=
function
()
{
$scope
.
runQuery
().
then
(
function
()
{
if
(
$scope
.
isValid
())
{
$scope
.
reset
();
$scope
.
runQuery
().
then
(
function
()
{
$scope
.
editor
.
index
=
0
;
$scope
.
reset
();
});
$scope
.
editor
.
index
=
0
;
});
}
};
};
$scope
.
reset
=
function
()
{
$scope
.
reset
=
function
()
{
...
...
src/app/partials/templating_editor.html
View file @
69e18905
...
@@ -47,7 +47,6 @@
...
@@ -47,7 +47,6 @@
</table>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<div
ng-if=
"editor.index == 1 || (editor.index == 2 && !currentIsNew)"
>
<div
ng-if=
"editor.index == 1 || (editor.index == 2 && !currentIsNew)"
>
...
@@ -56,7 +55,7 @@
...
@@ -56,7 +55,7 @@
<div
class=
"editor-row"
>
<div
class=
"editor-row"
>
<div
class=
"editor-option"
>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Variable name
</label>
<label
class=
"small"
>
Variable name
</label>
<input
type=
"text"
class=
"input-medium"
ng-model=
'current.name'
placeholder=
"name"
></input>
<input
type=
"text"
class=
"input-medium"
ng-model=
'current.name'
placeholder=
"name"
required
></input>
</div>
</div>
<div
class=
"editor-option"
>
<div
class=
"editor-option"
>
<label
class=
"small"
>
Type
</label>
<label
class=
"small"
>
Type
</label>
...
...
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