Move to Angular 1.5

This has been reasonably well tested, but further testing should be done on staging.

Also optimizes avatar handling to use a constant size and not 404.

Fixes #1434
This commit is contained in:
Joseph Schorr 2016-05-17 16:29:24 -04:00
parent dc42f22b79
commit 4aab834156
19 changed files with 91 additions and 133 deletions

View file

@ -36,7 +36,7 @@ quayPages.constant('pages', {
});
quayDependencies = ['ngRoute', 'chieffancypants.loadingBar', 'cfp.hotkeys', 'angular-tour', 'restangular', 'angularMoment',
'mgcrea.ngStrap', 'ngCookies', 'ngSanitize', 'angular-md5', 'pasvaz.bindonce', 'ansiToHtml', 'debounce',
'mgcrea.ngStrap', 'ngCookies', 'ngSanitize', 'angular-md5', 'pasvaz.bindonce', 'ansiToHtml',
'core-ui', 'core-config-setup', 'quayPages', 'infinite-scroll'];
if (window.__config && window.__config.MIXPANEL_KEY) {
@ -72,6 +72,12 @@ quayApp.config(['$tooltipProvider', function ($tooltipProvider) {
};
}]);
quayApp.config(['$compileProvider', function ($compileProvider) {
if (!window.__config['DEBUG']) {
$compileProvider.debugInfoEnabled(false);
}
}]);
// Configure the routes.
quayApp.config(['$routeProvider', '$locationProvider', 'pages', function($routeProvider, $locationProvider, pages) {
$locationProvider.html5Mode(true);

View file

@ -1133,12 +1133,19 @@ angular.module("core-config-setup", ['angularFileUpload'])
controller: function($scope, $element) {
var firstSet = true;
$scope.patternMap = {};
$scope.getRegexp = function(pattern) {
if (!pattern) {
pattern = '.*';
}
return new RegExp(pattern);
};
if (!pattern) {
pattern = '.*';
}
if ($scope.patternMap[pattern]) {
return $scope.patternMap[pattern];
}
return $scope.patternMap[pattern] = new RegExp(pattern);
};
$scope.$watch('binding', function(binding) {
if (firstSet && !binding && $scope.defaultValue) {

View file

@ -16,20 +16,38 @@ angular.module('quay').directive('avatar', function () {
$scope.AvatarService = AvatarService;
$scope.Config = Config;
$scope.isLoading = true;
$scope.hasGravatar = false;
$scope.showGravatar = false;
$scope.loadGravatar = false;
$scope.imageCallback = function(r) {
$timeout(function() {
$scope.isLoading = false;
$scope.hasGravatar = r;
}, 1);
$scope.imageCallback = function(result) {
$scope.isLoading = false;
if (!result) {
$scope.showGravatar = false;
return;
}
// Determine whether the gravatar is blank.
var canvas = document.createElement("canvas");
canvas.width = 512;
canvas.height = 512;
var ctx = canvas.getContext("2d");
ctx.drawImage($element.find('img')[0], 0, 0);
var blank = document.createElement("canvas");
blank.width = 512;
blank.height = 512;
var isBlank = canvas.toDataURL('text/png') == blank.toDataURL('text/png');
$scope.showGravatar = !isBlank;
};
$scope.$watch('size', function(size) {
size = size * 1 || 16;
$scope.fontSize = (size - 4) + 'px';
$scope.lineHeight = size + 'px';
$scope.imageSize = size;
});
$scope.$watch('data', function(data) {

View file

@ -147,18 +147,6 @@ angular.module('quay').directive('headerBar', function () {
});
};
$scope.appLinkTarget = function() {
if ($scope._appLinkTarget) {
return $scope._appLinkTarget;
}
if ($("div[ng-view]").length === 0) {
return $scope._appLinkTarget = "_self";
}
return $scope._appLinkTarget = "";
};
$scope.getEnterpriseLogo = function() {
return Config.getEnterpriseLogo(false);
};

View file

@ -14,6 +14,8 @@ angular.module('quay').directive('popupInputButton', function () {
'submitted': '&submitted'
},
controller: function($scope, $element) {
$scope.patternMap = {};
$scope.popupShown = function() {
setTimeout(function() {
var box = $('#input-box');
@ -26,7 +28,12 @@ angular.module('quay').directive('popupInputButton', function () {
if (!pattern) {
pattern = '.*';
}
return new RegExp(pattern);
if ($scope.patternMap[pattern]) {
return $scope.patternMap[pattern];
}
return $scope.patternMap[pattern] = new RegExp(pattern);
};
$scope.inputSubmit = function() {

View file

@ -77,7 +77,12 @@ angular.module('quay').directive('signinForm', function () {
if (redirectUrl == $location.path() || redirectUrl == null) {
return;
}
window.location = (redirectUrl ? redirectUrl : '/');
if (redirectUrl) {
window.location = redirectUrl
} else {
$location.path('/');
}
}, 500);
}, function(result) {
$scope.signingIn = false;

View file

@ -21,7 +21,7 @@
UserService.updateUserIn($scope, function(user) {
if (!user.anonymous) {
$location.path('/repository');
$location.path('/repository/');
}
});

View file

@ -1,22 +1,22 @@
/**
* Helper service for working with cookies.
*/
angular.module('quay').factory('CookieService', ['$cookies', '$cookieStore', function($cookies, $cookieStore) {
angular.module('quay').factory('CookieService', ['$cookies', function($cookies) {
var cookieService = {};
cookieService.putPermanent = function(name, value) {
document.cookie = escape(name) + "=" + escape(value) + "; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/";
};
cookieService.putSession = function(name, value) {
$cookies[name] = value;
$cookies.put(name, value);
};
cookieService.clear = function(name) {
$cookies[name] = '';
$cookies.remove(name);
};
cookieService.get = function(name) {
return $cookies[name];
return $cookies.get(name);
};
return cookieService;