<div class="content-grid mdl-grid content-layout login-content"
     [style.background-image]="'url(' + backgroundImageUrl + ')'">
    <div class="login-card-wide mdl-card mdl-shadow--4dp">
        <form [formGroup]="form" (submit)="onSubmit(form.value, $event)">
            <div class="mdl-card__title alfresco-logo">
                <!--HEADER TEMPLATE-->
                <template *ngIf="headerTemplate"
                          ngFor [ngForOf]="[data]"
                          [ngForTemplate]="headerTemplate">
                </template>
                <img *ngIf="!headerTemplate" class="center" [src]="logoImageUrl" alt="{{'LOGIN.LOGO' | translate }}">
            </div>
            <div class="mdl-card__supporting-text">

                <!--ERRORS AREA-->
                <div>
                    <div *ngIf="error" id="login-error" data-automation-id="login-error"
                         class="error mdl-card__supporting-text">{{errorMsg | translate }}</div>
                    <div *ngIf="success" id="login-success" data-automation-id="login-success" class="mdl-card__supporting-text" class="alfresco-login__message">{{'LOGIN.MESSAGES.LOGIN-SUCCESS' | translate }}</div>
                </div>

                <!--USERNAME FIELD-->
                <div [ngClass]="{'is-invalid': isErrorStyle(form.controls.username)}"
                     class="center mdl-textfield mdl-js-textfield mdl-textfield--floating-label">

                    <md-input-container class="adf-full-width">
                        <input md-input placeholder="{{'LOGIN.LABEL.USERNAME' | translate }}"
                               type="text"
                               class="mdl-textfield__input adf-full-width"
                               [formControl]="form.controls['username']"
                               autocapitalize="none"
                               id="username"
                               data-automation-id="username"
                               (blur)="trimUsername($event)"
                               tabindex="1">
                    </md-input-container>

                    <span class="alfresco-login__validation" for="username" *ngIf="formError.username">
                        <span id="username-error" class="alfresco-login__error" data-automation-id="username-error">{{formError.username | translate }}</span>
                    </span>
                </div>

                <!--PASSWORD FIELD-->
                <div class="center mdl-textfield mdl-js-textfield mdl-textfield--floating-label alfresco-login__password">
                    <md-icon *ngIf="!isPasswordShow" class="alfresco-login__password-icon" data-automation-id="show_password" (click)="toggleShowPassword()">visibility</md-icon>
                    <md-icon *ngIf="isPasswordShow" class="alfresco-login__password-icon" data-automation-id="hide_password" (click)="toggleShowPassword()">visibility_off</md-icon>

                    <md-input-container class="adf-full-width">
                        <input md-input placeholder="{{'LOGIN.LABEL.PASSWORD' | translate }}"
                               type="password"
                               class="mdl-textfield__input"
                               [formControl]="form.controls['password']"
                               id="password"
                               data-automation-id="password"
                               tabindex="2">
                    </md-input-container>
                    <span class="alfresco-login__validation" for="password" *ngIf="formError.password">
                        <span id="password-required" class="alfresco-login__error" data-automation-id="password-required">{{formError.password | translate }}</span>
                    </span>
                </div>

                <!--CUSTOM CONTENT-->
                <ng-content></ng-content>

                <br>
                <button type="submit" id="login-button" tabindex="3"
                        class="center mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect mdl-button--colored"
                        data-automation-id="login-button" [disabled]="!form.valid">{{'LOGIN.BUTTON.LOGIN' | translate }}</button>
                <br>
                <div class="center">
                    <label class=" mdl-checkbox mdl-js-checkbox mdl-js-ripple-effect" for="remember">
                        <input type="checkbox" id="remember" class="center mdl-checkbox__input">
                        <span id="login-remember" class="mdl-checkbox__label">{{'LOGIN.LABEL.REMEMBER' | translate }}</span>
                    </label>
                </div>
            </div>
            <div class="mdl-card__actions mdl-card--border mdl-card__link">

                <!--FOOTER TEMPLATE-->
                <template *ngIf="footerTemplate"
                          ngFor [ngForOf]="[data]"
                          [ngForTemplate]="footerTemplate">
                </template>
                <div class="login-action" *ngIf="!footerTemplate">
                    <div id="login-action-help" class="login-action-left"> <a href="{{needHelpLink}}">{{'LOGIN.ACTION.HELP' | translate
                        }}</a>
                    </div>
                    <div id="login-action-register" class="login-action-right"> <a href="{{registerLink}}">{{'LOGIN.ACTION.REGISTER' |
                        translate }}</a>
                    </div>
                </div>
            </div>
            <div class="mdl-card__menu">
                <div class="mdl-spinner mdl-js-spinner"></div>
            </div>
        </form>
    </div>
</div>
