Add API and UI support for displaying image locations
|
@ -1098,13 +1098,32 @@ def set_image_metadata(docker_image_id, namespace_name, repository_name,
|
|||
|
||||
|
||||
def get_repository_images(namespace_name, repository_name):
|
||||
return (Image
|
||||
.select(Image, ImageStorage)
|
||||
.join(Repository)
|
||||
.switch(Image)
|
||||
location_list = list((ImageStoragePlacement
|
||||
.select(ImageStoragePlacement, Image, ImageStorage, ImageStorageLocation)
|
||||
.join(ImageStorageLocation)
|
||||
.switch(ImageStoragePlacement)
|
||||
.join(ImageStorage, JOIN_LEFT_OUTER)
|
||||
.join(Image)
|
||||
.join(Repository)
|
||||
.where(Repository.name == repository_name,
|
||||
Repository.namespace == namespace_name))
|
||||
Repository.namespace == namespace_name)))
|
||||
|
||||
images = {}
|
||||
for location in location_list:
|
||||
# Make sure we're always retrieving the same image object.
|
||||
image = location.storage.image
|
||||
image_id = image.docker_image_id
|
||||
|
||||
if not image_id in images:
|
||||
images[image_id] = image
|
||||
image.storage.locations = set()
|
||||
else:
|
||||
image = images[image_id]
|
||||
|
||||
# Add the location to the image's locations set.
|
||||
image.storage.locations.add(location)
|
||||
|
||||
return images.values()
|
||||
|
||||
|
||||
def list_repository_tags(namespace_name, repository_name):
|
||||
|
|
|
@ -23,6 +23,7 @@ def image_view(image):
|
|||
'ancestors': image.ancestors,
|
||||
'dbid': image.id,
|
||||
'size': extended_props.image_size,
|
||||
'locations': [l.location.name for l in image.storage.locations]
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ def image_view(image):
|
|||
'command': json.loads(command) if command else None,
|
||||
'ancestors': image.ancestors,
|
||||
'dbid': image.id,
|
||||
'size': extended_props.image_size,
|
||||
'size': extended_props.image_size
|
||||
}
|
||||
|
||||
@resource('/v1/repository/<repopath:repository>')
|
||||
|
|
|
@ -3790,4 +3790,64 @@ pre.command:before {
|
|||
.form-change input {
|
||||
margin-top: 12px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.location-view {
|
||||
display: inline-block;
|
||||
margin-rigth: 6px;
|
||||
}
|
||||
|
||||
.location-view .flag {
|
||||
position: relative;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
.location-view .ping-tower {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.location-view .ping-sliver {
|
||||
margin: 1px;
|
||||
width: 14px;
|
||||
height: 3px;
|
||||
border: 1px solid #D5D5D5;
|
||||
transition: 0.5s ease;
|
||||
}
|
||||
|
||||
.location-view .ping-tower.good .ping-sliver {
|
||||
background: green;
|
||||
border: 1px solid green;
|
||||
}
|
||||
|
||||
.location-view .ping-tower.fair .ping-sliver {
|
||||
background: orange;
|
||||
border: 1px solid orange;
|
||||
}
|
||||
|
||||
.location-view .ping-tower.fair .ping-sliver:first-child {
|
||||
border: 1px solid #D5D5D5;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.location-view .ping-tower.barely .ping-sliver {
|
||||
background: rgb(255, 61, 0);
|
||||
border: 1px solid rgb(255, 61, 0);
|
||||
}
|
||||
|
||||
.location-view .ping-tower.barely .ping-sliver:first-child {
|
||||
border: 1px solid #D5D5D5;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.location-view .ping-tower.barely .ping-sliver:nth-child(2) {
|
||||
border: 1px solid #D5D5D5;
|
||||
background: transparent;
|
||||
}
|
||||
|
||||
.location-view .ping-tower.poor .ping-sliver:last-child {
|
||||
border: 1px solid red;
|
||||
background: red;
|
||||
}
|
||||
|
||||
|
||||
|
|
12
static/directives/location-view.html
Normal file
|
@ -0,0 +1,12 @@
|
|||
<span class="location-view-element" data-title="{{ getLocationTooltip(location, locationPing) }}" data-html="true" bs-tooltip>
|
||||
<span class="flag" ng-class="locationPing == -1 ? 'error' : ''">
|
||||
<img ng-src="{{ '/static/img/flags/' + getLocationImage(location) }}">
|
||||
</span>
|
||||
|
||||
<span class="ping-tower" ng-class="locationPingClass">
|
||||
<div class="ping-sliver"></div>
|
||||
<div class="ping-sliver"></div>
|
||||
<div class="ping-sliver"></div>
|
||||
<div class="ping-sliver"></div>
|
||||
</span>
|
||||
</span>
|
BIN
static/img/flags/AU.png
Normal file
After Width: | Height: | Size: 1.4 KiB |
BIN
static/img/flags/BR.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
static/img/flags/EU.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
static/img/flags/IE.png
Normal file
After Width: | Height: | Size: 893 B |
BIN
static/img/flags/JP.png
Normal file
After Width: | Height: | Size: 792 B |
7
static/img/flags/LICENSE.txt
Normal file
|
@ -0,0 +1,7 @@
|
|||
Copyright (c) 2013 Go Squared Ltd. http://www.gosquared.com/
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
BIN
static/img/flags/SG.png
Normal file
After Width: | Height: | Size: 958 B |
BIN
static/img/flags/US.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
static/img/flags/unknown.png
Normal file
After Width: | Height: | Size: 992 B |
134
static/js/app.js
|
@ -4604,6 +4604,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,
|
||||
|
|
|
@ -261,6 +261,14 @@
|
|||
<i class="fa fa-cloud-upload section-icon" bs-tooltip="tooltip.title"
|
||||
data-title="The amount of data sent between Docker and Quay.io when pushing/pulling"></i>
|
||||
<span class="section-info">{{ currentImage.size | bytes }}</span>
|
||||
</div>
|
||||
|
||||
<div class="image-section">
|
||||
<i class="fa fa-map-marker section-icon" bs-tooltip="tooltip.title"
|
||||
data-title="The geographic region(s) in which this image data is located"></i>
|
||||
<span class="section-info">
|
||||
<span class="location-view" location="location" ng-repeat="location in currentImage.locations"></span>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Image changes loading -->
|
||||
|
|