CloudFlare DNS: edit records on click (name, type, TTL, value, priority, proxy)

- Add updateDNSRecordCloudFlare backend (dnsManager, view, URL)
- Return real priority in getCurrentRecordsForDomainCloudFlare
- Edit (pencil) button + modal with all fields; Save calls update API
- openEditModal, closeEditModal, saveEditRecord in dns.js
This commit is contained in:
master3395
2026-02-16 14:39:46 +01:00
parent d5262891f0
commit 4af0d2e599
6 changed files with 245 additions and 1 deletions

View File

@@ -813,6 +813,8 @@ app.controller('addModifyDNSRecordsCloudFlare', function ($scope, $http, $window
$scope.couldNotAddRecord = true;
$scope.recordValueDefault = false;
$scope.records = [];
$scope.showEditModal = false;
$scope.editRecord = {};
// Hide records boxes
$(".aaaaRecord").hide();
@@ -1140,6 +1142,51 @@ app.controller('addModifyDNSRecordsCloudFlare', function ($scope, $http, $window
};
$scope.openEditModal = function (record) {
$scope.editRecord = {
id: record.id,
name: record.name,
type: record.type,
ttl: record.ttl,
content: record.content,
priority: record.priority || 0,
proxy: record.proxy,
proxiable: record.proxiable
};
$scope.showEditModal = true;
};
$scope.closeEditModal = function () {
$scope.showEditModal = false;
};
$scope.saveEditRecord = function () {
var url = "/dns/updateDNSRecordCloudFlare";
var data = {
selectedZone: $scope.selectedZone,
id: $scope.editRecord.id,
name: $scope.editRecord.name,
recordType: $scope.editRecord.type,
content: $scope.editRecord.content,
ttl: $scope.editRecord.ttl === 'AUTO' || $scope.editRecord.ttl === 1 ? 1 : parseInt($scope.editRecord.ttl, 10) || 3600,
priority: parseInt($scope.editRecord.priority, 10) || 0,
proxied: $scope.editRecord.proxy
};
var config = { headers: { 'X-CSRFToken': getCookie('csrftoken') } };
$http.post(url, data, config).then(function (response) {
if (response.data.update_status === 1) {
$scope.closeEditModal();
populateCurrentRecords();
new PNotify({ title: 'Success', text: 'Record updated.', type: 'success' });
} else {
$scope.errorMessage = response.data.error_message || 'Update failed';
new PNotify({ title: 'Error', text: $scope.errorMessage, type: 'error' });
}
}, function () {
new PNotify({ title: 'Error', text: 'Could not connect to server.', type: 'error' });
});
};
$scope.syncCF = function () {
$scope.recordsLoading = false;