Code coverage report for app/routes/layout-auth/login/login.js

Statements: 100% (25 / 25)      Branches: 100% (10 / 10)      Functions: 100% (5 / 5)      Lines: 100% (21 / 21)      Ignored: none     

All files » app/routes/layout-auth/login/ » login.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55                                              1 1 25 25 25 25 25 25 25 25 25 25 25       4   3 3 2 2 2   1 1            
/**
 * @author    Martin Micunda {@link http://martinmicunda.com}
 * @copyright Copyright (c) 2015, Martin Micunda
 * @license   GPL-3.0
 */
'use strict';
 
import template from './login.html!text';
import {RouteConfig, Component, View, Inject} from '../../../ng-decorators'; // jshint unused: false
 
//start-non-standard
@RouteConfig('auth.login', {
    url: '/',
    template: '<login></login>'
})
@Component({
    selector: 'login'
})
@View({
    template: template
})
@Inject('$rootScope', '$state', 'AuthenticationService', 'FormService')
//end-non-standard
class Login {
    constructor($rootScope, $state, AuthenticationService, FormService) {
        this.$rootScope = $rootScope;
        this.router = $state;
        this.result = null;
        this.isSubmitting = null;
        this.copyrightDate = new Date();
        this.saveButtonOptions = Object.assign({}, FormService.getModalSaveButtonOptions());
        this.saveButtonOptions.buttonDefaultText = 'Sign me in';
        this.saveButtonOptions.buttonSubmittingText = 'Signing me in';
        this.saveButtonOptions.buttonSuccessText = 'Signed me in';
        this.AuthenticationService = AuthenticationService;
        this.FormService = FormService;
    }
 
    login(isFormValid, form) {
        if(!isFormValid) {return;}
 
        this.isSubmitting = true;
        return this.AuthenticationService.login(this.credentials).then(() => {
            this.$rootScope.currentUser = this.AuthenticationService.getCurrentUser();
            this.FormService.onSuccess(this);
            this.router.go('app.schedule');
        }, (response) => {
            form.$setPristine();
            this.FormService.onFailure(this, response);
        });
    }
}
 
export default Login;