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

Add refresh button which updates sound device list #3387

Merged
merged 2 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@
' works on devices with valid sound output.')

else:
devices, indexes = self.build_device_lists()
self.sound_device_indexes = dict(zip(devices, indexes))
self.sound_devices_items = devices
self.sound_devices_selected = dict(zip(indexes, devices))[sd.default.device[1]]
self.sound_device_indexes = None
self.refresh_device_list()

Check warning on line 70 in jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py#L69-L70

Added lines #L69 - L70 were not covered by tests

# TODO: Remove hardcoded range and flux viewer
self.spec_viewer = self.app.get_viewer('spectrum-viewer')
Expand Down Expand Up @@ -118,6 +116,15 @@
didx = dict(zip(*self.build_device_lists()))[event['new']]
self.flux_viewer.update_sound_device(didx)

def refresh_device_list(self):
devices, indexes = self.build_device_lists()
self.sound_device_indexes = dict(zip(devices, indexes))
self.sound_devices_items = devices
self.sound_devices_selected = dict(zip(indexes, devices))[sd.default.device[1]]

Check warning on line 123 in jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py#L120-L123

Added lines #L120 - L123 were not covered by tests

def vue_refresh_device_list_in_dropdown(self, *args):
self.refresh_device_list()

Check warning on line 126 in jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py

View check run for this annotation

Codecov / codecov/patch

jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.py#L126

Added line #L126 was not covered by tests

def build_device_lists(self):
# dedicated function to build the current *output*
# device and index lists
Expand Down
5 changes: 5 additions & 0 deletions jdaviz/configs/cubeviz/plugins/sonify_data/sonify_data.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@
>
Stop stream
</plugin-action-button>
<plugin-action-button
@click="refresh_device_list_in_dropdown"
>
Refresh Device List
</plugin-action-button>
</v-row>
<v-row>
<v-select
Expand Down
Loading