<%= title "Worker & Job Queue".html_safe do -%>

	<% if Snorby::Worker.running? %>
		<%= menu_item "Restart Worker", restart_worker_settings_path, 'icons/restart.png', :confirm => "Are you sure you want to restart the worker process?" %>
	<% end %>

	<%= render :partial => 'settings/menu' %>
	
<%- end -%>

<div id='snorby-worker' class='grid_12 page boxit'>
	
	<% if Snorby::Worker.running? %>

		<table class='default' border="0" cellspacing="0" cellpadding="0">

			<tr>
				<th>Status</th>
				<th class="user">user</th>
				<th class="pid">pid</th>
				<th class="created_at">created_at</th>
				<th class="runtime">runtime</th>
				<th class="command">command</th>
				<th class="cpu">cpu</th>
				<th class="memory">memory</th>
			</tr>

			<tbody class='content process'>
				<td class='first'>
					<%= worker_status %>
				</td>
				<td class="user"><%= @process.user %></td>
				<td class="pid"><%= @process.pid %></td>
				<td class="created_at"><%= @process.created_at %></td>
				<td class="runtime"><%= @process.runtime %></td>
				<td class="command"><%= truncate(@process.command, :length => 35, :omission => '...') %></td>
				<td class="cpu" style='width:200px'><%= css_chart(percentage_for(@process.cpu, 100)) %></td>
				<td class="memory last" style='width:200px'><%= css_chart(percentage_for(@process.memory, 100)) %></td>
			</tbody>

		</table>
		
		<div class='table-tooltip'></div>

	<% else %>

		<div id='note-box' class='error'>
			<%= image_tag('icons/note-icon-white.png') %>
			The Snorby worker is not currently running. It's imperative you start the worker immediately!
			All backend calculations are performed asynchronously using the Snorby Worker.
		</div>

	<% end %>
	
</div>

<%= render :partial => 'jobs/jobs' %>
