Avoid using unnecessary checkbox for solr config

This commit is contained in:
Johannes Zellner
2022-02-09 16:22:44 +01:00
parent 12fa9731b8
commit 7fc92101d5
2 changed files with 10 additions and 14 deletions

View File

@@ -109,20 +109,13 @@
</div>
<div class="modal-body">
<p ng-bind-html=" 'emails.solrConfig.description' | tr "></p>
<div class="checkbox">
<label>
<input type="checkbox" ng-model="solrConfig.enabled">{{ 'emails.solrConfig.enableSolrCheckbox' | tr }}</input>
</label>
</div>
<!-- only show this when user is trying to enable -->
<p class="has-error" ng-show="!solrConfig.currentConfig.enabled && !solrConfig.enoughMemory">{{ 'emails.solrConfig.notEnoughMemory' | tr }}</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'main.dialog.cancel' | tr }}</button>
<button type="button" class="btn btn-success" ng-click="solrConfig.submit()" ng-disabled="(!solrConfig.currentConfig.enabled && !solrConfig.enoughMemory) || solrConfig.enabled === solrConfig.currentConfig.enabled || solrConfig.busy"><i class="fa fa-circle-notch fa-spin" ng-show="solrConfig.busy"></i> {{ 'main.dialog.save' | tr }}</button>
<button type="button" class="btn btn-default" data-dismiss="modal">{{ 'main.dialog.close' | tr }}</button>
<button type="button" class="btn btn-success" ng-hide="solrConfig.currentConfig.enabled" ng-click="solrConfig.submit(true)" ng-disabled="(!solrConfig.currentConfig.enabled && !solrConfig.enoughMemory) || solrConfig.busy"><i class="fa fa-circle-notch fa-spin" ng-show="solrConfig.busy"></i> {{ 'main.enableAction' | tr }}</button>
<button type="button" class="btn btn-danger" ng-show="solrConfig.currentConfig.enabled" ng-click="solrConfig.submit(false)" ng-disabled="solrConfig.busy"><i class="fa fa-circle-notch fa-spin" ng-show="solrConfig.busy"></i> {{ 'main.disableAction' | tr }}</button>
</div>
</div>
</div>
@@ -330,6 +323,9 @@
<div class="col-xs-6">
<span class="text-muted">{{ 'emails.settings.solrFts' | tr }}</span>
</div>
<div class="col-xs-6 text-right" ng-hide="solrConfig.currentConfig">
<i class="fa fa-circle-notch fa-spin"></i>
</div>
<div class="col-xs-6 text-right" ng-show="solrConfig.currentConfig">
<span ng-show="solrConfig.currentConfig.enabled">
{{ 'emails.settings.solrEnabled' | tr }}

View File

@@ -226,17 +226,17 @@ angular.module('Application').controller('EmailsController', ['$scope', '$locati
$('#solrConfigModal').modal('show');
},
submit: function () {
submit: function (newState) {
$scope.solrConfig.busy = true;
Client.setSolrConfig($scope.solrConfig.enabled, function (error) {
Client.setSolrConfig(newState, function (error) {
if (error) return console.error(error);
$timeout(function () {
$scope.solrConfig.busy = false;
// FIXME: these values are fake. but cannot get current status from mail server since it might be restarting
$scope.solrConfig.currentConfig.enabled = $scope.solrConfig.enabled;
$scope.solrConfig.running = $scope.solrConfig.enabled;
$scope.solrConfig.currentConfig.enabled = newState;
$scope.solrConfig.running = newState;
$timeout(function () { $scope.solrConfig.refresh(); }, 20000); // get real values after 20 seconds