#*
 * 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-1.9.1.js"></script>
		<script type="text/javascript" src="${context}/js/namespace.js"></script>
		<script type="text/javascript" src="${context}/js/underscore-1.4.4-min.js"></script>
		<script type="text/javascript" src="${context}/js/backbone-0.9.10-min.js"></script>
		<script type="text/javascript" src="${context}/js/jquery.simplemodal-1.4.4.js"></script>
		<script type="text/javascript" src="${context}/js/azkaban.table.sort.js"></script>
		<script type="text/javascript" src="${context}/js/azkaban.nav.js"></script>
		<script type="text/javascript" src="${context}/js/azkaban.main.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="all")
#parse( "azkaban/webapp/servlet/velocity/nav.vm" )
		<div class="messaging"><p id="messageClose">X</p><p id="message"></p></div>  

		<div class="content">
			#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
			<div id="all-jobs-content">
				<div class="section-hd">
#if ($allProjects)
					<h2>All Projects</h2>
					<div class="section-sub-hd">
						<h4><a href="${context}/">My Projects</a></h4>
					</div>
#else
					<h2>My Projects</h2>
					<div class="section-sub-hd">
						<h4><a href="${context}/?all">All Projects</a></h4>
					</div>
#end
					<form id="search-form" method="get">
						<input type="hidden" name="doaction" value="search">
						<input type="submit" value="Quick Search" class="search-btn">
#if ($allProjects)
						<input type="hidden" name="all" value="true">			
#end			
						<input id="searchtextbox" type="text" placeholder="project name containing ..." value=#if($search_term) ${search_term} #else "" #end class="search-input" name="searchterm">
					</form>

#if (!$hideCreateProject)
					<a id="create-project-btn" class="btn1 " href="#">Create Project</a>
#end
				</div><!-- end .section-hd -->
			</div>
			<table id="all-jobs" class="all-jobs job-table project-table">
				<thead>
					<tr>
						<th class="tb-name">Name</th>
						<th class="tb-up-date">Modified Date</th>
						<th class="tb-owner">Modified By</th>
					</tr>
				</thead>
				<tbody>
#if($projects)
#foreach($project in $projects)
					<tr class="row">
						<td class="tb-name expand project-expand" id="${project.name}">
							<span class="state-icon"></span>
							<a href="${context}/manager?project=${project.name}">$project.name</a>
						</td>
						<td class="tb-up-date">$utils.formatDate($project.lastModifiedTimestamp)</td>
						<td class="tb-owner">$project.lastModifiedUser</td>
					</tr>
					<tr class="childrow" id="${project.name}-child" style="display: none;">
						<td class="expandedFlow" colspan="3">
							<table class="innerTable">
								<thead>
									<tr><th class="tb-name">Flows</th></tr>
								</thead>
								<tbody id="${project.name}-tbody">
								</tbody>
							</table>
						</td>
					</tr>
#end
#else
					<tr><td class="last">No viewable projects found.</td></tr>
#end
				</tbody>
			</table>
		</div>

		<!-- modal content -->
		<div id="create-project" class="modal">
			<h3>Create Project</h3>
			<div id="errorMsg" class="box-error-message">$errorMsg</div>
			
			<div class="message">
				<fieldset>
					<dl>
						<dt><label for="path">Project Name</label></dt>
						<dd><input id="path" name="project" type="text" size="20" title="The project name."/></dd>
						<dt>Description</dt>
						<dd><textarea id="description" name="description" rows="2" cols="40"></textarea></dd>
					
						<input name="action" type="hidden" value="create" />
						<input name="redirect" type="hidden" value="$!context/" />
					</dl>
				</fieldset>
			</div>
			<div class="actions">
				<a class="yes btn2" id="create-btn" href="#">Create Project</a>
				<a class="no simplemodal-close btn3" href="#">Cancel</a>
			</div>
			<div id="invalid-session" class="modal">
				<h3>Invalid Session</h3>
				<p>Session has expired. Please re-login.</p>
				<div class="actions">
					<a class="yes btn2" id="login-btn" href="#">Re-login</a>
				</div>
			</div>
		</div>
	</body>
</html>


