From c88cf2caae73fa7d61d5b62e52c8628323bb3839 Mon Sep 17 00:00:00 2001 From: MariaAga Date: Wed, 21 Feb 2024 16:37:33 +0100 Subject: [PATCH] Fixes #37185 - webpack 5 adjustments --- app/views/job_invocations/show.html.erb | 17 ++++++++++++----- app/views/job_invocations/show.js.erb | 9 ++++++++- app/views/template_invocations/_refresh.js.erb | 14 ++++++++++---- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/app/views/job_invocations/show.html.erb b/app/views/job_invocations/show.html.erb index d6085ba23..b0e140862 100644 --- a/app/views/job_invocations/show.html.erb +++ b/app/views/job_invocations/show.html.erb @@ -1,9 +1,9 @@ <% title @job_invocation.description %> -<% stylesheet 'foreman_remote_execution/foreman_remote_execution' %> -<% javascript 'foreman_remote_execution/template_invocation' %> -<% javascript *webpack_asset_paths('foreman_remote_execution', :extension => 'js') %> +<%= webpacked_plugins_js_for :foreman_remote_execution %> +<% content_for(:javascripts) do -%> + <% javascript 'foreman_remote_execution/template_invocation' %><% end %> <% content_for(:stylesheets) do %> - <%= webpacked_plugins_css_for :foreman_remote_execution %> + <% stylesheet 'foreman_remote_execution/foreman_remote_execution' %> <% end %> <%= breadcrumbs name_field: 'description' %> @@ -47,6 +47,13 @@ diff --git a/app/views/job_invocations/show.js.erb b/app/views/job_invocations/show.js.erb index fbb19a4a7..94b103220 100644 --- a/app/views/job_invocations/show.js.erb +++ b/app/views/job_invocations/show.js.erb @@ -1,5 +1,12 @@ $('div#title_action div.btn-group').html('<%= button_group(job_invocation_task_buttons(@job_invocation.task)).html_safe %>'); <% if @auto_refresh %> - delayed_refresh($('script#job_invocation_refresh').data('refresh-url'), job_invocation_refresh_data()); + if(window.allJsLoaded){ + delayed_refresh($('script#job_invocation_refresh').data('refresh-url'), job_invocation_refresh_data()) + } + else { + $(document).on('loadJS', function() { + delayed_refresh($('script#job_invocation_refresh').data('refresh-url'), job_invocation_refresh_data()) + }); + } <% end %> diff --git a/app/views/template_invocations/_refresh.js.erb b/app/views/template_invocations/_refresh.js.erb index fed1160c3..2863ed427 100644 --- a/app/views/template_invocations/_refresh.js.erb +++ b/app/views/template_invocations/_refresh.js.erb @@ -1,7 +1,13 @@ <% if @auto_refresh %> -$(function() { - delayed_refresh($("div.terminal").data('refresh-url'), - {"since": "<%= @line_sets.last.try(:[], 'timestamp') || @since %>", "line_counter": $("div.terminal div.line").size()}); -}); + if(window.allJsLoaded){ + delayed_refresh($("div.terminal").data('refresh-url'), + {"since": "<%= @line_sets.last.try(:[], 'timestamp') || @since %>", "line_counter": $("div.terminal div.line").size()}) + } + else { + $(document).on('loadJS', function() { + delayed_refresh($("div.terminal").data('refresh-url'), + {"since": "<%= @line_sets.last.try(:[], 'timestamp') || @since %>", "line_counter": $("div.terminal div.line").size()}) + }); + } <% end %>