From a70761c096192e38800bf38d6c7f61f52bf72007 Mon Sep 17 00:00:00 2001 From: hb123f Date: Wed, 20 Mar 2019 12:20:44 -0400 Subject: CADI AAF Integration and merging the code Issue-ID: PORTAL-319 CADI AAF Integration and code merge Change-Id: I6e44f3b2741858d8d403b77a49ec9a0153084801 Signed-off-by: hb123f --- .../widget-details.controller.js | 38 ++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) (limited to 'ecomp-portal-FE-common/client/app/views/widget-onboarding/widget-details-dialog/widget-details.controller.js') 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); + } + } + }]); })(); -- cgit 1.2.3-korg