metacatui icon indicating copy to clipboard operation
metacatui copied to clipboard

Support Markdown in metadig report view

Open jeanetteclark opened this issue 1 year ago • 1 comments

Describe the feature you'd like

Rendering Markdown using showdown.js on metadig reports would give us a lot of flexibility to create much better looking reports.

Is your feature request related to a problem? Please describe.

We would like to show some informational checks with tables showing summaries of files. For example

"\nTable: Data summary\n\n|                         |     |\n|:------------------------|:----|\n|Name                     |df   |\n|Number of rows           |56   |\n|Number of columns        |2    |\n|_______________________  |     |\n|Column type frequency:   |     |\n|character                |2    |\n|________________________ |     |\n|Group variables          |None |\n\n\n**Variable type: character**\n\n|skim_variable        | n_missing| complete_rate| min| max| empty| n_unique| whitespace|\n|:--------------------|---------:|-------------:|---:|---:|-----:|--------:|----------:|\n|X                    |         0|             1|   0|  34|     8|       42|          0|\n|For.all.Sample.types |         0|             1|   0| 979|     6|       49|          0|\n\n"

would look like:

Screen Shot 2024-04-30 at 5 03 57 PM

(except without the colors maybe)

Right now the best we have is:

Screen Shot 2024-04-30 at 4 35 42 PM

which is not so readable.

I'd argue that this functionality is basically a requirement for the data quality suite to proceed. @mbjones can also weigh in on priority

jeanetteclark avatar May 01 '24 00:05 jeanetteclark

@jeanetteclark Fully agree that markdown support in check results would be super useful.

I briefly looked into how we handle this in the current system. Basically, there is a MdqRunView that renders the report runs by 1) fetching the report from solr, 2) parsing it into a model collection named QualityReport, and 3) passing the data from that report model to a template to be rendered.

The result output then gets rendered in the template by iterating over the results, and creating either an img tag or a span with class check-output based on the type of the output. See: https://github.com/NCEAS/metacatui/blob/main/src/js/templates/mdqRun.html#L274-L279

To add markdown support should be a matter of inserting a new block for markdown type outputs -- basically an else if in the view logic in a couple of places. See the current markdown template here: https://github.com/NCEAS/metacatui/blob/main/src/js/templates/markdown.html along with the associated MarkdownView that renders the Markdown. I think you could reuse a lot of this, and it may involve inserting a directive like <div class="markdown"><%- output.value %></div> in the report template in the output block around line 277.

I hope @robyngit can help guide us on what the approach would be to integrating the MarkdownView into the quality reports.

mbjones avatar May 01 '24 03:05 mbjones

data-quality-result-example.txt

Here's an example run with some markdown

jeanetteclark avatar Aug 28 '24 16:08 jeanetteclark

example-output-json.txt

@robyngit let me know if this looks ok

jeanetteclark avatar Aug 29 '24 19:08 jeanetteclark

Hey @robyngit - turns out the schema already supports multiple output fields so I can just add an attribute to it. How would an output like this fit into the MVP?

multi-output.txt

jeanetteclark avatar Sep 05 '24 22:09 jeanetteclark

@jeanetteclark It works with the current PR no problem! 💃🏻 Screenshot 2024-09-09 at 9 34 31 AM

For the next release, maybe we could think about how to show or link to these per-file results from the main dataset landing page.

robyngit avatar Sep 09 '24 13:09 robyngit