{{!
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements.  See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership.  The ASF licenses this file
* to you 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.
}}

<div id="index-content">
  <div class="main-content">
    <aside class="col-md-3 col-xs-12 no-padding">
      {{render 'databases'}}
    </aside>

    <div class="col-md-9 col-xs-12 query-container">
      {{render 'alerts'}}

      {{#panel-widget headingTranslation="titles.query.editor" classNames="query-editor-panel"}}
        {{render 'open-queries'}}

        <div class="toolbox">
          <button type="button" class="btn btn-sm btn-success execute-query"
                  {{bind-attr class="canExecute::disabled"}}
                  {{action "executeQuery"}}>
            {{t "buttons.execute"}}
          </button>
          <button type="button" class="btn btn-sm btn-default"
                  {{bind-attr class="canExecute::disabled"}}
                  {{action "explainQuery"}}>
            {{t "buttons.explain"}}
          </button>
          <button type="button" class="btn btn-sm btn-default save-query-as" {{action "saveQuery"}}>{{t "buttons.saveAs"}}</button>

          {{render 'insert-udfs'}}

          <button type="button" class="btn btn-sm btn-primary  pull-right" {{action "addQuery"}}>{{t "buttons.newQuery"}}</button>
        </div>
      {{/panel-widget}}

      {{#if queryParams}}
        {{#panel-widget headingTranslation="titles.query.parameters"}}
          <div class="form-horizontal">
            {{#each param in queryParams}}
              <div {{bind-attr class=":form-group param.value:has-success:has-error"}}>
                <label class="col-sm-3 control-label">{{param.name}}</label>
                  <div class="col-sm-9">
                    {{input value=param.value placeholder="value" class="form-control"}}
                  </div>
              </div>
            {{/each}}
          </div>
        {{/panel-widget}}
      {{/if}}

      {{#if displayJobTabs}}
        {{#panel-widget headingTranslation="titles.query.process"
                        isLoading=model.isRunning
                        menuItems=downloadMenu
                        menuHeadingTranslation="titles.download"
                        classNames="query-process-results-panel"}}
          {{#tabs-widget tabs=queryProcessTabs selectedTab=selectedQueryProcessTab}}
            {{outlet}}
          {{/tabs-widget}}
        {{/panel-widget}}
      {{/if}}
    </div>
  </div>

  {{#if tezUI.showOverlay}}
    {{render 'tez-ui'}}
  {{/if}}

  {{#if visualExplain.showOverlay}}
    {{render 'visual-explain'}}
  {{/if}}

  <div class="query-menu">
    {{#popover-widget classNames="fa fa-info-circle queries-icon" titleTranslation="popover.queryEditorHelp.title" }}
      <ul>
        <li>{{t 'popover.queryEditorHelp.content.line1'}}</li>
        <li>{{t 'popover.queryEditorHelp.content.line2'}}</li>
        <li>{{t 'popover.queryEditorHelp.content.line3'}}</li>
      </ul>
    {{/popover-widget}}

    <span {{bind-attr class="settings.showOverlay:active :fa :fa-gear :queries-icon"}} {{action 'toggleOverlay' 'settings'}}></span>

    <span {{bind-attr class="visualExplain.showOverlay:active :fa :fa-bar-chart :queries-icon"}} {{action 'toggleOverlay' 'visualExplain'}}></span>

    <span {{bind-attr class="tezUI.showOverlay:active :queries-icon :text-icon"}} {{action 'toggleOverlay' 'tezUI'}}>TEZ</span>
  </div>
</div>
