From 517ea65bc9a44ddd4b99f55b575c8895d3bf2382 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 17 Oct 2016 23:18:19 -0400 Subject: [PATCH] import validation --- src/Web/wwwroot/app/services/importService.js | 5 +++++ src/Web/wwwroot/app/tools/toolsImportController.js | 10 ++++++++-- src/Web/wwwroot/app/tools/views/toolsImport.html | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/Web/wwwroot/app/services/importService.js b/src/Web/wwwroot/app/services/importService.js index b1d62de534..3b7ee0451c 100644 --- a/src/Web/wwwroot/app/services/importService.js +++ b/src/Web/wwwroot/app/services/importService.js @@ -5,6 +5,11 @@ var _service = {}; _service.import = function (source, file, success, error) { + if (!file) { + error(); + return; + } + switch (source) { case 'local': importLocal(file, success, error); diff --git a/src/Web/wwwroot/app/tools/toolsImportController.js b/src/Web/wwwroot/app/tools/toolsImportController.js index 83f8d06da1..574cc94afb 100644 --- a/src/Web/wwwroot/app/tools/toolsImportController.js +++ b/src/Web/wwwroot/app/tools/toolsImportController.js @@ -25,9 +25,15 @@ }, importError); } - function importError() { + function importError(errorMessage) { + $analytics.eventTrack('Import Data Failed', { label: $scope.model.source }); $uibModalInstance.dismiss('cancel'); - toastr.error('Something went wrong. Try again.', 'Oh No!'); + if (errorMessage) { + toastr.error(errorMessage); + } + else { + toastr.error('Something went wrong. Try again.', 'Oh No!'); + } } $scope.close = function () { diff --git a/src/Web/wwwroot/app/tools/views/toolsImport.html b/src/Web/wwwroot/app/tools/views/toolsImport.html index cbe7d40dea..b088d274fe 100644 --- a/src/Web/wwwroot/app/tools/views/toolsImport.html +++ b/src/Web/wwwroot/app/tools/views/toolsImport.html @@ -18,7 +18,7 @@
- +