diff --git a/dev/metrics/initializers/sessions_helper_extension.rb b/dev/metrics/initializers/sessions_helper_extension.rb index aae8a2a2..12abe738 100644 --- a/dev/metrics/initializers/sessions_helper_extension.rb +++ b/dev/metrics/initializers/sessions_helper_extension.rb @@ -1,12 +1,28 @@ -# Slurm Adapter Extensions to extract metrics with sacct +# SessionsHelper Extensions to add job metrics to session card in OODv3.x Rails.application.config.after_initialize do Rails.logger.info 'Executing Sessions Helper extension ...' module BatchConnect::SessionsHelper - # UPDATE SUPPORT TICKET PARTIAL TO ADD JOB METRICS - # BETTER THAN UPDATE OTHER METHOD MORE LIKELY TO CHANGE - def support_ticket(session) - render(partial: 'batch_connect/sessions/card/support_ticket', locals: { session: session }) - render(partial: 'batch_connect/sessions/card/session_job_metrics', locals: { session: session }) if session.completed? + # UPDATE session_view TO ADD JOB METRICS PARTIAL + def session_view(session) + capture do + concat( + content_tag(:div) do + concat content_tag(:div, cancel_or_delete(session), class: 'float-right') + concat host(session) + concat created(session) + concat render_session_time(session) + concat id(session) + concat support_ticket(session) unless @user_configuration.support_ticket.empty? + if SlurmMetrics::MetricsHelper.new.metrics_enabled? && session.completed? + concat render(partial: 'batch_connect/sessions/card/session_job_metrics', locals: { session: session }) + end + concat display_choices(session) + safe_concat custom_info_view(session) if session.app.session_info_view + safe_concat completed_view(session) if session.app.session_completed_view && session.completed? + end + ) + concat content_tag(:div) { yield } + end end end diff --git a/dev/metrics/lib/slurm_metrics/metrics_helper.rb b/dev/metrics/lib/slurm_metrics/metrics_helper.rb index 22180c2e..88a802ca 100644 --- a/dev/metrics/lib/slurm_metrics/metrics_helper.rb +++ b/dev/metrics/lib/slurm_metrics/metrics_helper.rb @@ -68,5 +68,10 @@ def format_duration(seconds) def metrics_waiting_elapsed(completed_time) Time.now.to_i - completed_time > 10 end + + def metrics_enabled? + metrics_configuration = ::Configuration.config.fetch(:metrics_enabled, true) + ::Configuration.send(:to_bool, metrics_configuration) + end end end diff --git a/dev/metrics/views/batch_connect/sessions/card/_card_body.html.erb b/dev/metrics/views/batch_connect/sessions/card/_card_body.html.erb index 815ade02..d3312f5e 100644 --- a/dev/metrics/views/batch_connect/sessions/card/_card_body.html.erb +++ b/dev/metrics/views/batch_connect/sessions/card/_card_body.html.erb @@ -7,7 +7,7 @@ <%= render_card_partial('id', session) %> <%= render_card_partial('support_ticket', session) if Configuration.support_ticket_enabled? %> <%= render_card_partial('display_choices', session) %> - <%= render_card_partial('session_job_metrics', session) if session.completed?%> + <%= render_card_partial('session_job_metrics', session) if SlurmMetrics::MetricsHelper.new.metrics_enabled? && session.completed?%> <%= render_card_partial('custom_info_view', session) if session.app.session_info_view %> <%= render_card_partial('completed_view', session) if session.app.session_completed_view && session.completed? %> <%= render_connection(session) %> diff --git a/dev/metrics/views/batch_connect/sessions/card/_session_card_css.html.erb b/dev/metrics/views/batch_connect/sessions/card/_session_card_css.html.erb new file mode 100644 index 00000000..c1a040e6 --- /dev/null +++ b/dev/metrics/views/batch_connect/sessions/card/_session_card_css.html.erb @@ -0,0 +1,47 @@ + \ No newline at end of file diff --git a/dev/metrics/views/batch_connect/sessions/card/_session_card_assets.html.erb b/dev/metrics/views/batch_connect/sessions/card/_session_card_js.html.erb similarity index 70% rename from dev/metrics/views/batch_connect/sessions/card/_session_card_assets.html.erb rename to dev/metrics/views/batch_connect/sessions/card/_session_card_js.html.erb index bfbe5b21..d0bee25e 100644 --- a/dev/metrics/views/batch_connect/sessions/card/_session_card_assets.html.erb +++ b/dev/metrics/views/batch_connect/sessions/card/_session_card_js.html.erb @@ -1,52 +1,5 @@ -