<!--
  ~ 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 class="row detailsPage" data-ng-controller="DetailsController">
    <div class="col-lg-12 padding0">
      <ul class="breadcrumb">
          <li><button class="btn btn-link" data-ng-click="goBack()"><i class="fa fa-arrow-left"></i> Back To Result</button> </li>
      </ul>
    </div>
    <div role="tabpanel" class="col-lg-12 padding0">
        <div class="mB20">
          <h4><b>Name:</b> <span class="black">{{details.values.name}}</span></h2>
          <h4><b>Description:</b> <span class="black">{{details.values.description}}</span></h4>
          <h4 data-ng-show="isTable" data-disable="!tableName" data-select="onActivate('io')"><span class="lineage">Lineage</span> <ng-include data-table-type="io" src="'/modules/lineage/views/lineage_io.html'"/></h4> 
        </div>
        <tabset>
            <tab heading="Details">
                <table class="table table-bordered">
                    <thead>
                    <tr>
                        <th>Key</th>
                        <th>Value</th>
                    </tr>
                    </thead>
                    <tbody>
                   <tr data-ng-repeat="(key,value) in details.values" ng-if="value && !(key==='columns') && !(key==='name') && !(key==='description')">

                        <td>{{key}}</td>   

                        <td data-ng-if="isObject(value) && isString(value.id)" class="pointer"> 
                            <a data-ui-sref="details({id:value.id})">{{ value.id }}</a>
                         </td>

                        <td data-ng-if="isObject(value) && isObject(value.id) && isString(value.id.id)" class="pointer"><a data-ui-sref="details({id:value.id.id})">{{ value.id.id }}</a></td>

                        <td data-ng-if="isArray(value)">
                          <div class="row" data-ng-repeat="(key1, value1) in value" ng-if="value1">
                              <div data-ng-if="isObject(value1)" data-ng-repeat="(key2, value2) in value1" > 
                                <a data-ng-if="isString(value2) && key2 == 'id'" class="pointer pdLft15px" data-ui-sref="details({id:value2})">{{ value2 }}</a> 
                              </div>
                          </div>      
                        </td> 

                        <td data-ng-if="!isArray(value) && isObject(value[0]) && isString(value[0].id) && key=='inputTables'" data-ng-click="goDetails(value[0].id)" class="pointer">
                         
                          <div class="row" data-ng-repeat="(key1, value1) in value[0]" ng-if="value1">
                              <div class="col-md-6" data-ng-if="!isString(value1)" data-ng-repeat="(key2, value2) in value1 track by $index"></div>
                              <div data-ng-if="isString(value2)" data-ng-repeat="(key3, value3) in value2"> {{key3}}: {{value3}}</div>
                              <div class="col-md-6" data-ng-if="isString(value1)"> {{key1}} : {{value1 | date:'medium'}} UTC</div>
                          </div>
                          
                        </td>

                        <td data-ng-if="isNumber(value)">{{value * 1000 | date:'yyyy-MM-dd HH:mm:ss'}} UTC</td> 

                        <td data-ng-if="isString(value)">{{value}}</td> 

                    </tr>
                    </tbody>
                </table>
                <ng-include  src="'/modules/tags/instance/views/tags.html'"/>
            </tab>
            <tab data-heading="Schema" data-ng-if="isTable"><ng-include src="'/modules/details/views/schema.html'"/></tab>
            <!-- <tab data-heading="Output" data-ng-if="isTable" data-disable="!tableName" data-select="onActivate('outputs')"><ng-include data-table-type="outputs" src="'/modules/lineage/views/lineage.html'"/></tab>
            <tab data-heading="Input"  data-ng-if="isTable" data-disable="!tableName" data-select="onActivate('inputs')"><ng-include data-table-type="inputs" src="'/modules/lineage/views/lineage.html'"/></tab>
            <tab data-heading="Lineage"  data-ng-if="isTable" data-disable="!tableName" data-select="onActivate('io')"><ng-include data-table-type="io" src="'/modules/lineage_io/views/lineage_io.html'"/></tab> -->
        </tabset>
    </div>
</div>