<div class="search-container" ng-if="ctrl.isOpen">
	<div class="search-field-wrapper">
		<span style="position: relative;">
			<input  type="text" placeholder="Find dashboards by name" give-focus="ctrl.giveSearchFocus" tabindex="1"
			ng-keydown="ctrl.keyDown($event)" ng-model="ctrl.query.query" ng-model-options="{ debounce: 500 }" spellcheck='false' ng-change="ctrl.search()" />
		</span>
		<div class="search-switches">
			<i class="fa fa-filter"></i>
			<a class="pointer" href="javascript:void 0;" ng-click="ctrl.showStarred()" tabindex="2">
				<i class="fa fa-remove" ng-show="ctrl.query.starred"></i>
				starred
			</a> |
			<a class="pointer" href="javascript:void 0;" ng-click="ctrl.getTags()" tabindex="3">
				<i class="fa fa-remove" ng-show="ctrl.tagsMode"></i>
				tags
			</a>
			<span ng-if="ctrl.query.tag.length">
				|
				<span ng-repeat="tagName in ctrl.query.tag">
					<a ng-click="ctrl.removeTag(tagName, $event)" tag-color-from-name="tagName" class="label label-tag">
						<i class="fa fa-remove"></i>
						{{tagName}}
					</a>
				</span>
			</span>
		</div>
	</div>

	<div class="search-results-container" ng-if="ctrl.tagsMode">
		<div class="row">
			<div class="span6 offset1">
				<div ng-repeat="tag in ctrl.results" class="pointer" style="width: 180px; float: left;"
					ng-class="{'selected': $index === ctrl.selectedIndex }"
					ng-click="ctrl.filterByTag(tag.term, $event)">
					<a class="search-result-tag label label-tag" tag-color-from-name="tag.term">
						<i class="fa fa-tag"></i>
						<span>{{tag.term}} &nbsp;({{tag.count}})</span>
					</a>
				</div>
			</div>
		</div>
	</div>

	<div class="search-results-container" ng-if="!ctrl.tagsMode">
		<h6 ng-hide="ctrl.results.length">No dashboards matching your query were found.</h6>

		<a class="search-item pointer search-item-{{row.type}}" bindonce ng-repeat="row in ctrl.results"
			ng-class="{'selected': $index == ctrl.selectedIndex}" ng-href="{{row.url}}">

			<span class="search-result-tags">
				<span ng-click="ctrl.filterByTag(tag, $event)" ng-repeat="tag in row.tags" tag-color-from-name="tag"  class="label label-tag">
					{{tag}}
				</span>
				<i class="fa" ng-class="{'fa-star': row.isStarred, 'fa-star-o': !row.isStarred}"></i>
			</span>

			<span class="search-result-link">
				<i class="fa search-result-icon"></i>
				<span bo-text="row.title"></span>
			</span>
		</a>
	</div>

	<div class="search-button-row">
		<a class="btn btn-inverse pull-left" href="dashboard/new" ng-show="ctrl.contextSrv.isEditor" ng-click="ctrl.isOpen = false;">
			<i class="fa fa-plus"></i>
			Create New
		</a>

		<a class="btn btn-inverse pull-left" href="dashboard/new/?editview=import" ng-show="ctrl.contextSrv.isEditor" ng-click="ctrl.isOpen = false;">
			<i class="fa fa-upload"></i>
			Import
		</a>

		<a class="pull-right search-button-row-explore-link" target="_blank" href="https://grafana.net/dashboards?utm_source=grafana_search">
      Find dashboards on
		</a>

 		<div class="clearfix"></div>
	</div>
</div>
