@@ -2513,6 +2532,18 @@ $(document).ready(function() {
});
});
+ // Load config import modal
+ $(".toggle-config-import-modal").click(function() {
+ $.ajax({
+ url: 'import_config_tool',
+ cache: false,
+ async: true,
+ complete: function(xhr, status) {
+ $("#config-import-modal").html(xhr.responseText);
+ }
+ });
+ });
+
pms_version = false;
pms_logs_debug = false;
pms_logs = false;
diff --git a/plexpy/config.py b/plexpy/config.py
index 5ae95408..7cfa541e 100644
--- a/plexpy/config.py
+++ b/plexpy/config.py
@@ -22,6 +22,7 @@ import os
import re
import shutil
import time
+import threading
from configobj import ConfigObj
@@ -202,6 +203,7 @@ _DO_NOT_IMPORT_KEYS_DOCKER = [
]
IS_IMPORTING = False
+IMPORT_THREAD = None
def set_is_importing(value):
@@ -209,6 +211,15 @@ def set_is_importing(value):
IS_IMPORTING = value
+def set_import_thread(config=None, backup=False):
+ global IMPORT_THREAD
+ if config:
+ IMPORT_THREAD = threading.Thread(target=import_tautulli_config,
+ kwargs={'config': config, 'backup': backup})
+ else:
+ IMPORT_THREAD = None
+
+
def import_tautulli_config(config=None, backup=False):
if backup:
# Make a backup of the current config first
@@ -235,6 +246,7 @@ def import_tautulli_config(config=None, backup=False):
plexpy.CONFIG.write()
logger.info("Tautulli Config :: Tautulli config import complete.")
+ set_import_thread(None)
set_is_importing(False)
# Restart to apply changes
diff --git a/plexpy/webserve.py b/plexpy/webserve.py
index 08cf53cd..a9480a7a 100644
--- a/plexpy/webserve.py
+++ b/plexpy/webserve.py
@@ -3876,9 +3876,8 @@ class WebInterface(object):
if not config_path:
return {'result': 'error', 'message': 'No config specified for import'}
- threading.Thread(target=config.import_tautulli_config,
- kwargs={'config': config_path,
- 'backup': helpers.bool_true(backup)}).start()
+ config.set_import_thread(config=config_path, backup=helpers.bool_true(backup))
+
return {'result': 'success',
'message': 'Config import has started. Check the logs to monitor any problems. '
'Tautulli will restart automatically.'}
@@ -3896,6 +3895,11 @@ class WebInterface(object):
logger.warn("No app specified for import.")
return
+ @cherrypy.expose
+ @requireAuth(member_of("admin"))
+ def import_config_tool(self, **kwargs):
+ return serve_template(templatename="config_import.html", title="Import Tautulli Config")
+
@cherrypy.expose
@cherrypy.tools.json_out()
@requireAuth(member_of("admin"))
@@ -4158,7 +4162,8 @@ class WebInterface(object):
def do_state_change(self, signal, title, timer, **kwargs):
message = title
quote = self.random_arnold_quotes()
- plexpy.SIGNAL = signal
+ if signal:
+ plexpy.SIGNAL = signal
if plexpy.CONFIG.HTTP_ROOT.strip('/'):
new_http_root = '/' + plexpy.CONFIG.HTTP_ROOT.strip('/') + '/'
@@ -4207,6 +4212,13 @@ class WebInterface(object):
def reset_git_install(self, **kwargs):
return self.do_state_change('reset', 'Resetting to {}'.format(common.RELEASE), 120)
+ @cherrypy.expose
+ @requireAuth(member_of("admin"))
+ def restart_import_config(self, **kwargs):
+ if config.IMPORT_THREAD:
+ config.IMPORT_THREAD.start()
+ return self.do_state_change(None, 'Importing a Config', 15)
+
@cherrypy.expose
@requireAuth(member_of("admin"))
def get_changelog(self, latest_only=False, since_prev_release=False, update_shown=False, **kwargs):