mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Fix Add Metric in a less stupid way
This commit is contained in:
parent
b411de4e95
commit
9f88b4db97
2 changed files with 17 additions and 8 deletions
|
@ -81,14 +81,13 @@
|
|||
<i class="pointer icon-check" ng-click="metricEditor.index=-1"></i>
|
||||
</td>
|
||||
<td ng-show="metricEditor.index == $index">
|
||||
<i ng-click="deleteMetric($index); metricEditor.index = -1;" class="pointer icon-trash"></i>
|
||||
<i ng-click="deleteMetric(panel,$index); metricEditor.index = -1;" class="pointer icon-trash"></i>
|
||||
<td ng-show="metricEditor.index == $index">
|
||||
<i class="icon"></i></td>
|
||||
</tr>
|
||||
</table>
|
||||
<form class="form-inline">
|
||||
<!-- Not a big fan of this ng-click -->
|
||||
<button class="btn btn-success" ng-click="needs_refresh(); panel.metrics.push(metricDefaults({})); metricEditor.index = panel.metrics.length-1">Add Metric</button>
|
||||
<button class="btn btn-success" ng-click="needs_refresh(); addMetric(panel)">Add Metric</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
|
@ -163,7 +163,7 @@ define([
|
|||
}
|
||||
};
|
||||
|
||||
$scope.metricDefaults = function (m) {
|
||||
var metricDefaults = function (m) {
|
||||
if (_.isUndefined($scope.modeInfo[$scope.panel.mode])) {
|
||||
return [];
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ define([
|
|||
|
||||
|
||||
$scope.panel.metrics = _.map($scope.panel.metrics, function (m) {
|
||||
return $scope.metricDefaults(m);
|
||||
return metricDefaults(m);
|
||||
});
|
||||
|
||||
$scope.$watch('panel.mode', function (m) {
|
||||
|
@ -198,7 +198,7 @@ define([
|
|||
$scope.panel.display_field = $scope.modeInfo[m].defaults.display_field;
|
||||
$scope.panel.persistent_field = $scope.modeInfo[m].defaults.persistent_field;
|
||||
$scope.panel.metrics = _.map($scope.modeInfo[m].defaults.metrics, function (m) {
|
||||
return $scope.metricDefaults(m);
|
||||
return metricDefaults(m);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -710,6 +710,16 @@ define([
|
|||
|
||||
};
|
||||
|
||||
$scope.addMetric = function (panel,metric) {
|
||||
metric = metric || {};
|
||||
metric = metricDefaults(metric);
|
||||
panel.metrics.push(metric);
|
||||
if (!metric.field) {
|
||||
// no field defined, got into edit mode..
|
||||
$scope.metricEditor.index = panel.metrics.length - 1;
|
||||
}
|
||||
};
|
||||
|
||||
// This is expensive, it would be better to populate a scope object
|
||||
$scope.addMetricOptions = function (m) {
|
||||
if (_.isUndefined($scope.modeInfo[m])) {
|
||||
|
@ -739,8 +749,8 @@ define([
|
|||
$scope.$emit('render');
|
||||
};
|
||||
|
||||
$scope.deleteMetric = function (index) {
|
||||
$scope.panel.metrics = _.without($scope.panel.metrics, $scope.panel.metrics[index]);
|
||||
$scope.deleteMetric = function (panel,index) {
|
||||
panel.metrics = _.without(panel.metrics, panel.metrics[index]);
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue