<!-- This file is responsible for nav bar of the dashboard -->
<li class="dropdown" bs-tooltip="'Collections'" data-placement="bottom" style="padding-top:5px;"
    ng-show="dashboard.current.loader.dropdown_collections">
    <select class="span2" ng-model="dashboard.current.solr.core_name" ng-change="dashboard.refresh()"
            ng-options="c as c for c in dashboard.current.solr.core_list | orderBy:'toString()'"></select>
</li>

<li><a bs-tooltip="'Goto saved default'" data-placement="bottom" href='#/dashboard'><i class='icon-home'></i></a></li>

<!-- New menu -->
<li class="dropdown" bs-tooltip="'New'" data-placement="bottom" ng-show="showDropdown('new')">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <i class='icon-file'></i>
    </a>
    <ul class="dropdown-menu" style="padding:10px">
        <li><a class="link" bs-modal="'app/partials/solrSettings.html'" ng-click="$scope.type='default-ts'"><i
            class="icon-time"></i> Time-series dashboard </a></li>
        <li><a class="link" bs-modal="'app/partials/solrSettings.html'" ng-click="$scope.type='default-nts'"><i
            class="icon-th-large"></i> Non time-series dashboard </a></li>
    </ul>
</li>

<!-- Load menu -->
<li class="dropdown" bs-tooltip="'Load'" data-placement="bottom" ng-show="showDropdown('load')">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown"
       ng-click="elasticsearch_dblist('banana_title_s:'+elasticsearch.query+'*')">
        <i class='icon-folder-open'></i>
    </a>
    <ul class="dropdown-menu" style="padding:10px;z-index:1001">
        <li ng-show='dashboard.current.loader.load_local'>
            <h5>Local File
                <tip>Load dashboard JSON layout from file</tip>
            </h5>
            <form>
                <input type="file" id="dashupload" dash-upload/><br>
            </form>
        </li>
        <li ng-show='dashboard.current.loader.load_gist'>
            <h5>Gist
                <tip>Enter a gist number or url</tip>
            </h5>
            <form>
                <input type="text" ng-model="gist.url" placeholder="Gist number or URL"><br>
                <button class="btn" ng-click="gist_dblist(dashboard.gist_id(gist.url))"
                        ng-show="dashboard.is_gist(gist.url)"><i class="icon-github-alt"></i> Get gist:{{gist.url |
                    gistid}}
                </button>
                <h6 ng-show="gist.files.length">Dashboards in gist:{{gist.url | gistid}}
                    <small>click to load</small>
                </h6>
                <h6 ng-hide="gist.files.length || !gist.url.length">No gist dashboards found</h6>
                <table class="table table-condensed table-striped">
                    <tr ng-repeat="file in gist.files" class="pointer">
                        <td><a ng-click="dashboard.dash_load(file)">{{file.title}}</a></td>
                    </tr>
                </table>
            </form>
        </li>
        <li ng-show='dashboard.current.loader.load_elasticsearch'>
            <h5 ng-show="elasticsearch.dashboards.length">Saved Dashboards ({{hits}})</h5>
            <h5 ng-hide="elasticsearch.dashboards.length">No dashboards matching your query found</h5>
            <form style="margin-bottom: 0;">
                <input type="text" ng-model="elasticsearch.query"
                       ng-change="elasticsearch_dblist('banana_title_s:'+elasticsearch.query+'*')"
                       placeholder="Type to filter"/>
            </form>

            <div class="pagination pagination-centered" style="margin-top: 0;" ng-show="elasticsearch.dashboards.length">
                <ul>
                    <li ng-class="loadMenu.backwardButtonState"><a ng-click="getPrevSavedDashboard($event)"><i class="icon-backward"></i></a></li>
                    <li ng-repeat="page in loadMenu.pages.slice(loadMenu.firstPageShown-1, loadMenu.lastPageShown)" ng-class="page.state">
                        <a ng-click="getSavedDashboard($event, 'banana_title_s:'+elasticsearch.query+'*', page.offset, page.number)">{{page.number}}</a>
                    </li>
                    <li ng-class="loadMenu.forwardButtonState"><a ng-click="getNextSavedDashboard($event)"><i class="icon-forward"></i></a></li>
                </ul>
                <table class="table table-condensed table-striped">
                    <tr ng-repeat="row in elasticsearch.dashboards | orderBy:['id'] | limitTo:dashboard.current.loader.load_elasticsearch_size">
                        <td class="span11" style="vertical-align: middle;"><a href="#/dashboard/solr/{{row.id}}">{{row.id}}</a></td>
                        <td class="span1" ng-show="dashboard.current.loader.save_elasticsearch">
                            <a class="btn btn-danger" confirm-click="elasticsearch_delete(row.id)"
                               confirmation="Are you sure you want to delete {{row.id}} dashboard?">
                                <i class="icon-remove"></i></a>
                        </td>
                        <!--<td><a><i class="icon-share" ng-click="share = dashboard.share_link(row.id,'solr',row.id)" bs-modal="'app/panels/dashcontrol/share.html'"></i></a></td>-->
                    </tr>
                </table>
            </div>

        </li>
    </ul>
</li>

<!-- Save menu -->
<li class="dropdown" bs-tooltip="'Save'" data-placement="bottom" ng-show="showDropdown('save')">
    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
        <i class='icon-save'></i>
    </a>
    <ul class="dropdown-menu" style="padding:10px">
        <li ng-show="dashboard.current.loader.save_default || dashboard.current.loader.save_local">
            <h5>Locally</h5>
            <ul class="unstyled">
                <li ng-show="dashboard.current.loader.save_local"><a class="link" ng-click="dashboard.to_file()"><i
                    class="icon-download"></i> Export to File</a>
                    <tip>Export layout, not data, to file</tip>
                </li>
                <li ng-show="dashboard.current.loader.save_default"><a class="link" ng-click="set_default()"><i
                    class="icon-bookmark"></i> Set as Browser Default</a>
                    <tip>Store dashboard preference to browser's localStorage</tip>
                </li>
                <li ng-show="dashboard.current.loader.save_default"><a class="link" ng-click="purge_default()"><i
                    class="icon-ban-circle"></i> Clear Browser Default</a></li>
            </ul>
        </li>
        <li ng-show="dashboard.current.loader.save_gist">
            <h6>Gist</h6>
            <form class="input-append">
                <input class='input-medium' placeholder='Title' type="text" ng-model="gist.title"/>
                <button class="btn" ng-click="save_gist()"><i class="icon-github-alt"></i></button>
            </form>
            <br>
            <small ng-show="gist.last">Last gist: <a target="_blank" href="{{gist.last}}">{{gist.last}}</a></small>
        </li>

        <li ng-show="dashboard.current.loader.save_elasticsearch">
            <h5>Solr</h5>
            <form>
                <ul class="unstyled">
                    <li>
                        <label class="checkbox"><input type="checkbox" ng-model="dashboard.current.loader.save_as_public">
                            Make Public? <tip>If checked, the dashboard will be shared with everyone.</tip>
                        </label>
                    </li>
                    <li class="input-append">
                        <input class='input-medium' placeholder="{{dashboard.current.title}}" type="text"
                               ng-model="elasticsearch.title"/>
                        <button class="btn" ng-click="elasticsearch_save('dashboard', null)"><i class="icon-save"></i></button>
                    </li>
                </ul>
            </form>
        </li>
    </ul>
</li>

<!-- Configure menu -->
<li ng-show="dashboard.current.editable " bs-tooltip="'Configure dashboard'" data-placement="bottom">
    <a href='#' bs-modal="'app/partials/dasheditor.html'"><i class='icon-cog pointer'></i></a>
</li>
