<!--
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="cores" class="clearfix empty">

  <div id="ui-block" style="display:none">&nbsp;</div><!-- @todo what is this for? -->

  <div id="frame">

    <div id="actions" class="actions clearfix">

      <button id="add" class="action" ng-click="showAddCore()"><span>Add Core</span></button>
      <span ng-show="hasCores">
      <button id="unload" class="warn requires-core" ng-click="unloadCore()"><span>Unload</span></button>
      <button id="rename" class="action requires-core" ng-click="showRenameCore()"><span>Rename</span></button>
      <button id="swap" class="action requires-core" ng-click="showSwapCores()"><span>Swap</span></button>
      <button id="reload" class="requires-core" ng-click="reloadCore()"
         ng-class="{success: reloadSuccess, warn: reloadFailure}"><span>Reload</span></button>
      </span>
      <div class="action add" data-rel="add" ng-show="showAdd" style="display:block;left:0px;">

        <form>

          <p class="clearfix"><label for="add_name">name:</label>
          <input type="text" name="name" id="add_name" ng-model="newCore.name"></p>

          <p class="clearfix"><label for="add_instanceDir">instanceDir:</label>
          <input type="text" name="instanceDir" id="add_instanceDir" ng-model="newCore.instanceDir"></p>

          <p class="clearfix"><label for="add_dataDir">dataDir:</label>
          <input type="text" name="dataDir" id="add_dataDir" ng-model="newCore.dataDir"></p>

          <p class="clearfix"><label for="add_config">config:</label>
          <input type="text" name="config" id="add_config" ng-model="newCore.config"></p>

          <p class="clearfix"><label for="add_schema">schema:</label>
          <input type="text" name="schema" id="add_schema" ng-model="newCore.schema"></p>

          <div class="cloud" ng-show="isCloud">

            <p class="clearfix"><label for="add_collection">collection:</label>
            <input type="text" name="collection" id="add_collection" ng-model="newCore.collection"></p>

            <p class="clearfix"><label for="add_shard">shard:</label>
            <input type="text" name="add_shard" id="add_shard" ng-model="newCore.shard"></p>

          </div>

          <p class="clearfix note directory-note">

            <span><code>instanceDir</code> and <code>dataDir</code> need to exist before you can create the core</span>

          </p>

          <p class="clearfix note error" ng-show="addMessage">
            <span>{{addMessage}}</span>
          </p>

          <p class="clearfix buttons">
            <button type="submit" class="submit" ng-click="addCore()"><span>Add Core</span></button>
            <button type="reset" class="reset" ng-click="cancelAddCore()"><span>Cancel</span></button>
          </p>

        </form>

      </div>

      <div class="action rename" ng-show="showRename">

        <form>

          <input type="hidden" name="core" data-core="current">

          <p class="clearfix"><label for="rename_other">New Name:</label>
          <input type="text" name="other" ng-model="other" id="rename_other"></p>

          <p class="clearfix note error" ng-show="renameMessage">
            <span>{{renameMessage}}</span>
          </p>

          <p class="clearfix buttons">
            <button class="submit" ng-click="renameCore()"><span>Rename Core</span></button>
            <button type="reset" class="reset" ng-click="cancelRenameCore()"><span>Cancel</span></button>
          </p>
        </form>

      </div>

      <div class="action swap" ng-show="showSwap">

        <form>

          <p class="clearfix"><label for="swap_core">this:</label>
          <input type="text" id="swap_core" name="core" ng-model="selectedCore" readonly="readonly"></p>

          <p class="clearfix"><label for="swap_other">and:</label>
          <select id="swap_other" ng-model="swapOther" ng-options="core.name as core.name for core in swapCorelist" class="other">
          </select></p>

          <p class="clearfix note error" ng-show="swapMessage">
            <span>{{swapMessage}}</span>
          </p>

          <p class="clearfix buttons">
            <button type="submit" class="submit" ng-click="swapCores()"><span>Swap Cores</span></button>
            <button type="reset" class="reset" ng-click="cancelSwapCores()"><span>Cancel</span></button>
          </p>

        </form>

      </div>

    </div>

    <div id="data" class="requires-core" ng-show="hasCores">

      <div class="block" id="core-data">

          <h2><span>Core</span></h2>

          <div class="message-container">
              <div class="message"></div>
          </div>

          <div class="content">

          <ul>

            <li class="startTime"><dl class="clearfix">
              <dt><span>startTime:</span></dt>
                <dd class="timeago">{{core.startTime | timeago}}</dd>
            </dl></li>

            <li class="instanceDir"><dl class="clearfix">
              <dt><span>instanceDir:</span></dt>
                <dd>{{core.instanceDir}}</dd>
            </dl></li>

            <li class="dataDir"><dl class="clearfix">
              <dt><span>dataDir:</span></dt>
                <dd>{{core.dataDir}}</dd>
            </dl></li>

          </ul>

        </div>
      </div>

      <div class="block" id="index-data" ng-show="hasCores">

          <h2><span>Index</span></h2>

          <div class="message-container">
              <div class="message">{{core.message}}</div>
          </div>

          <div class="content">

          <ul>

            <li class="lastModified"><dl class="clearfix">
              <dt><span>lastModified:</span></dt>
                <dd class="timeago">{{core.index.lastModified | timeago}}</dd>
            </dl></li>

            <li class="version"><dl class="clearfix">
              <dt><span>version:</span></dt>
                <dd>{{core.index.version}}</dd>
            </dl></li>

            <li class="numDocs"><dl class="clearfix">
              <dt><span>numDocs:</span></dt>
                <dd>{{core.index.numDocs}}</dd>
            </dl></li>

            <li class="maxDoc"><dl class="clearfix">
              <dt><span>maxDoc:</span></dt>
                <dd>{{core.index.maxDoc}}</dd>
            </dl></li>

            <li class="deletedDocs"><dl class="clearfix">
              <dt><span>deletedDocs:</span></dt>
                <dd>{{core.index.deletedDocs}}</dd>
            </dl></li>

            <li class="current"><dl class="clearfix">
              <dt><span>current:</span></dt>
                <dd class="ico" ng-class="core.index.current ?'ico-1' : 'ico-0'"><span></span></dd>
            </dl></li>

            <li class="directory"><dl class="clearfix">
              <dt><span>directory:</span></dt>
                <dd>{{core.index.directory}}</dd>
            </dl></li>

          </ul>

        </div>
      </div>

    </div>

  </div>

  <div id="navigation" class="requires-core clearfix" ng-show="hasCores">
    <ul>
      <li ng-repeat="c in cores" ng-class="{current: core.name == c.name}"><a href="#~cores/{{c.name}}">{{c.name}}</a></li>
    </ul>
  </div>

</div>
