summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-common/client/app/views/widget-onboarding
diff options
context:
space:
mode:
Diffstat (limited to 'ecomp-portal-FE-common/client/app/views/widget-onboarding')
-rw-r--r--ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.controller.js38
-rw-r--r--ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.modal.html9
2 files changed, 43 insertions, 4 deletions
diff --git a/ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.controller.js b/ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.controller.js
index b6429015..bf0df9f0 100644
--- a/ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.controller.js
+++ b/ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.controller.js
@@ -38,7 +38,7 @@
'use strict';
(function () {
class WidgetOnboardingDetailsModalCtrl {
- constructor($scope, $log, $interval, applicationsService, adminsService, microserviceService, widgetsCatalogService, errorMessageByCode, ECOMP_URL_REGEX, $window,userProfileService, confirmBoxService, $cookies,items) {
+ constructor($scope, $timeout, $log, $interval, applicationsService, adminsService, microserviceService, widgetsCatalogService, errorMessageByCode, ECOMP_URL_REGEX, $window,userProfileService, confirmBoxService, $cookies,items) {
this.appUpdate = function(){
this.hasSelectedApp = false;
@@ -398,12 +398,46 @@
});
}
};
+ // Caches the file name supplied by the event handler.
+ $scope.widgetFileHandler = (event, files) => {
+ if(files[0]){
+ var fileName = files[0].name;
+ var validFormats = ['zip'];
+ //Get file extension
+ var ext = fileName.substring(fileName.lastIndexOf('.') + 1).toLowerCase();
+ //Check for valid format
+ if(validFormats.indexOf(ext) == -1){
+ document.getElementById('widget-onboarding-details-upload-file').value = null;
+ $scope.widgetFileTypeError=true;
+ $timeout(function(){
+ $scope.widgetFileTypeError=false;
+ }, 5000);
+ }
+ }
+ }; // file change handler
+
init();
$scope.$on('$stateChangeStart', e => {
e.preventDefault();
});
}
}
- WidgetOnboardingDetailsModalCtrl.$inject = ['$scope', '$log', '$interval', 'applicationsService', 'adminsService', 'microserviceService', 'widgetsCatalogService', 'errorMessageByCode', 'ECOMP_URL_REGEX', '$window','userProfileService', 'confirmBoxService', '$cookies','items'];
+ WidgetOnboardingDetailsModalCtrl.$inject = ['$scope', '$timeout', '$log', '$interval', 'applicationsService', 'adminsService', 'microserviceService', 'widgetsCatalogService', 'errorMessageByCode', 'ECOMP_URL_REGEX', '$window','userProfileService', 'confirmBoxService', '$cookies','items'];
angular.module('ecompApp').controller('WidgetOnboardingDetailsModalCtrl', WidgetOnboardingDetailsModalCtrl);
+
+ angular.module('ecompApp').directive('fileChange', ['$parse', function($parse){
+ return {
+ require: 'ngModel',
+ restrict: 'A',
+ link : function($scope, element, attrs, ngModel) {
+ var attrHandler = $parse(attrs['fileChange']);
+ var handler=function(e) {
+ $scope.$apply(function() {
+ attrHandler($scope, { $event:e, files:e.target.files } );
+ });
+ };
+ element[0].addEventListener('change',handler,false);
+ }
+ }
+ }]);
})();
diff --git a/ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.modal.html b/ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.modal.html
index ade07b95..3526ce0c 100644
--- a/ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.modal.html
+++ b/ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.modal.html
@@ -150,8 +150,13 @@
<div>
<input id="widget-onboarding-details-upload-file"
file-model="widgetOnboardingDetails.widget.file" type="file"
- class="widget-onboarding-details-upload-file ht" />
-
+ class="widget-onboarding-details-upload-file ht"
+ ng-model="widgetDetails.widgetFile"
+ file-change="widgetFileHandler($event,files)"/>
+ <div class="error-container"
+ ng-show="widgetFileTypeError" class="ng-hide">
+ <div class="err-message">File must be .zip</div>
+ </div>
<div class="error-container"
ng-show="widgetOnboardingDetails.widget.file == undefined && !widgetOnboardingDetails.isEditMode">