Commit f1e5238e by Mitsuhiro Tanda

escape dimension if it is variable name

parent d75d4a5c
...@@ -97,7 +97,7 @@ ...@@ -97,7 +97,7 @@
<li class="tight-form-item" style="width: 100px"> <li class="tight-form-item" style="width: 100px">
Dimensions Dimensions
</li> </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}}&nbsp;=&nbsp;{{value}} {{key}}&nbsp;=&nbsp;{{value}}
<a ng-click="removeDimension(key)"> <a ng-click="removeDimension(key)">
<i class="fa fa-remove"></i> <i class="fa fa-remove"></i>
......
...@@ -13,6 +13,7 @@ function (angular, _) { ...@@ -13,6 +13,7 @@ function (angular, _) {
$scope.target.namespace = $scope.target.namespace || ''; $scope.target.namespace = $scope.target.namespace || '';
$scope.target.metricName = $scope.target.metricName || ''; $scope.target.metricName = $scope.target.metricName || '';
$scope.target.dimensions = $scope.target.dimensions || {}; $scope.target.dimensions = $scope.target.dimensions || {};
$scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
$scope.target.statistics = $scope.target.statistics || {}; $scope.target.statistics = $scope.target.statistics || {};
$scope.target.period = $scope.target.period || 60; $scope.target.period = $scope.target.period || 60;
$scope.target.region = $scope.target.region || $scope.datasource.getDefaultRegion(); $scope.target.region = $scope.target.region || $scope.datasource.getDefaultRegion();
...@@ -94,6 +95,7 @@ function (angular, _) { ...@@ -94,6 +95,7 @@ function (angular, _) {
} }
$scope.target.dimensions[$scope.target.currentDimensionKey] = $scope.target.currentDimensionValue; $scope.target.dimensions[$scope.target.currentDimensionKey] = $scope.target.currentDimensionValue;
$scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
$scope.target.currentDimensionKey = ''; $scope.target.currentDimensionKey = '';
$scope.target.currentDimensionValue = ''; $scope.target.currentDimensionValue = '';
$scope.refreshMetricData(); $scope.refreshMetricData();
...@@ -102,10 +104,24 @@ function (angular, _) { ...@@ -102,10 +104,24 @@ function (angular, _) {
}; };
$scope.removeDimension = function(key) { $scope.removeDimension = function(key) {
key = key.replace(/\\\$/g, '$');
delete $scope.target.dimensions[key]; delete $scope.target.dimensions[key];
$scope.target.escapedDimensions = this.escapeDimensions($scope.target.dimensions);
$scope.refreshMetricData(); $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.statisticsOptionChanged = function() {
$scope.refreshMetricData(); $scope.refreshMetricData();
}; };
......
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