forked from danlucraft/redcar
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added task_manager plugin for viewing the status of background jobs
- Loading branch information
1 parent
e313b55
commit 785a9f3
Showing
9 changed files
with
170 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
|
||
require 'erb' | ||
require 'cgi' | ||
|
||
module Redcar | ||
class TaskManager | ||
class OpenCommand < Redcar::Command | ||
|
||
def execute | ||
controller = Controller.new | ||
tab = win.new_tab(HtmlTab) | ||
tab.html_view.controller = controller | ||
tab.focus | ||
end | ||
end | ||
|
||
class Controller | ||
def title | ||
"Tasks" | ||
end | ||
|
||
def index | ||
rhtml = ERB.new(File.read(File.join(File.dirname(__FILE__), "..", "views", "index.html.erb"))) | ||
rhtml.result(binding) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
|
||
Plugin.define do | ||
name "task_manager" | ||
version "0.3.5" | ||
|
||
object "Redcar::TaskManager" | ||
file "lib", "task_manager" | ||
|
||
dependencies "core", ">0", | ||
"HTML View", ">=0.3.2" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<% redcar_css = File.expand_path(File.join(Redcar.root, %w(plugins html_view assets redcar.css))) %> | ||
<link rel="stylesheet" href="file://<%= redcar_css %>" type="text/css" media="screen"> | ||
|
||
<h3>Task Manager</h3> | ||
|
||
<a href="controller/index">Refresh</a> | ||
|
||
<h4>Pending</h4> | ||
|
||
<table> | ||
<tr> | ||
<th>Enqueued</th> | ||
<th>Description</th> | ||
</tr> | ||
<% Redcar.app.task_queue.pending.each do |task| %> | ||
<tr> | ||
<td><%= task.enqueue_time.strftime("%X") %></td> | ||
<td><%= CGI.escapeHTML(task.description || task.class.to_s) %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<h4>In Process</h4> | ||
|
||
<table> | ||
<tr> | ||
<th>Started</th> | ||
<th>Description</th> | ||
</tr> | ||
<% if task = Redcar.app.task_queue.in_process %> | ||
<tr> | ||
<td><%= task.start_time.strftime("%X") %></td> | ||
<td><%= CGI.escapeHTML(task.description || task.class.to_s) %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<h4>Completed</h4> | ||
|
||
<table> | ||
<tr> | ||
<th>Completed</th> | ||
<th>Description</th> | ||
<th>Duration</th> | ||
</tr> | ||
<% Redcar.app.task_queue.completed.reverse.each do |task| %> | ||
<tr class="<%= "error" if task.error %>"> | ||
<td><%= task.completed_time.strftime("%X") %></td> | ||
<td><%= CGI.escapeHTML(task.description || task.class.to_s) %></td> | ||
<td><%= task.completed_time - task.start_time %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
|