diff --git a/data/interfaces/default/css/tautulli.css b/data/interfaces/default/css/tautulli.css index c05cf7e1..43ef642a 100644 --- a/data/interfaces/default/css/tautulli.css +++ b/data/interfaces/default/css/tautulli.css @@ -3678,6 +3678,9 @@ a:hover .overlay-refresh-image:hover { border: 1px solid #444; border-bottom-color: transparent; } +#newsletter-config-modal #cron-widget { + display: inline-block; +} #newsletter-config-modal #cron-widget select.cron-select { width: initial; display: inline; diff --git a/data/interfaces/default/newsletter_config.html b/data/interfaces/default/newsletter_config.html index ce47add2..a6f45bac 100644 --- a/data/interfaces/default/newsletter_config.html +++ b/data/interfaces/default/newsletter_config.html @@ -40,7 +40,8 @@
- + +

Set the schedule for the newsletter

@@ -385,13 +386,34 @@ $('#newsletter-config-modal').unbind('hidden.bs.modal'); - $('#cron-widget').cron({ - initial: "${newsletter['cron']}", - classes: "form-control cron-select", + var cron_widget = $('#cron-widget').cron({ + classes: 'form-control cron-select', + customValues: { + 'custom crontab' : 'custom' + }, onChange: function() { - $("#cron_value").val($(this).cron("value")); + var cron_type = $(this).find('select[name=cron-period]').val(); + if(cron_type == 'custom') { + $('#cron_type').val(cron_type); + $("#cron_value").show(); + } else { + $('#cron_type').val('widget'); + $("#cron_value").hide().val($(this).cron('value')); + } } - }); // apply cron with default options + }); + + if ('${newsletter['cron_type']}' === 'custom') { + $('#cron-widget').find('select[name=cron-period]').val('custom'); + $('#cron_type').val('${newsletter['cron_type']}'); + $("#cron_value").val('${newsletter['cron']}').show(); + } else { + $('#cron_type').val('${newsletter['cron_type']}'); + $("#cron_value").hide(); + cron_widget.cron('value', '${newsletter['cron']}'); + } + + // apply cron with default options var $incl_libraries = $('#newsletter_config_incl_libraries').selectize({ plugins: ['remove_button'], diff --git a/plexpy/__init__.py b/plexpy/__init__.py index d2e9341f..bc40027d 100644 --- a/plexpy/__init__.py +++ b/plexpy/__init__.py @@ -639,7 +639,7 @@ def dbcheck(): 'CREATE TABLE IF NOT EXISTS newsletters (id INTEGER PRIMARY KEY AUTOINCREMENT, ' 'agent_id INTEGER, agent_name TEXT, agent_label TEXT, ' 'friendly_name TEXT, newsletter_config TEXT, email_config TEXT, ' - 'subject TEXT, body TEXT, cron TEXT NOT NULL DEFAULT "0 0 * * 0", active INTEGER DEFAULT 0)' + 'subject TEXT, body TEXT, cron TEXT NOT NULL DEFAULT "0 0 * * 0", cron_type TEXT, active INTEGER DEFAULT 0)' ) # newsletter_log table :: This is a table which logs newsletters sent diff --git a/plexpy/newsletters.py b/plexpy/newsletters.py index 6bb35516..1a2a1ed2 100644 --- a/plexpy/newsletters.py +++ b/plexpy/newsletters.py @@ -230,6 +230,7 @@ def set_newsletter_config(newsletter_id=None, agent_id=None, **kwargs): 'subject': agent_class.subject, 'body': agent_class.body, 'cron': kwargs.get('cron'), + 'cron_type': kwargs.get('cron_type'), 'active': kwargs.get('active') }