From e33760fcd2b4e9c066252194df16f624b7d9c9ca Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 21 May 2018 17:44:13 -0400 Subject: [PATCH] Removed unused code --- static/css/quay.css | 10 --- static/directives/repo-search.html | 1 - static/js/directives/ui/location-view.js | 76 ------------------ static/js/directives/ui/repo-search.js | 76 ------------------ static/js/services/ping-service.js | 99 ------------------------ 5 files changed, 262 deletions(-) delete mode 100644 static/directives/repo-search.html delete mode 100644 static/js/directives/ui/location-view.js delete mode 100644 static/js/directives/ui/repo-search.js delete mode 100644 static/js/services/ping-service.js diff --git a/static/css/quay.css b/static/css/quay.css index 575a8fa52..33256d4b0 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -13,16 +13,6 @@ } } -.repo-search { - display: none; -} - -@media (min-width: 1200px) { - .repo-search { - display: inline-block; - } -} - .announcement a { color: lightblue; } diff --git a/static/directives/repo-search.html b/static/directives/repo-search.html deleted file mode 100644 index 2f313db34..000000000 --- a/static/directives/repo-search.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/static/js/directives/ui/location-view.js b/static/js/directives/ui/location-view.js deleted file mode 100644 index 388a89b06..000000000 --- a/static/js/directives/ui/location-view.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * An element which displays a small flag representing the given location, as well as a ping - * latency gauge for that location. - */ -angular.module('quay').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, PingService) { - 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 (East)' }, - 's3_us_west_1': { 'country': 'US', 'data': 'quay-registry-cali.s3.amazonaws.com', 'title': 'United States (West)' }, - - '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.getLocationTooltip = function(location, ping) { - var tip = $scope.getLocationTitle(location) + '
'; - if (ping == null) { - tip += '(Loading)'; - } else if (ping < 0) { - tip += '
Note: Could not contact server'; - } 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) { - var url = 'https://' + LOCATIONS[location]['data'] + '/okay.txt'; - PingService.pingUrl($scope, url, function(ping, success, count) { - if (count == 3 || !success) { - $scope.locationPing = success ? ping : -1; - } - }); - }; - - $scope.$watch('location', function(location) { - if (!location) { return; } - $scope.getLocationPing(location); - }); - } - }; - return directiveDefinitionObject; -}); diff --git a/static/js/directives/ui/repo-search.js b/static/js/directives/ui/repo-search.js deleted file mode 100644 index d46764404..000000000 --- a/static/js/directives/ui/repo-search.js +++ /dev/null @@ -1,76 +0,0 @@ -/** - * An element which displays a repository search box. - */ -angular.module('quay').directive('repoSearch', function () { - var number = 0; - var directiveDefinitionObject = { - priority: 0, - templateUrl: '/static/directives/repo-search.html', - replace: false, - transclude: false, - restrict: 'C', - scope: { - }, - controller: function($scope, $element, $location, UserService, Restangular, UtilService) { - var searchToken = 0; - $scope.$watch( function () { return UserService.currentUser(); }, function (currentUser) { - ++searchToken; - }, true); - - var repoHound = new Bloodhound({ - name: 'repositories', - remote: { - url: '/api/v1/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) { - var repo = data.repositories[i]; - datums.push({ - 'value': repo.name, - 'tokens': [repo.name, repo.namespace], - 'repo': repo - }); - } - return datums; - } - }, - datumTokenizer: function(d) { - return Bloodhound.tokenizers.whitespace(d.val); - }, - queryTokenizer: Bloodhound.tokenizers.whitespace - }); - repoHound.initialize(); - - var element = $($element[0].childNodes[0]); - element.typeahead({ 'highlight': true }, { - source: repoHound.ttAdapter(), - templates: { - 'suggestion': function (datum) { - template = '
'; - template += '' - template += '' + datum.repo.namespace +'/' + datum.repo.name + '' - if (datum.repo.description) { - template += '' + UtilService.getFirstMarkdownLineAsText(datum.repo.description) + '' - } - - template += '
' - return template; - } - } - }); - - element.on('typeahead:selected', function (e, datum) { - element.typeahead('val', ''); - $scope.$apply(function() { - $location.path('/repository/' + datum.repo.namespace + '/' + datum.repo.name); - }); - }); - } - }; - return directiveDefinitionObject; -}); diff --git a/static/js/services/ping-service.js b/static/js/services/ping-service.js deleted file mode 100644 index bce2254b4..000000000 --- a/static/js/services/ping-service.js +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Service which pings an endpoint URL and estimates the latency to it. - */ -angular.module('quay').factory('PingService', [function() { - var pingService = {}; - var pingCache = {}; - - var invokeCallback = function($scope, pings, callback) { - if (pings[0] == -1) { - setTimeout(function() { - $scope.$apply(function() { - callback(-1, false, -1); - }); - }, 0); - return; - } - - var sum = 0; - for (var i = 0; i < pings.length; ++i) { - sum += pings[i]; - } - - // Report the average ping. - setTimeout(function() { - $scope.$apply(function() { - callback(Math.floor(sum / pings.length), true, pings.length); - }); - }, 0); - }; - - var reportPingResult = function($scope, url, ping, callback) { - // Lookup the cached ping data, if any. - var cached = pingCache[url]; - if (!cached) { - cached = pingCache[url] = { - 'pings': [] - }; - } - - // If an error occurred, report it and done. - if (ping < 0) { - cached['pings'] = [-1]; - invokeCallback($scope, [-1], callback); - return; - } - - // Otherwise, add the current ping and determine the average. - cached['pings'].push(ping); - - // Invoke the callback. - invokeCallback($scope, cached['pings'], callback); - - // Schedule another check if we've done less than three. - if (cached['pings'].length < 3) { - setTimeout(function() { - pingUrlInternal($scope, url, callback); - }, 1000); - } - }; - - var pingUrlInternal = function($scope, url, callback) { - var path = url + '?cb=' + (Math.random() * 100); - var start = new Date(); - var xhr = new XMLHttpRequest(); - xhr.onerror = function() { - reportPingResult($scope, url, -1, callback); - }; - - xhr.onreadystatechange = function () { - if (xhr.readyState === xhr.HEADERS_RECEIVED) { - if (xhr.status != 200) { - reportPingResult($scope, url, -1, callback); - return; - } - - var ping = (new Date() - start); - reportPingResult($scope, url, ping, callback); - } - }; - - xhr.open("GET", path); - xhr.send(null); - }; - - pingService.pingUrl = function($scope, url, callback) { - if (pingCache[url]) { - invokeCallback($scope, pingCache[url]['pings'], callback); - return; - } - - // Note: We do each in a callback after 1s to prevent it running when other code - // runs (which can skew the results). - setTimeout(function() { - pingUrlInternal($scope, url, callback); - }, 1000); - }; - - return pingService; -}]);