Skip to content
This repository has been archived by the owner on Jul 18, 2019. It is now read-only.

Commit

Permalink
fix(jmx): ENTESB-9634 In the Charts edit page, the Elements select bo…
Browse files Browse the repository at this point in the history
…x disappears when the selected item is unselected using the CTRL button
  • Loading branch information
Alexandre Kieling committed Nov 8, 2018
1 parent ac66bbc commit 1f73dd6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
3 changes: 2 additions & 1 deletion plugins/jmx/html/chartEdit.html
Expand Up @@ -15,7 +15,8 @@ <h2>Chart</h2>
<div class="form-group col-md-6" ng-show="showElements()">
<label for="mbeans">Elements</label>
<select id="mbeans" class="form-control" size="20" multiple ng-model="selectedMBeans"
ng-options="name for (name, value) in mbeans"></select>
ng-options="name for (name, value) in mbeans"
ng-change="onSelectedMBeansChange()"></select>
</div>
<div class="form-group col-md-6" ng-show="showAttributes()">
<label for="attributes">Attributes</label>
Expand Down
17 changes: 16 additions & 1 deletion plugins/jmx/ts/charts/chartEdit.ts
Expand Up @@ -4,7 +4,9 @@ namespace Jmx {

jmxModule.controller("Jmx.ChartEditController", ["$scope", "$location", "workspace", "jolokia", ($scope, $location, workspace:Workspace, jolokia) => {
$scope.selectedAttributes = [];
$scope.selectedAttributesBackup = [];
$scope.selectedMBeans = [];
$scope.selectedMBeansBackup = [];
$scope.metrics = {};
$scope.mbeans = {};

Expand Down Expand Up @@ -45,9 +47,18 @@ namespace Jmx {
return $scope.canViewChart() && $scope.size($scope.mbeans) > 1;
};

$scope.onSelectedMBeansChange = () => {
// hack to avoid having an empty array of mbeans
if ($scope.selectedMBeans.length === 0) {
$scope.selectedMBeans = $scope.selectedMBeansBackup;
} else {
$scope.selectedMBeansBackup = $scope.selectedMBeans;
}
}

$scope.onSelectedAttributesChange = () => {
// hack to avoid having an empty array of attributes
if ($scope.selectedAttributes.length == 0 && $scope.selectedAttributesBackup) {
if ($scope.selectedAttributes.length === 0) {
$scope.selectedAttributes = $scope.selectedAttributesBackup;
} else {
$scope.selectedAttributesBackup = $scope.selectedAttributes;
Expand Down Expand Up @@ -154,6 +165,7 @@ namespace Jmx {
if ($scope.selectedMBeans.length < 1) {
$scope.selectedMBeans = _.keys($scope.mbeans);
}

if ($scope.selectedAttributes.length < 1) {
var attrKeys = _.keys($scope.metrics).sort();
if ($scope.selectedMBeans.length > 1) {
Expand All @@ -167,6 +179,9 @@ namespace Jmx {
$("#attributes").attr("size", _.keys($scope.metrics).length);
$("#mbeans").attr("size", _.keys($scope.mbeans).length);
Core.$apply($scope);

$scope.selectedMBeansBackup = $scope.selectedMBeans;
$scope.selectedAttributesBackup = $scope.selectedAttributes;
}
}

Expand Down

0 comments on commit 1f73dd6

Please sign in to comment.