<!--

    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.

-->
<div layout="row" width="100%" layout-wrap>
    <md-card flex-gt-sm="60" flex="100" style="height: 100%;">
        <md-card-title>
            <md-card-title-text>
                <span translate class="md-headline">profile.profile</span>
                <span style='opacity: 0.7;'>{{ vm.profileUser.email }}</span>
            </md-card-title-text>
        </md-card-title>
        <md-progress-linear md-mode="indeterminate" ng-disabled="!loading" ng-show="loading"></md-progress-linear>
        <span style="min-height: 5px;" flex="" ng-show="!loading"></span>
        <md-card-content>
            <form name="theForm" ng-submit="vm.save()" tb-confirm-on-exit confirm-form="theForm">
                <fieldset ng-disabled="loading">
                    <md-input-container class="md-block">
                        <label translate>user.email</label>
                        <input name="email" type="email" ng-model="vm.profileUser.email">
                    </md-input-container>
                    <md-input-container class="md-block">
                        <label translate>user.first-name</label>
                        <input name="firstName" ng-model="vm.profileUser.firstName">
                    </md-input-container>
                    <md-input-container class="md-block">
                        <label translate>user.last-name</label>
                        <input name="lastName" ng-model="vm.profileUser.lastName">
                    </md-input-container>
                    <md-input-container class="md-block">
                        <label translate>language.language</label>
                        <md-select name="language" ng-model="vm.profileUser.lang">
                            <md-option ng-repeat="lang in vm.languageList" ng-value="lang.value">
                                {{lang.name | translate}}
                            </md-option>
                        </md-select>
                    </md-input-container>
                    <md-button ng-disabled="loading" ng-click="vm.changePassword($event)"
                               class="md-raised md-primary">{{ 'profile.change-password' | translate }}
                    </md-button>
                    <div layout="row" layout-align="end center" width="100%" layout-wrap>
                        <md-button ng-disabled="loading || theForm.$invalid || !theForm.$dirty" type="submit"
                                   class="md-raised md-primary">{{ 'action.save' | translate }}
                        </md-button>
                    </div>
                </fieldset>
            </form>
        </md-card-content>
    </md-card>
</div>

