From ebe570d42f9a2e70a7bdbb7db2cdcf8577fc70f5 Mon Sep 17 00:00:00 2001 From: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> Date: Tue, 21 Feb 2023 11:12:56 -0800 Subject: [PATCH] Allow setting a custom Pushover sound * Closes #2005 --- data/interfaces/default/css/tautulli.css | 2 - .../interfaces/default/newsletter_config.html | 4 ++ data/interfaces/default/notifier_config.html | 10 +++ plexpy/newsletters.py | 3 +- plexpy/notifiers.py | 69 ++++++++++--------- 5 files changed, 54 insertions(+), 34 deletions(-) diff --git a/data/interfaces/default/css/tautulli.css b/data/interfaces/default/css/tautulli.css index ac99ae76..5f1d90a0 100644 --- a/data/interfaces/default/css/tautulli.css +++ b/data/interfaces/default/css/tautulli.css @@ -79,7 +79,6 @@ select.form-control { color: #eee !important; border: 0px solid #444 !important; background: #555 !important; - padding: 1px 2px; transition: background-color .3s; } .selectize-control.form-control .selectize-input { @@ -87,7 +86,6 @@ select.form-control { align-items: center; flex-wrap: wrap; margin-bottom: 4px; - padding-left: 5px; } .selectize-control.form-control.selectize-pms-ip .selectize-input { padding-left: 12px !important; diff --git a/data/interfaces/default/newsletter_config.html b/data/interfaces/default/newsletter_config.html index dc6de294..10583707 100644 --- a/data/interfaces/default/newsletter_config.html +++ b/data/interfaces/default/newsletter_config.html @@ -142,8 +142,10 @@
+ % if item['select_all']: + % endif % if isinstance(item['select_options'], dict): % for section, options in item['select_options'].items(): @@ -145,7 +147,9 @@ % endfor % else: + % if item['select_all']: + % endif % for option in sorted(item['select_options'], key=lambda x: x['text'].lower()): % endfor @@ -718,6 +722,12 @@ $('#pushover_priority').change( function () { pushoverPriority(); }); + + var $pushover_sound = $('#pushover_sound').selectize({ + create: true + }); + var pushover_sound = $pushover_sound[0].selectize; + pushover_sound.setValue(${json.dumps(next((c['value'] for c in notifier['config_options'] if c['name'] == 'pushover_sound'), [])) | n}); % elif notifier['agent_name'] == 'plexmobileapp': var $plexmobileapp_user_ids = $('#plexmobileapp_user_ids').selectize({ diff --git a/plexpy/newsletters.py b/plexpy/newsletters.py index 902eb69b..fdc1c5a8 100644 --- a/plexpy/newsletters.py +++ b/plexpy/newsletters.py @@ -971,7 +971,8 @@ class RecentlyAdded(Newsletter): 'description': 'Select the libraries to include in the newsletter.', 'name': 'newsletter_config_incl_libraries', 'input_type': 'selectize', - 'select_options': self._get_sections_options() + 'select_options': self._get_sections_options(), + 'select_all': True } ] diff --git a/plexpy/notifiers.py b/plexpy/notifiers.py index f0f02bf0..1a747be9 100644 --- a/plexpy/notifiers.py +++ b/plexpy/notifiers.py @@ -1435,21 +1435,24 @@ class EMAIL(Notifier): 'name': 'email_to', 'description': 'The email address(es) of the recipients.', 'input_type': 'selectize', - 'select_options': user_emails_to + 'select_options': user_emails_to, + 'select_all': True }, {'label': 'CC', 'value': self.config['cc'], 'name': 'email_cc', 'description': 'The email address(es) to CC.', 'input_type': 'selectize', - 'select_options': user_emails_cc + 'select_options': user_emails_cc, + 'select_all': True }, {'label': 'BCC', 'value': self.config['bcc'], 'name': 'email_bcc', 'description': 'The email address(es) to BCC.', 'input_type': 'selectize', - 'select_options': user_emails_bcc + 'select_options': user_emails_bcc, + 'select_all': True }, {'label': 'SMTP Server', 'value': self.config['smtp_server'], @@ -3216,31 +3219,34 @@ class PUSHOVER(Notifier): return self.make_request('https://api.pushover.net/1/messages.json', headers=headers, data=data, files=files) def get_sounds(self): - sounds = { - '': '', - 'alien': 'Alien Alarm (long)', - 'bike': 'Bike', - 'bugle': 'Bugle', - 'cashregister': 'Cash Register', - 'classical': 'Classical', - 'climb': 'Climb (long)', - 'cosmic': 'Cosmic', - 'echo': 'Pushover Echo (long)', - 'falling': 'Falling', - 'gamelan': 'Gamelan', - 'incoming': 'Incoming', - 'intermission': 'Intermission', - 'magic': 'Magic', - 'mechanical': 'Mechanical', - 'none': 'None (silent)', - 'persistent': 'Persistent (long)', - 'pianobar': 'Piano Bar', - 'pushover': 'Pushover (default)', - 'siren': 'Siren', - 'spacealarm': 'Space Alarm', - 'tugboat': 'Tug Boat', - 'updown': 'Up Down (long)' - } + sounds = [ + {'value': '', 'text': ''}, + {'value': 'alien', 'text': 'Alien Alarm (long)'}, + {'value': 'bike', 'text': 'Bike'}, + {'value': 'bugle', 'text': 'Bugle'}, + {'value': 'cashregister', 'text': 'Cash Register'}, + {'value': 'classical', 'text': 'Classical'}, + {'value': 'climb', 'text': 'Climb (long)'}, + {'value': 'cosmic', 'text': 'Cosmic'}, + {'value': 'echo', 'text': 'Pushover Echo (long)'}, + {'value': 'falling', 'text': 'Falling'}, + {'value': 'gamelan', 'text': 'Gamelan'}, + {'value': 'incoming', 'text': 'Incoming'}, + {'value': 'intermission', 'text': 'Intermission'}, + {'value': 'magic', 'text': 'Magic'}, + {'value': 'mechanical', 'text': 'Mechanical'}, + {'value': 'none', 'text': 'None (silent)'}, + {'value': 'persistent', 'text': 'Persistent (long)'}, + {'value': 'pianobar', 'text': 'Piano Bar'}, + {'value': 'pushover', 'text': 'Pushover (default)'}, + {'value': 'siren', 'text': 'Siren'}, + {'value': 'spacealarm', 'text': 'Space Alarm'}, + {'value': 'tugboat', 'text': 'Tug Boat'}, + {'value': 'updown', 'text': 'Up Down (long)'}, + {'value': 'vibrate', 'text': 'Vibrate Only'}, + ] + if self.config['sound'] not in [s['value'] for s in sounds]: + sounds.append({'value': self.config['sound'], 'text': self.config['sound']}) return sounds @@ -3281,9 +3287,10 @@ class PUSHOVER(Notifier): {'label': 'Sound', 'value': self.config['sound'], 'name': 'pushover_sound', - 'description': 'Set the notification sound. Leave blank for the default sound.', - 'input_type': 'select', - 'select_options': self.get_sounds() + 'description': 'Select a notification sound or enter a custom sound name. Leave blank for the default sound.', + 'input_type': 'selectize', + 'select_options': self.get_sounds(), + 'select_all': False }, {'label': 'Priority', 'value': self.config['priority'],