<!--
  #%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 >

    <card-layout class="centered" >
        <header-section>
            <div class="card-title" flex>Tables</div>
        </header-section>

        <body-section >

            <md-tabs md-dynamic-height  md-border-bottom md-selected="vm.selectedTabIndex" >
                <md-tab>
                    <md-tab-label>
                        <div >
                            Fields
                        </div>
                    </md-tab-label>
                    <md-tab-body>

                        <div >
                            <md-list class="list-item-table">
                                <md-list-item >
                                    <div flex="40" class="item-column md-list-item-text table-column-header">
                                       Field
                                    </div>
                                    <div flex="20" class="item-column md-list-item-text table-column-header">
                                        Data Type
                                    </div>
                                    <div flex="40" class="item-column md-list-item-text table-column-header">
                                        Description
                                    </div>
                                  <!--
                                  <div flex="20" class="item-column md-list-item-text table-column-header">
                                       Primary Key
                                    </div>
                                    <div flex="20" class="item-column md-list-item-text table-column-header">
                                       Nullable
                                    </div>
                                    -->
                                    <md-divider ng-if="!$last"></md-divider>
                                </md-list-item>
                                <md-list-item ng-repeat="field in vm.tableSchema.fields">
                                    <div flex="40" class="item-column md-list-item-text">
                                        {{field.name}}
                                    </div>
                                    <div flex="20" class="item-column md-list-item-text">
                                        {{field.derivedDataType}}
                                    </div>
                                    <div flex="40" class="item-column md-list-item-text">
                                        {{field.description}}
                                    </div>
                                    <!--
                                    <div flex="20" class="item-column md-list-item-text">
                                        <ng-md-icon icon="check" ng-if="field.primaryKey"></ng-md-icon>
                                        <ng-md-icon icon="not_interested" ng-if="!field.primaryKey"></ng-md-icon>
                                    </div>
                                    <div flex="20" class="item-column md-list-item-text">
                                        <ng-md-icon icon="check" ng-if="field.nullable"></ng-md-icon>
                                        <ng-md-icon icon="not_interested" ng-if="!field.nullable"></ng-md-icon>
                                    </div>
                                    -->
                                    <md-divider ng-if="!$last"></md-divider>
                                </md-list-item>
                            </md-list>

                            </ul>
                        </div>

                    </md-tab-body>
                </md-tab>
                <md-tab>
                    <md-tab-label>
                        <div >
                            Preview
                        </div>
                    </md-tab-label>
                    <md-tab-body>
                      <thinkbig-preview  ng-if="vm.selectedTabIndex == 1" default-schema-name="{{vm.schema}}" default-table-name="{{vm.tableName}}"></thinkbig-preview>
                    </md-tab-body>
                </md-tab>
                <md-tab  >
                    <md-tab-label>
                        <div >
                            Query
                        </div>
                    </md-tab-label>
                    <md-tab-body>
                        <thinkbig-hql-editor ng-model="vm.hql" default-schema-name="{{vm.schema}}" default-table-name="{{vm.tableName}}" allow-database-browse="false" allow-execute-query="true"
                                             ng-if="vm.selectedTabIndex == 2"></thinkbig-hql-editor>

                    </md-tab-body>
                </md-tab>
            </md-tabs>
        </body-section>

    </card-layout>
</div>
