From 971ef5e530c6c20e29acda0eae15257f7b3163fa Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Thu, 6 Jun 2013 22:28:14 +0400 Subject: [PATCH] Show never runned tasks --- .../rake_control_web/application.css | 2 ++ .../rake_control_web/application_controller.rb | 5 ++++- .../rake_control_web/tasks_controller.rb | 5 +++++ .../rake_control_web/application_helper.rb | 10 ++++++++++ .../views/rake_control_web/tasks/index.html.erb | 17 ++++++++++++----- 5 files changed, 33 insertions(+), 6 deletions(-) diff --git a/rake_control_web/app/assets/stylesheets/rake_control_web/application.css b/rake_control_web/app/assets/stylesheets/rake_control_web/application.css index 3fa3d95..18276fd 100644 --- a/rake_control_web/app/assets/stylesheets/rake_control_web/application.css +++ b/rake_control_web/app/assets/stylesheets/rake_control_web/application.css @@ -3,3 +3,5 @@ *= require rake_control_web/foundation.min *= require_self */ + +a.button { margin: 0; } diff --git a/rake_control_web/app/controllers/rake_control_web/application_controller.rb b/rake_control_web/app/controllers/rake_control_web/application_controller.rb index 5d72e51..5ff73f9 100644 --- a/rake_control_web/app/controllers/rake_control_web/application_controller.rb +++ b/rake_control_web/app/controllers/rake_control_web/application_controller.rb @@ -1,7 +1,10 @@ module RakeControlWeb class ApplicationController < ActionController::Base def tasks - Rake.application.tasks + Rails.application.load_tasks + Rake.application.tasks.keep_if do |task| + task.name =~ /^[a-z0-9_:]+$/ + end end end end diff --git a/rake_control_web/app/controllers/rake_control_web/tasks_controller.rb b/rake_control_web/app/controllers/rake_control_web/tasks_controller.rb index ec576c6..b065bc3 100644 --- a/rake_control_web/app/controllers/rake_control_web/tasks_controller.rb +++ b/rake_control_web/app/controllers/rake_control_web/tasks_controller.rb @@ -2,6 +2,11 @@ module RakeControlWeb class TasksController < ApplicationController def index @tasks = RakeControl::Storage.run.summary + (tasks.map(&:name) - @tasks.map(&:name)).each do |nr_task| # Never runned tasks + @tasks << RakeControl::Storage.run.new( + name: nr_task + ) + end end def run diff --git a/rake_control_web/app/helpers/rake_control_web/application_helper.rb b/rake_control_web/app/helpers/rake_control_web/application_helper.rb index 7e4310d..039c788 100644 --- a/rake_control_web/app/helpers/rake_control_web/application_helper.rb +++ b/rake_control_web/app/helpers/rake_control_web/application_helper.rb @@ -1,4 +1,14 @@ module RakeControlWeb module ApplicationHelper + def task_label run + case run.success + when true + 'success' + when false + 'alert' + else + 'secondary' + end + end end end diff --git a/rake_control_web/app/views/rake_control_web/tasks/index.html.erb b/rake_control_web/app/views/rake_control_web/tasks/index.html.erb index de4a956..09666c7 100644 --- a/rake_control_web/app/views/rake_control_web/tasks/index.html.erb +++ b/rake_control_web/app/views/rake_control_web/tasks/index.html.erb @@ -11,11 +11,18 @@ <% @tasks.each do |run| %> - <%= run.name %> - <%= time_ago_in_words(run.created_at) %> ago - <%= run.execution_time.round(6) %>s - <%= link_to 'Run', run_task_path(run.name, back: tasks_path), class: 'radius button' %> - <%= link_to 'History', task_runs_path(run.name), class: 'secondary radius button' %> + <%= run.name %> + <% if run.created_at %> + <%= time_ago_in_words(run.created_at) %> ago + <%= run.execution_time.round(6) %>s + <%= link_to 'Run', run_task_path(run.name, back: tasks_path), class: 'small radius button' %> + <%= link_to 'History', task_runs_path(run.name), class: 'secondary small radius button' %> + <% else %> + never + — + <%= link_to 'Run', run_task_path(run.name, back: tasks_path), class: 'small radius button' %> + History + <% end %> <% end %>