Add appstore login form dialog
This commit is contained in:
@@ -82,6 +82,46 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal appstore login -->
|
||||
<div class="modal fade" id="appstoreLoginModal" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">Login to the Cloudron Store</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form name="appstoreLoginForm" role="form" novalidate ng-submit="appstoreLogin.submit()" autocomplete="off">
|
||||
<input type="password" style="display: none;">
|
||||
|
||||
<div class="form-group" ng-class="{ 'has-error': (appstoreLoginForm.email.$dirty && appstoreLoginForm.email.$invalid) }">
|
||||
<label class="control-label">Email Address</label>
|
||||
<div class="control-label" ng-show="(!appstoreLoginForm.email.$dirty && appstoreLogin.error.email) || (appstoreLoginForm.email.$dirty && appstoreLoginForm.email.$invalid)">
|
||||
<small ng-show="appstoreLoginForm.email.$error.required">A valid email address is required</small>
|
||||
<small ng-show="(appstoreLoginForm.email.$dirty && appstoreLoginForm.email.$invalid) && !appstoreLoginForm.email.$error.required">The Email address is not valid</small>
|
||||
</div>
|
||||
<input type="email" class="form-control" ng-model="appstoreLogin.email" name="email" required autofocus>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<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>
|
||||
</div>
|
||||
<input type="password" class="form-control" ng-model="appstoreLogin.password" id="inputPlanChangePassword" name="password" required autofocus>
|
||||
</div>
|
||||
|
||||
<input class="ng-hide" type="submit" ng-disabled="appstoreLoginForm.$invalid"/>
|
||||
</form>
|
||||
</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>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<br/>
|
||||
|
||||
<div class="section-header">
|
||||
@@ -126,8 +166,8 @@
|
||||
|
||||
<div class="card" style="margin-bottom: 15px;" ng-show="user.admin">
|
||||
<div class="row">
|
||||
<div class="col-xs-12" ng-show="!appstoreAccount">
|
||||
No cloudron.io appstore account is linked to this Cloudron. Link an account so you can use the Cloudron store.
|
||||
<div class="col-xs-12 text-center" ng-show="!appstoreAccount">
|
||||
<button class="btn btn-success" ng-click="appstoreLogin.show()">Login to the Cloudron Store</button>
|
||||
</div>
|
||||
<div class="col-xs-12" ng-show="appstoreAccount">
|
||||
This Cloudron is using {{ appstoreAccount.email }}.
|
||||
|
||||
@@ -309,6 +309,55 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
fr.readAsDataURL(event.target.files[0]);
|
||||
};
|
||||
|
||||
$scope.appstoreLogin = {
|
||||
busy: false,
|
||||
error: {},
|
||||
email: '',
|
||||
password: '',
|
||||
|
||||
reset: function () {
|
||||
$scope.appstoreLogin.busy = false;
|
||||
$scope.appstoreLogin.error = {};
|
||||
$scope.appstoreLogin.email = '';
|
||||
$scope.appstoreLogin.password = '';
|
||||
|
||||
$scope.appstoreLoginForm.$setUntouched();
|
||||
$scope.appstoreLoginForm.$setPristine();
|
||||
},
|
||||
|
||||
show: function () {
|
||||
$scope.appstoreLogin.reset();
|
||||
$('#appstoreLoginModal').modal('show');
|
||||
},
|
||||
|
||||
submit: function () {
|
||||
$scope.appstoreLogin.error = {};
|
||||
$scope.appstoreLogin.busy = true;
|
||||
|
||||
console.log('submit', $scope.appstoreLogin.email, $scope.appstoreLogin.password)
|
||||
// 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);
|
||||
// return;
|
||||
// }
|
||||
|
||||
// // update user info in the background
|
||||
// Client.refreshUserInfo();
|
||||
|
||||
// $scope.appstoreLogin.reset();
|
||||
// $('#appstoreLoginModal').modal('hide');
|
||||
// });
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Client.onReady(function () {
|
||||
fetchBackups();
|
||||
|
||||
@@ -321,7 +370,7 @@ angular.module('Application').controller('SettingsController', ['$scope', '$loca
|
||||
});
|
||||
|
||||
// setup all the dialog focus handling
|
||||
['planChangeModal'].forEach(function (id) {
|
||||
['planChangeModal', 'appstoreLoginModal'].forEach(function (id) {
|
||||
$('#' + id).on('shown.bs.modal', function () {
|
||||
$(this).find("[autofocus]:first").focus();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user