mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
parse string date format
This commit is contained in:
parent
1626982a3a
commit
7d16307db4
@ -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, _) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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, _) {
|
|||||||
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, _) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user