<div class="">
	<div  class="tight-form">
		<ul class="tight-form-list pull-right">
			<li ng-show="parserError" class="tight-form-item">
				<a bs-tooltip="parserError" style="color: rgb(229, 189, 28)" role="menuitem">
					<i class="fa fa-warning"></i>
				</a>
			</li>
			<li class="tight-form-item small" ng-show="target.datasource">
				<em>{{target.datasource}}</em>
			</li>
			<li class="tight-form-item">
				<div class="dropdown">
					<a  class="pointer dropdown-toggle" data-toggle="dropdown" tabindex="1">
						<i class="fa fa-bars"></i>
					</a>
					<ul class="dropdown-menu pull-right" role="menu">
						<li role="menuitem"><a tabindex="1" ng-click="toggleQueryMode()">Switch editor mode</a></li>
						<li role="menuitem"><a tabindex="1" ng-click="duplicateDataQuery(target)">Duplicate</a></li>
						<li role="menuitem"><a tabindex="1" ng-click="moveDataQuery($index, $index-1)">Move up</a></li>
						<li role="menuitem"><a tabindex="1" ng-click="moveDataQuery($index, $index+1)">Move down</a></li>
					</ul>
				</div>
			</li>

			<li class="tight-form-item last">
				<a class="pointer" tabindex="1" ng-click="removeDataQuery(target)">
					<i class="fa fa-remove"></i>
				</a>
			</li>
		</ul>

		<ul class="tight-form-list">
			<li class="tight-form-item" style="min-width: 15px; text-align: center">
				{{target.refId}}
			</li>
			<li>
				<a class="tight-form-item" ng-click="target.hide = !target.hide; get_data();" role="menuitem">
					<i class="fa fa-eye"></i>
				</a>
			</li>
		</ul>

		<ul class="tight-form-list" ng-hide="target.rawQuery">
			<li class="tight-form-item query-keyword" style="width: 75px">
				FROM
			</li>
			<li>
				<metric-segment segment="measurementSegment" get-options="getMeasurements()" on-change="measurementChanged()"></metric-segment>
			</li>
			<li class="tight-form-item query-keyword" style="padding-left: 15px; padding-right: 15px;">
				WHERE
			</li>
			<li ng-repeat="segment in tagSegments">
				<metric-segment segment="segment" get-options="getTagsOrValues(segment, $index)" on-change="tagSegmentUpdated(segment, $index)"></metric-segment>
			</li>
		</ul>

		<div class="tight-form-flex-wrapper" ng-show="target.rawQuery">
			<input type="text" class="tight-form-clear-input" ng-model="target.query" spellcheck="false" style="width: 100%;" ng-blur="get_data()"></input>
		</div>

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

	<div ng-hide="target.rawQuery">

		<div class="tight-form" ng-repeat="selectParts in queryModel.selectModels">
			<ul class="tight-form-list">
				<li class="tight-form-item query-keyword tight-form-align" style="width: 75px;">
					<span ng-show="$index === 0">SELECT</span>
				</li>
				<li ng-repeat="part in selectParts">
					<influx-query-part-editor part="part" class="tight-form-item tight-form-func" remove-action="removeSelectPart(selectParts, part)" part-updated="selectPartUpdated(selectParts, part)" get-options="getPartOptions(part)"></influx-query-part-editor>
				</li>
				<li class="dropdown" dropdown-typeahead="selectMenu" dropdown-typeahead-on-select="addSelectPart(selectParts, $item, $subItem)">
				</li>
			</ul>
			<div class="clearfix"></div>
		</div>

		<div class="tight-form">
			<ul class="tight-form-list">
				<li class="tight-form-item query-keyword tight-form-align" style="width: 75px;">
					<span>GROUP BY</span>
				</li>
				<li ng-repeat="part in queryModel.groupByParts">
					<influx-query-part-editor part="part" class="tight-form-item tight-form-func" remove-action="removeGroupByPart(part, $index)" part-updated="get_data();" get-options="getPartOptions(part)"></influx-query-part-editor>
				</li>
				<li>
					<metric-segment segment="groupBySegment" get-options="getGroupByOptions()" on-change="groupByAction(part, $index)"></metric-segment>
				</li>
			</ul>
			<div class="clearfix"></div>
		</div>
	</div>

	<div class="tight-form">
		<ul class="tight-form-list">
			<li class="tight-form-item query-keyword tight-form-align" style="width: 75px;">
				ALIAS BY
			</li>
			<li>
				<input type="text" class="tight-form-clear-input input-xlarge" ng-model="target.alias" spellcheck='false' placeholder="Naming pattern" ng-blur="get_data()">
			</li>
			<li class="tight-form-item">
				Format as
			</li>
			<li>
				<select class="input-small tight-form-input" style="width: 104px" ng-model="target.resultFormat" ng-options="f.value as f.text for f in resultFormats" ng-change="get_data()"></select>
			</li>
		</ul>
		<div class="clearfix"></div>
	</div>

</div>
