2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-29 13:27:43 +00:00

portal ptr correspondence (#511)

This commit is contained in:
Britney Wright 2019-03-04 16:52:35 -05:00 committed by GitHub
parent 66b41de03b
commit d79e30a5bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 10 deletions

View File

@ -56,7 +56,7 @@
<tr>
<th>#</th>
<th class="col-md-2">Change Type</th>
<th class="col-md-1">Record Type</th>
<th>Record Type</th>
<th>Input Name</th>
<th class="col-md-1">TTL</th>
<th>Record Data</th>
@ -73,8 +73,10 @@
</select>
</td>
<td>
<select class="form-control" ng-model="change.type" >
<option value="A" selected>A</option>
<select class="form-control" ng-model="change.type">
<option value="A+PTR" selected>A+PTR</option>
<option>AAAA+PTR</option>
<option>A</option>
<option>AAAA</option>
<option>CNAME</option>
<option>PTR</option>
@ -101,10 +103,23 @@
</td>
<!--TTL based on change type-->
<!--record data name based on record type and change type-->
<td ng-if="change.changeType=='DeleteRecordSet'">
<td ng-if="change.changeType=='DeleteRecordSet' && change.type!='A+PTR' && change.type!='AAAA+PTR'">
<input class="form-control" placeholder="" disabled/>
</td>
<td ng-if="change.type=='A+PTR'">
<input name="record_address_{{$index}}" type="text" ng-model="change.record.address" required="string" class="form-control" placeholder="e.g. 1.1.1.1" ipv4>
<p ng-show="createBatchChangeForm.$submitted">
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.required" class="batch-change-error-help">Record data is required!</span>
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.ipv4" class="batch-change-error-help">must be a valid IPv4 Address!</span>
</p>
</td>
<td ng-if="change.type=='AAAA+PTR'">
<input name="record_address_{{$index}}" type="text" ng-model="change.record.address" required="string" class="form-control" placeholder="e.g. fd69:27cc:fe91::60" ipv6>
<p ng-show="createBatchChangeForm.$submitted">
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.required" class="batch-change-error-help">Record data is required!</span>
<span ng-show="createBatchChangeForm.record_address_{{$index}}.$error.ipv6" class="batch-change-error-help">must be a valid IPv6 Address!</span>
</p>
</td>
<td ng-if="change.type=='A' && change.changeType=='Add'">
<input name="record_address_{{$index}}" type="text" ng-model="change.record.address" ng-required="change.changeType=='Add'" class="form-control" placeholder="e.g. 1.1.1.1" ng-disabled="change.changeType=='DeleteRecordSet'" ipv4>
<p ng-show="createBatchChangeForm.$submitted">
@ -167,8 +182,8 @@
</tr>
</tbody>
</table>
<button type="button" id="addChange" class="btn btn-default" ng-click="addSingleChange()" ng-disabled="newBatch.changes.length == batchChangeLimit"><span class="fa fa-plus"></span> Add a Change</button>
<span ng-if="newBatch.changes.length == batchChangeLimit">Limit reached. Cannot add more than {{batchChangeLimit}} records per batch change.</span>
<button type="button" id="addChange" class="btn btn-default" ng-click="addSingleChange()" ng-disabled="newBatch.changes.length >= batchChangeLimit"><span class="fa fa-plus"></span> Add a Change</button>
<span ng-if="newBatch.changes.length >= batchChangeLimit">Limit reached. Cannot add more than {{batchChangeLimit}} records per batch change.</span>
</div>
<div class="panel-footer clearfix">
<div ng-if="formStatus=='pendingSubmit'" class="pull-right">

View File

@ -28,13 +28,13 @@
});
$scope.batch = {};
$scope.newBatch = {comments: "", changes: [{changeType: "Add", type: "A", ttl: 200}]};
$scope.newBatch = {comments: "", changes: [{changeType: "Add", type: "A+PTR", ttl: 200}]};
$scope.alerts = [];
$scope.batchChangeErrors = false;
$scope.formStatus = "pendingSubmit";
$scope.addSingleChange = function() {
$scope.newBatch.changes.push({changeType: "Add", type: "A", ttl: 200});
$scope.newBatch.changes.push({changeType: "Add", type: "A+PTR", ttl: 200});
var changesLength =$scope.newBatch.changes.length;
$timeout(function() {document.getElementsByClassName("changeType")[changesLength - 1].focus()});
};
@ -59,6 +59,17 @@
delete payload.ownerGroupId
}
function formatData(payload) {
for (var i = 0; i < payload.changes.length; i++) {
var entry = payload.changes[i]
if(entry.type == 'A+PTR' || entry.type == 'AAAA+PTR') {
entry.type = entry.type.slice(0, -4);
var newEntry = {changeType: entry.changeType, type: "PTR", ttl: entry.ttl, inputName: entry.record.address, record: {ptrdname: entry.inputName}}
payload.changes.splice(i+1, 0, newEntry)
}
}
}
function success(response) {
var alert = utilityService.success('Successfully Created Batch Change', response, 'createBatchChange: createBatchChange successful');
$scope.alerts.push(alert);
@ -68,6 +79,8 @@
$scope.batch = response.data;
}
formatData(payload);
return batchChangeService.createBatchChange(payload)
.then(success)
.catch(function (error){

View File

@ -114,7 +114,7 @@ describe('BatchChange', function(){
it('adds a change to the changes array', function() {
this.scope.addSingleChange();
expect(this.scope.newBatch).toEqual({comments: "", changes: [{changeType: "Add", type: "A", ttl: 200}, {changeType: "Add", type: "A", ttl: 200}]})
expect(this.scope.newBatch).toEqual({comments: "", changes: [{changeType: "Add", type: "A+PTR", ttl: 200}, {changeType: "Add", type: "A+PTR", ttl: 200}]})
});
});