-
Notifications
You must be signed in to change notification settings - Fork 356
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
Use browser's native printing dialog when exporting summaries to PDF #3998
Conversation
This pull request is not mergeable. Please rebase and repush. |
e2ca0c8
to
f46fd13
Compare
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.
Tested. Looks good
ping @dclarizio. This is the approach that allows us not to use Prince for some printing. We can use it to gradularly replace the printing. Also this allows us to enable printing in ManageIQ (not CF). @skateman : I thing you should replace |
@martinpovolny in general I would like to replace the button's icon and text to be more descriptive. What do you think about a printer icon and the text |
I'll try to test this today to see how it "feels" :) |
@skateman I tried to test this, but don't see the PDF download button on the summary screens: Perhaps this is still using the check for Prince being installed (which I don't have) to decide whether or not to show the button? If so, need to remove that check, but only for the summary screen buttons as we will still use Prince for list view PDF downloads. |
@dclarizio yup fixed, I also updated the icon and the tooltip to be more descriptive. |
@@ -29,11 +29,12 @@ class ApplicationHelper::Toolbar::DashboardSummaryToggleView < ApplicationHelper | |||
button_group('summary_download', [ | |||
button( | |||
:download_view, | |||
'fa fa-file-pdf-o fa-lg', | |||
N_('Download summary in PDF format'), | |||
'fa fa-print fa-lg', |
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.
@skateman Please change to "pficon pficon-print fa-lg"
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.
@epwinchell fixed
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.
@skateman Thanks
4c4bbef
to
5953f81
Compare
Tested in FF and Chrome . . . works well, but in FF the window doesn't auto close and in Chrome you have to check the box to print background images. I think the Chrome setting should be documented. @skateman please take a look at the codeclimate issue to see if it can be resolved, then we're ready to merge. |
@martinpovolny can you review/approve? |
25ceb26
to
35c0280
Compare
Checked commit skateman@5303854 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 **
|
Our current implementation of exporting to PDF does not support JavaScript execution, i.e. all the Angular/React components are not visible. As I converted the quadicons and @martinpovolny did the same with textual summaries it is necessary to do something about it. So here are the options I've found:
Rendering the components on the server-side (headless browser or just some NodeJS magic) would require major changes on the appliance and it would consume a lot of resources.
Rendering the components on the client-side and passing it to the server would be the easiest to do, but it might expose us to some new security issues. We can't assume that the components are all rendered on the given page where the user clicks on the Export to PDF button. Also the new components don't have support for inline base64 encoded images .
Rendering the components on the client-side and using the browser's native PDF printing feature seemed pretty easy. There are some CSS features that aren't fully supported (headers/footers) by the browser, but if they aren't really necessary, this solution is to simplest to implement.
I looked into all of these and chose the last one to be implemented. The existing PDF exporting buttons are now opening a new window and return a HTML with a reduced set of assets and a piece of JavaScript code that's responsible for opening the printing dialog and closing the window after the printing is finished/cancelled.
Instead of the header on each page I added a
<h1>
with the entity name and the creation date that was in the footer is now on the bottom of the summary.However, this solution is not ideal, we are appending a lot of custom styling to the page that's maintained by us and it's highly unstable. IMO these stylings should be included in patternfly somehow as
@media @print
rules. /cc @LHinsonRFE BZ: https://bugzilla.redhat.com/show_bug.cgi?id=1588072
Related issue: #4113
@miq-bot add_reviewer @martinpovolny
@miq-bot add_reviewer @epwinchell
@miq-bot add_label gaprindashvili/no, enhancement