Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…ts-server into rename-compile_cgi
  • Loading branch information
VaiTon committed Nov 12, 2019
2 parents 46b6657 + f9cf406 commit 910210a
Show file tree
Hide file tree
Showing 2,138 changed files with 94,185 additions and 36,474 deletions.
27 changes: 18 additions & 9 deletions cgi/import_file_process.pl
Expand Up @@ -51,8 +51,8 @@

ProductOpener::Display::init();

my $title = '';
my $html = '';
my $title = lang("import_file_status_title");
my $html = "<p>" . lang("import_file_status_description") . "</p>";

if (not defined $owner) {
display_error(lang("no_owner_defined"), 200);
Expand Down Expand Up @@ -156,7 +156,7 @@
if (defined $Org_id) {
$args_ref->{manufacturer} = 1;
$args_ref->{source_id} = $Org_id;
$args_ref->{global_values} = { data_sources => "Producers, Producer - " . $Org_id};
$args_ref->{global_values} = { data_sources => "Producers, Producer - " . $Org_id, imports => $import_id};
}
else {
$args_ref->{no_source} = 1;
Expand All @@ -168,32 +168,41 @@

store("$data_root/import_files/$owner/import_files.sto", $import_files_ref);

$html .= "<p>job_id: " . $results_ref->{job_id} . "</p>";

$html .= "<a href=\"/cgi/import_file_job_status.pl?file_id=$file_id&import_id=$import_id\">status</a>";

$html .= "<p>" . lang("import_file_status") . lang("sep"). ': <span id="result">' . lang("job_status_inactive") . '</span>';

if ($admin) {
$html .= " (shown to admins only: <a href=\"/cgi/import_file_job_status.pl?file_id=$file_id&import_id=$import_id\">status</a>) - poll: <div id=\"span\"></span>";
}

$html .= "Poll: <div id=\"poll\"></div> Result:<div id=\"result\"></div>";
$html .= "</p>";

$initjs .= <<JS
var poll_n = 0;
var timeout = 5000;
var job_info_state;
var statuses = {
"inactive" : "$Lang{job_status_inactive}{$lc}",
"active" : "$Lang{job_status_active}{$lc}",
"finished" : "$Lang{job_status_finished}{$lc}",
"failed" : "$Lang{job_status_failed}{$lc}"
};
(function poll() {
\$.ajax({
url: '/cgi/import_file_job_status.pl?file_id=$file_id&import_id=$import_id',
success: function(data) {
\$('#result').html(data.job_info.state);
\$('#result').html(statuses[data.job_info.state]);
job_info_state = data.job_info.state;
},
complete: function() {
// Schedule the next request when the current one's complete
if ((job_info_state == "inactive") || (job_info_state == "active")) {
setTimeout(poll, timeout);
timeout += 1000;
}
if (job_info_state == "finished") {
}
poll_n++;
\$('#poll').html(poll_n);
Expand Down
21 changes: 15 additions & 6 deletions cgi/import_file_select_format.pl
Expand Up @@ -109,18 +109,14 @@

$log->debug("after generate_import_export_columns_groups_for_select2", { lc=>$lc }) if $log->is_debug();


# Number of pre-selected columns
my $selected = 0;

# Upload a file

$html .= "<h1>" . lang("import_data_file_select_format_title") . "</h1>\n";
$html .= "<p>" . lang("import_data_file_select_format_description") . "</p>\n";

$html .= "<p>" . sprintf(lang("import_file_rows_columns"), @$rows_ref + 0, @$headers_ref + 0) . "</p>";

my $selected_columns_count = sprintf(lang("import_file_selected_columns"), '<span class="selected_columns">' . $selected . '</span>', @$headers_ref + 0);
my $selected_columns_count = sprintf(lang("import_file_selected_columns"), '<span class="selected_columns"></span>', @$headers_ref + 0);

$html .= start_multipart_form(-id=>"select_format_form", -action=>"/cgi/import_file_process.pl") ;

Expand All @@ -140,6 +136,7 @@
foreach my $column (@$headers_ref) {

my $examples = "";
my $instructions = "";

foreach my $example (@{$columns_fields_ref->{$column}{examples}}) {
$examples .= $example . "\n";
Expand All @@ -151,6 +148,10 @@
if ($examples ne "") {
$examples = "<p>" . lang("examples") . "</p>\n<pre>$examples</pre>\n";
}
else {
$examples = "<p>" . lang("empty_column") . "</p>\n";
$instructions = lang("empty_column_description");
}

# Only numbers? Display min and max-height
if ((defined $columns_fields_ref->{$column}{min}) and ($columns_fields_ref->{$column}{letters} == 0)) {
Expand All @@ -172,6 +173,7 @@
$examples
</td>
<td colspan="2" id="column_instructions_$col">
$instructions
</td>
</tr>
HTML
Expand Down Expand Up @@ -218,6 +220,7 @@
my $select2_options_json = to_json($select2_options_ref);

$initjs .= <<JS
var selected_columns = 0;
var columns = $columns_json;
Expand All @@ -229,7 +232,6 @@
\$('#columns_fields_json').val(JSON.stringify(columns_fields));
});
function show_column_info(col) {
\$('.column_info_row').hide();
Expand All @@ -239,6 +241,7 @@
\$('.column_row').click( function() {
var col = this.id.replace(/column_/, '');
show_column_info(col);
\$(document).foundation('equalizer', 'reflow');
}
);
Expand Down Expand Up @@ -373,12 +376,17 @@
var column = columns[col];
columns_fields[column]["field"] = \$(this).val();
init_select_field_option(col);
selected_columns++;
\$('.selected_columns').text(selected_columns);
}).on("select2:unselect", function(e) {
selected_columns--;
\$('.selected_columns').text(selected_columns);
});
if (columns_fields[column]["field"]) {
\$(this).val(columns_fields[column]["field"]);
\$(this).trigger('change');
selected_columns++;
}
init_select_field_option(col);
Expand All @@ -389,6 +397,7 @@
\$('.select2_field').each(init_select_field);
\$('.selected_columns').text(selected_columns);
JS
;
Expand Down
4 changes: 2 additions & 2 deletions cgi/import_file_upload.pl
Expand Up @@ -187,11 +187,11 @@
},
fail : function (e, data) {
\$("#file_input_error_$id").show();
\$("#file_input_button_$id").show();
\$("#file_input_msg_$id").hide();
},
always : function (e, data) {
\$("#progressbar_$id").hide();
\$("#file_input_button_$id").show();
\$("#file_input_msg_$id").hide();
},
start: function (e, data) {
\$("#file_input_button_$id").hide();
Expand Down

0 comments on commit 910210a

Please sign in to comment.