Add basic error handling

This commit is contained in:
Johannes Zellner
2016-07-26 14:09:11 +02:00
parent 99af676344
commit 7e3628f4c5
2 changed files with 18 additions and 4 deletions

View File

@@ -108,7 +108,7 @@
<div class="form-group" ng-class="{ 'has-error': (!appstoreLoginForm.password.$dirty && appstoreLogin.error.password) || (appstoreLoginForm.password.$dirty && appstoreLoginForm.password.$invalid) }">
<label class="control-label">Password</label>
<input type="password" class="form-control" ng-model="appstoreLogin.password" id="inputPlanChangePassword" name="password" required autofocus>
<input type="password" class="form-control" ng-model="appstoreLogin.password" id="inputAppstoreLoginPassword" name="password" required autofocus>
<div class="control-label" ng-show="(!appstoreLoginForm.password.$dirty && appstoreLogin.error.password) || (appstoreLoginForm.password.$dirty && appstoreLoginForm.password.$invalid)">
<small ng-show=" appstoreLoginForm.password.$dirty && appstoreLoginForm.password.$invalid">A password is required</small>
<small ng-show="!appstoreLoginForm.password.$dirty && appstoreLogin.error.password">Wrong password</small>
@@ -120,7 +120,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-success" ng-click="appstoreLogin.submit()" ng-disabled="appstoreLoginForm.$invalid || appstoreLogin.busy"><i class="fa fa-spinner fa-pulse" ng-show="appstoreLogin.busy"></i> Change</button>
<button type="button" class="btn btn-success" ng-click="appstoreLogin.submit()" ng-disabled="appstoreLoginForm.$invalid || appstoreLogin.busy"><i class="fa fa-spinner fa-pulse" ng-show="appstoreLogin.busy"></i> Login</button>
</div>
</div>
</div>

View File

@@ -335,13 +335,28 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
$scope.appstoreLogin.busy = true;
console.log('submit', $scope.appstoreLogin.email, $scope.appstoreLogin.password)
AppStore.login($scope.appstoreLogin.email, $scope.appstoreLogin.password, function (error, result) {
$scope.appstoreLogin.busy = false;
if (error && error.statusCode === 403) {
$scope.appstoreLogin.error.password = 'Wrong email or password';
$scope.appstoreLogin.password = '';
$('#inputAppstoreLoginPassword').focus();
$scope.appstoreLoginForm.password.$setPristine();
return;
}
console.log('---', error, result);
});
// var user = {
// id: $scope.user.id,
// displayName: $scope.appstoreLogin.displayName
// };
// Client.updateUser(user, function (error) {
// $scope.appstoreLogin.busy = false;
// if (error) {
// console.error('Unable log into appstore.', error);
@@ -357,7 +372,6 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
}
};
Client.onReady(function () {
fetchBackups();