metacatui
metacatui copied to clipboard
Support Markdown in metadig report view
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:
(except without the colors maybe)
Right now the best we have is:
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 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.
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?
@jeanetteclark It works with the current PR no problem! 💃🏻
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.