From 4c6b3b725275eaa8a87c22c56e0086722e7a7748 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Thu, 21 Jun 2018 23:09:19 +0100 Subject: Redesign the mini environment show page Start introducing some workflow, and simplifying the layout. Also improve the jobs partial, making it actually show when jobs are running. The next step is to run the build as a mini environment job, which should remove some unnecessary complexity. --- app/controllers/mini_environments_controller.rb | 2 +- app/views/mini_environments/show.html.erb | 77 ++++++++++++++++++------- app/views/shared/_jobs.html.erb | 75 ++++++++++++++++-------- 3 files changed, 108 insertions(+), 46 deletions(-) diff --git a/app/controllers/mini_environments_controller.rb b/app/controllers/mini_environments_controller.rb index 05cf558..9b8a16c 100644 --- a/app/controllers/mini_environments_controller.rb +++ b/app/controllers/mini_environments_controller.rb @@ -148,7 +148,7 @@ class MiniEnvironmentsController < ApplicationController MiniEnvironmentJob.enqueue(@mini_environment.id, :destroy) flash[:notice] = 'Destroying mini environment' - when 'Start' + when 'Start the mini environment' MiniEnvironmentJob.enqueue(@mini_environment.id, :start) flash[:notice] = 'Starting mini environment' diff --git a/app/views/mini_environments/show.html.erb b/app/views/mini_environments/show.html.erb index d680a46..7f3432a 100644 --- a/app/views/mini_environments/show.html.erb +++ b/app/views/mini_environments/show.html.erb @@ -27,34 +27,76 @@ License along with the GOV.UK Mini Environment Admin. If not, see

Name: <%= @mini_environment.name %>

+
-
- - View - +
+ <% status = @mini_environment.status %> + + <% if status[:running] %> + + View + -
<%= form_with(url: mini_environment_perform_action_path(@mini_environment), local: true, method: "post") do %> - <%= submit_tag('Start', - disabled: !@mini_environment.backend_data.present?, + <%= submit_tag("Destroy", role: 'button', - class: 'list-group-item btn btn-lg btn-success btn-block') + class: 'btn btn-lg btn-danger') %> <% end %> + <% else %> <%= form_with(url: mini_environment_perform_action_path(@mini_environment), local: true, method: "post") do %> - <%= submit_tag("Destroy", + <%= submit_tag('Start the mini environment', + disabled: !@mini_environment.backend_data.present?, role: 'button', - class: 'list-group-item btn btn-lg btn-danger btn-block', - style: 'margin-top: 5px;') + class: 'btn btn-lg btn-success') %> <% end %> -
+ <% end %> +
+
+ <% if @mini_environment.backend_data.present? %> +
+ +
+
+
+ <% @mini_environment.backend_data.each do |(key, value)| %> +
<%= key %>
+
<%= value %>
+ <% end %> +
+
+
+
+ <% end %> + + <%= render( + partial: 'shared/jobs', + locals: { jobs: jobs } + ) %>
@@ -81,7 +123,7 @@ Plus <%= uncustomised_services.length %> other services at the revision specifie <% end %> -

Initial Signon Users

+

Initial Signon Users

@@ -102,10 +144,3 @@ Plus <%= uncustomised_services.length %> other services at the revision specifie <% end %>
- -

Jobs

- -<%= render( - partial: 'shared/jobs', - locals: { jobs: jobs } -) %> diff --git a/app/views/shared/_jobs.html.erb b/app/views/shared/_jobs.html.erb index 73d59ce..5b559c1 100644 --- a/app/views/shared/_jobs.html.erb +++ b/app/views/shared/_jobs.html.erb @@ -4,7 +4,10 @@ role="tablist" aria-multiselectable="true"> + <% job_states = Que.job_states %> + <% jobs.each do |job| %> + <% job_state = job_states.find { |x| x[:id] == job.id } %>
@@ -38,24 +51,38 @@ >
-
-
<%= job['last_error'] %>
-
-
- <%= form_with(url: retry_now_que_job_path(job.id)) do %> - <%= submit_tag( - 'Retry now', - class: 'btn btn-primary btn-lg btn-block' - ) %> - <% end %> - <%= form_with(url: cancel_que_job_path(job.id)) do %> - <%= submit_tag( - 'Cancel Job', - class: 'btn btn-warning btn-lg btn-block', - style: 'margin-top: 5px;' - ) %> - <% end %> -
+ <% if job_state %> +
+ Running now +
+
+ PID: <%= job_state[:ruby_pid] %> +
+ <% elsif job.finished_at %> +
+ Finished after <%= job['error_count'] %> errors. +
+ <% else %> +
+
<%= job.last_error_message %>
+
<%= job.last_error_backtrace %>
+
+
+ <%= form_with(url: retry_now_que_job_path(job.id)) do %> + <%= submit_tag( + 'Retry now', + class: 'btn btn-primary btn-lg btn-block' + ) %> + <% end %> + <%= form_with(url: cancel_que_job_path(job.id)) do %> + <%= submit_tag( + 'Cancel', + class: 'btn btn-warning btn-lg btn-block', + style: 'margin-top: 5px;' + ) %> + <% end %> +
+ <% end %>
-- cgit v1.2.3