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
ae2201ef
Commit
ae2201ef
authored
Apr 12, 2015
by
Masaori Koshiba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add space after keywords
parent
ed69dded
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
61 deletions
+61
-61
public/app/plugins/datasource/kairosdb/datasource.js
+27
-27
public/app/plugins/datasource/kairosdb/queryCtrl.js
+34
-34
No files found.
public/app/plugins/datasource/kairosdb/datasource.js
View file @
ae2201ef
...
@@ -86,7 +86,7 @@ function (angular, _, kbn) {
...
@@ -86,7 +86,7 @@ function (angular, _, kbn) {
};
};
KairosDBDatasource
.
prototype
.
performTagSuggestQuery
=
function
(
metricname
,
range
,
type
,
keyValue
)
{
KairosDBDatasource
.
prototype
.
performTagSuggestQuery
=
function
(
metricname
,
range
,
type
,
keyValue
)
{
if
(
tagList
&&
(
metricname
===
tagList
.
metricName
)
&&
(
range
.
from
===
tagList
.
range
.
from
)
&&
if
(
tagList
&&
(
metricname
===
tagList
.
metricName
)
&&
(
range
.
from
===
tagList
.
range
.
from
)
&&
(
range
.
to
===
tagList
.
range
.
to
))
{
(
range
.
to
===
tagList
.
range
.
to
))
{
return
getTagListFromResponse
(
tagList
.
results
,
type
,
keyValue
);
return
getTagListFromResponse
(
tagList
.
results
,
type
,
keyValue
);
}
}
...
@@ -119,10 +119,10 @@ function (angular, _, kbn) {
...
@@ -119,10 +119,10 @@ function (angular, _, kbn) {
if
(
!
results
.
data
)
{
if
(
!
results
.
data
)
{
return
[];
return
[];
}
}
if
(
type
===
"key"
)
{
if
(
type
===
"key"
)
{
return
_
.
keys
(
results
.
data
.
queries
[
0
].
results
[
0
].
tags
);
return
_
.
keys
(
results
.
data
.
queries
[
0
].
results
[
0
].
tags
);
}
}
else
if
(
type
===
"value"
&&
_
.
has
(
results
.
data
.
queries
[
0
].
results
[
0
].
tags
,
keyValue
))
{
else
if
(
type
===
"value"
&&
_
.
has
(
results
.
data
.
queries
[
0
].
results
[
0
].
tags
,
keyValue
))
{
return
results
.
data
.
queries
[
0
].
results
[
0
].
tags
[
keyValue
];
return
results
.
data
.
queries
[
0
].
results
[
0
].
tags
[
keyValue
];
}
}
return
[];
return
[];
...
@@ -134,13 +134,13 @@ function (angular, _, kbn) {
...
@@ -134,13 +134,13 @@ function (angular, _, kbn) {
* @returns {*}
* @returns {*}
*/
*/
function
handleQueryError
(
results
)
{
function
handleQueryError
(
results
)
{
if
(
results
.
data
.
errors
&&
!
_
.
isEmpty
(
results
.
data
.
errors
))
{
if
(
results
.
data
.
errors
&&
!
_
.
isEmpty
(
results
.
data
.
errors
))
{
var
errors
=
{
var
errors
=
{
message
:
results
.
data
.
errors
[
0
]
message
:
results
.
data
.
errors
[
0
]
};
};
return
$q
.
reject
(
errors
);
return
$q
.
reject
(
errors
);
}
}
else
{
else
{
return
$q
.
reject
(
results
);
return
$q
.
reject
(
results
);
}
}
}
}
...
@@ -158,15 +158,15 @@ function (angular, _, kbn) {
...
@@ -158,15 +158,15 @@ function (angular, _, kbn) {
var
target
=
plotParams
[
index
].
alias
;
var
target
=
plotParams
[
index
].
alias
;
var
details
=
" ( "
;
var
details
=
" ( "
;
_
.
each
(
result
.
group_by
,
function
(
element
)
{
_
.
each
(
result
.
group_by
,
function
(
element
)
{
if
(
element
.
name
===
"tag"
)
{
if
(
element
.
name
===
"tag"
)
{
_
.
each
(
element
.
group
,
function
(
value
,
key
)
{
_
.
each
(
element
.
group
,
function
(
value
,
key
)
{
details
+=
key
+
"="
+
value
+
" "
;
details
+=
key
+
"="
+
value
+
" "
;
});
});
}
}
else
if
(
element
.
name
===
"value"
)
{
else
if
(
element
.
name
===
"value"
)
{
details
+=
'value_group='
+
element
.
group
.
group_number
+
" "
;
details
+=
'value_group='
+
element
.
group
.
group_number
+
" "
;
}
}
else
if
(
element
.
name
===
"time"
)
{
else
if
(
element
.
name
===
"time"
)
{
details
+=
'time_group='
+
element
.
group
.
group_number
+
" "
;
details
+=
'time_group='
+
element
.
group
.
group_number
+
" "
;
}
}
});
});
...
@@ -201,7 +201,7 @@ function (angular, _, kbn) {
...
@@ -201,7 +201,7 @@ function (angular, _, kbn) {
};
};
query
.
aggregators
=
[];
query
.
aggregators
=
[];
if
(
target
.
downsampling
!==
'(NONE)'
)
{
if
(
target
.
downsampling
!==
'(NONE)'
)
{
query
.
aggregators
.
push
({
query
.
aggregators
.
push
({
name
:
target
.
downsampling
,
name
:
target
.
downsampling
,
align_sampling
:
true
,
align_sampling
:
true
,
...
@@ -209,46 +209,46 @@ function (angular, _, kbn) {
...
@@ -209,46 +209,46 @@ function (angular, _, kbn) {
sampling
:
KairosDBDatasource
.
prototype
.
convertToKairosInterval
(
target
.
sampling
||
options
.
interval
)
sampling
:
KairosDBDatasource
.
prototype
.
convertToKairosInterval
(
target
.
sampling
||
options
.
interval
)
});
});
}
}
if
(
target
.
horizontalAggregators
)
{
if
(
target
.
horizontalAggregators
)
{
_
.
each
(
target
.
horizontalAggregators
,
function
(
chosenAggregator
)
{
_
.
each
(
target
.
horizontalAggregators
,
function
(
chosenAggregator
)
{
var
returnedAggregator
=
{
var
returnedAggregator
=
{
name
:
chosenAggregator
.
name
name
:
chosenAggregator
.
name
};
};
if
(
chosenAggregator
.
sampling_rate
)
{
if
(
chosenAggregator
.
sampling_rate
)
{
returnedAggregator
.
sampling
=
KairosDBDatasource
.
prototype
.
convertToKairosInterval
(
chosenAggregator
.
sampling_rate
);
returnedAggregator
.
sampling
=
KairosDBDatasource
.
prototype
.
convertToKairosInterval
(
chosenAggregator
.
sampling_rate
);
returnedAggregator
.
align_sampling
=
true
;
returnedAggregator
.
align_sampling
=
true
;
returnedAggregator
.
align_start_time
=
true
;
returnedAggregator
.
align_start_time
=
true
;
}
}
if
(
chosenAggregator
.
unit
)
{
if
(
chosenAggregator
.
unit
)
{
returnedAggregator
.
unit
=
chosenAggregator
.
unit
+
's'
;
returnedAggregator
.
unit
=
chosenAggregator
.
unit
+
's'
;
}
}
if
(
chosenAggregator
.
factor
&&
chosenAggregator
.
name
===
'div'
)
{
if
(
chosenAggregator
.
factor
&&
chosenAggregator
.
name
===
'div'
)
{
returnedAggregator
.
divisor
=
chosenAggregator
.
factor
;
returnedAggregator
.
divisor
=
chosenAggregator
.
factor
;
}
}
else
if
(
chosenAggregator
.
factor
&&
chosenAggregator
.
name
===
'scale'
)
{
else
if
(
chosenAggregator
.
factor
&&
chosenAggregator
.
name
===
'scale'
)
{
returnedAggregator
.
factor
=
chosenAggregator
.
factor
;
returnedAggregator
.
factor
=
chosenAggregator
.
factor
;
}
}
if
(
chosenAggregator
.
percentile
)
{
if
(
chosenAggregator
.
percentile
)
{
returnedAggregator
.
percentile
=
chosenAggregator
.
percentile
;
returnedAggregator
.
percentile
=
chosenAggregator
.
percentile
;
}
}
query
.
aggregators
.
push
(
returnedAggregator
);
query
.
aggregators
.
push
(
returnedAggregator
);
});
});
}
}
if
(
_
.
isEmpty
(
query
.
aggregators
))
{
if
(
_
.
isEmpty
(
query
.
aggregators
))
{
delete
query
.
aggregators
;
delete
query
.
aggregators
;
}
}
if
(
target
.
tags
)
{
if
(
target
.
tags
)
{
query
.
tags
=
angular
.
copy
(
target
.
tags
);
query
.
tags
=
angular
.
copy
(
target
.
tags
);
}
}
if
(
target
.
groupByTags
||
target
.
nonTagGroupBys
)
{
if
(
target
.
groupByTags
||
target
.
nonTagGroupBys
)
{
query
.
group_by
=
[];
query
.
group_by
=
[];
if
(
target
.
groupByTags
)
{
query
.
group_by
.
push
({
name
:
"tag"
,
tags
:
angular
.
copy
(
target
.
groupByTags
)});}
if
(
target
.
groupByTags
)
{
query
.
group_by
.
push
({
name
:
"tag"
,
tags
:
angular
.
copy
(
target
.
groupByTags
)});}
if
(
target
.
nonTagGroupBys
)
{
if
(
target
.
nonTagGroupBys
)
{
_
.
each
(
target
.
nonTagGroupBys
,
function
(
rawGroupBy
)
{
_
.
each
(
target
.
nonTagGroupBys
,
function
(
rawGroupBy
)
{
var
formattedGroupBy
=
angular
.
copy
(
rawGroupBy
);
var
formattedGroupBy
=
angular
.
copy
(
rawGroupBy
);
if
(
formattedGroupBy
.
name
===
'time'
)
{
if
(
formattedGroupBy
.
name
===
'time'
)
{
formattedGroupBy
.
range_size
=
KairosDBDatasource
.
prototype
.
convertToKairosInterval
(
formattedGroupBy
.
range_size
);
formattedGroupBy
.
range_size
=
KairosDBDatasource
.
prototype
.
convertToKairosInterval
(
formattedGroupBy
.
range_size
);
}
}
query
.
group_by
.
push
(
formattedGroupBy
);
query
.
group_by
.
push
(
formattedGroupBy
);
...
@@ -266,7 +266,7 @@ function (angular, _, kbn) {
...
@@ -266,7 +266,7 @@ function (angular, _, kbn) {
var
interval_regex
=
/
(\d
+
(?:\.\d
+
)?)([
Mwdhmsy
])
/
;
var
interval_regex
=
/
(\d
+
(?:\.\d
+
)?)([
Mwdhmsy
])
/
;
var
interval_regex_ms
=
/
(\d
+
(?:\.\d
+
)?)(
ms
)
/
;
var
interval_regex_ms
=
/
(\d
+
(?:\.\d
+
)?)(
ms
)
/
;
var
matches
=
intervalString
.
match
(
interval_regex_ms
);
var
matches
=
intervalString
.
match
(
interval_regex_ms
);
if
(
!
matches
)
{
if
(
!
matches
)
{
matches
=
intervalString
.
match
(
interval_regex
);
matches
=
intervalString
.
match
(
interval_regex
);
}
}
if
(
!
matches
)
{
if
(
!
matches
)
{
...
@@ -276,12 +276,12 @@ function (angular, _, kbn) {
...
@@ -276,12 +276,12 @@ function (angular, _, kbn) {
var
value
=
matches
[
1
];
var
value
=
matches
[
1
];
var
unit
=
matches
[
2
];
var
unit
=
matches
[
2
];
if
(
value
%
1
!==
0
)
{
if
(
value
%
1
!==
0
)
{
if
(
unit
===
'ms'
)
{
throw
new
Error
(
'Invalid interval value, cannot be smaller than the millisecond'
);}
if
(
unit
===
'ms'
)
{
throw
new
Error
(
'Invalid interval value, cannot be smaller than the millisecond'
);}
value
=
Math
.
round
(
kbn
.
intervals_in_seconds
[
unit
]
*
value
*
1000
);
value
=
Math
.
round
(
kbn
.
intervals_in_seconds
[
unit
]
*
value
*
1000
);
unit
=
'ms'
;
unit
=
'ms'
;
}
}
switch
(
unit
)
{
switch
(
unit
)
{
case
'ms'
:
case
'ms'
:
unit
=
'milliseconds'
;
unit
=
'milliseconds'
;
break
;
break
;
...
@@ -334,7 +334,7 @@ function (angular, _, kbn) {
...
@@ -334,7 +334,7 @@ function (angular, _, kbn) {
if
(
result
)
{
if
(
result
)
{
var
value
=
result
[
1
];
var
value
=
result
[
1
];
var
unit
=
result
[
2
];
var
unit
=
result
[
2
];
switch
(
unit
)
{
switch
(
unit
)
{
case
'ms'
:
case
'ms'
:
unit
=
'milliseconds'
;
unit
=
'milliseconds'
;
break
;
break
;
...
@@ -375,7 +375,7 @@ function (angular, _, kbn) {
...
@@ -375,7 +375,7 @@ function (angular, _, kbn) {
date
=
kbn
.
parseDate
(
date
);
date
=
kbn
.
parseDate
(
date
);
}
}
if
(
_
.
isDate
(
date
))
{
if
(
_
.
isDate
(
date
))
{
name
=
start_stop_name
+
"_absolute"
;
name
=
start_stop_name
+
"_absolute"
;
response_obj
[
name
]
=
date
.
getTime
();
response_obj
[
name
]
=
date
.
getTime
();
return
;
return
;
...
@@ -403,7 +403,7 @@ function (angular, _, kbn) {
...
@@ -403,7 +403,7 @@ function (angular, _, kbn) {
if
(
prvDelta
>=
limit
&&
nxtDelta
<
limit
)
if
(
prvDelta
>=
limit
&&
nxtDelta
<
limit
)
datapoints
[
LastIndx
][
0
]
=
datapoints
[
LastIndx
-
1
][
0
];
datapoints
[
LastIndx
][
0
]
=
datapoints
[
LastIndx
-
1
][
0
];
for
(
var
i
=
1
;
i
<
arrLength
-
1
;
i
++
){
for
(
var
i
=
1
;
i
<
arrLength
-
1
;
i
++
)
{
prvDelta
=
Math
.
abs
((
datapoints
[
i
][
0
]
-
datapoints
[
i
-
1
][
0
])
/
datapoints
[
i
-
1
][
0
]);
prvDelta
=
Math
.
abs
((
datapoints
[
i
][
0
]
-
datapoints
[
i
-
1
][
0
])
/
datapoints
[
i
-
1
][
0
]);
nxtDelta
=
Math
.
abs
((
datapoints
[
i
][
0
]
-
datapoints
[
i
+
1
][
0
])
/
datapoints
[
i
+
1
][
0
]);
nxtDelta
=
Math
.
abs
((
datapoints
[
i
][
0
]
-
datapoints
[
i
+
1
][
0
])
/
datapoints
[
i
+
1
][
0
]);
if
(
prvDelta
>=
limit
&&
nxtDelta
>=
limit
)
if
(
prvDelta
>=
limit
&&
nxtDelta
>=
limit
)
...
...
public/app/plugins/datasource/kairosdb/queryCtrl.js
View file @
ae2201ef
...
@@ -94,7 +94,7 @@ function (angular, _) {
...
@@ -94,7 +94,7 @@ function (angular, _) {
$scope
.
validateFilterTag
();
$scope
.
validateFilterTag
();
if
(
!
$scope
.
target
.
errors
.
tags
)
{
if
(
!
$scope
.
target
.
errors
.
tags
)
{
if
(
!
_
.
has
(
$scope
.
target
.
tags
,
$scope
.
target
.
currentTagKey
))
{
if
(
!
_
.
has
(
$scope
.
target
.
tags
,
$scope
.
target
.
currentTagKey
))
{
$scope
.
target
.
tags
[
$scope
.
target
.
currentTagKey
]
=
[];
$scope
.
target
.
tags
[
$scope
.
target
.
currentTagKey
]
=
[];
}
}
$scope
.
target
.
tags
[
$scope
.
target
.
currentTagKey
].
push
(
$scope
.
target
.
currentTagValue
);
$scope
.
target
.
tags
[
$scope
.
target
.
currentTagKey
].
push
(
$scope
.
target
.
currentTagValue
);
...
@@ -108,7 +108,7 @@ function (angular, _) {
...
@@ -108,7 +108,7 @@ function (angular, _) {
$scope
.
removeFilterTag
=
function
(
key
)
{
$scope
.
removeFilterTag
=
function
(
key
)
{
delete
$scope
.
target
.
tags
[
key
];
delete
$scope
.
target
.
tags
[
key
];
if
(
_
.
size
(
$scope
.
target
.
tags
)
===
0
)
{
if
(
_
.
size
(
$scope
.
target
.
tags
)
===
0
)
{
$scope
.
target
.
tags
=
null
;
$scope
.
target
.
tags
=
null
;
}
}
$scope
.
targetBlur
();
$scope
.
targetBlur
();
...
@@ -116,7 +116,7 @@ function (angular, _) {
...
@@ -116,7 +116,7 @@ function (angular, _) {
$scope
.
validateFilterTag
=
function
()
{
$scope
.
validateFilterTag
=
function
()
{
$scope
.
target
.
errors
.
tags
=
null
;
$scope
.
target
.
errors
.
tags
=
null
;
if
(
!
$scope
.
target
.
currentTagKey
||
!
$scope
.
target
.
currentTagValue
)
{
if
(
!
$scope
.
target
.
currentTagKey
||
!
$scope
.
target
.
currentTagValue
)
{
$scope
.
target
.
errors
.
tags
=
"You must specify a tag name and value."
;
$scope
.
target
.
errors
.
tags
=
"You must specify a tag name and value."
;
}
}
};
};
...
@@ -136,7 +136,7 @@ function (angular, _) {
...
@@ -136,7 +136,7 @@ function (angular, _) {
$scope
.
validateGroupBy
();
$scope
.
validateGroupBy
();
// nb: if error is found, means that user clicked on cross : cancels input
// nb: if error is found, means that user clicked on cross : cancels input
if
(
_
.
isEmpty
(
$scope
.
target
.
errors
.
groupBy
))
{
if
(
_
.
isEmpty
(
$scope
.
target
.
errors
.
groupBy
))
{
if
(
$scope
.
isTagGroupBy
)
{
if
(
$scope
.
isTagGroupBy
)
{
if
(
!
$scope
.
target
.
groupByTags
)
{
if
(
!
$scope
.
target
.
groupByTags
)
{
$scope
.
target
.
groupByTags
=
[];
$scope
.
target
.
groupByTags
=
[];
}
}
...
@@ -147,15 +147,15 @@ function (angular, _) {
...
@@ -147,15 +147,15 @@ function (angular, _) {
}
}
$scope
.
target
.
groupBy
.
tagKey
=
''
;
$scope
.
target
.
groupBy
.
tagKey
=
''
;
}
}
else
{
else
{
if
(
!
$scope
.
target
.
nonTagGroupBys
)
{
if
(
!
$scope
.
target
.
nonTagGroupBys
)
{
$scope
.
target
.
nonTagGroupBys
=
[];
$scope
.
target
.
nonTagGroupBys
=
[];
}
}
var
groupBy
=
{
var
groupBy
=
{
name
:
$scope
.
target
.
currentGroupByType
name
:
$scope
.
target
.
currentGroupByType
};
};
if
(
$scope
.
isValueGroupBy
)
{
groupBy
.
range_size
=
$scope
.
target
.
groupBy
.
valueRange
;}
if
(
$scope
.
isValueGroupBy
)
{
groupBy
.
range_size
=
$scope
.
target
.
groupBy
.
valueRange
;}
else
if
(
$scope
.
isTimeGroupBy
)
{
else
if
(
$scope
.
isTimeGroupBy
)
{
groupBy
.
range_size
=
$scope
.
target
.
groupBy
.
timeInterval
;
groupBy
.
range_size
=
$scope
.
target
.
groupBy
.
timeInterval
;
groupBy
.
group_count
=
$scope
.
target
.
groupBy
.
groupCount
;
groupBy
.
group_count
=
$scope
.
target
.
groupBy
.
groupCount
;
}
}
...
@@ -171,7 +171,7 @@ function (angular, _) {
...
@@ -171,7 +171,7 @@ function (angular, _) {
$scope
.
removeGroupByTag
=
function
(
index
)
{
$scope
.
removeGroupByTag
=
function
(
index
)
{
$scope
.
target
.
groupByTags
.
splice
(
index
,
1
);
$scope
.
target
.
groupByTags
.
splice
(
index
,
1
);
if
(
_
.
size
(
$scope
.
target
.
groupByTags
)
===
0
)
{
if
(
_
.
size
(
$scope
.
target
.
groupByTags
)
===
0
)
{
$scope
.
target
.
groupByTags
=
null
;
$scope
.
target
.
groupByTags
=
null
;
}
}
$scope
.
targetBlur
();
$scope
.
targetBlur
();
...
@@ -179,7 +179,7 @@ function (angular, _) {
...
@@ -179,7 +179,7 @@ function (angular, _) {
$scope
.
removeNonTagGroupBy
=
function
(
index
)
{
$scope
.
removeNonTagGroupBy
=
function
(
index
)
{
$scope
.
target
.
nonTagGroupBys
.
splice
(
index
,
1
);
$scope
.
target
.
nonTagGroupBys
.
splice
(
index
,
1
);
if
(
_
.
size
(
$scope
.
target
.
nonTagGroupBys
)
===
0
)
{
if
(
_
.
size
(
$scope
.
target
.
nonTagGroupBys
)
===
0
)
{
$scope
.
target
.
nonTagGroupBys
=
null
;
$scope
.
target
.
nonTagGroupBys
=
null
;
}
}
$scope
.
targetBlur
();
$scope
.
targetBlur
();
...
@@ -196,32 +196,32 @@ function (angular, _) {
...
@@ -196,32 +196,32 @@ function (angular, _) {
delete
$scope
.
target
.
errors
.
groupBy
;
delete
$scope
.
target
.
errors
.
groupBy
;
var
errors
=
{};
var
errors
=
{};
$scope
.
isGroupByValid
=
true
;
$scope
.
isGroupByValid
=
true
;
if
(
$scope
.
isTagGroupBy
)
{
if
(
$scope
.
isTagGroupBy
)
{
if
(
!
$scope
.
target
.
groupBy
.
tagKey
)
{
if
(
!
$scope
.
target
.
groupBy
.
tagKey
)
{
$scope
.
isGroupByValid
=
false
;
$scope
.
isGroupByValid
=
false
;
errors
.
tagKey
=
'You must supply a tag name'
;
errors
.
tagKey
=
'You must supply a tag name'
;
}
}
}
}
if
(
$scope
.
isValueGroupBy
)
{
if
(
$scope
.
isValueGroupBy
)
{
if
(
!
$scope
.
target
.
groupBy
.
valueRange
||
!
isInt
(
$scope
.
target
.
groupBy
.
valueRange
))
{
if
(
!
$scope
.
target
.
groupBy
.
valueRange
||
!
isInt
(
$scope
.
target
.
groupBy
.
valueRange
))
{
errors
.
valueRange
=
"Range must be an integer"
;
errors
.
valueRange
=
"Range must be an integer"
;
$scope
.
isGroupByValid
=
false
;
$scope
.
isGroupByValid
=
false
;
}
}
}
}
if
(
$scope
.
isTimeGroupBy
)
{
if
(
$scope
.
isTimeGroupBy
)
{
try
{
try
{
$scope
.
datasource
.
convertToKairosInterval
(
$scope
.
target
.
groupBy
.
timeInterval
);
$scope
.
datasource
.
convertToKairosInterval
(
$scope
.
target
.
groupBy
.
timeInterval
);
}
catch
(
err
)
{
}
catch
(
err
)
{
errors
.
timeInterval
=
err
.
message
;
errors
.
timeInterval
=
err
.
message
;
$scope
.
isGroupByValid
=
false
;
$scope
.
isGroupByValid
=
false
;
}
}
if
(
!
$scope
.
target
.
groupBy
.
groupCount
||
!
isInt
(
$scope
.
target
.
groupBy
.
groupCount
))
{
if
(
!
$scope
.
target
.
groupBy
.
groupCount
||
!
isInt
(
$scope
.
target
.
groupBy
.
groupCount
))
{
errors
.
groupCount
=
"Group count must be an integer"
;
errors
.
groupCount
=
"Group count must be an integer"
;
$scope
.
isGroupByValid
=
false
;
$scope
.
isGroupByValid
=
false
;
}
}
}
}
if
(
!
_
.
isEmpty
(
errors
))
{
if
(
!
_
.
isEmpty
(
errors
))
{
$scope
.
target
.
errors
.
groupBy
=
errors
;
$scope
.
target
.
errors
.
groupBy
=
errors
;
}
}
};
};
...
@@ -245,17 +245,17 @@ function (angular, _) {
...
@@ -245,17 +245,17 @@ function (angular, _) {
$scope
.
validateHorizontalAggregator
();
$scope
.
validateHorizontalAggregator
();
// nb: if error is found, means that user clicked on cross : cancels input
// nb: if error is found, means that user clicked on cross : cancels input
if
(
_
.
isEmpty
(
$scope
.
target
.
errors
.
horAggregator
))
{
if
(
_
.
isEmpty
(
$scope
.
target
.
errors
.
horAggregator
))
{
if
(
!
$scope
.
target
.
horizontalAggregators
)
{
if
(
!
$scope
.
target
.
horizontalAggregators
)
{
$scope
.
target
.
horizontalAggregators
=
[];
$scope
.
target
.
horizontalAggregators
=
[];
}
}
var
aggregator
=
{
var
aggregator
=
{
name
:
$scope
.
target
.
currentHorizontalAggregatorName
name
:
$scope
.
target
.
currentHorizontalAggregatorName
};
};
if
(
$scope
.
hasSamplingRate
)
{
aggregator
.
sampling_rate
=
$scope
.
target
.
horAggregator
.
samplingRate
;}
if
(
$scope
.
hasSamplingRate
)
{
aggregator
.
sampling_rate
=
$scope
.
target
.
horAggregator
.
samplingRate
;}
if
(
$scope
.
hasUnit
)
{
aggregator
.
unit
=
$scope
.
target
.
horAggregator
.
unit
;}
if
(
$scope
.
hasUnit
)
{
aggregator
.
unit
=
$scope
.
target
.
horAggregator
.
unit
;}
if
(
$scope
.
hasFactor
)
{
aggregator
.
factor
=
$scope
.
target
.
horAggregator
.
factor
;}
if
(
$scope
.
hasFactor
)
{
aggregator
.
factor
=
$scope
.
target
.
horAggregator
.
factor
;}
if
(
$scope
.
hasPercentile
)
{
aggregator
.
percentile
=
$scope
.
target
.
horAggregator
.
percentile
;}
if
(
$scope
.
hasPercentile
)
{
aggregator
.
percentile
=
$scope
.
target
.
horAggregator
.
percentile
;}
$scope
.
target
.
horizontalAggregators
.
push
(
aggregator
);
$scope
.
target
.
horizontalAggregators
.
push
(
aggregator
);
$scope
.
targetBlur
();
$scope
.
targetBlur
();
}
}
...
@@ -270,7 +270,7 @@ function (angular, _) {
...
@@ -270,7 +270,7 @@ function (angular, _) {
$scope
.
removeHorizontalAggregator
=
function
(
index
)
{
$scope
.
removeHorizontalAggregator
=
function
(
index
)
{
$scope
.
target
.
horizontalAggregators
.
splice
(
index
,
1
);
$scope
.
target
.
horizontalAggregators
.
splice
(
index
,
1
);
if
(
_
.
size
(
$scope
.
target
.
horizontalAggregators
)
===
0
)
{
if
(
_
.
size
(
$scope
.
target
.
horizontalAggregators
)
===
0
)
{
$scope
.
target
.
horizontalAggregators
=
null
;
$scope
.
target
.
horizontalAggregators
=
null
;
}
}
...
@@ -290,26 +290,26 @@ function (angular, _) {
...
@@ -290,26 +290,26 @@ function (angular, _) {
delete
$scope
.
target
.
errors
.
horAggregator
;
delete
$scope
.
target
.
errors
.
horAggregator
;
var
errors
=
{};
var
errors
=
{};
$scope
.
isAggregatorValid
=
true
;
$scope
.
isAggregatorValid
=
true
;
if
(
$scope
.
hasSamplingRate
)
{
if
(
$scope
.
hasSamplingRate
)
{
try
{
try
{
$scope
.
datasource
.
convertToKairosInterval
(
$scope
.
target
.
horAggregator
.
samplingRate
);
$scope
.
datasource
.
convertToKairosInterval
(
$scope
.
target
.
horAggregator
.
samplingRate
);
}
catch
(
err
)
{
}
catch
(
err
)
{
errors
.
samplingRate
=
err
.
message
;
errors
.
samplingRate
=
err
.
message
;
$scope
.
isAggregatorValid
=
false
;
$scope
.
isAggregatorValid
=
false
;
}
}
}
}
if
(
$scope
.
hasFactor
)
{
if
(
$scope
.
hasFactor
)
{
if
(
!
$scope
.
target
.
horAggregator
.
factor
)
{
if
(
!
$scope
.
target
.
horAggregator
.
factor
)
{
errors
.
factor
=
'You must supply a numeric value for this aggregator'
;
errors
.
factor
=
'You must supply a numeric value for this aggregator'
;
$scope
.
isAggregatorValid
=
false
;
$scope
.
isAggregatorValid
=
false
;
}
}
else
if
(
parseInt
(
$scope
.
target
.
horAggregator
.
factor
)
===
0
&&
$scope
.
target
.
currentHorizontalAggregatorName
===
'div'
)
{
else
if
(
parseInt
(
$scope
.
target
.
horAggregator
.
factor
)
===
0
&&
$scope
.
target
.
currentHorizontalAggregatorName
===
'div'
)
{
errors
.
factor
=
'Cannot divide by 0'
;
errors
.
factor
=
'Cannot divide by 0'
;
$scope
.
isAggregatorValid
=
false
;
$scope
.
isAggregatorValid
=
false
;
}
}
}
}
if
(
$scope
.
hasPercentile
)
{
if
(
$scope
.
hasPercentile
)
{
if
(
!
$scope
.
target
.
horAggregator
.
percentile
||
if
(
!
$scope
.
target
.
horAggregator
.
percentile
||
$scope
.
target
.
horAggregator
.
percentile
<=
0
||
$scope
.
target
.
horAggregator
.
percentile
<=
0
||
$scope
.
target
.
horAggregator
.
percentile
>
1
)
{
$scope
.
target
.
horAggregator
.
percentile
>
1
)
{
errors
.
percentile
=
'Percentile must be between 0 and 1'
;
errors
.
percentile
=
'Percentile must be between 0 and 1'
;
...
@@ -317,7 +317,7 @@ function (angular, _) {
...
@@ -317,7 +317,7 @@ function (angular, _) {
}
}
}
}
if
(
!
_
.
isEmpty
(
errors
))
{
if
(
!
_
.
isEmpty
(
errors
))
{
$scope
.
target
.
errors
.
horAggregator
=
errors
;
$scope
.
target
.
errors
.
horAggregator
=
errors
;
}
}
};
};
...
@@ -335,10 +335,10 @@ function (angular, _) {
...
@@ -335,10 +335,10 @@ function (angular, _) {
for
(
var
i
=
0
;
i
<
MetricList
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
MetricList
.
length
;
i
++
)
{
Metric
=
MetricList
[
i
];
Metric
=
MetricList
[
i
];
MetricArray
=
Metric
.
split
(
'.'
);
MetricArray
=
Metric
.
split
(
'.'
);
if
(
!
result
.
hasOwnProperty
(
MetricArray
[
0
]))
{
if
(
!
result
.
hasOwnProperty
(
MetricArray
[
0
]))
{
result
[
MetricArray
[
0
]]
=
{};
result
[
MetricArray
[
0
]]
=
{};
}
}
if
(
!
result
[
MetricArray
[
0
]].
hasOwnProperty
(
MetricArray
[
1
]))
{
if
(
!
result
[
MetricArray
[
0
]].
hasOwnProperty
(
MetricArray
[
1
]))
{
result
[
MetricArray
[
0
]][
MetricArray
[
1
]]
=
[];
result
[
MetricArray
[
0
]][
MetricArray
[
1
]]
=
[];
}
}
result
[
MetricArray
[
0
]][
MetricArray
[
1
]].
push
(
MetricArray
[
2
]);
result
[
MetricArray
[
0
]][
MetricArray
[
1
]].
push
(
MetricArray
[
2
]);
...
@@ -357,7 +357,7 @@ function (angular, _) {
...
@@ -357,7 +357,7 @@ function (angular, _) {
if
(
target
.
sampling
)
{
if
(
target
.
sampling
)
{
$scope
.
datasource
.
convertToKairosInterval
(
target
.
sampling
);
$scope
.
datasource
.
convertToKairosInterval
(
target
.
sampling
);
}
}
}
catch
(
err
)
{
}
catch
(
err
)
{
errs
.
sampling
=
err
.
message
;
errs
.
sampling
=
err
.
message
;
}
}
...
...
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