From 50941055fb2b39eb8100915a7b61013610b13f36 Mon Sep 17 00:00:00 2001 From: JonnyWong16 Date: Sun, 9 Oct 2016 14:34:05 -0700 Subject: [PATCH] Automatically show config modal when adding a new notifier --- data/interfaces/default/notifiers_table.html | 10 +-------- data/interfaces/default/settings.html | 23 +++++++++++++++----- plexpy/webserve.py | 2 +- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/data/interfaces/default/notifiers_table.html b/data/interfaces/default/notifiers_table.html index e3965e22..f9cdd632 100644 --- a/data/interfaces/default/notifiers_table.html +++ b/data/interfaces/default/notifiers_table.html @@ -31,15 +31,7 @@ DOCUMENTATION :: END // Load notification agent config modal $(".toggle-notifier-config-modal").click(function () { var notifier_id = $(this).data('id'); - $.ajax({ - url: 'get_notifier_config_modal', - data: { notifier_id: notifier_id }, - cache: false, - async: true, - complete: function (xhr, status) { - $("#notifier-config-modal").html(xhr.responseText); - } - }); + loadNotifierConfig(notifier_id); }); $('.trigger-tooltip').tooltip(); diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index d2b345ef..e9cbf05d 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -1897,6 +1897,18 @@ }); } + function loadNotifierConfig(notifier_id) { + $.ajax({ + url: 'get_notifier_config_modal', + data: { notifier_id: notifier_id }, + cache: false, + async: true, + complete: function (xhr, status) { + $("#notifier-config-modal").html(xhr.responseText).modal('show'); + } + }); + } + $(document).ready(function() { // Javascript to enable link to tab @@ -2401,12 +2413,13 @@ $(document).ready(function() { complete: function (xhr, status) { result = $.parseJSON(xhr.responseText); msg = result.message; - if (result.result == 'success') { - showMsg(' ' + msg, false, true, 5000) - } else { - showMsg(' ' + msg, false, true, 5000, true) - } $('#add-notifier-modal').modal('hide'); + if (result.result == 'success') { + showMsg(' ' + msg, false, true, 5000); + loadNotifierConfig(result.notifier_id); + } else { + showMsg(' ' + msg, false, true, 5000, true); + } getNotifiersTable(); } }); diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 47c27bb7..4b86b4a4 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -2943,7 +2943,7 @@ class WebInterface(object): result = notifiers.add_notifier_config(agent_id=agent_id, **kwargs) if result: - return {'result': 'success', 'message': 'Added notification agent.'} + return {'result': 'success', 'message': 'Added notification agent.', 'notifier_id': result} else: return {'result': 'error', 'message': 'Failed to add notification agent.'}