Add a progress bar for the renewal task
This commit is contained in:
@@ -354,32 +354,59 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
|
||||
|
||||
$scope.renewCerts = {
|
||||
busy: false,
|
||||
error: null,
|
||||
percent: 0,
|
||||
message: '',
|
||||
errorMessage: '',
|
||||
taskId: '',
|
||||
|
||||
show: function () {
|
||||
$scope.renewCerts.reset();
|
||||
$('#renewCertsModal').modal('show');
|
||||
},
|
||||
checkStatus: function () {
|
||||
Client.getLatestTaskByType('renewcerts', function (error, task) {
|
||||
if (error) return console.error(error);
|
||||
|
||||
submit: function () {
|
||||
$scope.renewCerts.busy = true;
|
||||
$scope.renewCerts.error = null;
|
||||
if (!task) return;
|
||||
|
||||
Client.renewCerts(null /* all domains */, function (error) {
|
||||
if (error) {
|
||||
Client.error(error);
|
||||
} else {
|
||||
$('#renewCertsModal').modal('hide');
|
||||
$scope.renewCerts.reset();
|
||||
}
|
||||
|
||||
$scope.renewCerts.busy = false;
|
||||
$scope.renewCerts.taskId = task.id;
|
||||
$scope.renewCerts.updateStatus();
|
||||
});
|
||||
},
|
||||
|
||||
reset: function () {
|
||||
$scope.renewCerts.busy = false;
|
||||
$scope.renewCerts.error = null;
|
||||
updateStatus: function () {
|
||||
Client.getTask($scope.renewCerts.taskId, function (error, data) {
|
||||
if (error) return window.setTimeout($scope.renewCerts.updateStatus, 5000);
|
||||
|
||||
if (!data.active) {
|
||||
$scope.renewCerts.busy = false;
|
||||
$scope.renewCerts.message = '';
|
||||
$scope.renewCerts.percent = 100; // indicates that 'result' is valid
|
||||
$scope.renewCerts.errorMessage = data.errorMessage;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$scope.renewCerts.busy = true;
|
||||
$scope.renewCerts.percent = data.percent;
|
||||
$scope.renewCerts.message = data.message;
|
||||
window.setTimeout($scope.renewCerts.updateStatus, 500);
|
||||
});
|
||||
},
|
||||
|
||||
renew: function () {
|
||||
$scope.renewCerts.busy = true;
|
||||
$scope.renewCerts.percent = 0;
|
||||
$scope.renewCerts.message = '';
|
||||
$scope.renewCerts.errorMessage = '';
|
||||
|
||||
Client.renewCerts(null /* all domains */, function (error, taskId) {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
$scope.renewCerts.errorMessage = error.message;
|
||||
|
||||
$scope.renewCerts.busy = false;
|
||||
} else {
|
||||
$scope.renewCerts.taskId = taskId;
|
||||
$scope.renewCerts.updateStatus();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -478,6 +505,8 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
|
||||
$scope.dyndnsConfigure.refresh();
|
||||
}
|
||||
});
|
||||
|
||||
$scope.renewCerts.checkStatus();
|
||||
});
|
||||
|
||||
document.getElementById('gcdnsKeyFileInput').onchange = readFileLocally($scope.domainConfigure.gcdnsKey, 'content', 'keyFileName');
|
||||
|
||||
Reference in New Issue
Block a user