Skip to content

Commit

Permalink
user API for metadata viewer plugin (#1634)
Browse files Browse the repository at this point in the history
* user API for metadata viewer plugin
* rename user-label from "Metadata Viewer" to "Metadata"

Co-authored-by: P. L. Lim <[email protected]>
  • Loading branch information
kecnry and pllim authored Sep 15, 2022
1 parent ce96985 commit d351f25
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ New Features
in Jy [#1564]

- User-friendly API access to plugins, with exposed functionality for: line analysis, gaussian
smooth, moment maps, compass, and collapse. [#1401, #1642, #1643, #1636, #1641]
smooth, moment maps, compass, collapse, and metadata. [#1401, #1642, #1643, #1636, #1641, #1634]

Cubeviz
^^^^^^^
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,32 @@

from jdaviz.core.registries import tray_registry
from jdaviz.core.template_mixin import PluginTemplateMixin, DatasetSelectMixin
from jdaviz.core.user_api import PluginUserApi
from jdaviz.utils import PRIHDR_KEY, COMMENTCARD_KEY

__all__ = ['MetadataViewer']


@tray_registry('g-metadata-viewer', label="Metadata Viewer")
@tray_registry('g-metadata-viewer', label="Metadata")
class MetadataViewer(PluginTemplateMixin, DatasetSelectMixin):
"""
See the :ref:`Metadata Viewer Plugin Documentation <imviz_metadata-viewer>` for more details.
Only the following attributes and methods are available through the
:ref:`public plugin API <plugin-apis>`:
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.show`
* :meth:`~jdaviz.core.template_mixin.PluginTemplateMixin.open_in_tray`
* ``dataset`` (:class:`~jdaviz.core.template_mixin.DatasetSelect`):
Dataset to expose the metadata.
* :attr:`show_primary`:
Whether to show MEF primary header metadata instead.
* :attr:`metadata`:
Read-only metadata. If the data is loaded from a multi-extension FITS file,
this can be the extension header or the primary header, depending on
``show_primary`` setting.
"""
template_file = __file__, "metadata_viewer.vue"
has_metadata = Bool(False).tag(sync=True)
has_primary = Bool(False).tag(sync=True)
Expand All @@ -21,6 +40,10 @@ def __init__(self, *args, **kwargs):
# override the default filters on dataset entries to require metadata in entries
self.dataset.add_filter('not_from_plugin')

@property
def user_api(self):
return PluginUserApi(self, expose=('dataset', 'show_primary'), readonly=('metadata',))

def reset(self):
self.has_metadata = False
self.has_primary = False
Expand Down

0 comments on commit d351f25

Please sign in to comment.