diff --git a/data/interfaces/default/js/script.js b/data/interfaces/default/js/script.js index 9f3ff621..5eac0f22 100644 --- a/data/interfaces/default/js/script.js +++ b/data/interfaces/default/js/script.js @@ -54,7 +54,7 @@ function showMsg(msg,loader,timeout,ms,error) { } } -function doAjaxCall(url,elem,reload,form) { +function doAjaxCall(url, elem, reload, form, callback) { // Set Message feedback = $("#ajaxMsg"); update = $("#updatebar"); @@ -157,6 +157,9 @@ function doAjaxCall(url,elem,reload,form) { complete: function(jqXHR, textStatus) { // Remove loaders and stuff, ajax request is complete! loader.remove(); + if (typeof callback === "function") { + callback(); + } } }); } diff --git a/data/interfaces/default/notification_config.html b/data/interfaces/default/notification_config.html index fab610d4..d1dd0675 100644 --- a/data/interfaces/default/notification_config.html +++ b/data/interfaces/default/notification_config.html @@ -147,9 +147,8 @@ from plexpy import helpers }) $('#save-notification-item').click(function () { - doAjaxCall('set_notification_config', $(this), 'tabs', true); // Reload modal to update certain fields - reloadModal(); + doAjaxCall('set_notification_config', $(this), 'tabs', true, reloadModal); return false; }); @@ -211,8 +210,8 @@ from plexpy import helpers }); $('#pushbullet_apikey, #pushover_apitoken, #scripts_folder').on('change', function () { - doAjaxCall('set_notification_config', $(this), 'tabs', true); - reloadModal(); + // Reload modal to update certain fields + doAjaxCall('set_notification_config', $(this), 'tabs', true, reloadModal); return false; }); diff --git a/data/interfaces/default/scheduler_table.html b/data/interfaces/default/scheduler_table.html new file mode 100644 index 00000000..b01c4b11 --- /dev/null +++ b/data/interfaces/default/scheduler_table.html @@ -0,0 +1,64 @@ +<%doc> +USAGE DOCUMENTATION :: PLEASE LEAVE THIS AT THE TOP OF THIS FILE + +For Mako templating syntax documentation please visit: http://docs.makotemplates.org/en/latest/ + +Filename: scheduler_table.html +Version: 0.1 + +DOCUMENTATION :: END + + +<%! +import arrow +import plexpy +from plexpy import common + +scheduled_jobs = [j.id for j in plexpy.SCHED.get_jobs()] +%> + + + + + + + + + + + + + % for job in common.SCHEDULER_LIST: + % if job in scheduled_jobs: + <% + sched_job = plexpy.SCHED.get_job(job) + run_interval = arrow.get(str(sched_job.trigger.interval), ['H:mm:ss', 'HH:mm:ss']) + next_run_interval = arrow.get(sched_job.next_run_time).timestamp - arrow.now().timestamp + %> + + + + + + + + % elif job == 'Check for active sessions' and plexpy.CONFIG.MONITORING_USE_WEBSOCKET: + + + + + + + + % else: + + + + + + + + % endif + % endfor + +
Scheduled TaskStateIntervalNext Run InNext Run Time
${sched_job.id}Active${arrow.get(run_interval).format('HH:mm:ss')}${arrow.get(next_run_interval).format('HH:mm:ss')}${arrow.get(sched_job.next_run_time).format('YYYY-MM-DD HH:mm:ss')}
${job}Using WebsocketsN/AN/AN/A
${job}InactiveN/AN/AN/A
\ No newline at end of file diff --git a/data/interfaces/default/settings.html b/data/interfaces/default/settings.html index 458d6a04..d302590c 100644 --- a/data/interfaces/default/settings.html +++ b/data/interfaces/default/settings.html @@ -130,51 +130,10 @@ scheduled_jobs = [j.id for j in plexpy.SCHED.get_jobs()]

PlexPy Scheduler

- - - - - - - - - - - - % for job in plexpy.common.SCHEDULER_LIST: - % if job in scheduled_jobs: - <% - sched_job = plexpy.SCHED.get_job(job) - run_interval = arrow.get(str(sched_job.trigger.interval), ['H:mm:ss', 'HH:mm:ss']) - next_run_interval = arrow.get(sched_job.next_run_time).timestamp - arrow.now().timestamp - %> - - - - - - - - % elif job == 'Check for active sessions' and plexpy.CONFIG.MONITORING_USE_WEBSOCKET: - - - - - - - - % else: - - - - - - - - % endif - % endfor - -
Scheduled TaskStateIntervalNext Run InNext Run Time
${sched_job.id}Active${arrow.get(run_interval).format('HH:mm:ss')}${arrow.get(next_run_interval).format('HH:mm:ss')}${arrow.get(sched_job.next_run_time).format('YYYY-MM-DD HH:mm:ss')}
${job}Using WebsocketsN/AN/AN/A
${job}InactiveN/AN/AN/A
+
+
Loading scheduler table...
+
+
@@ -1661,7 +1620,7 @@ $(document).ready(function() { var configForm = $("#configUpdate"); function saveSettings() { if (configForm.parsley().validate()) { - doAjaxCall('configUpdate', $(this), 'tabs', true); + doAjaxCall('configUpdate', $(this), 'tabs', true, getSchedulerTable); postSaveChecks(); return false; } else { @@ -2000,6 +1959,19 @@ $(document).ready(function() { }; $(this).on('focus keyup input', function() { resizeTextarea(this); }).removeAttr('data-autoresize'); }); + + function getSchedulerTable() { + $.ajax({ + url: 'get_scheduler_table', + cache: false, + async: true, + complete: function(xhr, status) { + $("#plexpy-scheduler-table").html(xhr.responseText); + } + }); + } + getSchedulerTable(); + }); \ No newline at end of file diff --git a/plexpy/webserve.py b/plexpy/webserve.py index 17be4019..0248ddd7 100644 --- a/plexpy/webserve.py +++ b/plexpy/webserve.py @@ -1321,6 +1321,10 @@ class WebInterface(object): raise cherrypy.HTTPRedirect("settings") + @cherrypy.expose + def get_scheduler_table(self, **kwargs): + return serve_template(templatename="scheduler_table.html") + @cherrypy.expose def get_notification_agent_config(self, agent_id, **kwargs): if agent_id.isdigit():