pdnscontrol
pdnscontrol copied to clipboard
Editing zone - After save showing just modified record
Hello,
I found this bug, it is probably because of changed behaviour of PowerDNS v4 API.
This is in tag last-3x-compat https://github.com/PowerDNS/pdnscontrol/blob/last-3x-compat/pdnscontrol/static/js/controllers.zone.js#L248-L252
// success. update local data from server
$scope.master.records = response.records;
$scope.master.comments = response.comments;
$scope.master.rrsets = convertZoneToRRsetList($scope.master);
$scope.zone = Restangular.copy($scope.master);
This is in master: https://github.com/PowerDNS/pdnscontrol/blob/master/pdnscontrol/static/js/controllers.zone.js#L244-L246
// success. update local data from server
$scope.master.rrsets = zoneSort(response.rrsets);
$scope.zone = Restangular.copy($scope.master);
But after zone record change, response.rrsets
returns just only changed record modified by 'PATCH' request, so record is changed in database, but after apply-ing change, I can see only modified record.
After refresh, I see all records ok.
I do not understand AngularJS and was not able to properly solve it, just made a temporary fix with another call. It works, but is not proper solution and make it blink, not smoothly rerender the screen.
diff --git a/pdnscontrol/static/js/controllers.zone.js b/pdnscontrol/static/js/controllers.zone.js
index 3ce014c..691e3f7 100644
--- a/pdnscontrol/static/js/controllers.zone.js
+++ b/pdnscontrol/static/js/controllers.zone.js
@@ -242,8 +242,10 @@ angular.module('ControlApp.controllers.zone').controller('ZoneDetailCtrl',
return;
}
// success. update local data from server
- $scope.master.rrsets = zoneSort(response.rrsets);
- $scope.zone = Restangular.copy($scope.master);
+ Restangular.one('servers', $scope.server._id).one('zones', $scope.zone.id).get().then(function(data) {
+ $scope.master.rrsets = zoneSort(data.rrsets);
+ $scope.zone = Restangular.copy($scope.master);
+ });
// send auto ptr changes to server
doAutoPtr(changes);
}, function(errorResponse) {
Thank you