blob: 3be92d42de93282f3aefaea80deac7f73f6b8042 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
{% load i18n l10n inline_formset %}
{% localize off %}<script type="text/javascript">
{% comment %}
/* TODO : à effacer ? */
var html = $("#message_list").html();
{% if MESSAGES and AJAX %}{% for message, message_type in MESSAGES %}
html += '<div class="alert alert-{{message_type}} alert-dismissible fade show"';
html += ' role="alert">';
html += ' {{message}}';
html += ' <button type="button" class="close" data-dismiss="alert"';
html += ' aria-label="Close">';
html += ' <span aria-hidden="true">×</span>';
html += ' </button>';
html += ' </div>';
{% endfor %}{% endif %}
$("#message_list").html(html);
{% endcomment %}
$("#import-list").find('select').prop('disabled', true);
$("#import-list").find('input').prop('disabled', true);
var import_table_update_import_ids = new Array();
var import_table_import_state = new Array();
{% for import in object_list %}{% if import.state == 'IP' or import.state == 'PP' %}
import_table_update_import_ids.push("{{import.import_id}}");
{% if not import.importer_type.type_label %}{# group #}{% for sub in import.import_list %}
import_table_update_import_ids.push("{{sub.id}}");{% endfor %}
{% endif %}{% endif %}{% endfor %}
var need_refresh = false;
if (import_table_update_import_ids.length) need_refresh = true;
$(document).ready(function(){
if (need_refresh) setInterval(function(){
import_table_update_import_list(import_table_update_import_ids)
}, 3 * 1000);
});
</script>
<h2>{{page_name}}</h2>
<div class='form' id="import-list">
{% if not object_list %}
<p>{% trans "No pending imports." %}</p>
{% else %}
<table class="table table-striped">
<tr>
<th>{% trans "Name" %}</th>
<th>{% trans "Type" %}</th>
<th>{% trans "Status" %}</th>
<th>{% trans "Action" %}</th>
<th>{% trans "Files" context "file" %}</th>
{% if not ARCHIVE_PAGE %}<th>{% trans "Pré-import form / matching" %}</th>
<th>{% trans "Diagnostic files" %}</th>{% endif %}
</tr>
{% for import in object_list %}
<tr id="import-{{import.import_id}}"
class='import-row{% if import.has_error or not import.pre_import_form_is_valid %}-error{% endif %}{% if import.pk in refreshed_pks %} bg-info{% endif %}'>
<td><ul class="simple">
<li><strong>{{import.name|default:"-"}}</strong></li>
<li><small><i class="fa fa-fw fa-calendar" aria-hidden="true"></i> {{import.creation_date|date:"DATE_FORMAT"}} {{import.creation_date|time:"H:i"}} - {% if import.end_date %}{{import.end_date|date:"DATE_FORMAT"}} {{import.end_date|time:"H:i"}}{% endif %}</small></li>
<li><small><i class="fa fa-fw fa-user" aria-hidden="true"></i> {{import.user}}</small></li>
</ul></td>
<td>
{{import.importer_type}} ({% if import.importer_type.type_label %}{% trans import.importer_type.type_label %}{% else %}{% trans "Group" %}{% endif %})
</td>
<td id="status-{{import.import_id}}">
{{import.status}}
</td>
<td>
<select class="form-control"
id='import-action-{{import.import_id}}'
name='import-action-{{import.import_id}}'>
<option value=''>--------</option>
{% for action, lbl in import.get_actions %}
<option value='{{action}}'>{{lbl}}</option>
{% endfor%}
</select>
</td>
<td><ul class="simple">
{% if import.imported_file %}<li>
<i class="fa fa-fw fa-file-text-o" aria-hidden="true"></i> <a href='{{import.imported_file.url}}'>{% trans "Source" %}</a>
</li>
{% if import.get_imported_images %}<li>
<i class="fa fa-fw fa-file-image-o" aria-hidden="true"></i> <a href="{{ import.get_imported_images.url }}">{% trans "Media" %}</a>
</li>{% endif %}
{% elif import.archive_file %}<li>
<i class="fa fa-fw fa-file-archive-o" aria-hidden="true"></i> <a href='{{import.archive_file.url}}'>{% trans "Archive" context "name" %}</a>
</li>{% endif %}
</ul></td>{% if not ARCHIVE_PAGE %}
<td><ul class="simple">
{% if import.has_pre_import_form %}<li>
{% if not import.pre_import_form_is_valid %}
<i class="text-danger fa fa-fw fa-exclamation-triangle" aria-hidden="true"></i>
{% else %}
<i class="fa fa-fw fa-check-square-o" aria-hidden="true"></i>
{% endif %}
<a href='{% url "import_pre_import_form" import.pk %}'>{% trans "Pre-import values" %}</a>
</li>{% endif %}
{% if import.need_matching %}<li>
<i class="fa fa-fw fa-arrows-h" aria-hidden="true"></i> <a href='{% url "import_link_unmatched" import.pk %}'>{% trans "Make match" %}</a>
</li>{% endif %}
</ul></td>
<td style="white-space: nowrap;"><ul class="simple">{% if import.error_file %}<li>
<i class="text-danger fa fa-fw fa-exclamation-triangle" aria-hidden="true"></i> <a href='{{import.error_file.url}}'>{% trans "Error" %}</a>
</li>{% endif %}
{% if import.result_file %}<li>
<i class="fa fa-fw fa-th" aria-hidden="true"></i> <a href='{{import.result_file.url}}'>{% trans "Result" %}</a>
</li>{% endif %}
{% if import.match_file %}<li>
<i class="fa fa-fw fa-arrows-h" aria-hidden="true"></i> <a href='{{import.match_file.url}}'>{% trans "Match" %}</a>
</li>{% endif %}</ul>
</td>{% endif %}
</tr>
{% if import.importer_type.type_label %}
<tr></tr>{# only for even and odd style #}
<tr id="progress-display-{{import.id}}"{% if sub.state != 'IP' and sub.state != 'PP' %} style="display:none"{% endif %}>
<td colspan="11">
<div class="progress bg-secondary">
<div id="progress-{{import.id}}" class="progress-bar progress-bar-striped {% if import.state == 'IP'%}bg-success{% else %}bg-info{% endif %} progress-bar-animated" role="progressbar"
aria-valuenow="{{import.current_line}}" aria-valuemin="0" aria-valuemax="{{import.number_of_line}}" style="width: {{import.progress_percent}}%">
{{import.current_line}} / {{import.number_of_line}}
</div>
</div>
</td>
</tr>
{% endif %}
{% if not import.importer_type.type_label and not ARCHIVE_PAGE %} {# group #}
{% for sub in import.import_list %}
<tr id="import-{{sub.import_id}}">
<td></td>
<td>{{sub.importer_type}}</td>
<td id="status-{{sub.import_id}}">{{sub.status}}</td>
<td></td>
<td><ul class="simple">
{% if sub.imported_file %}<li>
<i class="fa fa-fw fa-file-text-o" aria-hidden="true"></i> <a href='{{sub.imported_file.url}}'>{% trans "Source" %}</a>
</li>{% endif %}
{% if sub.get_imported_images %}<li>
<i class="fa fa-fw fa-file-image-o" aria-hidden="true"></i> <a href="{{ sub.get_imported_images.url }}">{% trans "Media" %}</a>
</li>{% endif %}
</ul></td>{% if not ARCHIVE_PAGE %}
<td><ul class="simple">
{% if sub.has_pre_import_form %}<li>
{% if not sub.pre_import_form_is_valid %}
<i class="text-danger fa fa-fw fa-exclamation-triangle" aria-hidden="true"></i>
{% else %}
<i class="fa fa-fw fa-check-square-o" aria-hidden="true"></i>
{% endif %}
<a href='{% url "import_pre_import_form" sub.pk %}'>{% trans "Pre-import values" %}</a>
</li>{% endif %}
{% if sub.need_matching %}<li>
<i class="fa fa-fw fa-arrows-h" aria-hidden="true"></i> <a href='{% url "import_link_unmatched" sub.pk %}'>{% trans "Make match" %}</a>
</li>{% endif %}
</ul></td>
<td><ul class="simple">
{% if sub.error_file %}<li>
<i class="text-danger fa fa-fw fa-exclamation-triangle" aria-hidden="true"></i> <a href='{{sub.error_file.url}}'>{% trans "Error" %}</a>
</li>{% endif %}
{% if sub.result_file %}<li>
<i class="fa fa-fw fa-th" aria-hidden="true"></i> <a href='{{sub.result_file.url}}'>{% trans "Result" %}</a>
</li>{% endif %}
{% if sub.match_file %}<li>
<i class="fa fa-fw fa-arrows-h" aria-hidden="true"></i> <a href='{{sub.match_file.url}}'>{% trans "Match" %}</a>
</li>{% endif %}
</ul>
</td>{% endif %}
</tr>
<tr></tr>{# only for even and odd style #}
<tr id="progress-display-{{sub.id}}"{% if sub.state != 'IP' and sub.state != 'PP' %} style="display:none"{% endif %}>
<td colspan="11">
<div class="progress bg-secondary">
<div id="progress-{{sub.id}}" class="progress-bar progress-bar-striped {% if sub.state == 'IP'%}bg-success{% else %}bg-info{% endif %} progress-bar-animated" role="progressbar"
aria-valuenow="{{sub.current_line}}" aria-valuemin="0" aria-valuemax="{{sub.number_of_line}}" style="width: {{sub.progress_percent}}%">
{{sub.current_line}} / {{sub.number_of_line}}
</div>
</div>
</td>
</tr>
{% endfor %}
{% endif %}
{% endfor %}
</table>
{% endif %}
</div>
{% endlocalize %}
|