Skip to content

Commit

Permalink
handle index settings same was as cluster settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lmenezes committed Jun 20, 2018
1 parent b404e25 commit c46dcb6
Show file tree
Hide file tree
Showing 12 changed files with 360 additions and 171 deletions.
12 changes: 0 additions & 12 deletions public/index_settings/blocks.html

This file was deleted.

10 changes: 0 additions & 10 deletions public/index_settings/cache.html

This file was deleted.

85 changes: 51 additions & 34 deletions public/index_settings/index.html
@@ -1,43 +1,60 @@
<h4>{{index}} settings</h4>
<div class="row">
<div class="col-xs-12">
<div class="form-group">
<select ng-model="group" ng-init="group = 'index_settings/index_settings.html'" class="form-control">
<option value="index_settings/index_settings.html">index</option>
<option value="index_settings/blocks.html">block operations</option>
<option value="index_settings/translog.html">translog</option>
<option value="index_settings/routing.html">routing</option>
<option value="index_settings/cache.html">cache</option>
<option value="index_settings/slowlog.html">slowlog</option>
</select>
</div>
<!-- filter -->
<div class="row query-container">
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
<input type="text" class="form-control" ng-model="settingsFilter.name"
ng-change="refreshVisibleProperties()" placeholder="filter settings by name"/>
</div>
<div class="col-xs-12">
<div ng-include src="group"></div>
<div class="col-lg-4 col-md-6 col-sm-6 col-xs-12">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="settingsFilter.showStatic"> show static settings <i class="fa fa-lock alert-warning"></i>
</label>
</div>
</div>
</div>
<div class="row" ng-show="pendingChanges">

<!-- settings form -->
<div class="row form-group" ng-repeat="group in groupedSettings.groups | filter:displayGroup | orderBy:'name'">
<div class="col-xs-12">
<table class="table">
<thead>
<tr>
<td>{{pendingChanges}} pending changes</td>
</tr>
</thead>
<tr ng-repeat="(p, v) in changes track by $index" ng-show="v">
<td>
<i class="fa fa-cog"> </i> {{p}} <span class="info-text"> set to value</span> {{v}}
<i class="fa fa-undo normal-action pull-right" ng-click="revert(p)"></i>
</td>
</tr>
</table>
<h6><b>{{group.name | uppercase}}</b></h6>
<hr class="header">
</div>
<div class="col-lg-12 text-right">
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12" ng-repeat="setting in group.settings | filter:displaySetting | orderBy:'name'">
<div class="form-group">
<div class="btn-group">
<button class="btn btn-success" ng-click="save()">
save
</button>
<label class="form-label">
{{setting.name}} <i class="fa fa-lock alert-warning" ng-show="setting.static"> </i>
</label>
<input type="text" class="form-control" ng-model="form[setting.name]"
ng-change="set(setting.name)" ng-disabled="setting.static"/>
</div>
</div>
</div>
<!-- pending changes -->
<div class="row" ng-show="pendingChanges" style="padding-top: {{(pendingChanges * 40) + 90}}px;">
<div class="pending-changes">
<div class="col-xs-12">
<table class="table">
<thead>
<tr class="text-center">
<td>{{pendingChanges}} pending changes</td>
</tr>
</thead>
<tr ng-repeat="(setting, value) in changes track by $index">
<td>
<i class="fa fa-cog"></i>
{{setting}} <span class="info-text">updated to</span> {{value}}
<i class="fa fa-undo normal-action pull-right" ng-click="revertSetting(setting)"></i>
</td>
</tr>
</table>
</div>
<div class="col-lg-12 text-right">
<div class="form-group">
<div class="btn-group">
<button class="btn btn-success" ng-click="save()">
save
</button>
</div>
</div>
</div>
</div>
Expand Down
20 changes: 0 additions & 20 deletions public/index_settings/index_settings.html

This file was deleted.

9 changes: 0 additions & 9 deletions public/index_settings/routing.html

This file was deleted.

21 changes: 0 additions & 21 deletions public/index_settings/slowlog.html

This file was deleted.

11 changes: 0 additions & 11 deletions public/index_settings/translog.html

This file was deleted.

165 changes: 144 additions & 21 deletions public/js/app.js
Expand Up @@ -774,21 +774,25 @@ angular.module('cerebro').controller('IndexSettingsController', ['$scope',
'$location', 'IndexSettingsDataService', 'AlertService',
function($scope, $location, IndexSettingsDataService, AlertService) {

$scope.originalSettings = undefined;
$scope.form = undefined;
$scope.settings = undefined;
$scope.groupedSettings = undefined;
$scope.changes = undefined;
$scope.pendingChanges = 0;
$scope.settingsFilter = {name: '', showStatic: false};
$scope.index = $location.search().index;

$scope.set = function(property) {
var value = $scope.settings[property];
if (value) {
if (!$scope.changes[property]) {
$scope.set = function(setting) {
var value = $scope.form[setting];
if (value !== $scope.settings[setting]) {
if ($scope.changes[setting]) {
$scope.changes[setting] = value;
} else {
$scope.changes[setting] = value;
$scope.pendingChanges += 1;
}
$scope.changes[property] = value;
} else {
$scope.removeChange(property);
$scope.removeChange(setting);
}
};

Expand All @@ -799,9 +803,23 @@ angular.module('cerebro').controller('IndexSettingsController', ['$scope',
}
};

$scope.revert = function(property) {
$scope.settings[property] = $scope.originalSettings[property];
$scope.removeChange(property);
$scope.revertSetting = function(setting) {
$scope.form[setting] = $scope.settings[setting];
$scope.removeChange(setting);
};

$scope.displayGroup = function(group) {
var matchedSettings = 0;
group.settings.forEach(function(s) {
matchedSettings += $scope.displaySetting(s) ? 1 : 0;
});
return matchedSettings > 0;
};

$scope.displaySetting = function(setting) {
var matchesName = setting.name.indexOf($scope.settingsFilter.name) >= 0;
var matchesType = (!setting.static || $scope.settingsFilter.showStatic);
return matchesName && matchesType;
};

$scope.save = function() {
Expand All @@ -819,20 +837,31 @@ angular.module('cerebro').controller('IndexSettingsController', ['$scope',
};

$scope.setup = function() {
$scope.settings = {};
$scope.originalSettings = {};
$scope.changes = {};
$scope.pendingChanges = 0;
var loadSetting = function(value, property) {
$scope.settings[property] = value;
$scope.originalSettings[property] = value;
};

IndexSettingsDataService.get(
$scope.index,
function(response) {
angular.forEach(response[$scope.index].settings, loadSetting);
angular.forEach(response[$scope.index].defaults, loadSetting);
$scope.settings = {};
$scope.form = {};
$scope.changes = {};
$scope.pendingChanges = 0;
var settings = response[$scope.index];
['defaults', 'settings'].forEach(function(group) {
angular.forEach(settings[group], function(value, setting) {
if (ValidIndexSettings.valid(setting)) {
setting = setting.substring('index.'.length);
$scope.settings[setting] = value;
$scope.form[setting] = value;
}
});
});
if (!$scope.groupedSettings) {
$scope.groupedSettings = new GroupedSettings(
Object.keys($scope.form).map(function(setting) {
var dynamic = DynamicIndexSettings.valid(setting);
return {name: setting, static: !dynamic};
})
);
}
},
function(error) {
AlertService.error('Error loading index settings', error);
Expand All @@ -858,6 +887,100 @@ angular.module('cerebro').factory('IndexSettingsDataService', ['DataService',
}
]);

var DynamicIndexSettings = (function() {
var settings = {
'mapper.dynamic': true,
'max_refresh_listeners': true,
'number_of_replicas': true,
'allocation.max_retries': true,
'auto_expand_replicas': true,
'blocks.metadata': true,
'blocks.read': true,
'blocks.read_only': true,
'blocks.read_only_allow_delete': true,
'blocks.write': true,
'compound_format': true,
'gc_deletes': true,
'indexing.slowlog.level': true,
'indexing.slowlog.reformat': true,
'indexing.slowlog.source': true,
'indexing.slowlog.threshold.index.debug': true,
'indexing.slowlog.threshold.index.info': true,
'indexing.slowlog.threshold.index.trace': true,
'indexing.slowlog.threshold.index.warn': true,
'mapping.depth.limit': true,
'mapping.nested_fields.limit': true,
'mapping.total_fields.limit': true,
'max_adjacency_matrix_filters': true,
'max_rescore_window': true,
'max_result_window': true,
'max_slices_per_scroll': true,
'merge.policy.expunge_deletes_allowed': true,
'merge.policy.floor_segment': true,
'merge.policy.max_merge_at_once': true,
'merge.policy.max_merge_at_once_explicit': true,
'merge.policy.max_merged_segment': true,
'merge.policy.reclaim_deletes_weight': true,
'merge.policy.segments_per_tier': true,
'merge.scheduler.auto_throttle': true,
'merge.scheduler.max_merge_count': true,
'merge.scheduler.max_thread_count': true,
'optimize_auto_generated_id': true,
'priority': true,
'recovery.initial_shards': true,
'refresh_interval': true,
'requests.cache.enable': true,
'routing.allocation.enable': true,
'routing.allocation.total_shards_per_node': true,
'routing.rebalance.enable': true,
'search.slowlog.level': true,
'search.slowlog.threshold.fetch.debug': true,
'search.slowlog.threshold.fetch.info': true,
'search.slowlog.threshold.fetch.trace': true,
'search.slowlog.threshold.fetch.warn': true,
'search.slowlog.threshold.query.debug': true,
'search.slowlog.threshold.query.info': true,
'search.slowlog.threshold.query.trace': true,
'search.slowlog.threshold.query.warn': true,
'shared_filesystem.recover_on_any_node': true,
'store.throttle.max_bytes_per_sec': true,
'store.throttle.type': true,
'translog.durability': true,
'translog.flush_threshold_size': true,
'ttl.disable_purge': true,
'unassigned.node_left.delayed_timeout': true,
'warmer.enabled': true,
'write.wait_for_active_shards': true
};

return {
valid: function(setting) {
return settings[setting] || false;
}
};
})();


var ValidIndexSettings = (function() {
var invalidSettings = [
'index.creation_date',
'index.provided_name',
'index.uuid',
'index.version.created'
];

return {
valid: function(setting) {
var valid = true;
invalidSettings.forEach(function(invalidSetting) {
valid = valid && setting.indexOf(invalidSetting) == -1;
});
return valid;
}
};
})();


angular.module('cerebro').controller('ModalController', ['$scope',
'ModalService', function($scope, ModalService) {

Expand Down

0 comments on commit c46dcb6

Please sign in to comment.