<!--
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="schema-browser" class="loaded">

  <div class="clearfix">

    <div id="data">

      <div id="field">

        <div class="field-options">

          <div class="block head">
            <h2>
              <span class="type">{{selectedType}}</span>:
              <span class="name">{{name}}</span>
            </h2>
          </div>

          <div class="partial" ng-show="partialState">

            <p>Because your Index is empty, we do not have enough Information about this Field</p>

          </div>

          <dl class="options clearfix">

            <dt class="field-type">Field-Type:</dt>
            <dd class="field-type">{{analysis.data.className}}</dd>

            <dt class="similarity" ng-show="display.similarity">Similarity:</dt>
            <dd class="similarity" ng-show="display.similarity">{{ display.similarity.details }} ({{ similarity.className }}) </dd>

            <dt class="position-increment-gap" ng-show="display.positionIncrementGap"><abbr title="Position Increment Gap">PI Gap</abbr>:</dt>
            <dd class="position-increment-gap" ng-show="display.positionIncrementGap">{{ display.positionIncrementGap }}</dd>

            <dt class="docs" ng-show="display.docs">Docs:</dt>
            <dd class="docs" ng-show="display.docs"><a href="{{display.docsUrl}}">{{display.docs | number}}</a></dd>

            <dt class="distinct" ng-show="display.distinct">Distinct:</dt>
            <dd class="distinct" ng-show="display.distinct">{{display.distinct}}</dd>

          </dl>

          <table class="flags" cellspacing="0" cellpadding="0" border="0">

            <thead>

              <tr>

                <td>Flags:</td>
                <th ng-repeat="key in display.columns">{{key.name}}</th>

              </tr>

            </thead>

              <tbody>
              <tr ng-repeat="row in display.rows track by row.name">
              <th>{{row.name}}</th>
              <td colspan="2" class="text" ng-show="row.comment">{{row.comment}}</td>
              <td ng-repeat="cell in row.cells"
                  ng-class="{'check':cell.value}">
                  <span ng-show="cell.value">√</span>
                  <span ng-show="!cell.value">&nbsp;</span>
              </td>
              </tr>
              </tbody>

          </table>

          <ul class="analyzer">
            <li class="clearfix {{analyzer.key}}" ng-class="{open: analyzer.show}" ng-repeat="analyzer in analysis.analyzers">

              <p><a class="analysis" ng-href="#/{{core}}/analysis?{{analysis.query}}"><span>{{analyzer.name}}&nbsp;Analyzer:</span></a></p>
              <dl>
                <dt><a ng-click="toggleAnalyzer(analyzer)" class="toggle">{{analyzer.detail.className}}</a></dt>
              </dl>
              <ul ng-show="analyzer.show">
                <li class="clearfix {{componentType.key}} data" ng-repeat="componentType in analyzer.detail.componentTypes" ng-show="componentType.components">
                  <p>{{componentType.label}}:</p>
                  <dl>
                      <dt ng-repeat-start="component in componentType.components">{{component.className}}</dt>
                      <dd ng-repeat-end ng-repeat="arg in component.args"
                          ng-class="{'ico-1': arg.booleanValue, 'ico-0': arg.booleanValue==false}">
                          {{arg.name}}<span ng-show="arg.value">: {{arg.value}}</span>
                      </dd>
                  </dl>
                </li>
              </ul>
            </li>
          </ul>

        </div>

        <div class="terminfo-holder loaded clearfix" ng-class="{disabled: noTermData}" ng-show="is.field">

          <div class="trigger">

            <button class="submit" ng-click="toggleTerms()"><span ng-class="{loader:isLoadingTerms}">Load Term Info</span></button>

            <a ng-show="showTerms" ng-click="toggleAutoload()" ng-class="{on:isAutoload}" class="autoload" title="Automatically load Term Info?"><span>Autoload</span></a>

          </div>

          <p ng-show="showTerms && noTerms" class="status">Sorry, no Term Info available :(</p>

          <div ng-show="showTerms && termInfo.topTerms" class="topterms-holder">

            <form>
            <p class="head">
              <input type="text" ng-model="topTermsCount" ng-change="loadTermInfo()">
              <a class="max-holder" ng-click="loadAllTopTerms()" title="Load all Top-Terms">/<span class="max">{{termInfo.maxTerms | number}}</span></a> Top-Terms:
              <a id="query_link" href="#/{{core}}/query?q={{name}}:[* TO *]"><span>Query</span>&nbsp;</a>
            </p>
            </form>

            <ul>
                <li class="clearfix" ng-repeat="countGroup in termInfo.topTerms">
                    <p><span>{{countGroup.count}}</span></p>
                    <ul>
                        <li ng-repeat="term in countGroup.terms" ng-class="{odd:$odd}"><a href="#/{{core}}/query?q={{name}}:{{term}}">{{term}}</a></li>
                    </ul>
                </li>

            </ul>

          </div>

          <div ng-show="showTerms && termInfo.histogram" class="histogram-holder">

            <p class="head">Histogram:</p>
            <ul>
               <li ng-repeat="row in termInfo.histogram" ng-class="{odd:$odd}">
                 <dl class="clearfix" style="width: {{(( row.value / termInfo.histogramMax ) * 100 )}}%;">
                   <dt><span>{{ row.key | number}}</span></dt>
                   <dd><span>{{ row.value | number }}</span></dd>
                 </dl>
               </li>

            </ul>

          </div>

        </div>

      </div>

    </div>

    <div id="related">
     <select id="type_or_name"
             ng-model="fieldOrType"
             chosen
             data-placeholder="Please select ..."
             ng-change="selectFieldOrType()"
             ng-options="f.value as f.label group by f.group for f in fieldsAndTypes"></select>

      <dl id="f-df-t">

        <dt class="field" ng-class="{active: selectedType=='Field'}" ng-show="leftbar.fields">Field</dt>
        <dd class="field" ng-class="{active: selectedType=='Field'}" ng-repeat="field in leftbar.fields"><a href="#/{{core}}/schema-browser?field={{field}}">{{field}}</a></dd>

        <dt class="copyfield" ng-show="leftbar.copyFieldSources">Copied from</dt>
        <dd class="copyfield" ng-repeat="field in leftbar.copyFieldSources"><a href="#/{{core}}/schema-browser?field={{field}}">{{field}}</a></dd>

        <dt class="copyfield" ng-show="leftbar.copyFieldDests">Copied to</dt>
        <dd class="copyfield" ng-repeat="field in leftbar.copyFieldDests"><a href="#/{{core}}/schema-browser?field={{field}}">{{field}}</a></dd>

        <dt class="dynamic-field" ng-class="{active: selectedType=='Dynamic Field'}" ng-show="leftbar.dynamicFields">Dynamic Field {{dynamicFields}} / {{dynamicFields.length()}}</dt>
        <dd class="dynamic-field" ng-class="{active: selectedType=='Dynamic Field'}" ng-repeat="field in leftbar.dynamicFields"><a href="#/{{core}}/schema-browser?dynamic-field={{field}}">{{field}}</a></dd>

        <dt class="type" ng-class="{active: selectedType=='Type'}" ng-show="leftbar.types">Type</dt>
        <dd class="type" ng-class="{active: selectedType=='Type'}" ng-repeat="type in leftbar.types"><a href="#/{{core}}/schema-browser?type={{type}}">{{type}}</a></dd>

      </dl>

      <dl class="ukf-dsf">

        <dt class="unique-key-field" ng-class="{active: isUniqueKeyField}" ng-show="uniqueKeyField">Unique Key Field</dt>
        <dd class="unique-key-field" ng-class="{active: isUniqueKeyField}"><a ng-href="#/{{core}}/schema-browser?field={{uniqueKeyField}}">{{uniqueKeyField}}</a></dd>

        <dt class="default-search-field" ng-class="{active: isDefaultSearchField}" ng-show="defaultSearchField">Default Search Field</dt>
        <dd class="default-search-field" ng-class="{active: isDefaultSearchField}"><a ng-href="#/{{core}}/schema-browser?field={{defaultSearchField}}">{{defaultSearchField}}</a></dd>

      </dl>

    </div>

  </div>

</div>
