aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuc Donnet2015-05-07 16:39:45 +0200
committerLuc Donnet2015-05-07 16:39:45 +0200
commitd6f9c8d86f1f2c7f482a700d446b7a1a63c8e29d (patch)
treef03992f20b94d5b74192b0f3d03698d1d3314c0b
parent73abd85f6181e33fe0b2fe31a5c46f2fbc44eb8a (diff)
downloadchouette-core-d6f9c8d86f1f2c7f482a700d446b7a1a63c8e29d.tar.bz2
Begin to refactor compliance check
-rw-r--r--app/assets/javascripts/partials/ie_report.js.coffee.erb2
-rw-r--r--app/assets/stylesheets/main/compliance_checks.css.scss1
-rw-r--r--app/models/compliance_check.rb92
-rw-r--r--app/views/compliance_checks/_compliance_check.html.erb5
-rw-r--r--app/views/compliance_checks/show.html.erb5
5 files changed, 31 insertions, 74 deletions
diff --git a/app/assets/javascripts/partials/ie_report.js.coffee.erb b/app/assets/javascripts/partials/ie_report.js.coffee.erb
index 77305e016..3e38ce87b 100644
--- a/app/assets/javascripts/partials/ie_report.js.coffee.erb
+++ b/app/assets/javascripts/partials/ie_report.js.coffee.erb
@@ -1,4 +1,4 @@
-jQuery ->
+$(".imports.show, .exports.show").ready ->
get_export_results = (html_container, html_element) ->
html_container.children().each ->
diff --git a/app/assets/stylesheets/main/compliance_checks.css.scss b/app/assets/stylesheets/main/compliance_checks.css.scss
index f36108c30..e3ba53937 100644
--- a/app/assets/stylesheets/main/compliance_checks.css.scss
+++ b/app/assets/stylesheets/main/compliance_checks.css.scss
@@ -3,6 +3,7 @@
}
#workspace.compliance_checks.show {
+ @import "../modules/job_status_colors";
.status {
margin-left: 10px;
diff --git a/app/models/compliance_check.rb b/app/models/compliance_check.rb
index f27dd7249..f0a78839f 100644
--- a/app/models/compliance_check.rb
+++ b/app/models/compliance_check.rb
@@ -1,49 +1,39 @@
class ComplianceCheck
- extend Enumerize
- extend ActiveModel::Naming
- extend ActiveModel::Translation
- include ActiveModel::Model
- attr_reader :datas
-
- def initialize(response)
- @datas = response
- end
-
- def links
- {}.tap do |links|
- datas.links.each do |link|
- links[link["rel"]] = link["href"]
- end
- end
- end
+ include JobConcern
def report
- report_path = links["action_report"]
- if report_path
- response = Ievkit.get(report_path)
- ComplianceCheckReport.new(response)
- else
- nil
+ Rails.cache.fetch("#{cache_key}/action_report", expires_in: cache_expiration) do
+ report_path = links["action_report"]
+ if report_path
+ response = Ievkit.get(report_path)
+ ComplianceCheckReport.new(response)
+ else
+ nil
+ end
end
end
def compliance_check_validation_report
- report_path = links["validation_report"]
- if report_path
- response = Ievkit.get(report_path)
- ComplianceCheckResult.new(response)
- else
- nil
+ Rails.cache.fetch("#{cache_key}/validation_report", expires_in: cache_expiration) do
+ report_path = links["validation_report"]
+ if report_path
+ response = Ievkit.get(report_path)
+ ComplianceCheckResult.new(response)
+ else
+ nil
+ end
end
end
def rule_parameter_set
- rule_parameter_set = links["validation_params"]
- if rule_parameter_set
- response = Ievkit.get(rule_parameter_set)
- rule_parameter_set = RuleParameterSet.new.tap { |rps| rps.parameters = response.validation }
- else
- nil
+ Rails.cache.fetch("#{cache_key}/validation_params", expires_in: cache_expiration) do
+ rule_parameter_set = links["validation_params"]
+ if rule_parameter_set
+ response = Ievkit.get(rule_parameter_set)
+ rule_parameter_set = RuleParameterSet.new.tap { |rps| rps.parameters = response.validation }
+ else
+ nil
+ end
end
end
@@ -60,40 +50,8 @@ class ComplianceCheck
end
end
- def id
- datas.id
- end
-
- def status
- datas.status.downcase
- end
-
def format
datas.type
end
- def referential_id
- Referential.where(:slug => referential_name).id
- end
-
- def referential_name
- datas.referential
- end
-
- def name
- datas.action_parameters.name
- end
-
- def user_name
- datas.action_parameters.user_name
- end
-
- def created_at
- Time.at(datas.created.to_i / 1000) if datas.created
- end
-
- def updated_at
- Time.at(datas.updated.to_i / 1000) if datas.updated
- end
-
end
diff --git a/app/views/compliance_checks/_compliance_check.html.erb b/app/views/compliance_checks/_compliance_check.html.erb
index 7892e59a2..2e0dbb333 100644
--- a/app/views/compliance_checks/_compliance_check.html.erb
+++ b/app/views/compliance_checks/_compliance_check.html.erb
@@ -8,9 +8,7 @@
</span>
<h5>
<%= link_to( referential_compliance_check_path(@referential, compliance_check.id), :class => "preview", :title => "#{ComplianceCheck.model_name.human.capitalize} #{compliance_check.name}") do %>
- <span class="name">
- <%= truncate(compliance_check.name, :length => 20) %>
- </span>
+ <%= job_status_title(compliance_check) %>
<% end %>
</h5>
</div>
@@ -21,7 +19,6 @@
<% end %>
</div>
<div class="panel-footer">
- <%= progress_bar_tag(compliance_check) %>
<div class="history">
<%= l compliance_check.created_at, :format => "%d/%m/%Y %H:%M" %> | <%= compliance_check.user_name %>
</div>
diff --git a/app/views/compliance_checks/show.html.erb b/app/views/compliance_checks/show.html.erb
index 70b94d726..a1793d585 100644
--- a/app/views/compliance_checks/show.html.erb
+++ b/app/views/compliance_checks/show.html.erb
@@ -2,10 +2,10 @@
<%= title_tag "#{t('imports.show.compliance_check_of')} #{title} #{@import.name} <span class='status status_#{@import.status}'>(#{ t('imports.statuses.'+ @import.status) })</span>" %>
<% @title = "#{@import.name}" %>
<% else %>
- <%= title_tag "#{@compliance_check.name} <span class='status status_#{@compliance_check.status}'>(#{ t('compliance_checks.statuses.'+@compliance_check.status) })</span>" %>
- <% @title = "#{@compliance_check.name}" %>
+ <%= title_tag job_status_title(@compliance_check) %>
<% end %>
+<% if !@compliance_check.aborted? %>
<div class="compliance_check_show">
<div class="links">
<% if !@import && @compliance_check.rule_parameter_set %>
@@ -45,6 +45,7 @@
<%= javascript_include_tag referential_compliance_check_path(@referential, @compliance_check.id,:format => :js) %>
<% end %>
</div>
+<% end %>
<% content_for :sidebar do %>
<ul class="actions">
<li>