Skip to content

Commit

Permalink
Add mosaic view js
Browse files Browse the repository at this point in the history
  • Loading branch information
ugyballoons committed Sep 6, 2024
1 parent fbcbe3d commit 0650382
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 56 deletions.
46 changes: 5 additions & 41 deletions python/lsst/ts/rubintv/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,56 +70,20 @@ class HasButton(BaseModel):
text_shadow: bool = False


class Camera(HasButton):
"""Represents a camera entity, capable of handling different channels like
images or movies.
class MosaicViewMeta(BaseModel):
channel: str
metaColumns: list[str]

This class extends the Pydantic BaseModel to leverage data validation. It
includes various attributes related to the camera, like its name, online
status, and associated channels. It also provides methods for setting
default values and categorizing channels.
Attributes
----------
online : bool
Indicates whether the camera is online.
metadata_from : str, optional
The source of metadata for the camera. Defaults to an empty string and
uses `name` if not set.
channels : list[Channel]
A list of channels (either images or movies) associated with the
camera. Defaults to an empty list.
night_report_label : str, optional
Label for the night report. Defaults to "Night Report".
metadata_cols : dict[str, str] | None, optional
A dictionary defining metadata columns. Defaults to
None.
image_viewer_link : str, optional
A link to the image viewer. Defaults to an empty string.
copy_row_template : str, optional
Template string for copying a row. Defaults to an empty string.
Methods
-------
default_as_name(cls: Type, v: str, values: Any) -> str
A class method that acts as a field validator for 'metadata_from'. It
defaults to using `name` if `metadata_from` is not set.
seq_channels() -> list[Channel]
Returns a list of sequential channels, i.e., channels that do not have
a per-day configuration.
pd_channels() -> list[Channel]
Returns a list of per-day channels, i.e., channels that have a per-day
configuration.
"""

class Camera(HasButton):
online: bool
metadata_from: str = ""
channels: list[Channel] = []
night_report_label: str = "Night Report"
metadata_cols: dict[str, str] | None = None
image_viewer_link: str = ""
copy_row_template: str = ""
mosaic_view_meta: list[dict[str, list[str]]] = []
mosaic_view_meta: list[MosaicViewMeta] = []

def seq_channels(self) -> list[Channel]:
return [c for c in self.channels if not c.per_day]
Expand Down
23 changes: 13 additions & 10 deletions python/lsst/ts/rubintv/models/models_data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,19 @@ cameras:
colour: "#83daee"

mosaic_view_meta:
- monitor:
- Exposure time
- Airmass
- RA
- Dec
- imexam:
- Exposure time
- PSF-FWHM
- mount:
- Mount motion image degradation
- channel: monitor
metaColumns:
- Exposure time
- Airmass
- RA
- Dec
- channel: imexam
metaColumns:
- Exposure time
- PSF-FWHM
- channel: mount
metaColumns:
- Mount motion image degradation


- name: startracker_narrow
Expand Down
10 changes: 5 additions & 5 deletions python/lsst/ts/rubintv/templates/mosaic.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
{% endblock breadcrumb %}

{% block content %}
<div id="camera-mosaic" class="columns">
{# React MosiacView root here #}
</div>
{% endif %}
<div id="camera-mosaic" class="columns">
{# React MosiacView root here #}
</div>
{% endblock content %}

{% block footer_scripts %}
<script src='{{ url_for("static", path="assets/mosaic-view.js") }}'></script>
{{ super() }}
{% endblock footer_scripts %}
{% endblock footer_scripts %}
15 changes: 15 additions & 0 deletions src/js/pages/mosaic-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { WebsocketClient } from "../modules/ws-service-client"

(function () {
console.log("Am in the function!")
const locationName = document.documentElement.dataset.locationname
const camera = window.APP_DATA.camera || {}
const date = window.APP_DATA.date || ''
const ws = new WebsocketClient()
ws.subscribe('service', 'camera', locationName, camera.name)
camera.mosaic_view_meta.forEach((view) => {
console.log('Subscribing to:', view.channel)
ws.subscribe('service', 'channel', locationName, camera.name, view.channel)
})
})()

1 change: 1 addition & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const pagesWithoutHistory = [
}), {})

const pagesWithHistory = [
'mosaic-view',
'night_report',
'single',
'current',
Expand Down

0 comments on commit 0650382

Please sign in to comment.