Merge pull request #2086 from coreos-inc/user-info
Add collection of user metadata: name and company
This commit is contained in:
commit
45b1148118
14 changed files with 178 additions and 33 deletions
|
@ -21,7 +21,11 @@
|
|||
|
||||
UserService.updateUserIn($scope, function(user) {
|
||||
if (!user.anonymous) {
|
||||
$location.path('/repository/');
|
||||
if (user.prompts && user.prompts.length) {
|
||||
$location.path('/updateuser/');
|
||||
} else {
|
||||
$location.path('/repository/');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
function UpdateUserCtrl($scope, UserService, $location, ApiService) {
|
||||
$scope.state = 'loading';
|
||||
$scope.metadata = {};
|
||||
|
||||
UserService.updateUserIn($scope, function(user) {
|
||||
if (!user.anonymous) {
|
||||
|
@ -45,15 +46,17 @@
|
|||
});
|
||||
};
|
||||
|
||||
$scope.updateUsername = function(username) {
|
||||
$scope.state = 'updating';
|
||||
var data = {
|
||||
'username': username
|
||||
};
|
||||
|
||||
ApiService.changeUserDetails(data).then(function() {
|
||||
window.location = '/';
|
||||
}, ApiService.errorDisplay('Could not update username'));
|
||||
$scope.updateUser = function(data) {
|
||||
$scope.state = 'updating';
|
||||
ApiService.changeUserDetails(data).then(function() {
|
||||
UserService.load(function(updated) {
|
||||
if (updated.prompts.length) {
|
||||
$scope.state = 'editing';
|
||||
} else {
|
||||
$location.url('/');
|
||||
}
|
||||
});
|
||||
}, ApiService.errorDisplay('Could not update user information'));
|
||||
};
|
||||
|
||||
$scope.hasPrompt = function(user, prompt_name) {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<div class="cor-loader-inline" ng-if="user.anonymous || state == 'updating'"></div>
|
||||
<!-- TODO: Support additional kinds of prompts here -->
|
||||
|
||||
<!-- Confirm username -->
|
||||
<div class="update-user" ng-show="hasPrompt(user, 'confirm_username') && state != 'updating'">
|
||||
<h2>Confirm Username</h2>
|
||||
<p>
|
||||
|
@ -8,7 +8,7 @@
|
|||
Docker CLI guidelines for use as a namespace in <span class="registry-title"></span>.
|
||||
</p>
|
||||
<p>Please confirm the selected username or enter a different username below:</p>
|
||||
<form name="usernameForm" ng-submit="updateUsername(username)">
|
||||
<form name="usernameForm" ng-submit="updateUser({'username': username})">
|
||||
<div class="namespace-input" binding="username" is-back-incompat="isBackIncompat"
|
||||
namespace-title="Username" style="margin-bottom: 20px;"
|
||||
has-external-error="state == 'existing'"></div>
|
||||
|
@ -33,4 +33,38 @@
|
|||
<i class="fa fa-exclamation-triangle"></i> Note: Usernames with dots or dashes are incompatible with Docker verion 1.8 or older
|
||||
</span>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Enter metadata -->
|
||||
<div class="update-user" ng-show="!hasPrompt(user, 'confirm_username') && (hasPrompt(user, 'enter_name') || hasPrompt(user, 'enter_company')) && state != 'updating'">
|
||||
<h2>Tell us a bit more about yourself</h2>
|
||||
<div>This information will be displayed in your user profile.</div>
|
||||
|
||||
<form name="metadataForm" ng-submit="updateUser(metadata)" style="margin-top: 20px;">
|
||||
<div class="form-group nested">
|
||||
<label for="name">Name</label>
|
||||
<div class="field-row">
|
||||
<span class="field-container">
|
||||
<input type="text" class="form-control" placeholder="Name" ng-model="metadata.name"></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group nested">
|
||||
<label for="firstName">Company</label>
|
||||
<div class="field-row">
|
||||
<span class="field-container">
|
||||
<input type="text" class="form-control" placeholder="Company name" ng-model="metadata.company"></span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style="margin-top: 20px">
|
||||
<input type="submit" class="btn btn-primary" value="Save Details"
|
||||
ng-disabled="!metadata.name && !metadata.company">
|
||||
<button class="btn btn-default"
|
||||
ng-click="updateUser({'company': '', 'name': ''})">
|
||||
No thanks</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
Reference in a new issue