Merge branch 'master' of ssh://bitbucket.org/yackob03/quay

This commit is contained in:
Jake Moshenko 2014-06-27 19:18:35 -04:00
commit e68d6a7302
18 changed files with 261 additions and 9 deletions

View file

@ -4618,6 +4618,140 @@ quayApp.directive('dockerfileBuildForm', function () {
});
quayApp.directive('locationView', function () {
var directiveDefinitionObject = {
priority: 0,
templateUrl: '/static/directives/location-view.html',
replace: false,
transclude: true,
restrict: 'C',
scope: {
'location': '=location'
},
controller: function($rootScope, $scope, $element, $http) {
var LOCATIONS = {
'local_us': { 'country': 'US', 'data': 'quay-registry.s3.amazonaws.com', 'title': 'United States' },
'local_eu': { 'country': 'EU', 'data': 'quay-registry-eu.s3-eu-west-1.amazonaws.com', 'title': 'Europe' },
's3_us_east_1': { 'country': 'US', 'data': 'quay-registry.s3.amazonaws.com', 'title': 'United States' },
's3_eu_west_1': { 'country': 'EU', 'data': 'quay-registry-eu.s3-eu-west-1.amazonaws.com', 'title': 'Europe' },
's3_ap_southeast_1': { 'country': 'SG', 'data': 'quay-registry-singapore.s3-ap-southeast-1.amazonaws.com', 'title': 'Singapore' },
's3_ap_southeast_2': { 'country': 'AU', 'data': 'quay-registry-sydney.s3-ap-southeast-2.amazonaws.com', 'title': 'Australia' },
// 's3_ap_northeast-1': { 'country': 'JP', 'data': 's3-ap-northeast-1.amazonaws.com', 'title': 'Japan' },
// 's3_sa_east1': { 'country': 'BR', 'data': 's3-east-1.amazonaws.com', 'title': 'Sao Paulo' }
};
$scope.locationPing = null;
$scope.locationPingClass = null;
$scope.getLocationTooltip = function(location, ping) {
var tip = $scope.getLocationTitle(location) + '<br>';
if (ping < 0) {
tip += '<br><b>Note: Could not contact server</b>';
} else {
tip += 'Estimated Ping: ' + (ping ? ping + 'ms' : '(Loading)');
}
return tip;
};
$scope.getLocationTitle = function(location) {
if (!LOCATIONS[location]) {
return '(Unknown)';
}
return 'Image data is located in ' + LOCATIONS[location]['title'];
};
$scope.getLocationImage = function(location) {
if (!LOCATIONS[location]) {
return 'unknown.png';
}
return LOCATIONS[location]['country'] + '.png';
};
$scope.getLocationPing = function(location) {
if (!$rootScope.__CACHED_LOCATION_PINGS) {
$rootScope.__CACHED_LOCATION_PINGS = {};
}
if ($rootScope.__CACHED_LOCATION_PINGS[location]) {
$scope.locationPing = $rootScope.__CACHED_LOCATION_PINGS[location];
return;
}
var conductPing = function() {
var path = 'http://' + LOCATIONS[location]['data'] + '/okay.txt?cb=' + (Math.random() * 100);
var start = new Date();
var xhr = new XMLHttpRequest();
xhr.onerror = function() {
$scope.$apply(function() {
$scope.locationPing = -1;
});
};
xhr.onreadystatechange = function () {
if (xhr.readyState === xhr.HEADERS_RECEIVED) {
if (xhr.status != 200) {
$scope.$apply(function() {
$scope.locationPing = -1;
});
return;
}
var ping = (new Date() - start);
$scope.$apply(function() {
$rootScope.__CACHED_LOCATION_PINGS[location] = $scope.locationPing = ping;
});
}
};
xhr.open("GET", path);
xhr.send(null);
return;
};
setTimeout(conductPing, 1000);
};
$scope.$watch('location', function(location) {
if (!location) { return; }
$scope.getLocationPing(location);
});
$scope.$watch('locationPing', function(locationPing) {
if (locationPing == null) {
$scope.locationPingClass = null;
return;
}
if (locationPing < 0) {
$scope.locationPingClass = 'error';
return;
}
if (locationPing < 100) {
$scope.locationPingClass = 'good';
return;
}
if (locationPing < 250) {
$scope.locationPingClass = 'fair';
return;
}
if (locationPing < 500) {
$scope.locationPingClass = 'barely';
return;
}
$scope.locationPingClass = 'poor';
});
}
};
return directiveDefinitionObject;
});
quayApp.directive('tagSpecificImagesView', function () {
var directiveDefinitionObject = {
priority: 0,

View file

@ -973,6 +973,7 @@ function RepoBuildCtrl($scope, Restangular, ApiService, $routeParams, $rootScope
var data = {
'file_id': build['resource_key'],
'subdirectory': subdirectory,
'docker_tags': build['job_config']['docker_tags']
};
if (build['pull_robot']) {
@ -2736,4 +2737,4 @@ function SuperUserAdminCtrl($scope, ApiService, Features, UserService) {
};
loadSeatUsage();
}
}