<!--
  #%L
  thinkbig-ui-feed-manager
  %%
  Copyright (C) 2017 ThinkBig Analytics
  %%
  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.
  #L%
  -->
<div class="md-padding">

            <div ng-if="vm.loadingHiveSchemas">
                <span class="hint">Initializing</span>
            <md-progress-linear md-mode="indeterminate" ></md-progress-linear>
            </div>
            <div id="hqlEditorContainer">
                <span class="md-input-label">Enter Query</span>
                <div class="hql-editor" ui-codemirror ng-model="vm.sql" ui-codemirror-opts="vm.codemirrorOptions">
                </div>
            </div>
                <span class="hint">Use CTRL + space for autocomplete on Table and Field names</span>
<div layout="row" layout-fill layout-align="space-between center">
            <md-button class="md-primary md-raised" ng-disabled="vm.sql == ''" ng-click="vm.query()" ng-if="vm.allowExecuteQuery">
                Execute Query
            </md-button>
    <span flex></span>
    <md-button ng-if="vm.allowFullscreen" class="md-raised" ng-if="vm.mode != 'fullscreen'" ng-click="vm.fullscreen()" >
        Full Screen
    </md-button>
</div>
              <div ng-if="vm.allowDatabaseBrowse" class="layout-padding-top">
                <div class="md-title">Browse Hive</div>
                <md-input-container>
                    <label>Database</label>
                    <md-select ng-model="vm.browseDatabaseName" >
                        <md-option ng-repeat="databaseName in vm.databaseNames" value="{{::databaseName}}">
                            {{::databaseName}}
                        </md-option>
                    </md-select>
                </md-input-container>
                <md-input-container>
                    <label>Table</label>
                    <md-select ng-model="vm.browseTableName" ng-change="vm.browseTable()" >
                        <md-option ng-repeat="(tableName,fields) in vm.databaseMetadata[vm.browseDatabaseName]" value="{{::tableName}}">
                            {{::tableName}}
                        </md-option>
                    </md-select>
                </md-input-container>
                </div>
            <md-progress-linear md-mode="indeterminate" ng-if="vm.executingQuery"></md-progress-linear>
                <div class="browse-results" ng-if="vm.queryResults.columns && vm.queryResults.rows.length >0">

                    <div ui-grid-auto-resize  style="width:100%;height:500px;"
                         ui-grid="vm.gridOptions"
                            ></div>
                    </div>
</div>
