diff options
| -rw-r--r-- | app/models/export.rb | 34 | ||||
| -rw-r--r-- | app/models/export_report.rb | 24 | ||||
| -rw-r--r-- | app/models/export_service.rb | 2 | ||||
| -rw-r--r-- | app/models/export_task.rb | 11 | ||||
| -rw-r--r-- | app/models/import.rb | 1 | ||||
| -rw-r--r-- | app/views/exports/_export.erb | 9 | ||||
| -rw-r--r-- | app/views/exports/_exports.html.erb | 3 | ||||
| -rw-r--r-- | app/views/exports/_results_dashboard.html.erb | 56 | ||||
| -rw-r--r-- | app/views/exports/index.html.erb | 7 | ||||
| -rw-r--r-- | app/views/exports/show.html.erb | 55 | ||||
| -rw-r--r-- | app/views/exports/show.js.coffee | 45 | ||||
| -rw-r--r-- | app/views/imports/_import.erb | 6 | ||||
| -rw-r--r-- | app/views/imports/index.html.erb | 8 |
13 files changed, 152 insertions, 109 deletions
diff --git a/app/models/export.rb b/app/models/export.rb index 6b60f3df1..6cb52fb6e 100644 --- a/app/models/export.rb +++ b/app/models/export.rb @@ -10,40 +10,40 @@ class Export end def report - report_path = datas.links[:report] + report_path = "http://localhost:8080/chouette_iev" + datas.links.select{ |link| link["rel"] == "action_report"}.first.href if report_path - response = IevApi.request(:get, compliance_check_path, params) + response = Ievkit.get(report_path) ExportReport.new(response) else - raise IevApi::IevError("Impossible to access report path link for import") + raise Ievkit::Error("Impossible to access report path link for export") end end def compliance_check - compliance_check_path = datas.links[:validation] + compliance_check_path = "http://localhost:8080/chouette_iev" + datas.links.select{ |link| link["rel"] == "validation_report"}.first.href if compliance_check_path - response = IevApi.request(:get, compliance_check_path, params) + response = Ievkit.get(compliance_check_path) ComplianceCheck.new(response) else - raise IevApi::IevError("Impossible to access compliance check path link for import") + raise Ievkit::Error("Impossible to access compliance check path link for export") end end def delete - delete_path = datas.links[:delete] + delete_path = "http://localhost:8080/chouette_iev" + datas.links.select{ |link| link["rel"] == "delete"}.first.href if delete_path - IevApi.request(:delete, delete_path, params) + Ievkit.delete(delete_path) else - raise IevApi::IevError("Impossible to access delete path link for import") + raise Ievkit::Error("Impossible to access delete path link for export") end end def cancel - cancel_path = datas.links[:cancel] + cancel_path = datas.links.select{ |link| link["rel"] == "cancel"}.first.href if cancel_path - IevApi.request(:delete, cancel_path, params) + Ievkit.delete(cancel_path) else - raise IevApi::IevError("Impossible to access cancel path link for import") + raise Ievkit::Error("Impossible to access cancel path link for export") end end @@ -60,7 +60,7 @@ class Export end def filename - datas.filename + datas.links.select{ |link| link["rel"] == "data"}.first.href.gsub( /\/.*\//, "" ) end def filename_extension @@ -89,14 +89,6 @@ class Export datas.action_parameters.user_name end - def no_save - datas.action_parameters.no_save - end - - def filename - datas.filename - end - def created_at? datas.created? end diff --git a/app/models/export_report.rb b/app/models/export_report.rb index 1bbf1bd6a..f739bf1a9 100644 --- a/app/models/export_report.rb +++ b/app/models/export_report.rb @@ -4,16 +4,12 @@ class ExportReport attr_reader :datas, :errors, :metadatas - def initialize( response ) - @datas = response.datas + def initialize(response) + @datas = response.action_report @errors = response.errors @metadatas = response.metadatas end - def zip_file - datas.zip_file - end - def error_files datas.files.select{ |file| file[:status] == "ERROR"} end @@ -39,35 +35,35 @@ class ExportReport end def lines - datas.stats.line_count if datas.stats_.line_count? + datas.stats.line_count if datas.stats.line_count? end def routes - datas.stats.route_count if datas.stats_.route_count? + datas.stats.route_count if datas.stats.route_count? end def connection_links - datas.stats.connection_link_count if datas.stats_.connection_link_count? + datas.stats.connection_link_count if datas.stats.connection_link_count? end def time_tables - datas.stats.time_table_count if datas.stats_.time_table_count? + datas.stats.time_table_count if datas.stats.time_table_count? end def stop_areas - datas.stats.stop_area_count if datas.stats_.stop_area_count? + datas.stats.stop_area_count if datas.stats.stop_area_count? end def access_points - datas.stats.access_point_count if datas.stats_.access_point_count? + datas.stats.access_point_count if datas.stats.access_point_count? end def vehicle_journeys - datas.stats.vehicle_journey_count if datas.stats_.vehicle_journey_count? + datas.stats.vehicle_journey_count if datas.stats.vehicle_journey_count? end def journey_patterns - datas.stats.journey_pattern_count if datas.stats_.journey_pattern_count? + datas.stats.journey_pattern_count if datas.stats.journey_pattern_count? end class LineItem diff --git a/app/models/export_service.rb b/app/models/export_service.rb index 307ec34cd..d41c045d1 100644 --- a/app/models/export_service.rb +++ b/app/models/export_service.rb @@ -8,7 +8,7 @@ class ExportService # Find an export whith his id def find(id) - Export.new(IevApi.scheduled_job(referential.slug, id, { :action => "exporter" })) + Export.new(Ievkit.scheduled_job(referential.slug, id, { :action => "exporter" })) end # Find all exports diff --git a/app/models/export_task.rb b/app/models/export_task.rb index 09c0aeef4..4d439b58a 100644 --- a/app/models/export_task.rb +++ b/app/models/export_task.rb @@ -53,19 +53,13 @@ class ExportTask < ActiveRecord::Base delay.export end - def save_requested? - !parameter_set["no_save"] - end - protected - option :no_save, :boolean option :format option :file_path option :references_type - validates_inclusion_of :no_save, :in => [ true, false] - validates_inclusion_of :format, :in => self.formats + validates_inclusion_of :format, :in => self.formats def chouette_command Chouette::Command.new(:schema => referential.slug) @@ -139,8 +133,7 @@ class ExportTask < ActiveRecord::Base end def full_name - return name unless no_save - "#{name} - #{I18n.t('activerecord.attributes.export_task.no_save')}" + return name end # Create ExportTask and ComplianceCheckTask associated and give export id to Chouette Loader diff --git a/app/models/import.rb b/app/models/import.rb index 905544a1e..b159b1688 100644 --- a/app/models/import.rb +++ b/app/models/import.rb @@ -113,5 +113,4 @@ class Import def updated_at Time.at(datas.updated.to_i / 1000) if updated_at? end - end diff --git a/app/views/exports/_export.erb b/app/views/exports/_export.erb index c406a1caa..8fb310e55 100644 --- a/app/views/exports/_export.erb +++ b/app/views/exports/_export.erb @@ -2,17 +2,14 @@ <div class="panel-heading"> <div class="panel-title clearfix"> <span class="pull-right"> - <!-- % puts "EXPORTEXPORTEXPORTEXPORTEXPORT = #{export.datas.links.inspect}" % --> - <!-- % puts "EXPORTEXPORTEXPORTEXPORTEXPORT = #{export.datas.links[2].href}" % --> - <!-- % puts "EXPORTEXPORTEXPORTEXPORTEXPORT = #{export.datas.links[3].href}" % --> - <%= link_to "#{Rails.application.config.iev_url}#{export.datas.links[3].href}", :method => :delete, :data => {:confirm => t('exports.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm" do %> + <%= link_to "#{Rails.application.config.iev_url}#{export.datas.links[4].href}", :method => :delete, :data => {:confirm => t('exports.actions.destroy_confirm')}, :class => "btn btn-danger btn-sm" do %> <span class="fa fa-trash-o"></span> <% end %> </span> <h5> - <%= link_to( "#{Rails.application.config.iev_url}#{export.datas.links[3].href}", :class => "preview", :title => "#{Export.model_name.human.capitalize} #{export.name}") do %> + <%= link_to( referential_export_path(@referential, export.id), :class => "preview", :title => "#{Export.model_name.human.capitalize} #{export.name}") do %> <span class="name"> - <%if !export.no_save %><i class="fa fa-save"></i><% end %> <%= truncate(export.name, :length => 20) %> + <i class="fa fa-save"></i> <%= truncate(export.name, :length => 20) %> </span> <% end %> </h5> diff --git a/app/views/exports/_exports.html.erb b/app/views/exports/_exports.html.erb index 52ec2df19..343b57cdd 100644 --- a/app/views/exports/_exports.html.erb +++ b/app/views/exports/_exports.html.erb @@ -2,8 +2,7 @@ <span class="search"> <%= t("will_paginate.page_entries_info.search") %></span> <%= page_entries_info @exports %> </div> <div class="exports paginated_content"> - <!-- %= paginated_content(@exports, "export", {:delete => false, :edit => true}) % --> - <%= paginated_content(@exports) %> + <%= paginated_content @exports, "exports/export" %> </div> <div class="pagination"> <%= will_paginate @exports, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer %> diff --git a/app/views/exports/_results_dashboard.html.erb b/app/views/exports/_results_dashboard.html.erb new file mode 100644 index 000000000..2bc264652 --- /dev/null +++ b/app/views/exports/_results_dashboard.html.erb @@ -0,0 +1,56 @@ +<div class="resume row"> + <div class="col-md-4"> + <% file_title = (@export.filename_extension==".zip") ? t("exports.show.graph.files.title_zip") : t("exports.show.graph.files.title_default", :extension => @export.filename_extension)%> + <div class="caption"><%= file_title %></div> + <div id="files_statistics"></div> + </div> + <div class="col-md-8"> + <div class="caption"><%= t "exports.show.graph.lines.title" %></div> + <div id="objects_statistics"></div> + </div> +</div> + +<div class="report"> + <div class="files files_error"> + <% @export.report.error_files.each_with_index do |file, index| %> + <div class="col-md-6"> + <%= image_tag "icons/file_xml_md.png" %><span class="file_name" title='<%= file.name %>'><%= truncate(file.name, :length => 40) %></span> + </div> + <% end %> + </div> + <div class="files files_ignored"> + <% @export.report.ignored_files.each_with_index do |file, index| %> + <div class="col-md-6"> + <%= image_tag "icons/file_xml_md.png" %><span class="file_name" title='<%= file.name %>'><%= truncate(file.name, :length => 40) %></span> + </div> + <% end %> + </div> + <div class="files files_ok"> + <% @export.report.ok_files.each_with_index do |file, index| %> + <div class="col-md-6"> + <%= image_tag "icons/file_xml_md.png" %><span class="file_name" title='<%= file.name %>'><%= truncate(file.name, :length => 40) %></span> + </div> + <% end %> + </div> + <div class="lines"> + <table class="table table-hover table-striped"> + <thead> + <tr> + <th><%= t("export_tasks.show.table.line.name") %></th> + <th><%= t("export_tasks.show.table.line.export") %></th> + </tr> + </thead> + <tbody> + <% @export.report.line_items.each_with_index do |line_item, index| %> + <% tr_class = (line_item.status == "saved") ? '' : 'class=\'danger\''%> + <tr <%= tr_class %>> + <td><%= line_item.name %></td> + <td><%= t("export_tasks.show.table.line." + line_item.status ) %></td> + </tr> + <% end %> + </tbody> + </table> + </div> +</div> +<%= javascript_include_tag referential_export_path(@referential, @export.id,:format => :js) %> + diff --git a/app/views/exports/index.html.erb b/app/views/exports/index.html.erb index 3fda99672..8775bbd71 100644 --- a/app/views/exports/index.html.erb +++ b/app/views/exports/index.html.erb @@ -5,7 +5,8 @@ <% content_for :sidebar do %> -<ul class="actions"> - <li><%= link_to t('exports.actions.new'), new_referential_export_path(@referential), :class => "add" %></li> -</ul> + <ul class="actions"> + <li><%= link_to t('exports.actions.new'), new_referential_export_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/exports/show.html.erb b/app/views/exports/show.html.erb index 5b6875cb1..dc278b11e 100644 --- a/app/views/exports/show.html.erb +++ b/app/views/exports/show.html.erb @@ -1,52 +1,17 @@ -<%= title_tag @export.name %> +<div class="test"> + <% title = "<i class='fa fa-save'></i>" %> + <%= title_tag "#{title} #{@export.name} <span class='status status_#{@export.status}'>#{ t('exports.statuses.'+ @export.status) }</span>" %> +</div> <div class="export_show"> - <div class="summary"> - <p> - <label><%= Export.human_attribute_name(:created_at) %>: </label> - <%= l @export.created_at %> - </p> - <p> - <label><%= Export.human_attribute_name(:status) %>: </label> - <%= t @export.status, :scope => "exports.statuses" %> - </p> - </div> + <%= render( :partial => "results_dashboard", :locals => { :referential => @referential} ) %> +</div> - <% if @export.references.present? %> - <h3><%= Export.human_attribute_name(:references) %></h3> - <ul> - <% @export.references.each do |reference| %> - <li><%= link_to "#{reference.class.model_name.humanize} #{reference.name}", [@referential, reference] %> - <% end %> +<% content_for :sidebar do %> + <ul class="actions"> + <li><%= link_to t('exports.actions.destroy'), referential_export_path(@referential, @export.id), :method => :delete, :data => {:confirm => t('exports.actions.destroy_confirm')}, :class => "remove" %></li> </ul> - <% end %> - <% if @export.log_messages.present? %> - <h3><%= t(".report") %></h3> - <table> - <tr> - <th class="severity"></th> - <th class="created_at"><%= ExportLogMessage.human_attribute_name(:created_at) %></th> - <th class="position"><%= ExportLogMessage.human_attribute_name(:position) %></th> - <th class="message"><%= ExportLogMessage.human_attribute_name(:full_message) %></th> - </tr> - <% @export.log_messages.each do |message| %> - <tr> - <td class="severity"><%= image_tag "severity-#{message.severity}.png", :alt => t(message.severity, :scope => "export_log_messages.severities") %></td> - <td class="created_at"><%= l message.created_at, :format => :short %></td> - <td class="position"><%= message.position %></td> - <td class="message"><%= message.full_message %></td> - </tr> - <% end %> - </table> - <% end %> -</div> + <%= history_tag(@export) %> -<% content_for :sidebar do %> -<ul class="actions"> - <% if @export.status == 'completed' %> - <li><%= link_to t('exports.actions.download'), referential_export_path(@referential, @export, :format => :zip), :class => "download" %></li> - <% end %> - <li><%= link_to t('exports.actions.destroy'), referential_export_path(@referential, @export), :method => :delete, :data => {:confirm => t('exports.actions.destroy_confirm')}, :class => "remove" %></li> -</ul> <% end %> diff --git a/app/views/exports/show.js.coffee b/app/views/exports/show.js.coffee new file mode 100644 index 000000000..de9ce8744 --- /dev/null +++ b/app/views/exports/show.js.coffee @@ -0,0 +1,45 @@ +jQuery -> + + get_export_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 'exports.show.graph.files.error' %>", value: <%= @export.report.error_files.count %> }, + {label: "<%= t 'exports.show.graph.files.ignored' %>", value: <%= @export.report.ignored_files.count %> }, + {label: "<%= t 'exports.show.graph.files.ok' %>", value: <%= @export.report.ok_files.count %> } + ] + colors: [ "#e22b1b", "#898e7f", "#8fc861" ] + }).on('click', update = (i, row) -> + switch i + when 0 then get_export_results( $(".report"), $(".files_error")) + when 1 then get_export_results( $(".report"), $(".files_ignored")) + when 2 then get_export_results( $(".report"), $(".files_ok")) + else console.log "Error no other value for donut chart") + + Morris.Bar({ + element: 'objects_statistics', + data: [ + { object: "<%= t("exports.show.graph.lines.lines_stats").html_safe %>", value: <%= @export.report.lines %> }, + { object: "<%= t("exports.show.graph.lines.routes_stats").html_safe %>", value: <%= @export.report.routes %> }, + { object: "<%= t("exports.show.graph.lines.connection_links_stats").html_safe %>", value: <%= @export.report.connection_links %> }, + { object: "<%= t("exports.show.graph.lines.time_tables_stats").html_safe %>", value: <%= @export.report.time_tables %> }, + { object: "<%= t("exports.show.graph.lines.stop_areas_stats").html_safe %>", value: <%= @export.report.stop_areas %> }, + { object: "<%= t("exports.show.graph.lines.access_points_stats").html_safe %>", value: <%= @export.report.access_points %> }, + { object: "<%= t("exports.show.graph.lines.vehicle_journeys_stats").html_safe %>", value: <%= @export.report.vehicle_journeys %> }, + { object: "<%= t("exports.show.graph.lines.journey_patterns_stats").html_safe %>", value: <%= @export.report.journey_patterns %> }, + ], + xkey: 'object', + ykeys: ['value'], + labels: ['<%= t "exports.show.graph.lines.objects_label" %>'] + xLabelAngle: 40, + xAxisLabelTopPadding: 7, + padding: 40, + hideHover: true + }).on('click', update = (i, row) -> + get_export_results( $(".report"), $(".lines")) )
\ No newline at end of file diff --git a/app/views/imports/_import.erb b/app/views/imports/_import.erb index cbed386f5..4acc4586b 100644 --- a/app/views/imports/_import.erb +++ b/app/views/imports/_import.erb @@ -8,9 +8,9 @@ </span> <h5> <%= link_to( referential_import_path(@referential, import.id), :class => "preview", :title => "#{ImportTask.model_name.human.capitalize} #{import.name}") do %> - <span class="name"> - <% if !import.no_save %><i class="fa fa-save"></i><% end %> <%= truncate(import.name, :length => 20) %> - </span> + <span class="name"> + <% if !import.no_save %><i class="fa fa-save"></i><% end %> <%= truncate(import.name, :length => 20) %> + </span> <% end %> </h5> </div> diff --git a/app/views/imports/index.html.erb b/app/views/imports/index.html.erb index 32bb6fe27..a44166352 100644 --- a/app/views/imports/index.html.erb +++ b/app/views/imports/index.html.erb @@ -5,8 +5,8 @@ <% content_for :sidebar do %> -<ul class="actions"> - <li><%= link_to t('imports.actions.new'), new_referential_import_path(@referential), :class => "add" %></li> - <li><%= link_to t('rule_parameter_sets.actions.index'), referential_rule_parameter_sets_path(@referential), :class => "link" %></li> -</ul> + <ul class="actions"> + <li><%= link_to t('imports.actions.new'), new_referential_import_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 %> |
