<div>
	<br><br><br>
	<div class='ui container'>
		<h1>Bull Ops: 
			<div class="ui inline dropdown">
				<div class="text">
					<%=req.params.queue?req.params.queue:'queue'%>
				</div>
				<i class="dropdown icon"></i>
				<div class="menu">
					<a class="item" href='/bull/cashflowy'>
						cashflowy
					</a>
				</div>
			</div>
		</h1>
		<div class="ui pointing secondary menu">
			<a class="item" href='/bull/<%=req.params.queue%>'>Overview</a>
			<a class="item" href='/bull/<%=req.params.queue%>/active'>Active</a>
			<a class="item" href='/bull/<%=req.params.queue%>/inactive'>Inactive</a>
			<a class="item" href='/bull/<%=req.params.queue%>/delayed'>Delayed</a>
			<a class="item" href='/bull/<%=req.params.queue%>/failed'>Failed</a>
			<a class="item" href='/bull/<%=req.params.queue%>/complete'>Complete</a>
		</div>

		<h3>Queue Stats:</h3>
		<table class="ui celled structured table">
			<thead>
				<tr>
					<th>Job</th>
					<th>Active</th>
					<th>Inactive</th>
					<th>Delayed</th>
					<th>Failed</th>
					<th>Completed</th>
				</tr>
			</thead>
			<tbody>
				<tr>
					<td>All</td>
					<td><a href="/bull/<%=req.params.queue%>/active"><%=overall_stats.active%></a></td>
					<td><a href="/bull/<%=req.params.queue%>/inactive"><%=overall_stats.waiting%></a></td>
					<td><a href="/bull/<%=req.params.queue%>/delayed"><%=overall_stats.delayed%></a></td>
					<td><a href="/bull/<%=req.params.queue%>/failed"><%=overall_stats.failed%></a></td>
					<td><a href="/bull/<%=req.params.queue%>/complete"><%=overall_stats.completed%></a></td>
					
				</tr>
				<!--  -->
			</tbody>
		</table>
		

		<h3>Repeats:</h3>
		<table class="ui celled structured table">
			<thead>
				<tr>
					<th>Name</th>
					<th>Cron</th>
					<th>Every(Sec)</th>
					<th>Next Execution</th>
					<th>End Date</th>
					<th>Delete Repeat</th>
					<th>Do now</th>
				</tr>
			</thead>
			<tbody>
				<%repeats.forEach(function(repeat){%>
				<tr>
					<td><%=repeat.name %></td>
					<td><%=repeat.cron ? repeat.cron : '-' %></td>
					<td><%=repeat.every ? repeat.every/1000+' secs': '-' %></td>
					<td><%=repeat.next? moment(repeat.next).fromNow() :'-'%></td>
					<td><%=repeat.endDate?repeat.endDate : '-' %></td>
					<td class="center aligned">
						<button class="circular red ui icon button delete_repeat" data-id='<%=repeat.key%>'>
							<i class="icon delete"></i>
						</button>
					</td>
					<td class="center aligned">
						<button class="circular green ui icon button do_now" data-id='<%=repeat.name%>'>
							<i class="icon plus"></i>
						</button>
					</td>
				</tr>
				<%})%>
				<!--  -->
			</tbody>
		</table>

		<br><br><br>
		<h3> Some parameters that you can use</h3>
		- n - number of items per page (default 30) <br>
		- job_state - items of a particular state <br>
		- page - the next page of items (default 1) <br>
		- order_by - order the items after they are selected (default asc) <br>
		<br>
	</div>

	
</div>
<script type="text/javascript">
	$(document).ready(function(){
		$('.delete_repeat').click(function(){
			var button = this;
			$(button).addClass('loading');
			var repeat_name=$(this).attr('data-id');
			// var job_id='';
			var r = confirm("Delete this permanently ?");
			if (r == true) {
				$.post("/bull/<%=req.params.queue%>/repeat/delete", {name: repeat_name}, function(result,status){
				console.log('result = '+result);
				console.log('status = '+status);// this runs only on sucess
				if(status=='success'){
					$(button).removeClass('loading');
					$(button).addClass('disabled');
				}
			});
			} else {
				$(button).removeClass('loading');
			}
		});
		$('.do_now').click(function(){
			var button = this;
			$(button).addClass('loading');
			var repeat_name=$(this).attr('data-id');
			// var job_id='';
			// var r = confirm("Delete this permanently ?");
			$.post("/bull/<%=req.params.queue%>/job/add", {name: repeat_name}, function(result,status){
				console.log('result = '+result);
				console.log('status = '+status);// this runs only on sucess
				if(status=='success'){
					$(button).removeClass('loading');
					$(button).addClass('disabled');
				}
			});
			
		});
	});
	$('.dropdown').dropdown();
	var path = window.location.pathname;
	$('a[href="'+path+'"]').addClass('active');
</script>