#*
 * 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")
  #parse ("azkaban/webapp/servlet/velocity/svgflowincludes.vm")
  <script type="text/javascript" src="${context}/js/moment.min.js"></script>
  <script type="text/javascript" src="${context}/js/bootstrap-datetimepicker.min.js"></script>
  <script type="text/javascript" src="${context}/js/azkaban/view/flow-execute-dialog.js"></script>
  <script type="text/javascript" src="${context}/js/azkaban/view/project.js"></script>
  <script type="text/javascript" src="${context}/js/azkaban/view/project-modals.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>
  <link rel="stylesheet" type="text/css" href="${context}/css/bootstrap-datetimepicker.css"/>
  <link rel="stylesheet" type="text/css" href="${context}/css/jquery-ui.css">
</head>
<body>

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

  #if ($errorMsg)
    #parse ("azkaban/webapp/servlet/velocity/errormsg.vm")
  #else

  ## Page header.

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

  <div class="container-full">

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

  ## Page content.

    <div class="row row-offcanvas row-offcanvas-right">
      <div class="col-xs-12 col-sm-9" id="flow-tabs">

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

        <div id="flow-tabs">
          #if ($flows)
            #foreach ($flow in $flows)
              <div class="panel panel-default" flow="${flow.id}" project="${project.name}">
                <div class="panel-heading flow-expander" id="${flow.id}">
                  #if (${exec})
                    <div class="pull-right">
                      <button type="button" class="btn btn-xs btn-success execute-flow"
                              flowId="${flow.id}">Execute Flow
                      </button>
                      <a href="${context}/manager?project=${project.name}&flow=${flow.id}#executions"
                         class="btn btn-info btn-xs">Executions</a>
                      <a href="${context}/manager?project=${project.name}&flow=${flow.id}#summary"
                         class="btn btn-info btn-xs">Summary</a>
                    </div>
                  #end
                  <span class="glyphicon glyphicon-chevron-down flow-expander-icon"></span>
                  <a href="${context}/manager?project=${project.name}&flow=${flow.id}">${flow.id}</a>
                </div>
                <div id="${flow.id}-child" class="panel-collapse panel-list collapse">
                  <ul class="list-group list-group-collapse expanded-flow-job-list"
                      id="${flow.id}-tbody"></ul>
                </div>
              </div>
            #end
          #else
            <div class="callout callout-default">
              <h4>No Flows</h4>
              <p>No flows have been uploaded to this project yet.</p>
            </div>
          #end
        </div><!-- /#flow-tabs -->
      </div><!-- /col-xs-8 -->

      <div class="col-xs-6 col-sm-3 sidebar-offcanvas">
        #parse ("azkaban/webapp/servlet/velocity/projectsidebar.vm")
      </div><!-- /col-xs-4 -->
    </div><!-- /row -->

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

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

