<!--

    Copyright © 2016-2020 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-content layout="row" layout-align="center center" style="width: 100%;">
    <md-card flex="initial" class="tb-login-card" md-theme="tb-dark">
        <md-card-title>
            <img src="{{vm.logoSvg}}" aria-label="logo" class="tb-login-logo"/>
        </md-card-title>
        <md-progress-linear class="md-warn" style="z-index: 1; max-height: 0px; width: inherit;"
                            md-mode="indeterminate" ng-disabled="!$root.loading" ng-show="$root.loading"></md-progress-linear>
        <md-card-content>
            <form class="login-form" ng-submit="vm.login()">
                <div layout="column" class="tb-padding" id="toast-parent">
                    <span style="height: 50px;"></span>
                    <md-input-container class="md-block">
                        <label translate>login.username</label>
                        <md-icon aria-label="{{ 'login.username' | translate }}" class="material-icons">
                            email
                        </md-icon>
                        <input id="username-input" type="email" autofocus ng-model="vm.user.name"/>
                    </md-input-container>
                    <md-input-container class="md-block">
                        <label translate>common.password</label>
                        <md-icon aria-label="{{ 'common.password' | translate }}" class="material-icons">
                            lock
                        </md-icon>
                        <input id="password-input" type="password" ng-model="vm.user.password"/>
                    </md-input-container>
                    <div layout-gt-sm="column" layout-align="center end" class="tb-padding">
                        <md-button ui-sref="login.resetPasswordRequest">{{ 'login.forgot-password' | translate }}
                        </md-button>
                    </div>
                    <md-button class="md-raised" type="submit">{{ 'login.login' | translate }}</md-button>
                    <div class="oauth-container" layout="column" ng-if="oauth2Clients.length">
                        <div class="container-divider">
                            <div class="line"><md-divider></md-divider></div>
                            <div class="text mat-typography">{{ "login.or" | translate | uppercase }}</div>
                            <div class="line"><md-divider></md-divider></div>
                        </div>
                        <md-button ng-repeat="oauth2Client in oauth2Clients" class="md-raised md-accent md-hue-2"
                                   layout="row" layout-align="center center" ng-href="{{ oauth2Client.url }}" target="_self">
                            <md-icon class="material-icons md-18" md-svg-icon="{{ oauth2Client.icon }}"></md-icon>
                            {{ 'login.login-with' | translate: {name: oauth2Client.name} }}
                        </md-button>
                    </div>
                </div>
            </form>
        </md-card-content>
    </md-card>
</md-content>
