Cache bust the search box when the user changes and fix an NPE in the landing page controller

This commit is contained in:
Joseph Schorr 2013-11-07 22:44:34 -05:00
parent fe69ba5ec1
commit ecd09358ee
2 changed files with 17 additions and 6 deletions

View file

@ -55,6 +55,7 @@ quayApp = angular.module('quay', ['restangular', 'angularMoment', 'angulartics',
username: null,
email: null,
askForPassword: false,
organizations: []
}
var userService = {}

View file

@ -15,8 +15,11 @@ $.fn.clipboardCopy = function() {
};
function HeaderCtrl($scope, $location, UserService, Restangular) {
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
var searchToken = 0;
$scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) {
$scope.user = currentUser;
++searchToken;
}, true);
$scope.signout = function() {
@ -40,6 +43,11 @@ function HeaderCtrl($scope, $location, UserService, Restangular) {
name: 'repositories',
remote: {
url: '/api/find/repository?query=%QUERY',
replace: function (url, uriEncodedQuery) {
url = url.replace('%QUERY', uriEncodedQuery);
url += '&cb=' + searchToken;
return url;
},
filter: function(data) {
var datums = [];
for (var i = 0; i < data.repositories.length; ++i) {
@ -215,11 +223,13 @@ function LandingCtrl($scope, $timeout, $location, Restangular, UserService, KeyS
if (namespace == $scope.user.username) {
return true;
}
for (var i = 0; i < $scope.user.organizations.length; ++i) {
var org = $scope.user.organizations[i];
if (org.name == namespace) {
return org.can_create_repo;
if ($scope.user.organizations) {
for (var i = 0; i < $scope.user.organizations.length; ++i) {
var org = $scope.user.organizations[i];
if (org.name == namespace) {
return org.can_create_repo;
}
}
}