-
Notifications
You must be signed in to change notification settings - Fork 357
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
Add Picture support in Generic Object Definition editor #2339
Conversation
to enable Save button
"ng-model" => "vm.changeImage"} | ||
|
||
:javascript | ||
$(":file").filestyle({placeholder: _("No file chosen"), icon: false}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__
? This is js..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But it's a JS inside a haml. So do we still need the __
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, it can be either placeholder: __("No file chosen"),
or placeholder: "#{_("No file chosen")}",
it is haml, but not ruby unless interpolating
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in fb22a12
vm.picture.extension = 'jpeg'; | ||
} else { | ||
vm.angularForm.generic_object_definition_image_file_status.$setValidity("incompatibleFileType", false); | ||
vm.imageUploadStatus = __("Incompatible image type"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this show the message while the file is still loading? (or is the time really close to 0 even for huge images?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this stage the file upload (or loading) hasn't even begun - it's just being vetted for the right extension.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.. but the file is being processed by the browser, in the background.
So, between you setting this and that onload
event firing, the message will be visible.
Will test.. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh.. sorry, I read the code wrong, no such problem here :). (I thought this happened always, not only on bad type.)
It does feel a bit weird that you have to punch the Upload button after chosing the file, but that's not a blocker, more of a detail for UX :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using the exact same UX in Catalog Explorer as well where we set custom images for Catalog Items. And that UX comes from Bootstrap Filestyle
- http://markusslima.github.io/bootstrap-filestyle/
I did give a shot to "angularize" Bootstrap Filestyle, as in, keep the Upload button disabled until a file is available to be uploaded, but once you run the JS script $(":file").filestyle
, it pretty much disregards all angular directives etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are using the exact same UX in Catalog Explorer ..
Ah, ok, then definitely not a problem here :)
(Though just to be clear, my objection was not to what I see in bootstrap-filestyle, but to the extra button they have to press after they chose the file.)
|
||
$timeout(function() { | ||
vm.angularForm.generic_object_definition_image_file_status.$setValidity("incompatibleFileType", true); | ||
vm.imageUploadStatus = __("Image upload complete"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would a different message make more sense here given this does not actually upload the image yet?
I mean, if I see "Image upload complete" I will think the image is already on the server. (And will wonder why submitting the form takes so long.)
(I guess there's no support for uploading the image in the background yet, right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Image upload complete" is just a helpful acknowledgement to the user that the chosen file is now ready to be saved.
LMK if you have other wording suggestions for that message.
I guess there's no support for uploading the image in the background yet, right?
No background support - it all happens in the main thread.
In my testing so far, I haven't come across a situation where the file loading is like a really lengthy, time-consuming operation -- it has been almost instantaneous in my tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Take a 40 MB png file, and connect to manageiq running on the network, not on localhost.
And suddenly it takes about 40 seconds to upload (and 2s to even show the spinner :)).
But I guess we don't have to optimize for such huge image users quite yet, but I wouldn't mislead them either .. what about "Image will be uploaded when you submit the form"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Will change that text.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thoughts, saying "...submit the form" sounds a bit techy, let's try and keep it very generic.
How about "Image is ready to be uploaded"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in fb22a12
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better, thanks! :)
@@ -76,6 +81,8 @@ function genericObjectDefinitionFormController(API, miqService, $q) { | |||
|
|||
assignAllObjectsToKeyValueArrays(true); | |||
|
|||
vm.pictureReset = ! vm.pictureReset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clicking reset twice will remove the picture?
I guess this should be always vm.pictureReset = false;
? (Unless I'm misunderstanding pictureReset
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vm.pictureReset
is just a toggle to trigger $onChanges
in the custom-image-component
every time Reset
is clicked.
$onChanges
in the custom-image-component
is in-charge of resetting the UI in the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aaah, can you make this explicit please?
Because now it looks like you're just switching the var for no reason, and not actually using it.
(I mean, if you look for pictureReset
in the code, you will just see that you set it to false, and that you negate it here. But never actually read that. .. So it's a bit hard to notice that you're using it for the side effect caused by changing it.)
I would make $onChanges
do that only when changes.pictureReset
, not on any change, unless you're relying on it happening for other changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in fb22a12
Overall LGTM, will test in the morning... (I vaguelly remember IE having some difference in the filetypes, but not sure if relevant here, so I want to check.) |
With this change there is no need for a virtual column for `picture_url_path` as once thought would be necessary. It is important to set `picture.image_href` to undefined in the model to avoid API failure during a Save operation
@lfu Please test. |
} else if (imageFile.type === 'image/jpg') { | ||
vm.picture.extension = 'jpg'; | ||
} else if (imageFile.type === 'image/jpeg') { | ||
vm.picture.extension = 'jpeg'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{"error":{"kind":"bad_request","message":"Failed to update generic object definition - Validation failed: Extension must be a png, jpg, or svg","klass":"Api::BadRequestError"}}
This has to be jpg
as well, not jpeg
.
And it seems like you may want to add a condition for SVG.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in fb22a12
Tested in UI .. except for being unable to upload jpg images, everything seemed to work :). Have not tested in IE as I'm unable to get it working.. so fingers crossed :). (That said, MDN claims IE11 supports |
f421ef0
to
fb22a12
Compare
Checked commits AparnaKarve/manageiq-ui-classic@5486e6b~...fb22a12 with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 app/views/generic_object_definition/show.html.haml
|
Testing looks good 👍 |
Oh, @AparnaKarve I found one more bug, sorry :)..
Expected: Actual: (Otherwise LGTM) |
@himdel Yes, I found that one too, and I'm thinking the fix should be to just hide the How about I do this in a follow-up PR, and close the chapter on this one since the core functionality is in? |
@AparnaKarve follow up sounds good, merging |
Requires - ManageIQ/manageiq-api#116
https://www.pivotaltracker.com/n/projects/1613907/stories/151742686
Automation > Automate > Generic Objects
Create Generic Object Screen
Generic Object Definition Summary Screen
Edit Generic Object Screen