]> git.openstreetmap.org Git - osqa.git/blob - forum_modules/exporter/templates/running.html
Migrate to Django 1.6
[osqa.git] / forum_modules / exporter / templates / running.html
1 {% extends basetemplate %}
2
3 {% load i18n %}
4
5 {% block subtitle %}
6     {% ifequal mode "exporter" %}{% trans "XML data exporter" %}{% else %}{% trans "XML data importer" %}{% endifequal %}
7 {% endblock %}
8 {% block description %}
9     {% ifequal mode "exporter" %}{% trans "Export database to XML format" %}{% else %}{% trans "Restore data from a previous export" %}{% endifequal %}
10 {% endblock %}
11
12 {% block adminjs %}
13     <style type="text/css">
14         .state_bar {
15             width:100%;
16             height: 20px;
17             border: 1px solid black;
18             margin-bottom: 15px;
19             position: relative;
20             background: #FDF;
21         }
22
23         .state_label {
24             margin-left: auto;
25             margin-right: auto;
26             z-index: 1000;
27             position: absolute;
28             left: 0px;
29             top: 0px;
30             width: 100%;
31             height: 100%;
32             text-align: center;
33         }
34
35         .progress {
36             position: absolute;
37             left: 0px;
38             top: 0px;
39             width: 0%;
40             height: 100%;
41             background: #DFF;
42             z-index: 0;
43         }
44
45         #download_link {
46             display: none;
47         }
48     </style>
49
50     <script type="text/javascript">
51     $(function() {
52         var exporting = {% ifequal mode "exporter" %}true{% else %}false{% endifequal %};
53
54         var state = null;
55
56         function set_state(name, data) {
57             var $bar = $('#state_' + name);
58
59             if (data[name] === undefined) {
60                 $bar.find('.state_label').html('{% trans "Skipped" %}')
61             } else if (state == null || data[name] != state[name]) {
62                 var width = $bar.width();
63
64                 $bar.find('.state_parsed').html(data[name].parsed);
65                 $bar.find('.state_count').html(data[name].count);
66                 $bar.find('.state_status').html(data[name].status);
67
68                 var rel_parse = data[name].parsed / data[name].count;
69
70                 $bar.find('.state_percentage').html(parseInt(rel_parse * 100) + '%');
71                 $bar.find('.progress').css('width', parseInt(rel_parse * width) + 'px')
72             }
73         }
74
75         function check_state() {
76             var done = false;
77
78              function callback(data) {
79                 if (done) {
80                    return;
81                 }
82                 set_state('overall', data.state);
83                 {% for s in steps %}
84                     set_state('{{ s.id }}', data.state);
85                 {% endfor %}
86
87                 $('#time_started').html(data.time_started);
88
89                 state = data;
90
91                 if (data.running) {
92                     check_state();
93                 } else {
94                     if (data.errors == false) {
95                         if (exporting) {
96                             $('#wait_message').html('{% trans "Your backup is ready to be downloaded."%}');
97                             $('#download_link_a').attr('href', '{% url "exporter_download" %}?file=' + data.state.overall.fname)
98                             $('#download_link').slideDown();
99                         } else {
100                             $('#wait_message').html('{% trans "All data sucessfully imported."%}')
101                         }
102                     } else {
103                         var msg;
104                         if (exporting) {
105                             msg = '{% trans "An error has occurred during the export proccess"%}';
106                         } else {
107                             msg = '{% trans "An error has occurred during the import proccess"%}';
108                         }
109                         $('#wait_message').html(msg + ': ' + data.errors + '<br />' +
110                         '{% trans "Please check the log file for a full stack trace." %}')
111                     }
112                 }
113
114                 done = true;
115              }
116
117              window.setTimeout(function() {
118                 if (!done) {
119                     done = true;
120                     check_state();
121                 }
122              }, 1000);
123
124              $.getJSON('{% url "exporter_state" %}', callback);
125         }
126
127         check_state();
128     });
129     </script>
130 {% endblock %}
131
132 {% block admincontent %}
133     <p id="wait_message">
134         {% ifequal mode "exporter" %}
135             {% trans "Please wait while we prepare your backup file to download." %}
136         {% else %}
137             {% trans "Please wait while we import your data." %}
138         {% endifequal %} -
139         {% blocktrans %}
140             Started <span id="time_started"></span>
141         {% endblocktrans %}
142     </p>
143     <p id="download_link"><a id="download_link_a" href="#">{% trans "Download file" %}</a></p>
144     <table style="width: 100%">
145         <tr>
146             <td colspan="2">
147                 <div class="state_bar" id="state_overall">
148                     <div class="state_label"><span class="state_status"></span> ({% trans "Total progress" %}: <span class="state_percentage">0%</span>)</div>
149                     <div class="progress"></div>
150                 </div>
151             </td>
152         </tr>
153         {% for s in steps %}
154         <tr>
155             <td>{{ s.name }}:</td>
156             <td width="100%">
157                 <div class="state_bar" id="state_{{ s.id }}">
158                     <div class="state_label"><span class="state_status"></span> - </span><span class="state_parsed">0</span> {% trans " of " %} <span class="state_count">{% trans "unknown" %}</span> (<span class="state_percentage">0%</span>)</div>
159                     <div class="progress"></div>
160                 </div>
161             </td>
162         </tr>
163         {% endfor %}
164     </table>
165 {% endblock %}