aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorAlban Peignier2015-05-19 11:00:47 +0200
committerAlban Peignier2015-05-19 11:00:47 +0200
commit840c0ee89722930d63d5f12fdbbf76adfbc8a717 (patch)
tree6e15856ec6a756fbaf191b32f592c8cedacde51b /app
parent53ec8195413d0137f439073a5fd9862ca4eb4a20 (diff)
downloadchouette-core-840c0ee89722930d63d5f12fdbbf76adfbc8a717.tar.bz2
Reload Import/Export/Validation pages every 30s when job is started
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/compliance_checks/show.js.coffee19
-rw-r--r--app/assets/javascripts/partials/ie_report.js.coffee.erb11
-rw-r--r--app/helpers/jobs_helper.rb7
-rw-r--r--app/views/compliance_checks/show.html.erb8
-rw-r--r--app/views/shared/_ie_report.html.erb6
5 files changed, 34 insertions, 17 deletions
diff --git a/app/assets/javascripts/compliance_checks/show.js.coffee b/app/assets/javascripts/compliance_checks/show.js.coffee
index 8b3c2d6ca..3a6cf0ace 100644
--- a/app/assets/javascripts/compliance_checks/show.js.coffee
+++ b/app/assets/javascripts/compliance_checks/show.js.coffee
@@ -1,12 +1,12 @@
$(".compliance_checks.show, .imports.compliance_check").ready ->
get_compliance_check_results = (html_container, css_class) ->
- html_container.each ->
+ html_container.each ->
if( $( this ).hasClass(css_class) )
$( this ).show()
else
$( this ).hide()
-
+
Morris.Donut({
element: 'error',
data: [
@@ -34,10 +34,15 @@ $(".compliance_checks.show, .imports.compliance_check").ready ->
when 0 then get_compliance_check_results( $(".report tbody tr"), "nok_warning")
when 1 then get_compliance_check_results( $(".report tbody tr"), "uncheck_warning")
when 2 then get_compliance_check_results( $(".report tbody tr"), "ok_warning") )
-
+
$(".notice").popover({ container: "body", html: false, trigger: "focus", placement: "bottom" })
# Hide and show error details
- $(".title_error").each ->
- $( this ).click ->
- $(this).next(".details_error").toggle()
- $(this).children("i").toggleClass("fa-plus-square fa-minus-square")
+ $(".title_error").each ->
+ $( this ).click ->
+ $(this).next(".details_error").toggle()
+ $(this).children("i").toggleClass("fa-plus-square fa-minus-square")
+
+ refreshInterval = $(".report").data("refresh-interval")
+ if refreshInterval > 0
+ reloadPage = () -> window.location.reload()
+ setInterval(reloadPage,refreshInterval * 1000)
diff --git a/app/assets/javascripts/partials/ie_report.js.coffee.erb b/app/assets/javascripts/partials/ie_report.js.coffee.erb
index 3e38ce87b..ec9e5f836 100644
--- a/app/assets/javascripts/partials/ie_report.js.coffee.erb
+++ b/app/assets/javascripts/partials/ie_report.js.coffee.erb
@@ -1,5 +1,5 @@
-$(".imports.show, .exports.show").ready ->
-
+$(".imports.show, .exports.show").ready ->
+
get_export_results = (html_container, html_element) ->
html_container.children().each ->
if( $( this ).is(html_element) )
@@ -40,7 +40,7 @@ $(".imports.show, .exports.show").ready ->
{ object: $("th.stop_areas").text(), value: $(".lines table").data("total-stop_areas") },
{ object: $("th.access_points").text(), value: $(".lines table").data("total-access_points") },
{ object: $("th.vehicle_journeys").text(), value: $(".lines table").data("total-vehicle_journeys") },
- { object: $("th.journey_patterns").text(), value: $(".lines table").data("total-journey_patterns") },
+ { object: $("th.journey_patterns").text(), value: $(".lines table").data("total-journey_patterns") },
],
xkey: 'object',
ykeys: ['value'],
@@ -51,3 +51,8 @@ $(".imports.show, .exports.show").ready ->
hideHover: true
}).on('click', update = (i, row) ->
get_export_results( $(".report"), $("div.lines")) )
+
+ refreshInterval = $(".report").data("refresh-interval")
+ if refreshInterval > 0
+ reloadPage = () -> window.location.reload()
+ setInterval(reloadPage,refreshInterval * 1000)
diff --git a/app/helpers/jobs_helper.rb b/app/helpers/jobs_helper.rb
new file mode 100644
index 000000000..00bd237e5
--- /dev/null
+++ b/app/helpers/jobs_helper.rb
@@ -0,0 +1,7 @@
+module JobsHelper
+
+ def job_refresh_interval(job)
+ job.started? ? 30 : 0
+ end
+
+end
diff --git a/app/views/compliance_checks/show.html.erb b/app/views/compliance_checks/show.html.erb
index ad2c3cd90..f91dfae96 100644
--- a/app/views/compliance_checks/show.html.erb
+++ b/app/views/compliance_checks/show.html.erb
@@ -11,7 +11,7 @@
<button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<%= t(".export") %> <span class="caret"></span>
</button>
- <ul class="dropdown-menu" role="menu">
+ <ul class="dropdown-menu" role="menu">
<li>
<% if @compliance_check.class == Import %>
<%= link_to t(".export_csv"), export_referential_import_path(@referential, @compliance_check.id) %>
@@ -20,7 +20,7 @@
<% end %>
</li>
</ul>
- </div>
+ </div>
</div>
<div class="resume">
@@ -34,7 +34,7 @@
</div>
</div>
- <div class="report">
+ <div class="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 } %>
</div>
</div>
@@ -49,5 +49,5 @@
</ul>
<%= history_tag(@compliance_check) %>
-
+
<% end %>
diff --git a/app/views/shared/_ie_report.html.erb b/app/views/shared/_ie_report.html.erb
index 51cb51706..709735f1d 100644
--- a/app/views/shared/_ie_report.html.erb
+++ b/app/views/shared/_ie_report.html.erb
@@ -9,7 +9,7 @@
</div>
</div>
-<div class="report">
+<div class="report" data-refresh-interval="<%= job_refresh_interval(job) %>">
<div class="files files_error" data-label="<%= t('.graph.files.error') %>">
<% job.report.error_files.each_with_index do |file, index| %>
<div class="col-md-6">
@@ -47,10 +47,10 @@
</tr>
</thead>
<tbody>
- <% job.report.line_items.each_with_index do |line_item, index| %>
+ <% job.report.line_items.each_with_index do |line_item, index| %>
<tr>
<td><%= line_item.status ? font_awesome_classic_tag("fa-check") : font_awesome_classic_tag("fa-times") %></td>
- <td><%= line_item.name %></td>
+ <td><%= line_item.name %></td>
<td><%= line_item.routes %></td>
<td><%= line_item.connection_links %></td>
<td><%= line_item.time_tables %></td>