]> git.openstreetmap.org Git - osqa.git/blobdiff - forum_modules/exporter/templates/running.html
Improving the statement for the user subscriptions tab management, putting the settin...
[osqa.git] / forum_modules / exporter / templates / running.html
index 79bfc3a7aacddbd451dd20a147a2fed326dd47e6..4dc90cadee661a15db07c97fac30bed822f31d64 100644 (file)
@@ -3,10 +3,10 @@
 {% load i18n %}
 
 {% block subtitle %}
-    {% trans "XML data exporter" %}
+    {% ifequal mode "exporter" %}{% trans "XML data exporter" %}{% else %}{% trans "XML data importer" %}{% endifequal %}
 {% endblock %}
 {% block description %}
-    {% trans "Export database to XML format" %}
+    {% ifequal mode "exporter" %}{% trans "Export database to XML format" %}{% else %}{% trans "Restore data from a previous export" %}{% endifequal %}
 {% endblock %}
 
 {% block adminjs %}
 
     <script type="text/javascript">
     $(function() {
+        var exporting = {% ifequal mode "exporter" %}true{% else %}false{% endifequal %};
+
         var state = null;
 
         function set_state(name, data) {
             var $bar = $('#state_' + name);
 
             if (data[name] === undefined) {
-                $bar.find('.state_label').html('{% trans "Skiped" %}')
+                $bar.find('.state_label').html('{% trans "Skipped" %}')
             } else if (state == null || data[name] != state[name]) {
                 var width = $bar.width();
 
         }
 
         function check_state() {
-         $.getJSON('{% url exporter_state %}', function(data) {
-            set_state('overall', data.state)
-            {% for s in steps %}
-                set_state('{{ s.id }}', data.state);
-            {% endfor %}
-
-            $('#time_started').html(data.time_started);
-
-            state = data;
-
-            if (data.running) {
-                check_state();
-            } else {
-                if (data.errors == false) {
-                    $('#wait_message').html('{% trans "Your backup is ready to be downloaded."%}')
-                    $('#download_link').slideDown();
+            var done = false;
+
+             function callback(data) {
+                if (done) {
+                   return;
+                }
+                set_state('overall', data.state);
+                {% for s in steps %}
+                    set_state('{{ s.id }}', data.state);
+                {% endfor %}
+
+                $('#time_started').html(data.time_started);
+
+                state = data;
+
+                if (data.running) {
+                    check_state();
                 } else {
-                    $('#wait_message').html('{% trans "An error has occurred during de export proccess: "%}' + data.errors + '<br />' +
-                    '{% trans "Please check the log file for a full stack trace." %}')
+                    if (data.errors == false) {
+                        if (exporting) {
+                            $('#wait_message').html('{% trans "Your backup is ready to be downloaded."%}');
+                            $('#download_link_a').attr('href', '{% url exporter_download %}?file=' + data.state.overall.fname)
+                            $('#download_link').slideDown();
+                        } else {
+                            $('#wait_message').html('{% trans "All data sucessfully imported."%}')
+                        }
+                    } else {
+                        var msg;
+                        if (exporting) {
+                            msg = '{% trans "An error has occurred during the export proccess"%}';
+                        } else {
+                            msg = '{% trans "An error has occurred during the import proccess"%}';
+                        }
+                        $('#wait_message').html(msg + ': ' + data.errors + '<br />' +
+                        '{% trans "Please check the log file for a full stack trace." %}')
+                    }
                 }
-            }
-         });
+
+                done = true;
+             }
+
+             window.setTimeout(function() {
+                if (!done) {
+                    done = true;
+                    check_state();
+                }
+             }, 1000);
+
+             $.getJSON('{% url exporter_state %}', callback);
         }
 
         check_state();
 
 {% block admincontent %}
     <p id="wait_message">
-        {% trans "Please wait while we prepare your backup file to download. Started" %} -
+        {% ifequal mode "exporter" %}
+            {% trans "Please wait while we prepare your backup file to download." %}
+        {% else %}
+            {% trans "Please wait while we import your data." %}
+        {% endifequal %} -
         {% blocktrans %}
             Started <span id="time_started"></span>
         {% endblocktrans %}
     </p>
-    <p id="download_link"><a href="{% url exporter_download %}">{% trans "Download file" %}</a></p>
+    <p id="download_link"><a id="download_link_a" href="#">{% trans "Download file" %}</a></p>
     <table style="width: 100%">
         <tr>
             <td colspan="2">