Skip to content

fix the bug of uploading files in the debug info disabled environment. #500

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/scripts/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,23 @@ function showDropdownFromTemplate($document, $timeout, $uibPosition) {
}
}

/**
* Upload the file, call the function specified in "input-file-change" attribute on change event.
*/
function inputFileChange($parse, $timeout) {
return {
restrict: 'A',
link: function (scope, element, attrs) {
var onChangeHandler = $parse(attrs.inputFileChange);
element.bind('change', function() {
$timeout (function () {
onChangeHandler(scope);
});
});
}
};
}

/**
* Displays a tooltip that shows the whole text of a truncated element (by ellipsis or else)
* Requires using a "tooltip-enable=true" attribute and set by default to true.
Expand Down Expand Up @@ -402,4 +419,5 @@ angular
.directive('slimScroll', slimScroll)
.directive('backTop', backToTop)
.directive('showDropdownFromTemplate', showDropdownFromTemplate)
.directive('inputFileChange', inputFileChange)
.directive('ellipsisTooltip', ellipsisTooltip);
7 changes: 5 additions & 2 deletions app/scripts/modals/file-browser-modal-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,9 @@ angular.module('workflow-variables').controller('FileBrowserModalCtrl', function
$('#selected-upload-file').click();
}

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

$scope.createFolder = function() {
Expand Down
8 changes: 4 additions & 4 deletions app/templates_versions/common/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* INSPINIA - Responsive Admin Theme
*
*/
(function () {
(function() {
angular.module('inspinia', [
'ui.router', // Routing
'ui.bootstrap', // Bootstrap
Expand All @@ -27,20 +27,20 @@
'gantt.corner'
])
.config(['momentPickerProvider',
function (momentPickerProvider) {
function(momentPickerProvider) {
momentPickerProvider.options({
minutesFormat: 'HH:mm'
});
}
])
.config(['calendarConfig',
function (calendarConfig) {
function(calendarConfig) {
calendarConfig.allDateFormats.moment.date.hour = 'HH:mm';
calendarConfig.showTimesOnWeekView = true;
}
])
.config(['$compileProvider',
function ($compileProvider) {
function($compileProvider) {
$compileProvider.debugInfoEnabled(false);
}
]);
Expand Down
10 changes: 5 additions & 5 deletions app/templates_versions/common/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@ function config($stateProvider, $urlRouterProvider) {
angular
.module('inspinia')
.config(config)
.run(function ($rootScope, $state, $interval, $http, $location) {
.run(function($rootScope, $state, $interval, $http, $location) {
$rootScope.$state = $state;
$rootScope.$interval = $interval;
});

angular
.module('inspinia')
.config(function ($httpProvider) {
.config(function($httpProvider) {
$httpProvider.defaults.headers.common = {};
$httpProvider.defaults.headers.post = {};
$httpProvider.defaults.headers.put = {};
Expand All @@ -64,13 +64,13 @@ angular

angular
.module('inspinia')
.run(function ($rootScope, $state, $http, $location) {
$rootScope.$on('$locationChangeStart', function (event) {
.run(function($rootScope, $state, $http, $location) {
$rootScope.$on('$locationChangeStart', function(event) {
if (!localStorage['pcaServiceUrl'] || !localStorage['schedulerRestUrl'] || !localStorage['notificationServiceUrl'] || !localStorage['catalogServiceUrl'] || !localStorage['appCatalogWorkflowsUrl'] || !localStorage['appCatalogBucketsUrl'] || !localStorage['configViews'] || !localStorage['rmRestUrl'] || !localStorage['restUrl']) {
getProperties($http, $location);
}
var myDataPromise = isSessionValide($http, getSessionId(), $location);
myDataPromise.then(function (result) {
myDataPromise.then(function(result) {
if (!result && $location.$$url != '/login') {
event.preventDefault();
$rootScope.$broadcast('event:StopRefreshing');
Expand Down
2 changes: 1 addition & 1 deletion app/views/modals/dataspace-file-browser.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ <h5>
<button id="new-folder-btn" uib-tooltip="{{'New folder'|translate}}" class="btn btn-white" ng-click="createFolder()">
<i class="fa fa fa-plus"></i>
</button>
<input type="file" id="selected-upload-file" onchange="angular.element(this).scope().fileSelected(this.files)" class="hidden" />
<input type="file" id="selected-upload-file" input-file-change="fileSelected()" class="hidden" />
<button id="upload-file-btn" uib-tooltip="{{'Upload a file'|translate}}" class="btn btn-white" ng-click="clickUpload()">
<i class="fa fa-upload"></i>
</button>
Expand Down