<!--

    Copyright © 2016-2018 The Thingsboard Authors

    Licensed 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.

-->
<md-sidenav class="md-sidenav-right md-whiteframe-4dp tb-sidenav-details"
      md-disable-backdrop="true"
      md-is-open="isOpen"
      md-component-id="right"
      ng-click="onClick($event)"
      layout="column">
      <header>
	      <md-toolbar class="md-theme-light" ng-style="{'height':headerHeightPx+'px'}">
	      	<div class="md-toolbar-tools" layout="row">
	      		<div flex class="md-toolbar-tools" layout="column" layout-align="start start">
		        	<span class="tb-details-title">{{headerTitle}}</span>
		        	<span class="tb-details-subtitle">{{headerSubtitle}}</span>
					<span style="width: 100%;" ng-transclude="headerPane"></span>
	        	</div>
				<div ng-transclude="detailsButtons"></div>
	        	<md-button class="md-icon-button" ng-click="closeDetails()">
	        		<md-icon aria-label="close" class="material-icons">close</md-icon>
	        	</md-button>	        	
	        </div>
		    <section ng-if="!isReadOnly" layout="row" layout-wrap
				   class="tb-header-buttons md-fab">
				<md-button ng-show="isEdit" ng-disabled="$root.loading || theForm.$invalid || !theForm.$dirty"
							 class="tb-btn-header md-accent md-hue-2 md-fab md-fab-bottom-right"
							 aria-label="{{ 'action.apply' | translate }}"
							 ng-click="detailsApply()">
					  <md-tooltip md-direction="top">
						  {{ 'action.apply-changes' | translate }}
					  </md-tooltip>
					  <ng-md-icon icon="done"></ng-md-icon>
				</md-button>
				<md-button ng-disabled="$root.loading || (isAlwaysEdit && !theForm.$dirty)" class="tb-btn-header md-accent md-hue-2 md-fab md-fab-bottom-right"
					 aria-label="{{ 'details.edit-mode' | translate }}"
					 ng-click="toggleDetailsEditMode()">
					<md-tooltip md-direction="top">
						{{ (isAlwaysEdit ? 'action.decline-changes' : 'details.toggle-edit-mode') | translate }}
					</md-tooltip>
					<ng-md-icon icon="{{isEdit ? 'close' : 'edit'}}" options='{"easing": "circ-in-out", "duration": 375, "rotation": "none"}'></ng-md-icon>
				</md-button>
			</section>
	      </md-toolbar>
      </header>
      <md-content flex>
			<div ng-transclude></div>
      </md-content>
</md-sidenav>	