externalldap: sync log history
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
/* global angular */
|
||||
/* global Clipboard */
|
||||
/* global $ */
|
||||
/* global $, TASK_TYPES */
|
||||
|
||||
angular.module('Application').controller('UserSettingsController', ['$scope', '$location', '$translate', '$timeout', 'Client', function ($scope, $location, $translate, $timeout, Client) {
|
||||
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
|
||||
@@ -119,11 +119,11 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
|
||||
busy: false,
|
||||
percent: 0,
|
||||
message: '',
|
||||
errorMessage: '',
|
||||
error: {},
|
||||
taskId: 0,
|
||||
errorMessage: '', // last task error
|
||||
tasks: [],
|
||||
|
||||
syncBusy: false,
|
||||
error: {}, // save error
|
||||
saveBusy: false,
|
||||
|
||||
// fields
|
||||
provider: 'noop',
|
||||
@@ -139,57 +139,43 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
|
||||
|
||||
currentConfig: {},
|
||||
|
||||
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;
|
||||
|
||||
Client.startExternalLdapSync(function (error, taskId) {
|
||||
if (error) {
|
||||
$scope.externalLdap.syncBusy = false;
|
||||
console.error('Unable to start ldap syncer task.', error);
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.externalLdap.taskId = taskId;
|
||||
$scope.externalLdap.updateStatus();
|
||||
});
|
||||
},
|
||||
|
||||
refresh: function() {
|
||||
init: function () {
|
||||
Client.getExternalLdapConfig(function (error, result) {
|
||||
if (error) return console.error('Unable to get external ldap config.', error);
|
||||
|
||||
$scope.externalLdap.currentConfig = result;
|
||||
$scope.externalLdap.checkStatus();
|
||||
$scope.externalLdap.refreshTasks();
|
||||
});
|
||||
},
|
||||
|
||||
refreshTasks: function () {
|
||||
Client.getTasksByType(TASK_TYPES.TASK_SYNC_EXTERNAL_LDAP, function (error, tasks) {
|
||||
if (error) return console.error(error);
|
||||
$scope.externalLdap.tasks = tasks.slice(0, 10);
|
||||
if ($scope.externalLdap.tasks.length && $scope.externalLdap.tasks[0].active) $scope.externalLdap.updateStatus();
|
||||
});
|
||||
},
|
||||
|
||||
updateStatus: function () {
|
||||
Client.getTask($scope.externalLdap.taskId, function (error, data) {
|
||||
var taskId = $scope.externalLdap.tasks[0].id;
|
||||
|
||||
Client.getTask(taskId, function (error, data) {
|
||||
if (error) return window.setTimeout($scope.externalLdap.updateStatus, 5000);
|
||||
|
||||
if (!data.active) {
|
||||
$scope.externalLdap.syncBusy = false;
|
||||
$scope.externalLdap.busy = false;
|
||||
$scope.externalLdap.message = '';
|
||||
$scope.externalLdap.percent = 100; // indicates that 'result' is valid
|
||||
$scope.externalLdap.errorMessage = data.success ? '' : data.error.message;
|
||||
|
||||
$scope.externalLdap.refreshTasks(); // update the tasks list dropdown
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.externalLdap.syncBusy = true;
|
||||
$scope.externalLdap.busy = true;
|
||||
$scope.externalLdap.percent = data.percent;
|
||||
$scope.externalLdap.message = data.message;
|
||||
window.setTimeout($scope.externalLdap.updateStatus, 3000);
|
||||
window.setTimeout($scope.externalLdap.updateStatus, 500);
|
||||
});
|
||||
},
|
||||
|
||||
@@ -214,8 +200,25 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
|
||||
$('#externalLdapModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
sync: function () {
|
||||
$scope.externalLdap.busy = true;
|
||||
$scope.externalLdap.percent = 0;
|
||||
$scope.externalLdap.message = '';
|
||||
$scope.externalLdap.errorMessage = '';
|
||||
|
||||
Client.startExternalLdapSync(function (error) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
$scope.externalLdap.errorMessage = error.message;
|
||||
$scope.externalLdap.busy = false;
|
||||
} else {
|
||||
$scope.externalLdap.refreshTasks();
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.externalLdap.saveBusy = true;
|
||||
$scope.externalLdap.error = {};
|
||||
|
||||
var config = {
|
||||
@@ -256,7 +259,7 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
|
||||
}
|
||||
|
||||
Client.setExternalLdapConfig(config, function (error) {
|
||||
$scope.externalLdap.busy = false;
|
||||
$scope.externalLdap.saveBusy = false;
|
||||
|
||||
if (error) {
|
||||
if (error.statusCode === 424) {
|
||||
@@ -282,7 +285,7 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
|
||||
}
|
||||
} else {
|
||||
$('#externalLdapModal').modal('hide');
|
||||
$scope.externalLdap.refresh();
|
||||
$scope.externalLdap.init();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -402,7 +405,7 @@ angular.module('Application').controller('UserSettingsController', ['$scope', '$
|
||||
};
|
||||
|
||||
Client.onReady(function () {
|
||||
$scope.externalLdap.refresh();
|
||||
$scope.externalLdap.init();
|
||||
$scope.profileConfig.refresh();
|
||||
$scope.userDirectoryConfig.refresh();
|
||||
$scope.refreshOIDCClients();
|
||||
|
||||
Reference in New Issue
Block a user