escape dimension if it is variable name
This commit is contained in:
@@ -97,7 +97,7 @@
|
||||
<li class="tight-form-item" style="width: 100px">
|
||||
Dimensions
|
||||
</li>
|
||||
<li ng-repeat="(key, value) in target.dimensions track by $index" class="tight-form-item">
|
||||
<li ng-repeat="(key, value) in target.escapedDimensions track by $index" class="tight-form-item">
|
||||
{{key}} = {{value}}
|
||||
<a ng-click="removeDimension(key)">
|
||||
<i class="fa fa-remove"></i>
|
||||
|
||||
@@ -13,6 +13,7 @@ function (angular, _) {
|
||||
$scope.target.namespace = $scope.target.namespace || '';
|
||||
$scope.target.metricName = $scope.target.metricName || '';
|
||||
$scope.target.dimensions = $scope.target.dimensions || {};
|
||||
$scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
|
||||
$scope.target.statistics = $scope.target.statistics || {};
|
||||
$scope.target.period = $scope.target.period || 60;
|
||||
$scope.target.region = $scope.target.region || $scope.datasource.getDefaultRegion();
|
||||
@@ -94,6 +95,7 @@ function (angular, _) {
|
||||
}
|
||||
|
||||
$scope.target.dimensions[$scope.target.currentDimensionKey] = $scope.target.currentDimensionValue;
|
||||
$scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
|
||||
$scope.target.currentDimensionKey = '';
|
||||
$scope.target.currentDimensionValue = '';
|
||||
$scope.refreshMetricData();
|
||||
@@ -102,10 +104,24 @@ function (angular, _) {
|
||||
};
|
||||
|
||||
$scope.removeDimension = function(key) {
|
||||
key = key.replace(/\\\$/g, '$');
|
||||
delete $scope.target.dimensions[key];
|
||||
$scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
|
||||
$scope.refreshMetricData();
|
||||
};
|
||||
|
||||
$scope.escapeDimensions = function(d) {
|
||||
var result = {};
|
||||
_.chain(d)
|
||||
.keys(d)
|
||||
.each(function(k) {
|
||||
var v = d[k];
|
||||
result[k.replace(/\$/g, '\\$')] = v.replace(/\$/g, '\\$');
|
||||
});
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
$scope.statisticsOptionChanged = function() {
|
||||
$scope.refreshMetricData();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user