<!--

    Copyright © 2016-2017 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="tb-site-sidenav md-sidenav-left md-whiteframe-z2"
      hide-print=""      
      md-component-id="left"
      aria-label="Toggle Nav"
      ng-click="vm.sidenavClicked()"
      md-is-open="vm.showSidenav()"
      md-is-locked-open="vm.lockSidenav()"
      layout="column">
      <header class="tb-nav-header">
          <md-toolbar md-scroll-shrink class="tb-nav-header-toolbar">
          	 <div flex layout="row" layout-align="start center" class="md-toolbar-tools inset">
				<md-icon md-svg-src="{{vm.logoSvg}}" aria-label="logo" class="tb-logo-title"></md-icon>
          	 </div>
          </md-toolbar>
      </header>
      <md-content flex layout="column" role="navigation">
      	 <md-toolbar flex>
         	<tb-side-menu></tb-side-menu>
         </md-toolbar> 
      </md-content>      	
  </md-sidenav>

  <div flex layout="column" tabIndex="-1" role="main">
    <md-toolbar class="md-whiteframe-z1 tb-primary-toolbar" ng-class="{'md-hue-1': vm.displaySearchMode()}">
    	<div layout="row" flex class="md-toolbar-tools">
		      <md-button id="main" hide-gt-sm
		      		class="md-icon-button" ng-click="vm.openSidenav()" aria-label="{{ 'home.menu' | translate }}" ng-class="{'tb-invisible': vm.displaySearchMode()}">
		      		<md-icon aria-label="{{ 'home.menu' | translate }}" class="material-icons">menu</md-icon>
		      </md-button>
	          <md-button class="md-icon-button" aria-label="{{ 'action.back' | translate }}" ng-click="searchConfig.showSearch = !searchConfig.showSearch" ng-class="{'tb-invisible': !vm.displaySearchMode()}" >
		      	  <md-icon aria-label="{{ 'action.back' | translate }}" class="material-icons">arrow_back</md-icon>
	          </md-button>		    
			  <div flex layout="row" ng-show="!vm.displaySearchMode()" tb-no-animate class="md-toolbar-tools">
				  <span ng-cloak ncy-breadcrumb></span>
			  </div>
			  <md-input-container ng-show="vm.displaySearchMode()" md-theme="tb-search-input" flex>
	              <label>&nbsp;</label>
	              <input ng-model="searchConfig.searchText" ng-change="vm.searchTextUpdated()" placeholder="{{ 'common.enter-search' | translate }}"/>
	          </md-input-container>		      
		      <md-button class="md-icon-button" aria-label="{{ 'action.search' | translate }}" ng-show="searchConfig.searchEnabled" ng-click="searchConfig.showSearch = !searchConfig.showSearch">
		      	  <md-icon aria-label="{{ 'action.search' | translate }}" class="material-icons">search</md-icon>
          	  </md-button>
		      <md-button ng-show="!vm.displaySearchMode()" hide-xs hide-sm class="md-icon-button" ng-click="vm.toggleFullscreen()" aria-label="{{ 'fullscreen.toggle' | translate }}">
	    			<ng-md-icon icon="{{vm.Fullscreen.isEnabled() ? 'fullscreen_exit' : 'fullscreen'}}" options='{"easing": "circ-in-out", "duration": 375, "rotation": "none"}'></ng-md-icon>
		      </md-button>          	  
	      	  <div hide-xs hide-sm ng-show="!vm.displaySearchMode()" class="tb-user-info" layout="row">
  		        <md-icon aria-label="{{ 'home.avatar' | translate }}" class="material-icons tb-mini-avatar">account_circle</md-icon>
  		        <div layout="column">
	             	<span class="tb-user-display-name">{{vm.userDisplayName()}}</span>
	             	<span class="tb-user-authority">{{vm.authorityName()}}</span>
             	</div>
              </div>
 		      <md-menu md-position-mode="target-right target">
			      <md-button class="md-icon-button"  aria-label="{{ 'home.open-user-menu' | translate }}" ng-click="$mdOpenMenu($event)">
			      	<md-icon md-menu-origin aria-label="{{ 'home.open-user-menu' | translate }}" class="material-icons">more_vert</md-icon>
			      </md-button>
			      <md-menu-content width="4">
			        <md-menu-item>
			          <md-button ng-click="vm.openProfile()">
			          	<md-icon md-menu-align-target aria-label="{{ 'home.profile' | translate }}" class="material-icons">account_circle</md-icon>
						<span translate>home.profile</span>
			          </md-button>
			        </md-menu-item>
			        <md-menu-item>
			          <md-button ng-click="vm.logout()">
			          	<md-icon md-menu-align-target aria-label="{{ 'home.logout' | translate }}" class="material-icons">exit_to_app</md-icon>
						<span translate>home.logout</span>
			          </md-button>
			        </md-menu-item>
			      </md-menu-content>
		      </md-menu>		      
      	</div>
    </md-toolbar>
   	<md-progress-linear class="md-warn" style="z-index: 10; max-height: 0px; width: 100%;" md-mode="indeterminate" ng-show="loading"></md-progress-linear>
    
    <div flex layout="column" id="toast-parent" style="position: relative;">
    	<md-content ng-cloak flex layout="column" class="page-content" ui-view name="content"></md-content>
    </div>
  </div>
