#*
 * Copyright 2012 LinkedIn Corp.
 * 
 * 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 lang="en">
	<head>

#parse ("azkaban/webapp/servlet/velocity/style2.vm")
#parse ("azkaban/webapp/servlet/velocity/javascript.vm")

		<link rel="stylesheet" type="text/css" href="${context}/css/jquery-ui-1.10.1.custom.css" />
		<link rel="stylesheet" type="text/css" href="${context}/css/azkaban-svg.css" />
		<script type="text/javascript" src="${context}/js/jqueryui/jquery-ui-1.10.1.custom.js"></script>
		<script type="text/javascript" src="${context}/js/azkaban.ajax.utils.js"></script>
		<script type="text/javascript" src="${context}/js/azkaban.nav.js"></script>
		<script type="text/javascript" src="${context}/js/azkaban.project.view.js"></script>
		<script type="text/javascript">
			var contextURL = "${context}";
			var currentTime = ${currentTime};
			var timezone = "${timezone}";
			var errorMessage = null;
			var successMessage = null;

			var projectId = ${project.id};
			var execAccess = ${exec};
			var projectName = "$project.name";
		</script>
	</head>
	<body>

#set ($current_page="all")
#parse ("azkaban/webapp/servlet/velocity/nav2.vm")

		<div class="container">

## Page error or success message.

#if ($errorMsg)
			<div class="panel panel-danger">
				<div class="panel-heading">Error</div>
				<div class="panel-body">
					$errorMsg
				</div>
			</div>
#else
	#if ($error_message != "null")
			<div class="alert alert-danger">$error_message</div>
	#elseif ($success_message != "null")
			<div class="alert alert-success">$success_message</div>
	#end

	## Alert message

			<div class="alert alert-dismissable alert-messaging" id="messaging">
				<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
				<p id="messaging-message"></p>
			</div>

	## Page header.

			<div class="page-header">
				<h1><a href="${context}/manager?project=${project.name}">Project <small>$project.name</small></a></h1>
				<p>$project.description</p>
			</div>

	## Page content.

			<div class="row">
				<div class="col-lg-8">
					
	## Breadcrumb

					<ol class="breadcrumb">
						<li class="active"><a href="${context}/manager?project=${project.name}"><strong>Project</strong> $project.name</a></li>
					</ol>

	#set ($project_page = "flows")
	#parse ("azkaban/webapp/servlet/velocity/projectnav.vm")

					<div class="panel panel-default" id="flow-tabs">
						<div class="panel-heading">
							<div class="pull-right" id="project-options">
								<button id="project-upload-btn" class="btn btn-xs btn-primary">Upload</button>
								<button id="project-delete-btn" class="btn btn-xs btn-danger">Delete Project</button>
							</div>
							Flows
						</div>
						<div class="panel-body">

	#if ($flows)
		#foreach ($flow in $flows)
							<div class="panel panel-info" flow="${flow.id}" project="${project.name}">
								<div class="panel-heading flow-expander" id="${flow.id}">
									<a href="${context}/manager?project=${project.name}&flow=${flow.id}">${flow.id}</a>
								</div>
								<div id="${flow.id}-child" class="panel-collapse collapse">
									<table class="table">
										<tbody id="${flow.id}-tbody">
										</tbody>
									</table>
								</div>
								<div class="panel-footer">
			#if (${exec})
									<button type="button" class="btn btn-sm btn-primary execute-flow" flowId="${flow.id}">Execute Flow</button>
									<a href="${context}/manager?project=${project.name}&flow=${flow.id}#executions" class="btn btn-primary btn-sm">Executions</a>
									<a href="${context}/manager?project=${project.name}&flow=${flow.id}#summary" class="btn btn-primary btn-sm">Summary</a>
			#end
								</div>
							</div>
		#end
	#else
							<p>No flows uploaded to this project</p>
	#end
						</div>
					</div>
				</div><!-- /col-lg-8 -->

				<div class="col-lg-4">
	#parse ("azkaban/webapp/servlet/velocity/projectsidebar.vm")
				</div><!-- /col-lg-4 -->
			</div><!-- /row -->

## Upload project modal

			<div class="modal fade" id="upload-project-modal">
				<div class="modal-dialog">
					<div class="modal-content">
						<form id="upload-project-form" enctype="multipart/form-data" method="post" action="$!context/manager">
							<div class="modal-header">
								<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
								<h4 class="modal-title">Upload Project Files</h4>
							</div>
							<div class="modal-body">
								<div class="alert alert-danger" id="upload-project-modal-error-msg">$error_msg</div>
								<fieldset class="form-horizontal">
									<div class="form-group">
										<label for="path" class="col-sm-2 control-label">Job Archive</label>
										<div class="col-sm-10">
											<input type="file" class="form-control" id="file" name="file">
										</div>
									</div>
								</fieldset>
							</div>
							<div class="modal-footer">
								<input type="hidden" name="project" value="$project.name">
								<input type="hidden" name="action" value="upload">
								<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
								<button type="button" class="btn btn-primary" id="upload-project-btn">Upload</button>
							</div>
						</form>
					</div>
				</div>
			</div>

	## Delete project modal.
			
			<div class="modal fade" id="delete-project-modal">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
							<h4 class="modal-title">Delete Project</h4>
						</div>
						<div class="modal-body">
							<p>Warning: This project will be deleted and may not be recoverable.</p>
						</div>
						<div class="modal-footer">
							<form id="delete-form">
								<input type="hidden" name="project" value="$project.name">
								<input type="hidden" name="delete" value="true">
								<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
								<button type="button" class="btn btn-danger" id="delete-btn">Yes</button>
							</form>
						</div>
					</div>
				</div>
			</div>

	#parse ("azkaban/webapp/servlet/velocity/invalidsessionmodal.vm")
	#parse ("azkaban/webapp/servlet/velocity/flowexecutionpanel.vm")
	#parse ("azkaban/webapp/servlet/velocity/messagedialog.vm")
#end

#parse ("azkaban/webapp/servlet/velocity/footer.vm")

		</div><!-- /container -->
	</body>
</html>

