mirror of
https://github.com/Tautulli/Tautulli.git
synced 2025-07-08 06:00:51 -07:00
Add custom cron to newsletter schedule
This commit is contained in:
parent
a4de63095f
commit
c260543586
4 changed files with 33 additions and 7 deletions
|
@ -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;
|
||||
|
|
|
@ -40,7 +40,8 @@
|
|||
<div class="row">
|
||||
<div class="col-md-12">
|
||||
<div id="cron-widget"></div>
|
||||
<input type="hidden" id="cron_value" name="cron" />
|
||||
<input type="text" id="cron_value" name="cron" value="${newsletter['cron']}" />
|
||||
<input type="hidden" id="cron_type" name="cron_type" value="${newsletter['cron_type']}" />
|
||||
</div>
|
||||
</div>
|
||||
<p class="help-block">Set the schedule for the newsletter</p>
|
||||
|
@ -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'],
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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')
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue