Resolve issues with theme changes.

Add new clear api's
This commit is contained in:
Tim Bentley 2020-05-20 07:40:23 +00:00
parent 8d58fb76ca
commit 67f4a0cc81
3 changed files with 34 additions and 2 deletions

View File

@ -38,6 +38,7 @@ log = logging.getLogger(__name__)
@controller_views.route('/live-item') @controller_views.route('/live-item')
def controller_text_api(): def controller_text_api():
log.debug('controller-v2-live-item')
live_controller = Registry().get('live_controller') live_controller = Registry().get('live_controller')
current_item = live_controller.service_item current_item = live_controller.service_item
data = [] data = []
@ -85,6 +86,7 @@ def controller_text_api():
@controller_views.route('/show', methods=['POST']) @controller_views.route('/show', methods=['POST'])
@login_required @login_required
def controller_set(): def controller_set():
log.debug('controller-v2-show-post')
data = request.json data = request.json
if not data: if not data:
log.error('Missing request data') log.error('Missing request data')
@ -97,6 +99,7 @@ def controller_set():
@controller_views.route('/progress', methods=['POST']) @controller_views.route('/progress', methods=['POST'])
@login_required @login_required
def controller_direction(): def controller_direction():
log.debug('controller-v2-progress-post')
ALLOWED_ACTIONS = ['next', 'previous'] ALLOWED_ACTIONS = ['next', 'previous']
data = request.json data = request.json
if not data: if not data:
@ -114,6 +117,7 @@ def controller_direction():
@controller_views.route('/theme-level', methods=['GET']) @controller_views.route('/theme-level', methods=['GET'])
@login_required @login_required
def get_theme_level(): def get_theme_level():
log.debug('controller-v2-theme-level-get')
theme_level = Registry().get('settings').value('themes/theme level') theme_level = Registry().get('settings').value('themes/theme level')
if theme_level == ThemeLevel.Global: if theme_level == ThemeLevel.Global:
theme_level = 'global' theme_level = 'global'
@ -127,6 +131,7 @@ def get_theme_level():
@controller_views.route('/theme-level', methods=['POST']) @controller_views.route('/theme-level', methods=['POST'])
@login_required @login_required
def set_theme_level(): def set_theme_level():
log.debug('controller-v2-theme-level-post')
data = request.json data = request.json
if not data: if not data:
log.error('Missing request data') log.error('Missing request data')
@ -139,10 +144,13 @@ def set_theme_level():
abort(400) abort(400)
if theme_level == 'global': if theme_level == 'global':
Registry().get('settings').setValue('themes/theme level', 1) Registry().get('settings').setValue('themes/theme level', 1)
Registry().execute('theme_update_global')
elif theme_level == 'service': elif theme_level == 'service':
Registry().get('settings').setValue('themes/theme level', 2) Registry().get('settings').setValue('themes/theme level', 2)
Registry().execute('theme_update_service')
elif theme_level == 'song': elif theme_level == 'song':
Registry().get('settings').setValue('theme/theme level', 3) Registry().get('settings').setValue('themes/theme level', 3)
Registry().execute('theme_update_global')
else: else:
log.error('Unsupported data passed ' + theme_level) log.error('Unsupported data passed ' + theme_level)
abort(400) abort(400)
@ -152,6 +160,7 @@ def set_theme_level():
@controller_views.route('/themes', methods=['GET']) @controller_views.route('/themes', methods=['GET'])
@login_required @login_required
def get_themes(): def get_themes():
log.debug('controller-v2-themes-get')
theme_level = Registry().get('settings').value('themes/theme level') theme_level = Registry().get('settings').value('themes/theme level')
theme_list = [] theme_list = []
current_theme = '' current_theme = ''
@ -182,6 +191,7 @@ def get_theme():
""" """
Get the current theme Get the current theme
""" """
log.debug('controller-v2-theme-get')
theme_level = Registry().get('settings').value('themes/theme level') theme_level = Registry().get('settings').value('themes/theme level')
if theme_level == ThemeLevel.Service: if theme_level == ThemeLevel.Service:
theme = Registry().get('settings').value('servicemanager/service theme') theme = Registry().get('settings').value('servicemanager/service theme')
@ -193,6 +203,7 @@ def get_theme():
@controller_views.route('/theme', methods=['POST']) @controller_views.route('/theme', methods=['POST'])
@login_required @login_required
def set_theme(): def set_theme():
log.debug('controller-v2-themes-post')
data = request.json data = request.json
theme = '' theme = ''
theme_level = Registry().get('settings').value('themes/theme level') theme_level = Registry().get('settings').value('themes/theme level')
@ -214,3 +225,19 @@ def set_theme():
log.error('Unimplemented method') log.error('Unimplemented method')
return '', 501 return '', 501
return '', 204 return '', 204
@controller_views.route('/clear/<controller>', methods=['POST'])
@login_required
def controller_clear(controller):
"""
Clears the slide controller display
:param controller: the Live or Preview controller
:return: HTTP return code
"""
log.debug(f'controller-v2-clear-get {controller}')
if controller in ['live', 'preview']:
getattr(Registry().get(f'{controller}_controller'), f'slidecontroller_{controller}_clear').emit()
return '', 204
else:
return '', 404

View File

@ -52,7 +52,7 @@ def service_items():
'ccli_number': str(ccli_number), 'ccli_number': str(ccli_number),
'notes': str(service_item.notes), 'notes': str(service_item.notes),
'selected': (service_item.unique_identifier == current_unique_identifier), 'selected': (service_item.unique_identifier == current_unique_identifier),
'is_valid': str(service_item.is_valid) 'is_valid': service_item.is_valid
}) })
return jsonify(service_items) return jsonify(service_items)

View File

@ -505,9 +505,12 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
getattr(self, getattr(self,
'slidecontroller_{}_previous'.format(self.type_prefix)).connect(self.on_slide_selected_previous) 'slidecontroller_{}_previous'.format(self.type_prefix)).connect(self.on_slide_selected_previous)
if self.is_live: if self.is_live:
getattr(self, 'slidecontroller_live_clear').connect(self.on_clear)
self.mediacontroller_live_play.connect(self.media_controller.on_media_play) self.mediacontroller_live_play.connect(self.media_controller.on_media_play)
self.mediacontroller_live_pause.connect(self.media_controller.on_media_pause) self.mediacontroller_live_pause.connect(self.media_controller.on_media_pause)
self.mediacontroller_live_stop.connect(self.media_controller.on_media_stop) self.mediacontroller_live_stop.connect(self.media_controller.on_media_stop)
else:
getattr(self, 'slidecontroller_preview_clear').connect(self.on_clear)
def new_song_menu(self): def new_song_menu(self):
""" """
@ -1485,6 +1488,7 @@ class PreviewController(RegistryBase, SlideController):
slidecontroller_preview_set = QtCore.pyqtSignal(list) slidecontroller_preview_set = QtCore.pyqtSignal(list)
slidecontroller_preview_next = QtCore.pyqtSignal() slidecontroller_preview_next = QtCore.pyqtSignal()
slidecontroller_preview_previous = QtCore.pyqtSignal() slidecontroller_preview_previous = QtCore.pyqtSignal()
slidecontroller_preview_clear = QtCore.pyqtSignal()
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
""" """
@ -1511,6 +1515,7 @@ class LiveController(RegistryBase, SlideController):
slidecontroller_live_next = QtCore.pyqtSignal() slidecontroller_live_next = QtCore.pyqtSignal()
slidecontroller_live_previous = QtCore.pyqtSignal() slidecontroller_live_previous = QtCore.pyqtSignal()
slidecontroller_toggle_display = QtCore.pyqtSignal(str) slidecontroller_toggle_display = QtCore.pyqtSignal(str)
slidecontroller_live_clear = QtCore.pyqtSignal()
mediacontroller_live_play = QtCore.pyqtSignal() mediacontroller_live_play = QtCore.pyqtSignal()
mediacontroller_live_pause = QtCore.pyqtSignal() mediacontroller_live_pause = QtCore.pyqtSignal()
mediacontroller_live_stop = QtCore.pyqtSignal() mediacontroller_live_stop = QtCore.pyqtSignal()