diff options
| author | Luc Donnet | 2017-09-05 11:09:37 +0200 |
|---|---|---|
| committer | Luc Donnet | 2017-09-05 11:09:37 +0200 |
| commit | 70e8e93b0ebf4596c0ffd64620415db2450f4595 (patch) | |
| tree | 3d211dfb6cf7b75e8879e5a0b9d8a5c082961383 /app | |
| parent | 7497709ff181bb426eef11e2a7eff44b9b178e9c (diff) | |
| download | chouette-core-70e8e93b0ebf4596c0ffd64620415db2450f4595.tar.bz2 | |
Clean up compliance checks existing code Refs #4389 @1
Diffstat (limited to 'app')
22 files changed, 0 insertions, 1052 deletions
diff --git a/app/controllers/compliance_check_tasks_controller.rb b/app/controllers/compliance_check_tasks_controller.rb deleted file mode 100644 index c2995c94d..000000000 --- a/app/controllers/compliance_check_tasks_controller.rb +++ /dev/null @@ -1,49 +0,0 @@ -class ComplianceCheckTasksController < ChouetteController - defaults :resource_class => ComplianceCheckTask - - respond_to :html, :only => [:new, :create] - respond_to :js, :only => [:new, :create] - - belongs_to :referential - - def new - begin - new! - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def create - begin - create! do |success, failure| - success.html { redirect_to referential_compliance_checks_path(@referential) } - end - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def references - references_type = params[:filter].pluralize - references = @referential.send(references_type).where("name ilike ?", "%#{params[:q]}%").select("id, name") - puts references.inspect - respond_to do |format| - format.json do - render :json => references.collect { |child| { :id => child.id, :name => child.name } } - end - end - end - - protected - - def build_resource - @compliance_check_task ||= ComplianceCheckTask.new( params[:compliance_check_task] || {} ) - end - - -end diff --git a/app/controllers/compliance_checks_controller.rb b/app/controllers/compliance_checks_controller.rb index 2d67aae98..07438cf99 100644 --- a/app/controllers/compliance_checks_controller.rb +++ b/app/controllers/compliance_checks_controller.rb @@ -1,87 +1,4 @@ -require 'will_paginate/array' - class ComplianceChecksController < ChouetteController - defaults :resource_class => ComplianceCheck - - respond_to :html, :js - respond_to :zip, :only => :export - belongs_to :referential - - def index - begin - index! do - build_breadcrumb :index - end - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def show - begin - show! do |format| - build_breadcrumb :show - end - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def report - resource - build_breadcrumb :report - end - - def references - @references = referential.send(params[:type]).where("name ilike ?", "%#{params[:q]}%") - respond_to do |format| - format.json do - render json: @references.collect { |child| { id: child.id, name: child.name } } - end - end - end - - def rule_parameter_set - begin - @rule_parameter_set = resource.rule_parameter_set - build_breadcrumb :rule_parameter_set - render "rule_parameter_sets/show" - rescue Ievkit::Error, Faraday::Error => error - logger.error("Iev failure : #{error.message}") - flash[:error] = t(error.locale_for_error) - redirect_to referential_path(@referential) - end - end - - def export - respond_to do |format| - format.zip { send_file ComplianceCheckExport.new(resource, @referential.id, request).export, :type => :zip } - end - end - - protected - - alias_method :compliance_check, :resource - - def compliance_check_service - ComplianceCheckService.new(@referential) - end - - def resource - @compliance_check ||= compliance_check_service.find(params[:id]) - @line_items = @compliance_check.report.line_items - if @line_items.size > 500 - @line_items = @line_items.paginate(page: params[:page], per_page: 20) - end - @compliance_check - end - def collection - @compliance_checks ||= compliance_check_service.all.sort_by{ |compliance_check| compliance_check.created_at }.reverse.paginate(:page => params[:page]) - end end diff --git a/app/helpers/compliance_check_tasks_helper.rb b/app/helpers/compliance_check_tasks_helper.rb deleted file mode 100644 index 5ba8bdc46..000000000 --- a/app/helpers/compliance_check_tasks_helper.rb +++ /dev/null @@ -1,11 +0,0 @@ -module ComplianceCheckTasksHelper - - def button_link_class( compliance_check_task ) - if compliance_check_task.any_error_severity_failure? || compliance_check_task.status == "failed" - "btn-danger" - else - "btn-default" - end - end - -end diff --git a/app/helpers/compliance_checks_helper.rb b/app/helpers/compliance_checks_helper.rb deleted file mode 100644 index d7e42e187..000000000 --- a/app/helpers/compliance_checks_helper.rb +++ /dev/null @@ -1,96 +0,0 @@ -# -*- coding: utf-8 -*- -module ComplianceChecksHelper - - def fields_for_compliance_check_format(form) - begin - render :partial => compliance_check_partial_name(form), :locals => { :form => form } - rescue ActionView::MissingTemplate - "" - end - end - - def compliance_check_partial_name(form) - "fields_#{form.object.format.underscore}_compliance_check" - end - - def compliance_icon( compliance_check) - return nil unless compliance_check.compliance_check_validation_report - compliance_check.compliance_check_validation_report.tap do |cct| - if cct.failed? || cct.any_error_severity_failure? - return 'icons/link_page_alert.png' - else - return 'icons/link_page.png' - end - end - end - - def status_icon( compliance_check_result_status, compliance_check_result_severity ) - if compliance_check_result_status == "uncheck" - ("<i class='fa fa-ban status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe - elsif compliance_check_result_status == "ok" - ("<i class='fa fa-check status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe - else - ("<i class='fa fa-times status_" + compliance_check_result_status + "_" + compliance_check_result_severity + "'></i>").html_safe - end - end - - def test_definition (compliance_check_result_code) - Rails.application.config.validation_spec + I18n.locale.to_s + "/" + compliance_check_result_code +".html" - end - - def object_url (referential_id, error) - location = "/referentials/" + referential_id.to_s - object_path = error[:source].object_path - if object_path.first[:type] == "vehicle_journey" - object_path.delete_at 1 - end - - types, identifiers = object_path.reverse.map { |resource| [ resource[:type], resource[:id] ] }.transpose - - method_name = (['referential'] + types + ['path']).join('_') - identifiers.unshift referential_id - - return send method_name, *identifiers - end - - def object_labels_hash (error) - ### THE error HASH STRUCTURE - # 1. error[:source] - # 0..1 file - # 1 filename - # 0..1 line_number - # 0..1 column_number - # 0..1 objectid - # 0..1 label - # 0.. object_path - # 1 type - # 1 id - # 0.. error[:target] - # 0..1 error[:error_value] - # 0..1 error[:reference_value] - object_labels_hash = Hash.new - object_labels_hash[:source_objectid] = error[:source].objectid if error[:source].objectid.present? - object_labels_hash[:source_label] = error[:source].label if error[:source].label.present? - if error[:source].file.present? - object_labels_hash[:filename] = error[:source].file.filename - object_labels_hash[:line_number] = error[:source].file.line_number if error[:source].file.line_number.present? - object_labels_hash[:column_number] = error[:source].file.column_number if error[:source].file.column_number.present? - end - - if error[:target].present? - error[:target].each_with_index do |target, index| - object_labels_hash["target_#{index}_objectid".to_sym] = target[:objectid] if target[:objectid] - object_labels_hash["target_#{index}_label".to_sym] = target[:label] if target[:label] - end - end - if error[:error_value].present? - object_labels_hash[:error_value] = error[:error_value] - end - if error[:reference_value].present? - object_labels_hash[:reference_value] = error[:reference_value] - end - return object_labels_hash - end - - -end diff --git a/app/models/compliance_check.rb b/app/models/compliance_check.rb index d3e4054a6..a9dbc4211 100644 --- a/app/models/compliance_check.rb +++ b/app/models/compliance_check.rb @@ -1,58 +1,3 @@ class ComplianceCheck - include JobConcern - def initialize( response ) - @datas = response - end - - def report? - links["action_report"].present? - end - - def report - Rails.cache.fetch("#{cache_key}/action_report", expires_in: cache_expiration) do - if report_path = links["action_report"] - ComplianceCheckReport.new Ievkit.get(report_path) - end - end - end - - def compliance_check_validation_report? - links["validation_report"].present? - end - - def compliance_check_validation_report - Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do - if report_path = links["validation_report"] - ComplianceCheckResult.new Ievkit.get(report_path) - end - end - end - - def rule_parameter_set? - links["validation_params"].present? - end - - def rule_parameter_set - Rails.cache.fetch("#{cache_key}/validation_params", expires_in: cache_expiration) do - if rule_parameter_set_path = links["validation_params"] - response = Ievkit.get(rule_parameter_set_path) - RuleParameterSet.new(name: '', compliance_check: self).tap do |rps| - rps.parameters = response.validation - end - end - end - end - - def destroy - if delete_path = links["delete"] - Ievkit.delete(delete_path) - elsif cancel_path = links["cancel"] - Ievkit.delete(cancel_path) - end - end - - def format - datas.type - end end diff --git a/app/models/compliance_check_export.rb b/app/models/compliance_check_export.rb deleted file mode 100644 index 95abb3b27..000000000 --- a/app/models/compliance_check_export.rb +++ /dev/null @@ -1,56 +0,0 @@ -require 'tempfile' - -class ComplianceCheckExport - include ERB::Util - include ComplianceChecksHelper - - require 'zip' - - attr_accessor :template, :detailed_errors_template, :request - attr_reader :compliance_check - - def initialize(compliance_check, referential_id, request) - @request = request - @compliance_check = compliance_check - @referential_id = referential_id - @template = File.open('app/views/compliance_checks/summary_errors_index.csv.erb' ) { |f| f.read } - @detailed_errors_template = File.open('app/views/compliance_checks/detailed_errors_index.csv.erb' ) { |f| f.read } - end - - def export - begin - Dir.mktmpdir("#{I18n.t('compliance_check_results.file.zip_name_prefix')}_#{@referential_id}_#{@compliance_check.id}_", Dir.tmpdir) { |temp_dir| - - File.open(temp_dir + "/#{I18n.t('compliance_check_results.file.summary_errors_file_prefix')}" , "a:utf-8") do |f| - f.write("\ufeff") - f.write(render) - f.flush - end - - File.open(temp_dir + "/#{I18n.t('compliance_check_results.file.detailed_errors_file_prefix')}" , "a:utf-8") do |f| - f.write("\ufeff") - f.write(detailed_errors_render) - f.flush - end - - zip_file = Tempfile.new(["#{I18n.t('compliance_check_results.file.zip_name_prefix')}_#{@referential_id}_#{@compliance_check.id}_", ".zip"]) - - ::Zip::File.open(zip_file.path, ::Zip::File::CREATE) do |zipfile| - Dir[File.join(temp_dir, '*.csv')].each do |f| - zipfile.add(File.basename(f), f) - end - end - return zip_file - } - end - end - - def render() - ERB.new(@template).result(binding) - end - - def detailed_errors_render() - ERB.new(@detailed_errors_template).result(binding) - end - -end diff --git a/app/models/compliance_check_report.rb b/app/models/compliance_check_report.rb deleted file mode 100644 index 94deb8cc9..000000000 --- a/app/models/compliance_check_report.rb +++ /dev/null @@ -1,9 +0,0 @@ -class ComplianceCheckReport - include ReportConcern - - def initialize( response ) - @datas = response.action_report - end - -end - diff --git a/app/models/compliance_check_result.rb b/app/models/compliance_check_result.rb index cd956a021..06f8649f5 100644 --- a/app/models/compliance_check_result.rb +++ b/app/models/compliance_check_result.rb @@ -1,76 +1,3 @@ class ComplianceCheckResult - extend ActiveModel::Naming - extend ActiveModel::Translation - include ActiveModel::Model - - attr_accessor :datas - - def initialize(response) - @datas = response.validation_report - end - - def tests? - datas.tests? - end - - def ok_error - all('ok', 'error') - end - - def nok_error - all('nok', 'error') - end - - def na_error - all('uncheck', 'error') - end - - def ok_warning - all('ok', 'warning') - end - - def nok_warning - all('nok', 'warning') - end - - def na_warning - all('uncheck', 'warning') - end - - def all(status, severity) - tests? ? tests.select { |test| test.result == status.downcase && test.severity == severity.downcase } : [] - end - - def tests - @tests ||= tests? ? datas.tests.map{ |test| Test.new(test) } : [] - end - - class Test - attr_reader :options - - def initialize( options ) - @options = options - end - - def test_id - options.test_id if options.test_id? - end - - def severity - options.severity.downcase if options.severity? - end - - def result - options.result.downcase if options.result? - end - - def errors - options.errors if options.errors? - end - - def error_count - options.error_count if options.error_count? - end - end end diff --git a/app/models/compliance_check_service.rb b/app/models/compliance_check_service.rb deleted file mode 100644 index c27f36894..000000000 --- a/app/models/compliance_check_service.rb +++ /dev/null @@ -1,23 +0,0 @@ -class ComplianceCheckService - - attr_reader :referential - - def initialize(referential) - @referential = referential - end - - # Find a validation whith this id - def find(id) - ComplianceCheck.new(Ievkit.scheduled_job(referential.slug, id, { :action => "validator" })) - end - - # Find all validations - def all - [].tap do |jobs| - Ievkit.jobs(referential.slug, { :action => "validator" }).each do |job| - jobs << ComplianceCheck.new(job) - end - end - end - -end diff --git a/app/models/compliance_check_task.rb b/app/models/compliance_check_task.rb deleted file mode 100644 index da0508cbf..000000000 --- a/app/models/compliance_check_task.rb +++ /dev/null @@ -1,114 +0,0 @@ -class ComplianceCheckTask - extend Enumerize - extend ActiveModel::Naming - extend ActiveModel::Translation - extend ActiveModel::Callbacks - include ActiveModel::Validations - include ActiveModel::Conversion - - enumerize :references_type, in: %w( network line company group_of_line ) - attr_accessor :rule_parameter_set_id, :referential_id, :user_id, :user_name, :name, :references_type, :reference_ids - - validates_presence_of :referential_id, :user_id, :user_name, :name - - def initialize( params = {} ) - params.each {|k,v| send("#{k}=",v)} - end - - def referential - Referential.find(referential_id) - end - - def organisation - referential.organisation - end - - def rule_parameter_set - organisation.rule_parameter_sets.find(rule_parameter_set_id) if rule_parameter_set_id.present? - end - - def save - if valid? - # Call Iev Server - begin - Ievkit.create_job( referential.slug, "validator", "", { - :file1 => params_io, - } ) - rescue Exception => exception - raise exception - end - true - else - false - end - end - - def self.references_types - self.references_type.values - end - - def params - {}.tap do |h| - h["parameters"] = validation_params ? action_params.merge(validation_params) : action_params - end - end - - def action_params - { - "validate" => { - "name" => name, - "references_type" => references_type, - "reference_ids" => reference_ids, - "user_name" => user_name, - "organisation_name" => organisation.name, - "referential_name" => referential.name, - } - - } - end - - def validation_params - { - "validation" => rule_parameter_set.parameters - } if rule_parameter_set.present? - end - - def self.data_formats - self.data_format.values - end - - def params_io - file = StringIO.new( params.to_json ) - Faraday::UploadIO.new(file, "application/json", "parameters.json") - end - - def transport_data_io - file = File.new(saved_resources_path, "r") - if file_extname == ".zip" - Faraday::UploadIO.new(file, "application/zip", original_filename ) - elsif file_extname == ".xml" - Faraday::UploadIO.new(file, "application/xml", original_filename ) - end - end - - def save_resources - FileUtils.mkdir_p root - FileUtils.cp resources.path, saved_resources_path - end - - def delete_resources - FileUtils.rm saved_resources_path if File.exists? saved_resources_path - end - - def original_filename - resources.original_filename - end - - def file_extname - File.extname(resources.original_filename) - end - - def saved_resources_path - "#{root}/#{Time.now.to_i}#{file_extname}" - end -end diff --git a/app/models/concerns/report_concern.rb b/app/models/concerns/report_concern.rb deleted file mode 100644 index f195f8f36..000000000 --- a/app/models/concerns/report_concern.rb +++ /dev/null @@ -1,170 +0,0 @@ -module ReportConcern - extend ActiveSupport::Concern - extend ActiveModel::Naming - extend ActiveModel::Translation - include ActiveModel::Model - - included do - attr_reader :datas - end - - module ClassMethods - end - - delegate :progression?, :progression, :zip_file, :stats, to: :datas - - def failure_code? - datas.result == "NOK" && datas.failure? - end - - def failure_code - datas.failure.code.downcase if failure_code? - end - - def percentage(a, b) - (a.to_f / b.to_f * 100).round(0) - end - - def level_progress - percentage( progression.current_step, progression.steps_count) if progression? - end - - def last_step - datas.progression.steps.last if progression? - end - - def current_step - datas.progression.steps[ progression.current_step - 1] - end - - def step_progress - percentage( current_step.realized, current_step.total ) - end - - def step_progress_name - return last_step.step if progression.current_step == progression.steps_count - - current_step.step - end - - def files - @files ||= datas.files || [] - end - - def error_files - files.select{ |file| file[:status] == "ERROR"} - end - - def ignored_files - files.select{ |file| file[:status] == "IGNORED"} - end - - def ok_files - files.select{ |file| file[:status] == "OK"} - end - - def line_items - @line_items ||= [].tap do |line_items| - datas.lines.each do |line| - line_items << LineItem.new(line) - end if datas.lines? - end - end - - def saved_lines - line_items.map(&:status).count(true) - end - - def unsaved_lines - line_items.map(&:status).count(false) - end - - def lines - stats.present? ? stats.line_count : 0 - end - - def routes - stats.present? ? stats.route_count : 0 - end - - def connection_links - stats.present? ? stats.connection_link_count : 0 - end - - def time_tables - stats.present? ? stats.time_table_count : 0 - end - - def stop_areas - stats.present? ? stats.stop_area_count : 0 - end - - def access_points - stats.present? ? stats.access_point_count : 0 - end - - def vehicle_journeys - stats.present? ? stats.vehicle_journey_count : 0 - end - - def journey_patterns - stats.present? ? stats.journey_pattern_count : 0 - end - - class LineItem - attr_reader :options - - def initialize( options ) - @options = options - end - - def name - @name ||= options.name if options.name? - end - - def stats - @stats ||= options.stats if options.stats? - end - - def status - @status ||= if options.status? - if %w{ok warning}.include? options.status.downcase - true - else - false - end - else - false - end - end - - def routes - stats ? stats.route_count : 0 - end - - def connection_links - stats ? stats.connection_link_count : 0 - end - - def time_tables - stats ? stats.time_table_count : 0 - end - - def stop_areas - stats ? stats.stop_area_count : 0 - end - - def access_points - stats ? stats.access_point_count : 0 - end - - def vehicle_journeys - stats ? stats.vehicle_journey_count : 0 - end - - def journey_patterns - stats ? stats.journey_pattern_count : 0 - end - - end -end diff --git a/app/views/compliance_check_tasks/new.html.erb b/app/views/compliance_check_tasks/new.html.erb deleted file mode 100644 index 3f43a7dd7..000000000 --- a/app/views/compliance_check_tasks/new.html.erb +++ /dev/null @@ -1,39 +0,0 @@ -<%= title_tag t(".title") %> - -<%= semantic_form_for [@referential, @compliance_check_task], :url => referential_compliance_check_tasks_path(@referential) do |form| %> - <%= form.inputs do %> - <%= form.input :user_name, :as => :hidden, :input_html => { :value => current_user.name } %> <%= form.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } %> - <%= form.input :referential_id, :as => :hidden, :input_html => { :value => @referential.id } %> - <%= form.input :name %> - <%= form.input :rule_parameter_set_id, :as => :select, - :collection => @referential.organisation.rule_parameter_sets.map { |rps| [ rps.name, rps.id ] }, :include_blank => false %> - <%= form.input :references_type, :as => :select, :include_blank => t(".all") %> - <% @compliance_check_task.class.references_types.each do |type| %> - <%= form.input :reference_ids, :as => :reference_ids, :json => references_referential_compliance_check_tasks_path(@referential, :format => :json) + "?filter=#{type}", :hint_text => t('search_hint'), :no_result_text => t('no_result_text'),:searching_text => t('searching_term'), :id => "#{type}_reference_ids", :input_html => { :id => "#{type}_reference_ids" }, :wrapper_html => { :style => "display:none;", :id => "#{type}", :"data-type" => "#{type}" } %> - <% end %> - <% end %> - - <%= form.actions do %> - <%= form.action :submit, :as => :button , :label => t( 'formtastic.validate' ) %> - <%= form.action :cancel, :as => :link %> - <% end %> -<% end %> - -<!-- = title_tag t('.title') - -= semantic_form_for [@referential, @compliance_check_task], :url => referential_compliance_check_tasks_path(@referential) do |form| - = form.inputs do - = form.input :user_name, :as => :hidden, :input_html => { :value => current_user.name } - = form.input :user_id, :as => :hidden, :input_html => { :value => current_user.id } - = form.input :referential_id, :as => :hidden, :input_html => { :value => @referential.id } - = form.input :name - = form.input :rule_parameter_set_id, :as => :select, - :collection => @referential.organisation.rule_parameter_sets.map { |rps| [ rps.name, rps.id ] }, :include_blank => false - = form.input :references_type, :as => :select, :include_blank => t(".all") - - @compliance_check_task.class.references_types.each do |type| - - = form.input :reference_ids, as: :reference_ids, json: references_referential_compliance_check_tasks_path(@referential, format: :json) + "?filter=#{type}", hint_text: t('search_hint'), no_result_text: t('no_result_text'), searching_text: t('searching_term'), id: "#{type}_reference_ids", input_html: { :id => "#{type}_reference_ids" }, wrapper_html: { :style => "display:none;", :id => "#{type}", :"data-type" => "#{type}" } - - = form.actions do - = form.action :submit, as: :button, label: t('formtastic.validate') - = form.action :cancel, as: :link --> diff --git a/app/views/compliance_check_tasks/new.js.coffee b/app/views/compliance_check_tasks/new.js.coffee deleted file mode 100644 index ba62f53b2..000000000 --- a/app/views/compliance_check_tasks/new.js.coffee +++ /dev/null @@ -1,7 +0,0 @@ -jQuery -> - <% ComplianceCheckTask.references_types.map { |type| type_ids_model_references_type( ComplianceCheckTask, type)}.each do |rt| %> - $("textarea.<%= rt.input_class %>").tokenInput('<%= references_referential_compliance_check_tasks_path(@referential, :type => rt.relation_name, :format => :json) %>', { prePopulate: $('#').data('pre'), minChars: 1, hintText: '<%= t('search_hint') %>', noResultsText: '<%= t('no_result_text') %>', searchingText: '<%= t('searching_term') %>'}); - <% end %> - - # - ComplianceCheckTask.references_types.map { |type| type_ids_model_references_type( ComplianceCheckTask, type)}.each do |rt| - # $("textarea.#{rt.input_class}").tokenInput("#{references_referential_compliance_check_tasks_path(@referential, :type => rt.relation_name, format: :json)}", { prePopulate: $('#').data('pre'), minChars: 1, hintText: "#{t('search_hint')}", noResultsText: "#{t('no_result_text')}", searchingText: "#{t('searching_term')}"}); diff --git a/app/views/compliance_checks/_compliance_check.html.slim b/app/views/compliance_checks/_compliance_check.html.slim deleted file mode 100644 index 383a7ea82..000000000 --- a/app/views/compliance_checks/_compliance_check.html.slim +++ /dev/null @@ -1,17 +0,0 @@ -#index_item.panel.panel-default - .panel-heading - .panel-title.clearfix - span.pull-right - = link_to referential_compliance_check_path(@referential, compliance_check.id), :method => :delete, :data => {:confirm => t('compliance_checks.actions.destroy_confirm')}, class: 'btn btn-danger btn-sm' do - span.fa.fa-trash-o - h5 - = link_to referential_compliance_check_path(@referential, compliance_check.id), class: 'preview', title: "#{ComplianceCheck.model_name.human.capitalize} #{compliance_check.name}" do - = job_status_title(compliance_check) - - .panel-body - p - = link_to( font_awesome_classic_tag("fa-external-link") + t("compliance_checks.actions.report"), report_referential_compliance_check_path(@referential, compliance_check.id)) if compliance_check.report? - .panel-footer - .history - = l compliance_check.created_at, :format => "%d/%m/%Y %H:%M" - = " | #{compliance_check.user_name}" diff --git a/app/views/compliance_checks/_compliance_check_results.html.slim b/app/views/compliance_checks/_compliance_check_results.html.slim deleted file mode 100644 index 8e86c174e..000000000 --- a/app/views/compliance_checks/_compliance_check_results.html.slim +++ /dev/null @@ -1,92 +0,0 @@ -p - form.form-inline - .form-group - label = t('shared.ie_report.search') - input#filter.form-control type="text" - - .form-group - label = ComplianceCheckResult.human_attribute_name(:severity) - select.filter-severity.form-control - option - option value="severity-error" - = t('compliance_check_result.severities.error') - option value="severity-warning" - = t('compliance_check_result.severities.warning') - - .form-group - label = ComplianceCheckResult.human_attribute_name(:status) - select.filter-status.form-control - option - option value="status-ok" - = t('compliance_check_result.statuses.ok') - option value="status-nok" - = t('compliance_check_result.statuses.nok') - option value="status-uncheck" - = t('compliance_check_result.statuses.uncheck') - - -table.table.table-hover.toggle-circle.toggle-medium data-filter="#filter" data-page-size="20" data-title-nok="#{t('compliance_check_result.statuses.nok')}" data-title-uncheck="#{t('compliance_check_result.statuses.uncheck')}" data-title-ok="#{t('compliance_check_result.statuses.ok')}" - thead - tr - th data-sort-ignore="true" - = ComplianceCheckResult.human_attribute_name(:status) - th.col-md-1 data-sort-ignore="true" - = ComplianceCheckResult.human_attribute_name(:severity) - th.col-md-3 - = ComplianceCheckResult.human_attribute_name(:rule_code) - th.col-md-2 - = t('compliance_check_results.errors') - th.col-md-6 data-toggle="true" data-sort-ignore="true" - = ComplianceCheckResult.human_attribute_name(:detail) - th data-hide="all" data-sort-ignore="true" - - tbody - - if compliance_check_validation_report - - compliance_check_validation_report.tests.each_with_index do |test, index| - tr class="#{test.result}_#{test.severity}" - td data-value="status-#{test.result}" - = status_icon( test.result, test.severity ) - td data-value="severity-#{test.severity}" - = t("compliance_check_result.severities.#{test.severity}_txt") - td data-value="#{test.result}_#{test.severity}" - = link_to test.test_id, test_definition(test.test_id), title: ComplianceCheckResult.human_attribute_name(test.test_id), target: "compliance_check" - td - = "#{test.error_count || 0} #{ComplianceCheckResult.human_attribute_name(:violation_count)}" if test.errors.present? - td - = truncate(t("activemodel.attributes.compliance_check_result.#{test.test_id}"), length: 50) - td - p - b - = t("activemodel.attributes.compliance_check_result.#{test.test_id}") - - - if test.errors.present? - - test.errors.first(10).each do |error| - dl.inline - dt - - if error["source"].present? - - if error[:source].object_path.present? - - if error[:source].label.present? - = link_to error[:source].label, object_url(@referential.id, error), target: :_blank - - else - = link_to "#{error[:source].object_path.type} (#{error[:source].object_path.id})", object_url(@referential.id, error), target: :_blank - - - if error[:source].file.present? - = error[:source].objectid if error[:source].objectid.present? - - dd = t("compliance_check_result.details.detail_#{error[:error_id]}", object_labels_hash(error)) - - - if error[:source].file.present? - p.file_error - = error[:source].file.filename - = ", li: #{error[:source].file.line_number}" if error[:source].file.line_number.present? - = ", co: #{error[:source].file.column_number}" if error[:source].file.column_number.present? - - - else - tr - td colspan="6" - = t('compliance_check_results.in_progress') - - tfoot.hide-if-no-paging - tr - td colspan="5" - ul.pagination.pagination-centered diff --git a/app/views/compliance_checks/_compliance_checks.html.slim b/app/views/compliance_checks/_compliance_checks.html.slim deleted file mode 100644 index 48db9ae94..000000000 --- a/app/views/compliance_checks/_compliance_checks.html.slim +++ /dev/null @@ -1,9 +0,0 @@ -.page_info - span.search = t('will_paginate.page_entries_info.search') - = page_entries_info @compliance_checks - -.compliance_checks.paginated_content - = paginated_content @compliance_checks, "compliance_checks/compliance_check" - -.pagination - = will_paginate @compliance_checks, :container => false, renderer: RemoteBootstrapPaginationLinkRenderer
\ No newline at end of file diff --git a/app/views/compliance_checks/detailed_errors_index.csv.slim b/app/views/compliance_checks/detailed_errors_index.csv.slim deleted file mode 100644 index 7fe20e282..000000000 --- a/app/views/compliance_checks/detailed_errors_index.csv.slim +++ /dev/null @@ -1,37 +0,0 @@ -= I18n.t('activemodel.attributes.compliance_check_result.severity'); -= I18n.t('activemodel.attributes.compliance_check_result.rule_code'); -= I18n.t('activemodel.attributes.compliance_check_result.object'); -= I18n.t('activemodel.attributes.compliance_check_result.resource'); -= I18n.t('activemodel.attributes.compliance_check_result.title'); -= I18n.t('activemodel.attributes.compliance_check_result.detail') - -- @compliance_check.compliance_check_validation_report.tests.each do |r| - - if r.errors.present? - - r.errors.first(10).each do |error| - - case r.severity - - when "warning" - = I18n.t('compliance_check_result.severities.warning_txt') - - when "error" - = I18n.t('compliance_check_result.severities.error_txt') - - = r.test_id; - - - if error["source"].present? - = error["source"]["objectid"] if error["source"]["objectid"].present? - - - if error["source"]["object_path"].present? - = object_url(@referential_id, error) - - elsif error["source"]["file"].present? - = File.basename(error["source"]["file"]["filename"]) + " - " - = I18n.t("compliance_check_results.index.column") + ":" - = error["source"]["file"]["column_number"] + "," - = I18n.t("compliance_check_results.index.line") + ":" - = error["source"]["file"]["line_number"] - - - else - = I18n.t("activemodel.attributes.compliance_check_result.#{r.test_id}"); - = I18n.t("compliance_check_result.details.detail_#{error['error_id']}", object_labels_hash(error) ) - = "\n" - -/ <%= I18n.t("activemodel.attributes.compliance_check_result.severity") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.rule_code") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.object") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.resource") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.title") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.detail") %> -/ <% @compliance_check.compliance_check_validation_report.tests.each do |r| %><% if r.errors.present? %><% r.errors.first(10).each do |error| %><% case r.severity %><% when "warning" %><%= I18n.t "compliance_check_result.severities.warning_txt" %><% when "error" %><%= I18n.t "compliance_check_result.severities.error_txt" %><% end %>;<%= r.test_id %>;<% if error["source"].present? %><%= error["source"]["objectid"] if error["source"]["objectid"].present? %>;<% if error["source"]["object_path"].present? %><%= object_url(@referential_id, error) %><% elsif error["source"]["file"].present? %><%= File.basename(error["source"]["file"]["filename"]) +" - " %><%= I18n.t "compliance_check_results.index.column" %>:<%= error["source"]["file"]["column_number"] %>,<%= I18n.t "compliance_check_results.index.line" %>:<%= error["source"]["file"]["line_number"] %><% end %>;<% else %>;;<% end %><%= I18n.t("activemodel.attributes.compliance_check_result."+r.test_id) %>;<%= I18n.t("compliance_check_result.details.detail_#{error['error_id']}", object_labels_hash(error) )%><%= "\n" %><% end %><% end %><% end %> diff --git a/app/views/compliance_checks/index.html.slim b/app/views/compliance_checks/index.html.slim deleted file mode 100644 index 392c46663..000000000 --- a/app/views/compliance_checks/index.html.slim +++ /dev/null @@ -1,14 +0,0 @@ -= title_tag t('.title') - -.warning - = t('.warning') - -#compliance_checks - = render 'compliance_checks' - -- content_for :sidebar do - ul.actions - li - = link_to t('compliance_check_tasks.actions.new'), new_referential_compliance_check_task_path(), class: 'add' - li - = link_to t('rule_parameter_sets.actions.index'), organisation_rule_parameter_sets_path, class: 'link'
\ No newline at end of file diff --git a/app/views/compliance_checks/index.js.slim b/app/views/compliance_checks/index.js.slim deleted file mode 100644 index cfd8dc40d..000000000 --- a/app/views/compliance_checks/index.js.slim +++ /dev/null @@ -1 +0,0 @@ -| $('#compliance_checks').html("#{escape_javascript(render('compliance_checks'))}");
\ No newline at end of file diff --git a/app/views/compliance_checks/report.html.slim b/app/views/compliance_checks/report.html.slim deleted file mode 100644 index be2bb8adc..000000000 --- a/app/views/compliance_checks/report.html.slim +++ /dev/null @@ -1,41 +0,0 @@ -= title_tag job_status_title(@compliance_check) - -.compliance_check_show - .links - - if @compliance_check.class == Import - = link_to(font_awesome_classic_tag('fa-eye') + t("compliance_checks.report.action_report"), referential_import_path(@referential, @compliance_check.id)) - = link_to font_awesome_classic_tag("fa-external-link") + t("compliance_checks.rule_parameter_set"), rule_parameter_set_referential_import_path(@referential, @compliance_check.id) if @compliance_check.rule_parameter_set? - - else - = link_to(font_awesome_classic_tag('fa-eye') + t("compliance_checks.report.action_report"), referential_compliance_check_path(@referential, @compliance_check.id)) - = link_to font_awesome_classic_tag("fa-external-link") + t("compliance_checks.rule_parameter_set"), rule_parameter_set_referential_compliance_check_path(@referential, @compliance_check.id) if @compliance_check.rule_parameter_set? - - .btn-group.pull-right - button.btn.btn-default.dropdown-toggle type="button" data-toggle="dropdown" aria-expanded="false" - = t('compliance_checks.show.export') - span.caret - - ul.dropdown-menu role="menu" - li - - if @compliance_check.class == Import - = link_to t('compliance_checks.show.export_csv'), export_referential_import_path(@referential, @compliance_check.id) - - else - = link_to t("compliance_checks.show.export_csv"), export_referential_compliance_check_path(@referential, @compliance_check.id) - - .report data-refresh-interval="#{job_refresh_interval(@compliance_check)}" - = render partial: 'compliance_checks/compliance_check_results', locals: { compliance_check_validation_report: @compliance_check.compliance_check_validation_report } - -- content_for :sidebar do - - if @compliance_check.compliance_check_validation_report && @compliance_check.compliance_check_validation_report.nok_error.blank? - .row - = font_awesome_classic_tag('fa-thumbs-up fa-5x col-md-3') - p#validation_success.col-md-7 - = t('.validation_success') - - ul.actions - li - - if @compliance_check.class != Import - = link_to t('compliance_checks.actions.destroy'), referential_compliance_check_path(@referential, @compliance_check.id), method: :delete, :data => {:confirm => t('compliance_checks.actions.destroy_confirm')}, class: 'remove' - - = history_tag(@compliance_check) - #error.graph - #warning.graph
\ No newline at end of file diff --git a/app/views/compliance_checks/show.html.slim b/app/views/compliance_checks/show.html.slim deleted file mode 100644 index 8c6900981..000000000 --- a/app/views/compliance_checks/show.html.slim +++ /dev/null @@ -1,22 +0,0 @@ -.test - = title_tag job_status_title(@compliance_check) - -- if @compliance_check.report.failure_code? - .alert.alert-danger - = t("iev.failure.#{@compliance_check.report.failure_code}") - -.progress_bars - = progress_bar_tag(@compliance_check) - -.compliance_check.show - .links - = link_to font_awesome_classic_tag("fa-external-link") + t("compliance_checks.actions.report"), report_referential_compliance_check_path(@referential, @compliance_check.id) if @compliance_check.compliance_check_validation_report? - - = render partial: "shared/ie_report", locals: { job: @compliance_check, type: :validation, line_items: @line_items } - -- content_for :sidebar do - ul.actions - li - = link_to t('compliance_checks.actions.destroy'), referential_compliance_check_path(@referential, @compliance_check.id), method: :delete, data: {confirm: t('compliance_checks.actions.destroy_confirm')}, class: 'remove' - - = history_tag(@compliance_check)
\ No newline at end of file diff --git a/app/views/compliance_checks/summary_errors_index.csv.slim b/app/views/compliance_checks/summary_errors_index.csv.slim deleted file mode 100644 index 8c88d5cf6..000000000 --- a/app/views/compliance_checks/summary_errors_index.csv.slim +++ /dev/null @@ -1,34 +0,0 @@ -= I18n.t("activemodel.attributes.compliance_check_result.severity"); -= I18n.t("activemodel.attributes.compliance_check_result.status"); -= I18n.t("activemodel.attributes.compliance_check_result.rule_code"); -= I18n.t("activemodel.attributes.compliance_check_result.title"); -= I18n.t("activemodel.attributes.compliance_check_result.url"); -= I18n.t("activemodel.attributes.compliance_check_result.violation_count_txt"); -= I18n.t("activemodel.attributes.compliance_check_result.objects") - -- @compliance_check.compliance_check_validation_report.tests.each do |r| - - case r.severity - - when "warning" - = I18n.t("compliance_check_result.severities.warning_txt") - - when "error" - = I18n.t("compliance_check_result.severities.error_txt") - - = r.result; - = r.test_id; - - = I18n.t("activemodel.attributes.compliance_check_result.#{r.test_id}"); - = Rails.application.config.validation_spec + I18n.locale.to_s + "/" + r.test_id + ".html"; - - = r.error_count - - - if r.error_count > 0 - - if r.errors.present? - - r.errors.first(10).each do |error| - - if error["source"] - = error["source"]["objectid"] + " " - - else - = " " - -/ <%= I18n.t("activemodel.attributes.compliance_check_result.severity") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.status") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.rule_code") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.title") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.url") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.violation_count_txt") %>;<%= I18n.t("activemodel.attributes.compliance_check_result.objects") %> -/ <% @compliance_check.compliance_check_validation_report.tests.each do |r| %><% case r.severity %><% when "warning" %><%= I18n.t "compliance_check_result.severities.warning_txt" %><% when "error" %><%= I18n.t "compliance_check_result.severities.error_txt" %><% end %>;<%= r.result %>;<%= r.test_id %>;<%= I18n.t("activemodel.attributes.compliance_check_result."+r.test_id) %>;<%= Rails.application.config.validation_spec + I18n.locale.to_s + "/" + r.test_id + ".html" %>;<%= r.error_count %><% if r.error_count > 0 %><% if r.errors.present? %>;<% r.errors.first(10).each do |error| %><% if error["source"] %><%= error["source"]["objectid"] + " " %><% else %><%= " " %><% end %><% end %><% end %><% end %> -/ <% end %> |
