Add external ldap progress bar

This commit is contained in:
Girish Ramakrishnan
2019-11-07 11:35:04 -08:00
parent 2e6e320bd9
commit 836a3659b6
2 changed files with 104 additions and 18 deletions

View File

@@ -433,8 +433,10 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
$scope.externalLdap = {
busy: false,
percent: 0,
message: '',
errorMessage: '',
error: {},
syncBusy: false,
taskId: 0,
// fields
@@ -446,30 +448,49 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
bindPassword: '',
usernameField: '',
checkStatus: function () {
Client.getLatestTaskByType('syncExternalLdap', function (error, task) {
if (error) return console.error(error);
if (!task) return;
$scope.externalLdap.taskId = task.id;
$scope.externalLdap.updateStatus();
});
},
sync: function () {
$scope.externalLdap.syncBusy = true;
$scope.externalLdap.busy = true;
Client.startExternalLdapSync(function (error, taskId) {
if (error) {
$scope.externalLdap.syncBusy = false;
$scope.externalLdap.busy = false;
console.error('Unable to start ldap syncer task.', error);
return;
}
$scope.externalLdap.taskId = taskId;
$scope.externalLdap.updateStatus();
});
},
function refreshTaskStatus() {
Client.getTask(taskId, function (error, result) {
if (error) console.error(error);
if (result && result.active) return $timeout(refreshTaskStatus, 2000);
updateStatus: function () {
Client.getTask($scope.externalLdap.taskId, function (error, data) {
if (error) return window.setTimeout($scope.externalLdap.updateStatus, 5000);
$scope.externalLdap.syncBusy = false;
if (!data.active) {
$scope.externalLdap.busy = false;
$scope.externalLdap.message = '';
$scope.externalLdap.percent = 100; // indicates that 'result' is valid
$scope.externalLdap.errorMessage = data.success ? '' : data.error.message;
refreshUsers();
});
return refreshUsers();
}
refreshTaskStatus();
$scope.externalLdap.busy = true;
$scope.externalLdap.percent = data.percent;
$scope.externalLdap.message = data.message;
window.setTimeout($scope.externalLdap.updateStatus, 3000);
});
},