This commit is contained in:
Joseph Schorr 2013-10-10 20:48:33 -04:00
commit 2ae4dbd9fa
17 changed files with 300 additions and 65 deletions

View file

@ -5,7 +5,8 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
verified: false,
anonymous: true,
username: null,
email: null
email: null,
askForPassword: false,
}
var userService = {}
@ -22,6 +23,9 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
'$username': userResponse.username,
'verified': userResponse.verified
});
mixpanel.people.set_once({
'$created': new Date()
})
}
});
};
@ -41,8 +45,10 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
if ($location.host() === 'quay.io') {
keyService['stripePublishableKey'] = 'pk_live_P5wLU0vGdHnZGyKnXlFG4oiu';
keyService['githubClientId'] = '5a8c08b06c48d89d4d1e';
} else {
keyService['stripePublishableKey'] = 'pk_test_uEDHANKm9CHCvVa2DLcipGRh';
keyService['githubClientId'] = 'cfbc4aca88e5c1b40679';
}
return keyService;
@ -116,6 +122,8 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
$analyticsProvider.virtualPageviews(true);
$locationProvider.html5Mode(true);
$routeProvider.
when('/repository/:namespace/:name', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl}).
when('/repository/:namespace/:name/tag/:tag', {templateUrl: '/static/partials/view-repo.html', controller: RepoCtrl}).

View file

@ -130,7 +130,7 @@ function RepoListCtrl($scope, Restangular, UserService) {
});
}
function LandingCtrl($scope, $timeout, Restangular, UserService) {
function LandingCtrl($scope, $timeout, Restangular, UserService, KeyService) {
$('.form-signup').popover();
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
@ -141,6 +141,13 @@ function LandingCtrl($scope, $timeout, Restangular, UserService) {
$scope.user = currentUser;
}, true);
angulartics.waitForVendorApi(mixpanel, 500, function(loadedMixpanel) {
var mixpanelId = loadedMixpanel.get_distinct_id();
$scope.github_state_clause = '&state=' + mixpanelId;
});
$scope.githubClientId = KeyService.githubClientId;
$scope.awaitingConfirmation = false;
$scope.registering = false;
@ -162,12 +169,6 @@ function LandingCtrl($scope, $timeout, Restangular, UserService) {
$scope.registering = false;
mixpanel.alias($scope.newUser.username);
mixpanel.people.set_once({
'$email': $scope.newUser.email,
'$username': $scope.newUser.username,
'$created': new Date(),
'verified': false
});
}, function(result) {
$scope.registering = false;
$scope.registerError = result.data.message;
@ -468,9 +469,13 @@ function RepoAdminCtrl($scope, Restangular, $routeParams, $rootScope) {
});
}
function UserAdminCtrl($scope, Restangular, PlanService, KeyService, $routeParams) {
function UserAdminCtrl($scope, $timeout, Restangular, PlanService, UserService, KeyService, $routeParams) {
$scope.plans = PlanService.planList();
$scope.$watch(function () { return UserService.currentUser(); }, function (currentUser) {
$scope.askForPassword = currentUser.askForPassword;
}, true);
var subscribedToPlan = function(sub) {
$scope.subscription = sub;
$scope.subscribedPlan = PlanService.getPlan(sub.plan);
@ -557,4 +562,33 @@ function UserAdminCtrl($scope, Restangular, PlanService, KeyService, $routeParam
$scope.subscribe(requested);
}
}
$scope.updatingUser = false;
$scope.changePasswordSuccess = false;
$('.form-change-pw').popover();
$scope.changePassword = function() {
$('.form-change-pw').popover('hide');
$scope.updatingUser = true;
$scope.changePasswordSuccess = false;
var changePasswordPost = Restangular.one('user/');
changePasswordPost.customPUT($scope.user).then(function() {
$scope.updatingUser = false;
$scope.changePasswordSuccess = true;
// Reset the form
$scope.user.password = '';
$scope.user.repeatPassword = '';
$scope.changePasswordForm.$setPristine();
UserService.load();
}, function(result) {
$scope.updatingUser = false;
$scope.changePasswordError = result.data.message;
$timeout(function() {
$('.form-change-pw').popover('show');
});
});
};
}