Add notifier text preview

This commit is contained in:
JonnyWong16 2016-11-02 22:52:24 -07:00
commit d874697eef
6 changed files with 91 additions and 4 deletions

View file

@ -151,6 +151,13 @@
<input class="form-control" type="text" id="${action['name']}_subject" name="${action['name']}_subject" value="${notifier['notify_text'][action['name']]['subject']}" data-parsley-trigger="change" required>
<p class="help-block">Set custom arguments passed to the script.</p>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-8">
<input type="button" class="btn btn-bright notifier-text-preview" data-action="${action['name']}" value="Preview Arguments">
</div>
</div>
</div>
</li>
</ul>
</li>
@ -171,6 +178,13 @@
<textarea class="form-control" id="${action['name']}_body" name="${action['name']}_body" data-parsley-trigger="change" data-autoresize required>${notifier['notify_text'][action['name']]['body']}</textarea>
<p class="help-block">Set a custom body.</p>
</div>
<div class="form-group">
<div class="row">
<div class="col-md-8">
<input type="button" class="btn btn-bright notifier-text-preview" data-action="${action['name']}" value="Preview Text">
</div>
</div>
</div>
</li>
</ul>
</li>
@ -335,6 +349,28 @@
})
% endif
$('.notifier-text-preview').click(function () {
var action = $(this).data('action');
var subject = $('#' + action + '_subject').val();
var body = $('#' + action + '_body').val();
$.ajax({
url: 'get_notify_text_preview',
data: {
notify_action: action,
subject: subject,
body: body,
agent_id: "${notifier['agent_id']}",
agent_name: "${notifier['agent_name']}"
},
cache: false,
async: true,
complete: function (xhr, status) {
$("#notifier-text-preview-modal").html(xhr.responseText).modal('show');
}
});
});
$('#test_notifier').click(function () {
doAjaxCall('set_notifier_config', $(this), 'tabs', true, false, sendTestNotification);
});