2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-09-01 14:55:22 +00:00

Merge pull request #1393 from Jay07GIT/reset_file_batchchange_upload

Reset the batch file name when re-upload the same file again
This commit is contained in:
Nicholas Spadaccino
2024-09-24 16:17:31 -04:00
committed by GitHub

View File

@@ -162,16 +162,32 @@
$scope.alerts.push(alert); $scope.alerts.push(alert);
} }
function resetFileInput() {
$scope.csvInput = null;
var inputElement = document.getElementById('batchChangeCsv');
if (inputElement) {
inputElement.value = null;
}
if ($scope.createBatchChangeForm && $scope.createBatchChangeForm.batchChangeCsv) {
$scope.createBatchChangeForm.batchChangeCsv.$setViewValue(null);
$scope.createBatchChangeForm.batchChangeCsv.$render();
}
}
$scope.uploadCSV = function(file, batchChangeLimit) { $scope.uploadCSV = function(file, batchChangeLimit) {
parseFile(file, batchChangeLimit).then(function(dataLength){ parseFile(file, batchChangeLimit).then(function(dataLength){
$scope.alerts.push({type: 'success', content: 'Successfully imported ' + dataLength + ' DNS changes.' }); $scope.alerts.push({type: 'success', content: 'Successfully imported ' + dataLength + ' DNS changes.' });
resetFileInput();
}, function(error) { }, function(error) {
$scope.alerts.push({type: 'danger', content: error}); $scope.alerts.push({type: 'danger', content: error});
}); });
function parseFile(file, batchChangeLimit) { function parseFile(file, batchChangeLimit) {
return $q(function(resolve, reject) { return $q(function(resolve, reject) {
if (!file.name.endsWith('.csv')) { if (!file || !file.name) {
$log.debug('No file selected or file has no name property');
}
else if (!file.name.endsWith('.csv')) {
reject("Import failed. File should be of .csv type."); reject("Import failed. File should be of .csv type.");
} }
else { else {