mirror of
https://github.com/ansible/awx.git
synced 2026-01-11 10:00:01 -03:30
File drag-n-drop
Added an onerror handler to the FileReader. If the file cannot be read for some reason, throw an alert dialog letting user know things went wrong.
This commit is contained in:
parent
ca607f2372
commit
5c7152dec1
@ -760,7 +760,7 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
||||
// Support dropping files on an element. Used on credentials page for SSH/RSA private keys
|
||||
// Inspired by https://developer.mozilla.org/en-US/docs/Using_files_from_web_applications
|
||||
//
|
||||
.directive('awDropFile', [ function() {
|
||||
.directive('awDropFile', ['Alert', function(Alert) {
|
||||
return {
|
||||
require: 'ngModel',
|
||||
link: function(scope, element, attrs, ctrl) {
|
||||
@ -783,6 +783,9 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job
|
||||
ctrl.$setViewValue(reader.result);
|
||||
ctrl.$render();
|
||||
};
|
||||
reader.onerror = function() {
|
||||
Alert('Error','There was an error reading the selected file.');
|
||||
}
|
||||
reader.readAsText(files[0]);
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user