Commit 333aeb43 by Mekal Zheng

use methods of kbn to convert interval string to both second and millisecond

parent af798092
......@@ -219,38 +219,9 @@ function (angular, _, moment, kbn, ElasticQueryBuilder, IndexPattern, ElasticRes
return $q.when([]);
}
// convert interval string to milliseconds
var intervalToSecond = function (intervalString) {
if (!intervalString) {
return 1;
} else {
var interval = parseInt(intervalString);
if (isNaN(interval)) {
return 1;
} else {
var lastIndex = intervalString.length - 1;
var unit = intervalString.slice(lastIndex);
var scale = 1;
switch (unit) {
case 'd':
scale = 86400;
break;
case 'h':
scale = 3600;
break;
case 'm':
scale = 60;
break;
default:
scale = 1;
}
return interval * scale;
}
}
};
// intervalSecond: interval in seconds
payload = payload.replace(/\$intervalSecond/g, intervalToSecond(options.interval));
// intervalSec: interval in seconds
payload = payload.replace(/\$intervalSec/g, kbn.interval_to_seconds(options.interval));
payload = payload.replace(/\$intervalMs/g, kbn.interval_to_ms(options.interval));
payload = payload.replace(/\$interval/g, options.interval);
payload = payload.replace(/\$timeFrom/g, options.range.from.valueOf());
payload = payload.replace(/\$timeTo/g, options.range.to.valueOf());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment