2
0
mirror of https://github.com/VinylDNS/vinyldns synced 2025-08-22 10:10:12 +00:00

Export CSV in batch changes

This commit is contained in:
Jay07GIT 2024-09-13 23:07:58 +05:30
parent d0aea448ae
commit 2dce5ab425
No known key found for this signature in database
GPG Key ID: AC6B0308EFC79008
3 changed files with 35 additions and 1 deletions

View File

@ -41,7 +41,9 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<p><strong>ID:</strong> {{batch.id}}</p> <p><strong>ID:</strong> {{batch.id}}
<button class="btn-right-corner" ng-click="exportToCSV(batch.id)">Export CSV</button>
</p>
<p><strong>Submitted:</strong> {{batch.createdTimestamp}}</p> <p><strong>Submitted:</strong> {{batch.createdTimestamp}}</p>
<p ng-if="'@rootAccountName' != batch.userName"><strong>Submitter:</strong> {{batch.userName}}</p> <p ng-if="'@rootAccountName' != batch.userName"><strong>Submitter:</strong> {{batch.userName}}</p>
<p ng-if="batch.comments"><strong>Description:</strong> {{batch.comments}}</p> <p ng-if="batch.comments"><strong>Description:</strong> {{batch.comments}}</p>

View File

@ -133,6 +133,11 @@ a.action-link {
border-bottom-left-radius: 4px; border-bottom-left-radius: 4px;
} }
.btn-right-corner {
float: right;
margin-left: 10px;
}
.form-control.zone-edit { .form-control.zone-edit {
background: #F9F9F9; background: #F9F9F9;
color:#555; color:#555;

View File

@ -138,6 +138,33 @@
$("#cancel_batch_change").modal("hide"); $("#cancel_batch_change").modal("hide");
} }
$scope.exportToCSV = function (batchId) {
var filename = batchId + '.csv';
var csv = [];
var changes = document.querySelectorAll("table tr");
$log.debug(batchId)
for (var i = 0; i < changes.length; i++) {
var row = [], cols = changes[i].querySelectorAll("td, th");
for (var j = 0; j < cols.length; j++) {
row.push('"' + cols[j].innerText + '"');
}
csv.push(row.join(","));
}
var csvFile = new Blob([csv.join("\n")], { type: "text/csv" });
// Create a link to download it
var downloadBatchChanges = document.createElement("a");
downloadBatchChanges.download = filename;
// Create a URL for the link
downloadBatchChanges.href = window.URL.createObjectURL(csvFile);
document.body.appendChild(downloadBatchChanges);
downloadBatchChanges.click();
document.body.removeChild(downloadBatchChanges);
}
$timeout($scope.refresh, 0); $timeout($scope.refresh, 0);
}); });
})(); })();