forked from ManageIQ/manageiq-ui-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request ManageIQ#2302 from mzazrivec/get_rid_of_static_ui_…
…lookup_in_helpers app helpers: get rid of ui_lookup() with static string argument
- Loading branch information
Showing
37 changed files
with
367 additions
and
196 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
app/assets/javascripts/components/generic_object/custom-image-component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
ManageIQ.angular.app.component('customImageComponent', { | ||
bindings: { | ||
picture: '=', | ||
pictureUploaded: '=', | ||
pictureUrlPath: '@', | ||
pictureReset: '<', | ||
newRecord: '<', | ||
angularForm: '<', | ||
}, | ||
controllerAs: 'vm', | ||
controller: customImageComponentController, | ||
templateUrl: '/static/generic_object/custom-image-component.html.haml', | ||
}); | ||
|
||
customImageComponentController.$inject = ['$timeout']; | ||
|
||
function customImageComponentController($timeout) { | ||
var vm = this; | ||
|
||
vm.$onInit = function() { | ||
vm.changeImage = false; | ||
vm.imageUploadStatus = ""; | ||
}; | ||
|
||
vm.$onChanges = function() { | ||
vm.changeImage = false; | ||
vm.imageUploadStatus = ""; | ||
vm.angularForm.generic_object_definition_image_file_status.$setValidity("incompatibleFileType", true); | ||
angular.element(":file").filestyle('clear'); | ||
}; | ||
|
||
vm.uploadClicked = function() { | ||
var reader = new FileReader(); | ||
var imageFile = angular.element('#generic_object_definition_image_file')[0].files[0]; | ||
vm.imageUploadStatus = ""; | ||
|
||
if (imageFile === undefined) { | ||
return; | ||
} | ||
|
||
if (imageFile.type === 'image/png') { | ||
vm.picture.extension = 'png'; | ||
} else if (imageFile.type === 'image/jpg') { | ||
vm.picture.extension = 'jpg'; | ||
} else if (imageFile.type === 'image/jpeg') { | ||
vm.picture.extension = 'jpeg'; | ||
} else { | ||
vm.angularForm.generic_object_definition_image_file_status.$setValidity("incompatibleFileType", false); | ||
vm.imageUploadStatus = __("Incompatible image type"); | ||
return; | ||
} | ||
|
||
reader.onload = function(event) { | ||
vm.picture.content = btoa(event.target.result); | ||
|
||
$timeout(function(){ | ||
vm.angularForm.generic_object_definition_image_file_status.$setValidity("incompatibleFileType", true); | ||
vm.imageUploadStatus = __("Image upload complete"); | ||
vm.pictureUploaded = true; | ||
}); | ||
}; | ||
|
||
if (imageFile) { | ||
reader.readAsBinaryString(imageFile); | ||
} | ||
}; | ||
|
||
vm.changeImageSelected = function() { | ||
if (!vm.changeImage) { | ||
vm.angularForm.generic_object_definition_image_file_status.$setValidity("incompatibleFileType", true); | ||
vm.imageUploadStatus = ""; | ||
$(":file").filestyle('clear'); | ||
} | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.