From 278c28f3504f69187f5036beba1dadcf1746d9e9 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Thu, 8 May 2014 19:09:43 -0400 Subject: [PATCH 1/3] Fix NPE in user service --- static/js/controllers.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/static/js/controllers.js b/static/js/controllers.js index e44e3447b..2b2c4225e 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -1587,12 +1587,14 @@ function UserAdminCtrl($scope, $timeout, $location, ApiService, PlanService, Use $scope.cuser = jQuery.extend({}, user); - for (var i = 0; i < $scope.cuser.logins.length; i++) { - if ($scope.cuser.logins[i].service == 'github') { - var githubId = $scope.cuser.logins[i].service_identifier; - $http.get('https://api.github.com/user/' + githubId).success(function(resp) { - $scope.githubLogin = resp.login; - }); + if ($scope.cuser.logins) { + for (var i = 0; i < $scope.cuser.logins.length; i++) { + if ($scope.cuser.logins[i].service == 'github') { + var githubId = $scope.cuser.logins[i].service_identifier; + $http.get('https://api.github.com/user/' + githubId).success(function(resp) { + $scope.githubLogin = resp.login; + }); + } } } }); From e2992d08bbdeea8a0fa62e0441dbdb24ce363b1d Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 9 May 2014 17:23:35 -0400 Subject: [PATCH 2/3] Further JS fixes --- static/js/app.js | 2 +- static/js/controllers.js | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/static/js/app.js b/static/js/app.js index 8d6869978..9c701d62a 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -84,7 +84,7 @@ function createOrganizationTeam(ApiService, orgname, teamname, callback) { 'teamname': teamname }; - ApiService.updateOrganizationTeam(data, params).then(callback, function() { + ApiService.updateOrganizationTeam(data, params).then(callback, function(resp) { bootbox.dialog({ "message": resp.data ? resp.data : 'The team could not be created', "title": "Cannot create team", diff --git a/static/js/controllers.js b/static/js/controllers.js index 2b2c4225e..e32c0797a 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -4,11 +4,16 @@ $.fn.clipboardCopy = function() { clip.on('complete', function() { // Resets the animation. var elem = $('#clipboardCopied')[0]; + if (!elem) { + return; + } + elem.style.display = 'none'; elem.classList.remove('animated'); // Show the notification. setTimeout(function() { + if (!elem) { return; } elem.style.display = 'inline-block'; elem.classList.add('animated'); }, 10); From b4e091baddc2ffc470ae2853688af2ba318036a6 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 9 May 2014 17:54:11 -0400 Subject: [PATCH 3/3] Fix the build view controller to always search for the build to update --- static/js/controllers.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/static/js/controllers.js b/static/js/controllers.js index e32c0797a..d9684cbdc 100644 --- a/static/js/controllers.js +++ b/static/js/controllers.js @@ -1021,7 +1021,6 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope $scope.currentParentEntry = null; $scope.currentBuild = build; - $scope.currentBuildIndex = index; if (opt_updateURL) { if (build) { @@ -1099,8 +1098,18 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope ApiService.getRepoBuildStatus(null, params, true).then(function(resp) { // Note: We use extend here rather than replacing as Angular is depending on the // root build object to remain the same object. - $.extend(true, $scope.builds[$scope.currentBuildIndex], resp); - var currentBuild = $scope.builds[$scope.currentBuildIndex]; + var matchingBuilds = $.grep($scope.builds, function(elem) { + return elem['id'] == resp['id'] + }); + + var currentBuild = matchingBuilds.length > 0 ? matchingBuilds[0] : null; + if (currentBuild) { + currentBuild = $.extend(true, currentBuild, resp); + } else { + currentBuild = resp; + $scope.builds.push(currentBuild); + } + checkPollTimer(); // Load the updated logs for the build.