#*
 * 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/style.vm")
#parse("azkaban/webapp/servlet/velocity/javascript.vm")

		<script type="text/javascript" src="${context}/js/azkaban.table.sort.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="container-full">
#parse ("azkaban/webapp/servlet/velocity/message.vm")
#parse ("azkaban/webapp/servlet/velocity/alerts.vm")
		</div>

## Page Header and project search form.

		<div class="az-page-header">
      <div class="container-full">
        <div class="row">
          <div class="col-lg-6">
#if ($allProjects)
            <h1><a href="${context}/index">All Projects</a></h1>
#else
            <h1><a href="${context}/index">My Projects</a></h1>
#end
          </div>
          <div class="col-lg-6">
            <form id="search-form" method="get" class="form-inline az-page-header-form" role="form">
              <input type="hidden" name="doaction" value="search">
#if ($allProjects)
              <input type="hidden" name="all" value="true">				
#end
              <div class="form-group col-md-9">
                <div class="input-group">
                  <input id="search-textbox" type="text" placeholder="Project name containing..." value=#if($search_term) ${search_term} #else "" #end class="form-control input-sm" name="searchterm">
                  <span class="input-group-btn">
                    <button class="btn btn-sm btn-primary">Quick Search</button>
                  </span>
                </div>
              </div>
#if (!$hideCreateProject)
              <div class="form-group col-md-3" id="create-project">
## Note: The Create Project button is not completely flush to the right because
## form-group has padding.
                <div class="pull-right">
                  <button type="button" id="create-project-btn" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-plus"></span> Create Project</button>
                </div>
              </div>
#end
            </form>
          </div>
        </div>
			</div>
		</div>

## Table of projects.

		<div class="container-full">
			<div class="row">
				<div class="col-lg-12">
          <table class="table table-condensed table-striped table-bordered table-hover" id="all-jobs">
            <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.isEmpty())
	#foreach ($project in $projects)
              <tr class="az-project-row">
                <td id="${project.name}" class="tb-name project-expand expanded">
                  <span class="state-icon state-icon-expand az-expander"></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 collapse" id="${project.name}-child">
                <td colspan="3">
                  <table class="table table-bordered">
                    <thead>
                      <tr>
                        <th class="tb-name">Flows</th>
                      </tr>
                    </thead>
                    <tbody id="${project.name}-tbody">
                    </tbody>
                  </table>
                </td>
              </tr>
	#end
#else
              <tr>
                <td colspan="3">No viewable projects found.</td>
              </tr>
#end
            </tbody>
          </table>
				</div>
			</div>

## Modal dialog to be displayed to create a new project.

			<div class="modal" id="create-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">Create Project</h4>
						</div>
						<div class="modal-body">
							<div class="alert alert-danger" id="modal-error-msg">$error_msg</div>
							<fieldset class="form-horizontal">
								<div class="form-group">
									<label for="path" class="col-sm-2 control-label">Name</label>
									<div class="col-sm-10">
										<input id="path" name="project" type="text" class="form-control" placeholder="Project name">
									</div>
								</div>
								<div class="form-group">
									<label for="description" class="col-sm-2 control-label">Description</label>
									<div class="col-sm-10">
										<textarea id="description" name="description" rows="2" cols="40" class="form-control" placeholder="Project description"></textarea>
									</div>
								</div>
							</fieldset>
						</div>
						<div class="modal-footer">
							<input name="action" type="hidden" value="create">
							<input name="redirect" type="hidden" value="$!context/">
							<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
							<button type="button" class="btn btn-primary" id="create-btn">Create Project</button>
						</div>
					</div>
				</div>
			</div>

#parse ("azkaban/webapp/servlet/velocity/invalidsessionmodal.vm")
		</div><!-- /container -->
	</body>
</html>


