#*
 * Copyright 2012 LinkedIn, Inc
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
*#

<!DOCTYPE html> 
<html>
	<head>
#parse( "azkaban/webapp/servlet/velocity/style.vm" )
		<script type="text/javascript" src="${context}/js/jquery/jquery.js"></script>    
		<script type="text/javascript" src="${context}/js/jqueryui/jquery-ui.custom.min.js"></script>
		<script type="text/javascript" src="${context}/js/namespace.js"></script>
		<script type="text/javascript" src="${context}/js/underscore-1.2.1-min.js"></script>
		<script type="text/javascript" src="${context}/js/backbone-0.5.3-min.js"></script>
		<script type="text/javascript" src="${context}/js/jquery.simplemodal.js"></script>
		<script type="text/javascript" src="${context}/js/azkaban.nav.js"></script>
		<script type="text/javascript" src="${context}/js/azkaban.scheduled.view.js"></script>
		<script type="text/javascript">
			var contextURL = "${context}";
			var currentTime = ${currentTime};
			var timezone = "${timezone}";
			var errorMessage = null;
			var successMessage = null;
	
		</script>
	</head>
	<body>
#set($current_page="schedule")
#parse( "azkaban/webapp/servlet/velocity/nav.vm" )
		<div class="messaging"><p id="messageClose">X</p><p id="message"></p></div>  

		<div class="content">
		
#if($errorMsg)
                                <div class="box-error-message">$errorMsg</div>
#else
#if($error_message != "null")
                                <div class="box-error-message">$error_message</div>
#elseif($success_message != "null")
                                <div class="box-success-message">$success_message</div>
#end
#end		
		
			<div id="all-scheduledFlows-content">
				<div class="section-hd">
					<h2>Scheduled Flows</h2>
				</div>
			</div>
			
			<div class="scheduledFlows">
				<table id="scheduledFlowsTbl">
					<thead>
						<tr>
							<!--th class="execid">Execution Id</th-->
							<th>Flow</th>
							<th>Project</th>
							<th>User</th>
							<th>Submitted By</th>
							<th class="date">First Scheduled to Run</th>
							<th class="date">Next Execution Time</th>
							<th class="date">Repeats Every</th>
							<th class="action">Action</th>
						</tr>
					</thead>
					<tbody>
						#if($schedules)
#foreach($sched in $schedules)
						<tr class="row" >

							<td class="tb-name">
								<a href="${context}/manager?project=${sched.projectName}&flow=${sched.flowName}">${sched.flowName}</a>
							</td>
							<td>
								<a href="${context}/manager?project=${sched.projectName}">${sched.projectName}</a>
							</td>
							<td>${sched.submitUser}</td>
							<td>${sched.submitUser}</td>
							<td>$utils.formatDateTime(${sched.firstSchedTime})</td>
							<td>$utils.formatDateTime(${sched.nextExecTime})</td>
							<td>$utils.formatPeriod(${sched.period})</td>
							<td><button id="removeSchedBtn" onclick="removeSched(${sched.projectId}, '${sched.flowName}')" >Remove Schedule</button></td>
						</tr>
#end
#else
						<tr><td class="last">No Scheduled Flow Found</td></tr>
#end
					</tbody>
				</table>
				
				
			</div>
		</div>
	</body>
</html>
