Commit 7d16307d by Mitsuhiro Tanda

parse string date format

parent 1626982a
...@@ -2,10 +2,11 @@ define([ ...@@ -2,10 +2,11 @@ define([
'angular', 'angular',
'lodash', 'lodash',
'moment', 'moment',
'app/core/utils/datemath',
'./query_ctrl', './query_ctrl',
'./directives', './directives',
], ],
function (angular, _) { function (angular, _, moment, dateMath) {
'use strict'; 'use strict';
var module = angular.module('grafana.services'); var module = angular.module('grafana.services');
...@@ -21,8 +22,8 @@ function (angular, _) { ...@@ -21,8 +22,8 @@ function (angular, _) {
} }
CloudWatchDatasource.prototype.query = function(options) { CloudWatchDatasource.prototype.query = function(options) {
var start = convertToCloudWatchTime(options.range.from); var start = convertToCloudWatchTime(options.range.from, false);
var end = convertToCloudWatchTime(options.range.to); var end = convertToCloudWatchTime(options.range.to, true);
var queries = []; var queries = [];
options = angular.copy(options); options = angular.copy(options);
...@@ -253,8 +254,8 @@ function (angular, _) { ...@@ -253,8 +254,8 @@ function (angular, _) {
this.performDescribeAlarmsForMetric(region, namespace, metricName, dimensions, statistic, period).then(function(alarms) { this.performDescribeAlarmsForMetric(region, namespace, metricName, dimensions, statistic, period).then(function(alarms) {
var eventList = []; var eventList = [];
var start = convertToCloudWatchTime(range.from); var start = convertToCloudWatchTime(range.from, false);
var end = convertToCloudWatchTime(range.to); var end = convertToCloudWatchTime(range.to, true);
_.each(alarms.MetricAlarms, function(alarm) { _.each(alarms.MetricAlarms, function(alarm) {
self.performDescribeAlarmHistory(region, alarm.AlarmName, start, end).then(function(history) { self.performDescribeAlarmHistory(region, alarm.AlarmName, start, end).then(function(history) {
_.each(history.AlarmHistoryItems, function(h) { _.each(history.AlarmHistoryItems, function(h) {
...@@ -344,7 +345,10 @@ function (angular, _) { ...@@ -344,7 +345,10 @@ function (angular, _) {
}); });
} }
function convertToCloudWatchTime(date) { function convertToCloudWatchTime(date, roundUp) {
if (_.isString(date)) {
date = dateMath.parse(date, roundUp);
}
return Math.round(date.valueOf() / 1000); return Math.round(date.valueOf() / 1000);
} }
......
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