domains: show current task in renewCert, syncDns

This commit is contained in:
Girish Ramakrishnan
2023-05-14 11:47:21 +02:00
parent 500d2361ec
commit b7b01d5605

View File

@@ -489,23 +489,20 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
percent: 0,
message: '',
errorMessage: '',
taskId: '',
tasks: [],
checkStatus: function () {
refreshTasks: function () {
Client.getTasksByType(TASK_TYPES.TASK_CHECK_CERTS, function (error, tasks) {
if (error) return console.error(error);
if (!tasks.length) return;
$scope.renewCerts.tasks = tasks.slice(0, 10);
$scope.renewCerts.taskId = tasks[0].id;
if ($scope.renewCerts.tasks.length) $scope.renewCerts.updateStatus();
});
},
updateStatus: function () {
Client.getTask($scope.renewCerts.taskId, function (error, data) {
var taskId = $scope.renewCerts.tasks[0].id;
Client.getTask(taskId, function (error, data) {
if (error) return window.setTimeout($scope.renewCerts.updateStatus, 5000);
if (!data.active) {
@@ -514,7 +511,7 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
$scope.renewCerts.percent = 100; // indicates that 'result' is valid
$scope.renewCerts.errorMessage = data.success ? '' : data.error.message;
$scope.renewCerts.checkStatus();
$scope.renewCerts.refreshTasks(); // update the tasks list dropdown
return;
}
@@ -533,16 +530,13 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
$scope.renewCerts.errorMessage = '';
// always rebuild the nginx configs when triggered via the UI. we assume user is clicking this because something is wrong
Client.renewCerts({ rebuild: true }, function (error, taskId) {
Client.renewCerts({ rebuild: true }, 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();
$scope.renewCerts.checkStatus();
$scope.renewCerts.refreshTasks();
}
});
}
@@ -553,23 +547,19 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
percent: 0,
message: '',
errorMessage: '',
taskId: '',
tasks: [],
checkStatus: function () {
refreshTasks: function () {
Client.getTasksByType(TASK_TYPES.TASK_SYNC_DNS_RECORDS, function (error, tasks) {
if (error) return console.error(error);
if (!tasks.length) return;
$scope.syncDns.tasks = tasks.slice(0, 10);
$scope.syncDns.taskId = tasks[0].id;
if ($scope.syncDns.tasks.length) $scope.syncDns.updateStatus();
});
},
updateStatus: function () {
Client.getTask($scope.syncDns.taskId, function (error, data) {
var taskId = $scope.syncDns.tasks[0].id;
Client.getTask(taskId, function (error, data) {
if (error) return window.setTimeout($scope.syncDns.updateStatus, 5000);
if (!data.active) {
@@ -578,7 +568,7 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
$scope.syncDns.percent = 100; // indicates that 'result' is valid
$scope.syncDns.errorMessage = data.success ? '' : data.error.message;
$scope.syncDns.checkStatus();
$scope.syncDns.refreshTasks(); // update the tasks list dropdown
return;
}
@@ -596,16 +586,13 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
$scope.syncDns.message = '';
$scope.syncDns.errorMessage = '';
Client.setDnsRecords({}, function (error, taskId) {
Client.setDnsRecords({}, function (error /*, taskId */) {
if (error) {
console.error(error);
$scope.syncDns.errorMessage = error.message;
$scope.syncDns.busy = false;
} else {
$scope.syncDns.taskId = taskId;
$scope.syncDns.updateStatus();
$scope.syncDns.checkStatus();
$scope.syncDns.refreshTasks();
}
});
}
@@ -744,8 +731,8 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
$scope.ready = true;
});
$scope.renewCerts.checkStatus();
$scope.syncDns.checkStatus();
$scope.renewCerts.refreshTasks();
$scope.syncDns.refreshTasks();
});
document.getElementById('gcdnsKeyFileInput').onchange = readFileLocally($scope.domainConfigure.gcdnsKey, 'content', 'keyFileName');