Add UI to sync dns

This commit is contained in:
Girish Ramakrishnan
2021-02-24 22:18:39 -08:00
parent 5f0ff047d4
commit 8dc0236e89
3 changed files with 94 additions and 2 deletions
+33
View File
@@ -302,6 +302,39 @@
</div>
</div>
<div class="text-left">
<h3>{{ 'domains.syncDns.title' | tr }}</h3>
</div>
<div class="card">
<div class="row">
<div class="col-md-12">
<p ng-bind-html="'domains.syncDns.description' | tr"></p>
</div>
</div>
<div class="row">
<div class="col-md-12" style="margin-bottom: 10px;">
<div ng-show="syncDns.busy" class="progress progress-striped active animateMe">
<div class="progress-bar progress-bar-success" role="progressbar" style="width: {{ syncDns.percent }}%"></div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<p ng-show="syncDns.busy">{{ syncDns.message }}</p>
<p ng-hide="syncDns.busy">
<div class="has-error" ng-show="!syncDns.active">{{ syncDns.errorMessage }}</div>
</p>
</div>
<div class="col-md-6 text-right">
<button class="btn btn-outline btn-primary" ng-click="syncDns.sync()" ng-disabled="syncDns.busy" style="margin-right: 10px">{{ 'domains.syncDns.syncAction' | tr }}</button>
<a class="btn btn-primary pull-right" ng-href="/logs.html?taskId={{syncDns.taskId}}" ng-disabled="!syncDns.taskId" target="_blank">{{ 'domains.syncDns.showLogsAction' | tr }}</a>
</div>
</div>
</div>
<div class="text-left">
<h3>{{ 'domains.changeDashboardDomain.title' | tr }}</h3>
</div>
+60 -2
View File
@@ -2,7 +2,7 @@
/* global async */
/* global angular */
/* global $ */
/* global $, TASK_TYPES */
angular.module('Application').controller('DomainsController', ['$scope', '$location', 'Client', function ($scope, $location, Client) {
Client.onReady(function () { if (!Client.getUserInfo().isAtLeastAdmin) $location.path('/'); });
@@ -389,7 +389,7 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
taskId: '',
checkStatus: function () {
Client.getLatestTaskByType('renewcerts', function (error, task) {
Client.getLatestTaskByType(TASK_TYPES.TASK_RENEW_CERTS, function (error, task) {
if (error) return console.error(error);
if (!task) return;
@@ -439,6 +439,64 @@ angular.module('Application').controller('DomainsController', ['$scope', '$locat
}
};
$scope.syncDns = {
busy: false,
percent: 0,
message: '',
errorMessage: '',
taskId: '',
checkStatus: function () {
Client.getLatestTaskByType(TASK_TYPES.TASK_SYNC_DNS_RECORDS, function (error, task) {
if (error) return console.error(error);
if (!task) return;
$scope.syncDns.taskId = task.id;
$scope.syncDns.updateStatus();
});
},
updateStatus: function () {
Client.getTask($scope.syncDns.taskId, function (error, data) {
if (error) return window.setTimeout($scope.syncDns.updateStatus, 5000);
if (!data.active) {
$scope.syncDns.busy = false;
$scope.syncDns.message = '';
$scope.syncDns.percent = 100; // indicates that 'result' is valid
$scope.syncDns.errorMessage = data.success ? '' : data.error.message;
return;
}
$scope.syncDns.busy = true;
$scope.syncDns.percent = data.percent;
$scope.syncDns.message = data.message;
window.setTimeout($scope.syncDns.updateStatus, 500);
});
},
sync: function () {
$scope.syncDns.busy = true;
$scope.syncDns.percent = 0;
$scope.syncDns.message = '';
$scope.syncDns.errorMessage = '';
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.domainRemove = {
busy: false,
error: null,