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
ca6476a5
Commit
ca6476a5
authored
Aug 10, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'influxdb_operators' of
https://github.com/thuck/grafana
into thuck-influxdb_operators
parents
fb9f9548
950d4bb2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
10 deletions
+35
-10
public/app/plugins/datasource/influxdb/queryBuilder.js
+7
-3
public/app/plugins/datasource/influxdb/queryCtrl.js
+28
-7
No files found.
public/app/plugins/datasource/influxdb/queryBuilder.js
View file @
ca6476a5
...
...
@@ -10,14 +10,18 @@ function (_) {
function
renderTagCondition
(
tag
,
index
)
{
var
str
=
""
;
var
operator
=
(
tag
.
operator
||
'='
);
if
(
index
>
0
)
{
str
=
(
tag
.
condition
||
'AND'
)
+
' '
;
}
if
(
tag
.
value
&&
tag
.
value
[
0
]
===
'/'
&&
tag
.
value
[
tag
.
value
.
length
-
1
]
===
'/'
)
{
return
str
+
'"'
+
tag
.
key
+
'"'
+
' =~ '
+
tag
.
value
;
if
(
tag
.
value
&&
(
operator
===
'=~'
||
operator
===
'!~'
)
&&
/^
\/
.*
\/
$/
.
test
(
tag
.
value
))
{
return
str
+
'"'
+
tag
.
key
+
'"'
+
' '
+
operator
+
' '
+
tag
.
value
;
}
else
if
(
tag
.
value
&&
/^
\/
.*
\/
$/
.
test
(
tag
.
value
))
{
return
str
+
'"'
+
tag
.
key
+
'"'
+
' =~ '
+
tag
.
value
;
}
return
str
+
'"'
+
tag
.
key
+
'"'
+
" = '"
+
tag
.
value
+
"'"
;
return
str
+
'"'
+
tag
.
key
+
'" '
+
operator
+
" '"
+
tag
.
value
+
"'"
;
}
var
p
=
InfluxQueryBuilder
.
prototype
;
...
...
public/app/plugins/datasource/influxdb/queryCtrl.js
View file @
ca6476a5
...
...
@@ -35,7 +35,13 @@ function (angular, _, InfluxQueryBuilder) {
$scope
.
tagSegments
.
push
(
MetricSegment
.
newCondition
(
tag
.
condition
));
}
$scope
.
tagSegments
.
push
(
new
MetricSegment
({
value
:
tag
.
key
,
type
:
'key'
,
cssClass
:
'query-segment-key'
}));
$scope
.
tagSegments
.
push
(
new
MetricSegment
.
newOperator
(
"="
));
if
(
tag
.
operator
)
{
$scope
.
tagSegments
.
push
(
MetricSegment
.
newOperator
(
tag
.
operator
));
}
else
if
(
/^
\/
.*
\/
$/
.
test
(
tag
.
value
))
{
$scope
.
tagSegments
.
push
(
MetricSegment
.
newOperator
(
'=~'
));
}
else
{
$scope
.
tagSegments
.
push
(
MetricSegment
.
newOperator
(
'='
));
}
$scope
.
tagSegments
.
push
(
new
MetricSegment
({
value
:
tag
.
value
,
type
:
'value'
,
cssClass
:
'query-segment-value'
}));
});
...
...
@@ -150,6 +156,12 @@ function (angular, _, InfluxQueryBuilder) {
query
=
$scope
.
queryBuilder
.
buildExploreQuery
(
'TAG_VALUES'
,
$scope
.
tagSegments
[
index
-
2
].
value
);
}
else
if
(
segment
.
type
===
'condition'
)
{
return
$q
.
when
([
new
MetricSegment
(
'AND'
),
new
MetricSegment
(
'OR'
)]);
}
else
if
(
segment
.
type
===
'operator'
&&
/^
(?!\/
.*
\/
$
)
/
.
test
(
$scope
.
tagSegments
[
index
+
1
].
value
))
{
return
$q
.
when
([
MetricSegment
.
newOperator
(
'='
),
MetricSegment
.
newOperator
(
'<>'
),
MetricSegment
.
newOperator
(
'<'
),
MetricSegment
.
newOperator
(
'>'
)]);
}
else
if
(
segment
.
type
===
'operator'
&&
/^
\/
.*
\/
$/
.
test
(
$scope
.
tagSegments
[
index
+
1
].
value
))
{
return
$q
.
when
([
MetricSegment
.
newOperator
(
'=~'
),
MetricSegment
.
newOperator
(
'!~'
)]);
}
else
{
return
$q
.
when
([]);
...
...
@@ -238,6 +250,7 @@ function (angular, _, InfluxQueryBuilder) {
$scope
.
rebuildTargetTagConditions
=
function
()
{
var
tags
=
[];
var
tagIndex
=
0
;
var
tagOperator
=
""
;
_
.
each
(
$scope
.
tagSegments
,
function
(
segment2
,
index
)
{
if
(
segment2
.
type
===
'key'
)
{
if
(
tags
.
length
===
0
)
{
...
...
@@ -246,25 +259,33 @@ function (angular, _, InfluxQueryBuilder) {
tags
[
tagIndex
].
key
=
segment2
.
value
;
}
else
if
(
segment2
.
type
===
'value'
)
{
tagOperator
=
$scope
.
getTagValueOperator
(
segment2
.
value
,
tags
[
tagIndex
].
operator
);
if
(
tagOperator
)
{
$scope
.
tagSegments
[
index
-
1
]
=
MetricSegment
.
newOperator
(
tagOperator
);
tags
[
tagIndex
].
operator
=
tagOperator
;
}
tags
[
tagIndex
].
value
=
segment2
.
value
;
$scope
.
tagSegments
[
index
-
1
]
=
$scope
.
getTagValueOperator
(
segment2
.
value
);
}
else
if
(
segment2
.
type
===
'condition'
)
{
tags
.
push
({
condition
:
segment2
.
value
});
tagIndex
+=
1
;
}
else
if
(
segment2
.
type
===
'operator'
)
{
tags
[
tagIndex
].
operator
=
segment2
.
value
;
}
});
$scope
.
target
.
tags
=
tags
;
$scope
.
$parent
.
get_data
();
};
$scope
.
getTagValueOperator
=
function
(
tagValue
)
{
if
(
tagValue
[
0
]
===
'/'
&&
tagValue
[
tagValue
.
length
-
1
]
===
'/'
)
{
return
MetricSegment
.
newOperator
(
'=~'
);
$scope
.
getTagValueOperator
=
function
(
tagValue
,
tagOperator
)
{
if
(
tagOperator
!==
'=~'
&&
tagOperator
!==
'!~'
&&
/^
\/
.*
\/
$/
.
test
(
tagValue
))
{
return
'=~'
;
}
else
if
((
tagOperator
===
'=~'
||
tagOperator
===
'!~'
)
&&
/^
(?!\/
.*
\/
$
)
/
.
test
(
tagValue
))
{
return
'='
;
}
return
MetricSegment
.
newOperator
(
'='
);
};
function
MetricSegment
(
options
)
{
...
...
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