From 32c0a14d96f4db55a580cd057317899dede1fb69 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Mon, 5 Jan 2015 15:18:01 -0500 Subject: [PATCH] Get mapped fields (Github and Redis) working --- static/css/core-ui.css | 2 +- static/css/quay.css | 6 ++ .../directives/config/config-setup-tool.html | 65 ++++++++------- static/js/core-config-setup.js | 79 +++++++++++++++++++ 4 files changed, 117 insertions(+), 35 deletions(-) diff --git a/static/css/core-ui.css b/static/css/core-ui.css index aa63347c8..bfe58608c 100644 --- a/static/css/core-ui.css +++ b/static/css/core-ui.css @@ -70,7 +70,7 @@ width: 100%; display: table-cell; float: none; - padding: 10px; + padding: 20px; } .co-tabs li { diff --git a/static/css/quay.css b/static/css/quay.css index d085ab206..87605cede 100644 --- a/static/css/quay.css +++ b/static/css/quay.css @@ -4918,3 +4918,9 @@ i.slack-icon { vertical-align: middle; color: rgb(53, 186, 53); } + +.registry-logo-preview { + border: 1px solid #eee; + vertical-align: middle; + padding: 4px; +} \ No newline at end of file diff --git a/static/directives/config/config-setup-tool.html b/static/directives/config/config-setup-tool.html index 874322ab9..1eed02743 100644 --- a/static/directives/config/config-setup-tool.html +++ b/static/directives/config/config-setup-tool.html @@ -1,6 +1,6 @@
-
+
@@ -12,13 +12,13 @@ Enterprise Logo URL: + placeholder="http://example.com/logo.png">
- This is optional. If not specified, the default logo will be used. + Enter the full URL to your company's logo.
- + @@ -44,13 +44,14 @@ User Creation: - +
- +
- If enabled, users can be created from the registry UI. + If enabled, user accounts can be created by anyone. + Users can always be created in the users panel under this superuser view.
@@ -83,7 +84,7 @@
- +
Server hostname:Server Hostname: @@ -141,9 +142,9 @@ - + @@ -160,8 +161,8 @@
Redis hostname:Redis Hostname: -
Redis password: - +
@@ -489,24 +490,22 @@ - + - - + + @@ -609,24 +608,22 @@
Github Endpoint:Github: - - -
- https://github.com/ for github.com. For Github enterprise, the internal Github endpoint. -
+
API Endpoint:
Github Endpoint: + placeholder="https://my.githubserver">
- https://api.github.com/ for github.com. For Github Enterprise, leave empty. + The Github Enterprise endpoint.
- + - - + + diff --git a/static/js/core-config-setup.js b/static/js/core-config-setup.js index 9ef952f5c..a42cf9f88 100644 --- a/static/js/core-config-setup.js +++ b/static/js/core-config-setup.js @@ -11,6 +11,7 @@ angular.module("core-config-setup", ['angularFileUpload']) }, controller: function($rootScope, $scope, $element, $timeout, ApiService) { $scope.config = null; + $scope.mapped = {}; $scope.parseDbUri = function(value) { if (!value) { return null; } @@ -41,11 +42,89 @@ angular.module("core-config-setup", ['angularFileUpload']) return uri; }; + var githubSelector = function(key) { + return function(value) { + if (!value || !$scope.config) { return; } + + if (!$scope.config[key]) { + $scope.config[key] = {}; + } + + if (value == 'enterprise') { + $scope.config[key]['GITHUB_ENDPOINT'] = ''; + $scope.config[key]['API_ENDPOINT'] = ''; + } else if (value == 'hosted') { + $scope.config[key]['GITHUB_ENDPOINT'] = 'https://github.com/'; + $scope.config[key]['API_ENDPOINT'] = 'https://api.github.com/'; + } + }; + }; + + var getKey = function(config, path) { + var parts = path.split('.'); + var current = config; + for (var i = 0; i < parts.length; ++i) { + var part = parts[i]; + if (!config[part]) { return null; } + current = config[part]; + } + return current; + }; + + var initializeMappedLogic = function(config) { + var gle = getKey(config, 'GITHUB_LOGIN_CONFIG.GITHUB_ENDPOINT'); + var gte = getKey(config, 'GITHUB_TRIGGER_CONFIG.GITHUB_ENDPOINT'); + + $scope.mapped['GITHUB_LOGIN_KIND'] = gle == 'https://github.com/' ? 'hosted' : 'enterprise'; + $scope.mapped['GITHUB_TRIGGER_KIND'] = gte == 'https://github.com/' ? 'hosted' : 'enterprise'; + + $scope.mapped['redis'] = {}; + $scope.mapped['redis']['host'] = getKey(config, 'BUILDLOGS_REDIS.host') || getKey(config, 'USER_EVENTS_REDIS.host'); + $scope.mapped['redis']['port'] = getKey(config, 'BUILDLOGS_REDIS.port') || getKey(config, 'USER_EVENTS_REDIS.port'); + $scope.mapped['redis']['password'] = getKey(config, 'BUILDLOGS_REDIS.password') || getKey(config, 'USER_EVENTS_REDIS.password'); + }; + + var redisSetter = function(keyname) { + return function(value) { + if (value == null || !$scope.config) { return; } + + if (!$scope.config['BUILDLOGS_REDIS']) { + $scope.config['BUILDLOGS_REDIS'] = {}; + } + + if (!$scope.config['USER_EVENTS_REDIS']) { + $scope.config['USER_EVENTS_REDIS'] = {}; + } + + if (!value) { + delete $scope.config['BUILDLOGS_REDIS'][keyname]; + delete $scope.config['USER_EVENTS_REDIS'][keyname]; + return; + } + + $scope.config['BUILDLOGS_REDIS'][keyname] = value; + $scope.config['USER_EVENTS_REDIS'][keyname] = value; + }; + }; + + // Add mapped logic. + $scope.$watch('mapped.GITHUB_LOGIN_KIND', githubSelector('GITHUB_LOGIN_CONFIG')); + $scope.$watch('mapped.GITHUB_TRIGGER_KIND', githubSelector('GITHUB_TRIGGER_CONFIG')); + + $scope.$watch('mapped.redis.host', redisSetter('host')); + $scope.$watch('mapped.redis.port', redisSetter('port')); + $scope.$watch('mapped.redis.password', redisSetter('password')); + + $scope.$watch('config', function(value) { + window.console.log(value); + }, true); + $scope.$watch('isActive', function(value) { if (!value) { return; } ApiService.scGetConfig().then(function(resp) { $scope.config = resp['config']; + initializeMappedLogic($scope.config); }); }); }
Github Endpoint:Github: - - -
- https://github.com/ for github.com. For Github enterprise, the internal Github endpoint. -
+
API Endpoint:
Github Endpoint: + placeholder="https://my.githubserver">
- https://api.github.com/ for github.com. For Github Enterprise, leave empty. + The Github Enterprise endpoint.