Skip to content

Commit

Permalink
fix stuck shard state
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonardo Menezes committed Jan 19, 2017
1 parent 8f29de9 commit a664f7f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 56 deletions.
26 changes: 6 additions & 20 deletions public/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,12 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http',
);
};

$scope.isSelected = function(shard) {
var relocating = $scope.relocatingShard;
return relocating && shard.index === relocating.index &&
shard.node === relocating.node && shard.shard === relocating.shard;
};

$scope.canReceiveShard = function(index, node) {
var shard = $scope.relocatingShard;
if (shard && index) { // in case num indices < num columns
Expand Down Expand Up @@ -2116,26 +2122,6 @@ angular.module('cerebro').directive('ngPlainInclude', function() {
};
});

angular.module('cerebro').directive('ngShard', function() {
return {
scope: true,
link: function(scope) {
var shard = scope.shard;
scope.state = shard.state.toLowerCase();
scope.replica = !shard.primary && shard.node;
scope.id = shard.shard + '_' + shard.node + '_' + shard.index;
scope.clazz = scope.replica ? 'shard-replica' : '';
scope.equal = function(other) {
return other && shard.index === other.index &&
shard.node === other.node && shard.shard === other.shard;
};
},
templateUrl: function() {
return 'overview/shard.html';
}
};
});

angular.module('cerebro').factory('AceEditorService', function() {

this.init = function(name) {
Expand Down
21 changes: 20 additions & 1 deletion public/overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,26 @@
</td>
<td ng-repeat="index in page.elements track by $index">
<span ng-repeat="shard in index.shards[node.id] | orderBy:'shard' track by $index">
<ng-shard></ng-shard>
<span class="dropdown">
<span class="shard shard-{{shard.state | lowercase}} normal-action"
ng-class="{'shard-replica': !shard.primary && shard.node}"
data-toggle="dropdown"
id="{{shard.shard}}_{{shard.node}}_{{shard.index}}">
<small>{{shard.shard}}</small>
</span>
<ul class="dropdown-menu"
aria-labelledby="{{shard.shard}}_{{shard.node}}_{{shard.index}}">
<li ng-click="shardStats(shard.index, shard.node, shard.shard)" data-toggle="modal" href="#confirm_dialog" target="_self">
<a target="_self"><i class="fa fa-fw fa-info-circle"> </i> display shard stats</a>
</li>
<li ng-click="select(shard)" ng-hide="isSelected(relocatingShard)">
<a target="_self"><i class="fa fa-fw fa-arrows"> </i> select for relocation</a>
</li>
<li ng-click="select()" ng-show="isSelected(relocatingShard)">
<a target="_self"><i class="fa fa-fw fa-arrows"> </i> unselect for relocation</a>
</li>
</ul>
</span>
</span>
<span class="shard shard-spot normal-action" ng-click="relocateShard(node)"
ng-show="canReceiveShard(index, node)">
Expand Down
16 changes: 0 additions & 16 deletions public/overview/shard.html

This file was deleted.

6 changes: 6 additions & 0 deletions src/app/components/overview/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,12 @@ angular.module('cerebro').controller('OverviewController', ['$scope', '$http',
);
};

$scope.isSelected = function(shard) {
var relocating = $scope.relocatingShard;
return relocating && shard.index === relocating.index &&
shard.node === relocating.node && shard.shard === relocating.shard;
};

$scope.canReceiveShard = function(index, node) {
var shard = $scope.relocatingShard;
if (shard && index) { // in case num indices < num columns
Expand Down
19 changes: 0 additions & 19 deletions src/app/shared/directives/shard.js

This file was deleted.

0 comments on commit a664f7f

Please sign in to comment.