diff --git a/build/docker/api/application.conf b/build/docker/api/application.conf index f3d2e8ef2..6a5dd8732 100644 --- a/build/docker/api/application.conf +++ b/build/docker/api/application.conf @@ -351,6 +351,10 @@ akka.http { # Set to `infinite` to disable. bind-timeout = 5s + # A default request timeout is applied globally to all routes and can be configured using the + # akka.http.server.request-timeout setting (which defaults to 20 seconds). + # request-timeout = 60s + # Show verbose error messages back to the client verbose-error-messages = on } diff --git a/modules/api/src/it/resources/application.conf b/modules/api/src/it/resources/application.conf index dd3b7006e..f96a2c5e5 100644 --- a/modules/api/src/it/resources/application.conf +++ b/modules/api/src/it/resources/application.conf @@ -348,6 +348,10 @@ akka.http { # Set to `infinite` to disable. bind-timeout = 5s + # A default request timeout is applied globally to all routes and can be configured using the + # akka.http.server.request-timeout setting (which defaults to 20 seconds). + # request-timeout = 60s + # Show verbose error messages back to the client verbose-error-messages = on } diff --git a/modules/api/src/main/resources/application.conf b/modules/api/src/main/resources/application.conf index c1ee28ca9..68b519c26 100644 --- a/modules/api/src/main/resources/application.conf +++ b/modules/api/src/main/resources/application.conf @@ -367,6 +367,10 @@ akka.http { # Set to `infinite` to disable. bind-timeout = 5s + # A default request timeout is applied globally to all routes and can be configured using the + # akka.http.server.request-timeout setting (which defaults to 20 seconds). + # request-timeout = 60s + # Show verbose error messages back to the client verbose-error-messages = on } diff --git a/modules/api/src/universal/conf/application.conf b/modules/api/src/universal/conf/application.conf index ff70827df..56008f0a7 100644 --- a/modules/api/src/universal/conf/application.conf +++ b/modules/api/src/universal/conf/application.conf @@ -352,6 +352,10 @@ akka.http { # Set to `infinite` to disable. bind-timeout = 5s + # A default request timeout is applied globally to all routes and can be configured using the + # akka.http.server.request-timeout setting (which defaults to 20 seconds). + # request-timeout = 60s + # Show verbose error messages back to the client verbose-error-messages = on } diff --git a/modules/docs/src/main/mdoc/operator/config-api.md b/modules/docs/src/main/mdoc/operator/config-api.md index 37026de6c..c25243e51 100644 --- a/modules/docs/src/main/mdoc/operator/config-api.md +++ b/modules/docs/src/main/mdoc/operator/config-api.md @@ -990,7 +990,10 @@ dotted-hosts = { # The time period within which the TCP binding process must be completed. # Set to `infinite` to disable. bind-timeout = 5s - + # A default request timeout is applied globally to all routes and can be configured using the + # akka.http.server.request-timeout setting (which defaults to 20 seconds). + # request-timeout = 60s + # Show verbose error messages back to the client verbose-error-messages = on } diff --git a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlBatchChangeRepository.scala b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlBatchChangeRepository.scala index d06959ba6..48458d09a 100644 --- a/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlBatchChangeRepository.scala +++ b/modules/mysql/src/main/scala/vinyldns/mysql/repository/MySqlBatchChangeRepository.scala @@ -17,9 +17,9 @@ package vinyldns.mysql.repository import java.sql.Timestamp - import cats.data._ import cats.effect._ + import java.time.Instant import org.slf4j.LoggerFactory import scalikejdbc._ @@ -166,8 +166,8 @@ class MySqlBatchChangeRepository } def getBatchFromSingleChangeId( - singleChangeId: String - )(implicit s: DBSession): Option[BatchChange] = + singleChangeId: String + )(implicit s: DBSession): Option[BatchChange] = GET_BATCH_CHANGE_METADATA_FROM_SINGLE_CHANGE .bind(singleChangeId) .map(extractBatchChange(None)) @@ -181,12 +181,9 @@ class MySqlBatchChangeRepository .apply() batchMeta.copy(changes = changes) } - monitor("repo.BatchChangeJDBC.updateSingleChanges") { IO { - logger.info( - s"Updating single change statuses: ${singleChanges.map(ch => (ch.id, ch.status))}" - ) + logger.info(s"Updating single change status: ${singleChanges.map(ch => (ch.id, ch.status))}") DB.localTx { implicit s => for { headChange <- singleChanges.headOption @@ -194,8 +191,7 @@ class MySqlBatchChangeRepository _ = UPDATE_SINGLE_CHANGE.batchByName(batchParams: _*).apply() batchChange <- getBatchFromSingleChangeId(headChange.id) } yield batchChange - } - } + }} } } diff --git a/modules/portal/app/models/Meta.scala b/modules/portal/app/models/Meta.scala index b04e18cf0..a5db1af77 100644 --- a/modules/portal/app/models/Meta.scala +++ b/modules/portal/app/models/Meta.scala @@ -32,7 +32,7 @@ object Meta { Meta( config.getOptional[String]("vinyldns.version").getOrElse("unknown"), config.getOptional[Boolean]("shared-display-enabled").getOrElse(false), - config.getOptional[Int]("batch-change-limit").getOrElse(1000), + config.getOptional[Int]("api.limits.batchchange-routing-max-items-limit").getOrElse(1000), config.getOptional[Long]("default-ttl").getOrElse(7200L), config.getOptional[Boolean]("manual-batch-review-enabled").getOrElse(false), config.getOptional[Boolean]("scheduled-changes-enabled").getOrElse(false), diff --git a/modules/portal/app/views/dnsChanges/dnsChangeNew.scala.html b/modules/portal/app/views/dnsChanges/dnsChangeNew.scala.html index 712de04c2..4ca86c4c9 100644 --- a/modules/portal/app/views/dnsChanges/dnsChangeNew.scala.html +++ b/modules/portal/app/views/dnsChanges/dnsChangeNew.scala.html @@ -326,7 +326,7 @@ - +

See documentation for sample CSV

Limit reached. Cannot add more than {{batchChangeLimit}} records per DNS change.

@@ -336,6 +336,9 @@
+ {{ confirmationPrompt }} There were errors, please review the highlighted rows and then proceed. diff --git a/modules/portal/public/lib/dns-change/dns-change-new.controller.js b/modules/portal/public/lib/dns-change/dns-change-new.controller.js index 1297d061a..931426f9a 100644 --- a/modules/portal/public/lib/dns-change/dns-change-new.controller.js +++ b/modules/portal/public/lib/dns-change/dns-change-new.controller.js @@ -44,6 +44,7 @@ $scope.manualReviewEnabled; $scope.naptrFlags = ["U", "S", "A", "P"]; + $scope.addSingleChange = function() { $scope.newBatch.changes.push({changeType: "Add", type: "A+PTR"}); var changesLength = $scope.newBatch.changes.length; @@ -161,14 +162,14 @@ $scope.alerts.push(alert); } - $scope.uploadCSV = function(file) { - parseFile(file).then(function(dataLength){ - $scope.alerts.push({type: 'success', content: 'Successfully imported ' + dataLength + ' changes.' }); + $scope.uploadCSV = function(file, batchChangeLimit) { + parseFile(file, batchChangeLimit).then(function(dataLength){ + $scope.alerts.push({type: 'success', content: 'Successfully imported ' + dataLength + ' DNS changes.' }); }, function(error) { $scope.alerts.push({type: 'danger', content: error}); }); - function parseFile(file) { + function parseFile(file, batchChangeLimit) { return $q(function(resolve, reject) { if (!file.name.endsWith('.csv')) { reject("Import failed. File should be of ‘.csv’ type."); @@ -177,6 +178,9 @@ var reader = new FileReader(); reader.onload = function(e) { var rows = e.target.result.split("\n"); + if(rows.length - 1 > batchChangeLimit) + {reject("Import failed. Cannot add more than " + batchChangeLimit + " records per DNS change."); + } else { if (rows[0].trim() == "Change Type,Record Type,Input Name,TTL,Record Data") { $scope.newBatch.changes = []; for(var i = 1; i < rows.length; i++) { @@ -186,10 +190,10 @@ } $scope.$apply() resolve($scope.newBatch.changes.length); - } else { + } else { reject("Import failed. CSV header must be: Change Type,Record Type,Input Name,TTL,Record Data"); } - } + }} reader.readAsText(file); } }); diff --git a/modules/portal/public/lib/dns-change/dns-change.service.js b/modules/portal/public/lib/dns-change/dns-change.service.js index 8103e1e2d..5d84a6abf 100644 --- a/modules/portal/public/lib/dns-change/dns-change.service.js +++ b/modules/portal/public/lib/dns-change/dns-change.service.js @@ -30,7 +30,17 @@ "allowManualReview": allowManualReview } var url = utilityService.urlBuilder('/api/dnschanges', params); - return $http.post(url, data, {headers: utilityService.getCsrfHeader()}); + let loader = $("#loader"); + loader.modal({ + backdrop: "static", + keyboard: false, //remove option to close with keyboard + show: true //Display loader! + }) + let promis = $http.post(url, data, {headers: utilityService.getCsrfHeader()}); + // Hide loader when api gets response + promis.then(()=>loader.modal("hide")) + .catch(()=>loader.modal("hide")) + return promis }; this.getBatchChanges = function (maxItems, startFrom, ignoreAccess, approvalStatus, userName, dateTimeRangeStart, dateTimeRangeEnd) { diff --git a/modules/portal/test/models/MetaSpec.scala b/modules/portal/test/models/MetaSpec.scala index 2bea1b3b3..cee972091 100644 --- a/modules/portal/test/models/MetaSpec.scala +++ b/modules/portal/test/models/MetaSpec.scala @@ -34,7 +34,7 @@ class MetaSpec extends Specification with Mockito { Meta(Configuration.from(config)).sharedDisplayEnabled must beTrue } "get the batch-change-limit value in config" in { - val config = Map("batch-change-limit" -> 21) + val config = Map("api.limits.batchchange-routing-max-items-limit" -> 21) Meta(Configuration.from(config)).batchChangeLimit must beEqualTo(21) } "default to 1000 if batch-change-limit is not found" in { diff --git a/test/api/functional/application.conf b/test/api/functional/application.conf index e0f35df07..5c7f48aa3 100644 --- a/test/api/functional/application.conf +++ b/test/api/functional/application.conf @@ -302,6 +302,10 @@ akka.http { # Set to `infinite` to disable. bind-timeout = 5s + # A default request timeout is applied globally to all routes and can be configured using the + # akka.http.server.request-timeout setting (which defaults to 20 seconds). + # request-timeout = 60s + # Show verbose error messages back to the client verbose-error-messages = on } diff --git a/test/api/integration/application.conf b/test/api/integration/application.conf index c09038a85..e7c8c20e1 100644 --- a/test/api/integration/application.conf +++ b/test/api/integration/application.conf @@ -360,6 +360,10 @@ akka.http { # Set to `infinite` to disable. bind-timeout = 5s + # A default request timeout is applied globally to all routes and can be configured using the + # akka.http.server.request-timeout setting (which defaults to 20 seconds). + # request-timeout = 60s + # Show verbose error messages back to the client verbose-error-messages = on }