Skip to content
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

New feature/66 browser native dataset file preview #2172

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from

Conversation

luistoptal
Copy link
Collaborator

@luistoptal luistoptal commented Jan 10, 2025

Pull request for issue: #66

This PR adds a preview modal for the dataset table, eg http://gigadb.gigasciencejournal.com/dataset/100094

The video shows a handful of cases
Screencast from 10-01-25 16:20:33.webm

  • images are displayed as simple img elements
  • text files, pdf and html are displayed within an iframe using the native browser behavior
  • other types are filtered out and the preview button is greyed out and disabled

How to test?

In http://gigadb.gigasciencejournal.com/adminFile/create you can add any arbitrary files via their url to any dataset to test the modal, eg
https://s2.q4cdn.com/175719177/files/doc_presentations/Placeholder-PDF.pdf
https://images.pexels.com/photos/378570/pexels-photo-378570.jpeg
http://gigadb.gigasciencejournal.com/
https://raw.githubusercontent.com/gigascience/gigadb-website/refs/heads/develop/README.md
etc

How have functionalities been implemented?

  • added a button to the protected/views/dataset/view.php that opens a modal to preview the file

  • if the file is "not supported" the preview button is disabled. What is supported is defined by protected/views/dataset/view.php:417
    image

  • protected/views/dataset/_preview_modal.php contains the code related to the preview modal. At the core, there is a conditional that determines what to do for each file type:

    • image: render a element
    • files of type TEXT, HTML and PDF: render an iframe pointing to the image location
    • anything else renders a "unsupported" message.
  • this kind of structure is built to be easily extendable by adding more valid cases

  • I have also renamed the id of a preexisting modal to something more meaningful

Any issues with implementation?

--

Any changes to automated tests?

Added acceptance test that checks for the presence of the preview button and that it toggles a preview modal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant