aboutsummaryrefslogtreecommitdiffstats
path: root/app/views/import_tasks
diff options
context:
space:
mode:
authorMarc Florisson2014-01-22 17:41:04 +0100
committerMarc Florisson2014-01-22 17:41:04 +0100
commitc9437fc2e96f415e38c1e72fa10337769381f289 (patch)
tree199b39a7c8c5cc2cfef539f73f73c1b5fbea8a72 /app/views/import_tasks
parent4e71abdc01f9f04ce6eec1989fa756ffc823fd65 (diff)
downloadchouette-core-c9437fc2e96f415e38c1e72fa10337769381f289.tar.bz2
merge branch validation
Diffstat (limited to 'app/views/import_tasks')
-rw-r--r--app/views/import_tasks/_fields_csv_import.erb1
-rw-r--r--app/views/import_tasks/_fields_gtfs_import.erb7
-rw-r--r--app/views/import_tasks/_import_task.erb20
-rw-r--r--app/views/import_tasks/_results_dashboard.html.erb67
-rw-r--r--app/views/import_tasks/index.html.erb18
-rw-r--r--app/views/import_tasks/new.html.erb31
-rw-r--r--app/views/import_tasks/show.html.erb20
-rw-r--r--app/views/import_tasks/show.js.coffee41
8 files changed, 205 insertions, 0 deletions
diff --git a/app/views/import_tasks/_fields_csv_import.erb b/app/views/import_tasks/_fields_csv_import.erb
new file mode 100644
index 000000000..b4ae719a5
--- /dev/null
+++ b/app/views/import_tasks/_fields_csv_import.erb
@@ -0,0 +1 @@
+<%= form.input :object_id_prefix, :input_html => { :value => @referential.prefix } %>
diff --git a/app/views/import_tasks/_fields_gtfs_import.erb b/app/views/import_tasks/_fields_gtfs_import.erb
new file mode 100644
index 000000000..842a24ab7
--- /dev/null
+++ b/app/views/import_tasks/_fields_gtfs_import.erb
@@ -0,0 +1,7 @@
+<%= form.input :object_id_prefix, :input_html => { :value => @referential.prefix } %>
+<%= form.input :max_distance_for_commercial , :as => :number , :input_html => { :title => t("tipsy.hints.import_task.max_distance_for_commercial"), :value => 50 } %>
+<%= form.input :ignore_last_word , :as => :boolean , :input_html => { :title => t("tipsy.hints.import_task.ignore_last_word"), :value => false }%>
+<%= form.input :ignore_end_chars , :as => :number , :input_html => { :title => t("tipsy.hints.import_task.ignore_end_chars"), :value => 0 }%>
+<%= form.input :max_distance_for_connection_link , :as => :number , :input_html => { :title => t("tipsy.hints.import_task.max_distance_for_connection_link"), :value => 100 }%>
+
+
diff --git a/app/views/import_tasks/_import_task.erb b/app/views/import_tasks/_import_task.erb
new file mode 100644
index 000000000..afa235d4d
--- /dev/null
+++ b/app/views/import_tasks/_import_task.erb
@@ -0,0 +1,20 @@
+<%= div_for import_task do %>
+ <div class="icon">
+ <%= link_to image_tag("import_task-#{import_task.status}.png"), referential_import_task_path(@referential, import_task) %>
+ </div>
+ <div class="resume">
+ <ul class="header clearfix">
+ <li class="title"><%= link_to(import_task.name, referential_import_task_path(@referential, import_task)) %></li>
+ <li class="remove"><%= link_to "<i class='fa fa-trash-o'></i>".html_safe, referential_import_task_path(@referential, import_task), :method => :delete, :class => "delete", :data => {:confirm => t('import_tasks.actions.destroy_confirm')} %></li>
+ </ul>
+ <div class="links">
+ <p><%= link_to image_tag("icons/file_#{import_task.file_path_extension}.png") + t("import_tasks.index.imported_file"), file_to_import_referential_import_task_path(@referential, import_task) %></p>
+ <% if import_task.compliance_check_task.present? %>
+ <p><%= link_to image_tag('icons/link_page.png') + t("import_tasks.compliance_check_task"), referential_compliance_check_task_path(@referential, import_task.compliance_check_task) %></p>
+ <% end %>
+ </div>
+ <div class="history">
+ <%= l import_task.created_at, :format => "%d/%m/%Y %H:%M" %> | <%= import_task.user_name %>
+ </div>
+ </div>
+<% end %>
diff --git a/app/views/import_tasks/_results_dashboard.html.erb b/app/views/import_tasks/_results_dashboard.html.erb
new file mode 100644
index 000000000..d1e674964
--- /dev/null
+++ b/app/views/import_tasks/_results_dashboard.html.erb
@@ -0,0 +1,67 @@
+ <div class="resume">
+ <div class="col1">
+ <% file_title = (@import_task.file_path_extension=="zip") ? t( "import_tasks.show.graph.files.title_zip") : t( "import_tasks.show.graph.files.title_default", :extension => @import_task.file_path_extension)%>
+ <div class="caption"><%= file_title %></div>
+ <div id="files_statistics"></div>
+ </div>
+ <div class="col2">
+ <div class="caption"><%= t "import_tasks.show.graph.lines.title" %></div>
+ <div id="objects_statistics"></div>
+ </div>
+ </div>
+ <div class="report">
+ <div class="files files_error">
+ <% @files_list["error"].each_with_index do |error, index| %>
+ <% index += 1 %>
+ <%= image_tag "icons/file_xml_md.png" %><span class="file_name"><%= truncate(error["name"], :length => 20) %></span> <% if index%4 == 0 %><br><% end %>
+ <% end %>
+ </div>
+ <div class="files files_ignored">
+ <% @files_list["ignored"].each_with_index do |ignored, index| %>
+ <% index += 1 %>
+ <%= image_tag "icons/file_xml_md.png" %><span class="file_name"><%= truncate(ignored["name"], :length => 20) %></span> <% if index%4 == 0 %><br><% end %>
+ <% end %>
+ </div>
+ <div class="files files_ok">
+ <% @files_list["ok"].each_with_index do |ok, index| %>
+ <% index += 1 %>
+ <%= image_tag "icons/file_xml_md.png" %><span class="file_name"><%= truncate(ok["name"], :length => 20) %></span> <% if index%4 == 0 %><br><% end %>
+ <% end %>
+ </div>
+ <div class="lines">
+ <table class="table table-hover">
+ <thead>
+ <tr>
+ <th>#</th>
+ <th><%= t("import_tasks.show.table.line.name") %></th>
+ <th><%= t("import_tasks.show.table.line.save") %></th>
+ <th><%= t("import_tasks.show.table.line.routes") %></th>
+ <th><%= t("import_tasks.show.table.line.connection_links") %></th>
+ <th><%= t("import_tasks.show.table.line.time_tables") %></th>
+ <th><%= t("import_tasks.show.table.line.stop_areas") %></th>
+ <th><%= t("import_tasks.show.table.line.access_points") %></th>
+ <th><%= t("import_tasks.show.table.line.vehicle_journeys") %></th>
+ <th><%= t("import_tasks.show.table.line.journey_patterns") %></th>
+ </tr>
+ </thead>
+ <tbody>
+ <% @lines_list.each_with_index do |line, index| %>
+ <tr>
+ <td><%= index + 1 %></td>
+ <td><%= line["name"] %></td>
+ <td><%= t("import_tasks.show.table.line." + line["status"] ) %></td>
+ <td><%= line["stats"]["route_count"] %></td>
+ <td><%= line["stats"]["connection_link_count"] %></td>
+ <td><%= line["stats"]["time_table_count"] %></td>
+ <td><%= line["stats"]["stop_area_count"] %></td>
+ <td><%= line["stats"]["acces_point_count"] %></td>
+ <td><%= line["stats"]["vehicle_journey_count"] %></td>
+ <td><%= line["stats"]["journey_pattern_count"] %></td>
+ </tr>
+ <% end %>
+ </tbody>
+ </table>
+ </div>
+ </div>
+ <%= javascript_include_tag referential_import_task_path(@import_task.referential, @import_task,:format => :js) %>
+
diff --git a/app/views/import_tasks/index.html.erb b/app/views/import_tasks/index.html.erb
new file mode 100644
index 000000000..df70120b5
--- /dev/null
+++ b/app/views/import_tasks/index.html.erb
@@ -0,0 +1,18 @@
+<%= title_tag t('.title') %>
+<div class="warning"><%= t('.warning') %> </div>
+<div class="page_info">
+ <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @import_tasks %>
+</div>
+<div class="import_tasks paginated_content">
+ <%= render :partial => "import_task", :collection => @import_tasks %>
+</div>
+<div class="pagination">
+ <%= will_paginate @import_tasks, :container => false %>
+</div>
+
+<% content_for :sidebar do %>
+<ul class="actions">
+ <li><%= link_to t('import_tasks.actions.new'), new_referential_import_task_path(@referential), :class => "add" %></li>
+ <li><%= link_to t('rule_parameter_sets.actions.index'), referential_rule_parameter_sets_path(@referential), :class => "link" %></li>
+</ul>
+<% end %>
diff --git a/app/views/import_tasks/new.html.erb b/app/views/import_tasks/new.html.erb
new file mode 100644
index 000000000..13888ad39
--- /dev/null
+++ b/app/views/import_tasks/new.html.erb
@@ -0,0 +1,31 @@
+<%= title_tag t(".title") %>
+
+<%= semantic_form_for([@referential, @import_task], :as => :import_task, :url => new_referential_import_task_path(@referential), :method => :get) do |form| %>
+ <%= form.inputs do %>
+ <%= form.input :format, :as => :radio, :collection => ImportTask.formats, :required => true, :include_blank => false %>
+ <% end %>
+<% end %>
+
+<% @available_imports.each do |import_task| %>
+ <%= semantic_form_for [@referential, import_task], :as => :import_task, :url => referential_import_tasks_path(@referential), :html => { :id => "#{import_task.format}_new", :style => ('display: none' unless @import_task == import_task)} do |form| %>
+
+ <%= form.inputs do %>
+ <%= fields_for_import_task_format form %>
+ <% end %>
+
+ <%= form.inputs do %>
+ <%= form.input :format, :as => :hidden %>
+ <%= form.input :no_save, :as => :boolean, :collection => [true, false] %>
+ <%= form.input :rule_parameter_set_id, :as => :select,
+ :collection => @referential.rule_parameter_sets.map { |rps| [ rps.name, rps.id ] }, :include_blank => true %>
+ <%= form.input :resources, :as => :file %>
+ <% end %>
+
+ <%= form.actions do %>
+ <%= form.action :submit, :as => :button , :label => t( 'formtastic.import' ) %>
+ <%= form.action :cancel, :as => :link %>
+ <% end %>
+ <% end %>
+<% end %>
+
+
diff --git a/app/views/import_tasks/show.html.erb b/app/views/import_tasks/show.html.erb
new file mode 100644
index 000000000..781b9b07e
--- /dev/null
+++ b/app/views/import_tasks/show.html.erb
@@ -0,0 +1,20 @@
+<%= title_tag "#{@import_task.full_name} <span class='status status_#{@import_task.status}'>#{ t('import_tasks.show.'+@import_task.status) }</span>" %>
+
+<div class="import_task_show">
+ <div class="links">
+ <%= link_to t("import_tasks.show.imported_file"), file_to_import_referential_import_task_path(@import_task.referential, @import_task), :class => "btn btn-default" %>
+ <% if @import_task.compliance_check_task %>
+ <%= link_to t("import_tasks.compliance_check_task"), referential_compliance_check_task_path(@import_task.referential, @import_task.compliance_check_task), :class => "btn btn-default" %>
+ <% end %>
+ </div>
+ <%= render( :partial => "results_dashboard") if @import_task.completed? %>
+</div>
+
+<% content_for :sidebar do %>
+<ul class="actions">
+ <li><%= link_to t('import_tasks.actions.destroy'), referential_import_task_path(@referential, @import_task), :method => :delete, :data => {:confirm => t('import_tasks.actions.destroy_confirm')}, :class => "remove" %></li>
+</ul>
+
+<%= history_tag(@import_task) %>
+
+<% end %>
diff --git a/app/views/import_tasks/show.js.coffee b/app/views/import_tasks/show.js.coffee
new file mode 100644
index 000000000..accd8e720
--- /dev/null
+++ b/app/views/import_tasks/show.js.coffee
@@ -0,0 +1,41 @@
+jQuery ->
+
+ get_import_results = (html_container, html_element) ->
+ html_container.children().each ->
+ if( $( this ).is(html_element) )
+ $( this ).show()
+ else
+ $( this ).hide()
+
+ Morris.Donut({
+ element: 'files_statistics',
+ data: [
+ {label: "<%= t 'import_tasks.show.graph.files.error' %>", value: <%= @files_stats["error_count"] %> },
+ {label: "<%= t 'import_tasks.show.graph.files.ignored' %>", value: <%= @files_stats["ignored_count"] %> },
+ {label: "<%= t 'import_tasks.show.graph.files.ok' %>", value: <%= @files_stats["ok_count"] %> }
+ ]
+ colors: [ "#e22b1b", "#ffbd2b", "#8fc861" ]
+ }).on('click', update = (i, row) ->
+ switch i
+ when 0 then get_import_results( $(".report"), $(".files_error"))
+ when 1 then get_import_results( $(".report"), $(".files_ignored"))
+ when 2 then get_import_results( $(".report"), $(".files_ok"))
+ else console.log "Error no other value for donut chart")
+
+ Morris.Bar({
+ element: 'objects_statistics',
+ data: [
+ { object: "<%= t("import_tasks.show.graph.lines.lines_stats") %>", value: <%= @lines_stats["line_count"] %> },
+ { object: "<%= t("import_tasks.show.graph.lines.routes_stats") %>", value: <%= @lines_stats["route_count"] %> },
+ { object: "<%= t("import_tasks.show.graph.lines.connection_links_stats") %>", value: <%= @lines_stats["connection_link_count"] %> },
+ { object: "<%= t("import_tasks.show.graph.lines.time_tables_stats") %>", value: <%= @lines_stats["time_table_count"] %> },
+ { object: "<%= t("import_tasks.show.graph.lines.stop_areas_stats") %>", value: <%= @lines_stats["stop_area_count"] %> },
+ { object: "<%= t("import_tasks.show.graph.lines.access_points_stats") %>", value: <%= @lines_stats["access_point_count"] %> },
+ { object: "<%= t("import_tasks.show.graph.lines.vehicle_journeys_stats") %>", value: <%= @lines_stats["vehicle_journey_count"] %> },
+ { object: "<%= t("import_tasks.show.graph.lines.journey_patterns_stats") %>", value: <%= @lines_stats["journey_pattern_count"] %> },
+ ],
+ xkey: 'object',
+ ykeys: ['value'],
+ labels: ['<%= t "import_tasks.show.graph.lines.objects_label" %>']
+ }).on('click', update = (i, row) ->
+ get_import_results( $(".report"), $(".lines")) ) \ No newline at end of file