Closes #244: feedback when saving inbox scanning configuration

This commit is contained in:
Benjamin Gamard 2018-10-19 16:10:39 +02:00
parent d4fe719a2c
commit 8fff672d2f
3 changed files with 18 additions and 3 deletions

View File

@ -3,7 +3,7 @@
/**
* Settings inbox page controller.
*/
angular.module('docs').controller('SettingsInbox', function($scope, $rootScope, Restangular) {
angular.module('docs').controller('SettingsInbox', function($scope, $rootScope, Restangular, $translate, $timeout) {
// Get the inbox configuration
Restangular.one('app/config_inbox').get().then(function (data) {
$scope.inbox = data;
@ -15,8 +15,14 @@ angular.module('docs').controller('SettingsInbox', function($scope, $rootScope,
});
// Save the inbox configuration
$scope.saveResult = undefined;
$scope.editInboxConfig = function () {
return Restangular.one('app').post('config_inbox', $scope.inbox);
return Restangular.one('app').post('config_inbox', $scope.inbox).then(function () {
$scope.saveResult = $translate.instant('settings.inbox.saved');
$timeout(function() {
$scope.saveResult = undefined;
}, 5000);
});
};
$scope.testInboxConfig = function () {
@ -26,6 +32,9 @@ angular.module('docs').controller('SettingsInbox', function($scope, $rootScope,
Restangular.one('app').post('test_inbox').then(function (data) {
$scope.testResult = data;
$scope.testLoading = false;
$timeout(function() {
$scope.testResult = undefined;
}, 5000);
});
});
};

View File

@ -397,7 +397,8 @@
"test": "Test the parameters",
"last_sync": "Last synchronization: {{ data.date | date: 'medium' }}, {{ data.count }} message{{ data.count > 1 ? 's' : '' }} imported",
"test_success": "The connection to the inbox is successful ({{ count }} <strong>unread</strong> message{{ count > 1 ? 's' : '' }})",
"test_fail": "An error occurred while connecting to the inbox, please check the parameters"
"test_fail": "An error occurred while connecting to the inbox, please check the parameters",
"saved": "IMAP configuration saved successfully"
},
"monitoring": {
"background_tasks": "Background tasks",

View File

@ -71,6 +71,11 @@
</div>
</form>
<div class="alert col-sm-9 alert-success"
ng-show="saveResult">
{{ saveResult }}
</div>
<div class="alert col-sm-9"
ng-class="{ 'alert-success': testResult.count >= 0, 'alert-danger': testResult.count == -1 }"
ng-show="testResult"