feat(auth): login spinner (#2999)

pull/3003/head
xAt0mZ 2019-07-10 18:13:03 +02:00 committed by Anthony Lapenna
parent 4084e7c8ec
commit 693182fbd3
2 changed files with 8 additions and 1 deletions

View File

@ -43,7 +43,10 @@
</div>
</a>
<button type="submit" class="btn btn-primary btn-sm pull-right" ng-click="authenticateUser()"><i class="fa fa-sign-in-alt" aria-hidden="true"></i> Login</button>
<button type="submit" class="btn btn-primary btn-sm pull-right" ng-click="authenticateUser()" button-spinner="state.loginInProgress" ng-disabled="state.loginInProgress">
<span ng-hide="state.loginInProgress"><i class="fa fa-sign-in-alt" aria-hidden="true"></i> Login</span>
<span ng-show="state.loginInProgress">Login in progress...</span>
</button>
<span class="pull-right" style="margin: 5px;" ng-if="state.AuthenticationError">
<i class="fa fa-exclamation-triangle red-icon" aria-hidden="true" style="margin-right: 2px;"></i>

View File

@ -23,12 +23,14 @@ function($async, $q, $scope, $state, $stateParams, $sanitize, Authentication, Us
await ExtensionService.retrieveAndSaveEnabledExtensions();
} catch (err) {
Notifications.error('Failure', err, 'Unable to retrieve enabled extensions');
$scope.state.loginInProgress = false;
}
}
$scope.authenticateUser = function() {
var username = $scope.formValues.Username;
var password = $scope.formValues.Password;
$scope.state.loginInProgress = true;
Authentication.login(username, password)
.then(function success() {
@ -53,6 +55,7 @@ function($async, $q, $scope, $state, $stateParams, $sanitize, Authentication, Us
})
.catch(function error() {
$scope.state.AuthenticationError = 'Invalid credentials';
$scope.state.loginInProgress = false;
});
});
};
@ -96,6 +99,7 @@ function($async, $q, $scope, $state, $stateParams, $sanitize, Authentication, Us
})
.catch(function error(err) {
Notifications.error('Failure', err, 'Unable to retrieve endpoints');
$scope.state.loginInProgress = false;
});
}