Skip to content

Commit d9f72eb

Browse files
author
TAO Xinxiu (Isabelle)
authored
fix the bug of uploading files in the debug info disabled environment. (#500)
1 parent 22863bf commit d9f72eb

File tree

5 files changed

+33
-12
lines changed

5 files changed

+33
-12
lines changed

app/scripts/directives.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,23 @@ function showDropdownFromTemplate($document, $timeout, $uibPosition) {
351351
}
352352
}
353353

354+
/**
355+
* Upload the file, call the function specified in "input-file-change" attribute on change event.
356+
*/
357+
function inputFileChange($parse, $timeout) {
358+
return {
359+
restrict: 'A',
360+
link: function (scope, element, attrs) {
361+
var onChangeHandler = $parse(attrs.inputFileChange);
362+
element.bind('change', function() {
363+
$timeout (function () {
364+
onChangeHandler(scope);
365+
});
366+
});
367+
}
368+
};
369+
}
370+
354371
/**
355372
* Displays a tooltip that shows the whole text of a truncated element (by ellipsis or else)
356373
* Requires using a "tooltip-enable=true" attribute and set by default to true.
@@ -402,4 +419,5 @@ angular
402419
.directive('slimScroll', slimScroll)
403420
.directive('backTop', backToTop)
404421
.directive('showDropdownFromTemplate', showDropdownFromTemplate)
422+
.directive('inputFileChange', inputFileChange)
405423
.directive('ellipsisTooltip', ellipsisTooltip);

app/scripts/modals/file-browser-modal-controller.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,9 @@ angular.module('workflow-variables').controller('FileBrowserModalCtrl', function
171171
$('#selected-upload-file').click();
172172
}
173173

174-
$scope.fileSelected = function(files) {
175-
var selectedFile = files[0];
174+
$scope.fileSelected = function() {
175+
var element = document.getElementById('selected-upload-file');
176+
var selectedFile = element.files[0];
176177
if (selectedFile) {
177178
var pathname = $scope.currentPath + selectedFile.name;
178179
if (selectedFile.name.includes(':')) {
@@ -185,6 +186,8 @@ angular.module('workflow-variables').controller('FileBrowserModalCtrl', function
185186
$scope.refreshFiles();
186187
}, function () {});
187188
}
189+
// clean up the value to allow the user to upload twice the file with same name, otherwise the function won't be triggered.
190+
element.value = '';
188191
}
189192

190193
$scope.createFolder = function() {

app/templates_versions/common/app.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* INSPINIA - Responsive Admin Theme
33
*
44
*/
5-
(function () {
5+
(function() {
66
angular.module('inspinia', [
77
'ui.router', // Routing
88
'ui.bootstrap', // Bootstrap
@@ -27,20 +27,20 @@
2727
'gantt.corner'
2828
])
2929
.config(['momentPickerProvider',
30-
function (momentPickerProvider) {
30+
function(momentPickerProvider) {
3131
momentPickerProvider.options({
3232
minutesFormat: 'HH:mm'
3333
});
3434
}
3535
])
3636
.config(['calendarConfig',
37-
function (calendarConfig) {
37+
function(calendarConfig) {
3838
calendarConfig.allDateFormats.moment.date.hour = 'HH:mm';
3939
calendarConfig.showTimesOnWeekView = true;
4040
}
4141
])
4242
.config(['$compileProvider',
43-
function ($compileProvider) {
43+
function($compileProvider) {
4444
$compileProvider.debugInfoEnabled(false);
4545
}
4646
]);

app/templates_versions/common/config.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ function config($stateProvider, $urlRouterProvider) {
4545
angular
4646
.module('inspinia')
4747
.config(config)
48-
.run(function ($rootScope, $state, $interval, $http, $location) {
48+
.run(function($rootScope, $state, $interval, $http, $location) {
4949
$rootScope.$state = $state;
5050
$rootScope.$interval = $interval;
5151
});
5252

5353
angular
5454
.module('inspinia')
55-
.config(function ($httpProvider) {
55+
.config(function($httpProvider) {
5656
$httpProvider.defaults.headers.common = {};
5757
$httpProvider.defaults.headers.post = {};
5858
$httpProvider.defaults.headers.put = {};
@@ -64,13 +64,13 @@ angular
6464

6565
angular
6666
.module('inspinia')
67-
.run(function ($rootScope, $state, $http, $location) {
68-
$rootScope.$on('$locationChangeStart', function (event) {
67+
.run(function($rootScope, $state, $http, $location) {
68+
$rootScope.$on('$locationChangeStart', function(event) {
6969
if (!localStorage['pcaServiceUrl'] || !localStorage['schedulerRestUrl'] || !localStorage['notificationServiceUrl'] || !localStorage['catalogServiceUrl'] || !localStorage['appCatalogWorkflowsUrl'] || !localStorage['appCatalogBucketsUrl'] || !localStorage['configViews'] || !localStorage['rmRestUrl'] || !localStorage['restUrl']) {
7070
getProperties($http, $location);
7171
}
7272
var myDataPromise = isSessionValide($http, getSessionId(), $location);
73-
myDataPromise.then(function (result) {
73+
myDataPromise.then(function(result) {
7474
if (!result && $location.$$url != '/login') {
7575
event.preventDefault();
7676
$rootScope.$broadcast('event:StopRefreshing');

app/views/modals/dataspace-file-browser.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ <h5>
1919
<button id="new-folder-btn" uib-tooltip="{{'New folder'|translate}}" class="btn btn-white" ng-click="createFolder()">
2020
<i class="fa fa fa-plus"></i>
2121
</button>
22-
<input type="file" id="selected-upload-file" onchange="angular.element(this).scope().fileSelected(this.files)" class="hidden" />
22+
<input type="file" id="selected-upload-file" input-file-change="fileSelected()" class="hidden" />
2323
<button id="upload-file-btn" uib-tooltip="{{'Upload a file'|translate}}" class="btn btn-white" ng-click="clickUpload()">
2424
<i class="fa fa-upload"></i>
2525
</button>

0 commit comments

Comments
 (0)