diff --git a/assets/app/index.html b/assets/app/index.html index 32bf3dcde8c3..d693724e3bf4 100644 --- a/assets/app/index.html +++ b/assets/app/index.html @@ -131,6 +131,7 @@ + diff --git a/assets/app/scripts/controllers/builds.js b/assets/app/scripts/controllers/builds.js index 6500aae6165e..4293b2a47e32 100644 --- a/assets/app/scripts/controllers/builds.js +++ b/assets/app/scripts/controllers/builds.js @@ -11,9 +11,13 @@ angular.module('openshiftConsole') .controller('BuildsController', function ($scope, DataService, $filter, LabelFilter) { $scope.builds = {}; $scope.unfilteredBuilds = {}; + $scope.buildConfigs = {}; $scope.labelSuggestions = {}; $scope.alerts = $scope.alerts || {}; $scope.emptyMessage = "Loading..."; + + $scope.buildsByBuildConfig = {}; + var watches = []; watches.push(DataService.watch("builds", $scope, function(builds) { @@ -23,7 +27,23 @@ angular.module('openshiftConsole') $scope.builds = LabelFilter.getLabelSelector().select($scope.unfilteredBuilds); $scope.emptyMessage = "No builds to show"; updateFilterWarning(); + + $scope.buildsByBuildConfig = {}; + angular.forEach($scope.builds, function(build, buildName) { + var buildConfigName = ""; + if (build.metadata.labels) { + buildConfigName = build.metadata.labels.buildconfig || ""; + } + $scope.buildsByBuildConfig[buildConfigName] = $scope.buildsByBuildConfig[buildConfigName] || {}; + $scope.buildsByBuildConfig[buildConfigName][buildName] = build; + }); + console.log("builds (subscribe)", $scope.unfilteredBuilds); + })); + + watches.push(DataService.watch("buildConfigs", $scope, function(buildConfigs) { + $scope.buildConfigs = buildConfigs.by("metadata.name"); + console.log("buildConfigs (subscribe)", $scope.buildConfigs); })); var updateFilterWarning = function() { diff --git a/assets/app/scripts/directives/util.js b/assets/app/scripts/directives/util.js new file mode 100644 index 000000000000..5edf46c4fd24 --- /dev/null +++ b/assets/app/scripts/directives/util.js @@ -0,0 +1,11 @@ +angular.module('openshiftConsole') + .directive('selectOnFocus', function() { + return { + restrict: 'A', + link: function($scope, element, attrs) { + $(element).focus(function () { + $(this).select(); + }); + } + }; + }); \ No newline at end of file diff --git a/assets/app/scripts/filters/resources.js b/assets/app/scripts/filters/resources.js index 233159911a0f..2da49ecf1260 100644 --- a/assets/app/scripts/filters/resources.js +++ b/assets/app/scripts/filters/resources.js @@ -55,4 +55,15 @@ angular.module('openshiftConsole') } return null; }; + }) + .filter('webhookURL', function(DataService) { + return function(buildConfig, type, secret, project) { + return DataService.url({ + type: "buildConfigHooks", + id: buildConfig, + namespace: project, + secret: secret, + hookType: type, + }); + }; }); \ No newline at end of file diff --git a/assets/app/scripts/filters/util.js b/assets/app/scripts/filters/util.js index 3f57abac7f9b..bf83c0a0d232 100644 --- a/assets/app/scripts/filters/util.js +++ b/assets/app/scripts/filters/util.js @@ -30,4 +30,14 @@ angular.module('openshiftConsole') } return amount + (unit != "" ? " " + unit : ""); } + }) + .filter('helpLink', function() { + return function(type) { + switch(type) { + case "webhooks": + return "http://docs.openshift.org/latest/using_openshift/builds.html#webhook-triggers" + default: + return "http://docs.openshift.org/latest/welcome/index.html"; + } + }; }); \ No newline at end of file diff --git a/assets/app/scripts/services/data.js b/assets/app/scripts/services/data.js index 3d4061a31dd2..d24c340fd2ed 100644 --- a/assets/app/scripts/services/data.js +++ b/assets/app/scripts/services/data.js @@ -535,6 +535,8 @@ angular.module('openshiftConsole') var URL_NAMESPACED_WATCH_LIST = URL_ROOT_TEMPLATE + "watch/namespaces/{namespace}/{type}{?q*}"; var URL_NAMESPACED_GET_LIST = URL_ROOT_TEMPLATE + "namespaces/{namespace}/{type}{?q*}"; var URL_NAMESPACED_GET_OBJECT = URL_ROOT_TEMPLATE + "namespaces/{namespace}/{type}/{id}{?q*}"; + // TODO is there a better way to get this template instead of building it, introspection? + var BUILD_HOOKS_URL = URL_ROOT_TEMPLATE + "{type}/{id}/{secret}/{hookType}{?q*}"; // Set the api version the console is currently able to talk to API_CFG.openshift.version = "v1beta1"; @@ -549,6 +551,8 @@ angular.module('openshiftConsole') // https://github.com/openshift/origin/issues/230 var SERVER_TYPE_MAP = { builds: API_CFG.openshift, + buildConfigs: API_CFG.openshift, + buildConfigHooks: API_CFG.openshift, deploymentConfigs: API_CFG.openshift, images: API_CFG.openshift, oAuthAccessTokens: API_CFG.openshift, @@ -580,27 +584,48 @@ angular.module('openshiftConsole') delete params.namespace; } var template; + var templateOptions = { + protocol: protocol, + serverUrl: SERVER_TYPE_MAP[type].hostPort, + apiPrefix: SERVER_TYPE_MAP[type].prefix, + apiVersion: SERVER_TYPE_MAP[type].version, + type: type, + id: id, + namespace: namespace + }; if (isWebsocket) { template = namespaceInPath ? URL_NAMESPACED_WATCH_LIST : URL_WATCH_LIST; } else if (id) { - template = namespaceInPath ? URL_NAMESPACED_GET_OBJECT : URL_GET_OBJECT; + if (type == "buildConfigHooks") { + templateOptions.secret = params.secret; + templateOptions.hookType = params.hookType; + params = angular.copy(params); + delete params.secret; + delete params.hookType; + template = BUILD_HOOKS_URL; + } + else + { + template = namespaceInPath ? URL_NAMESPACED_GET_OBJECT : URL_GET_OBJECT; + } } else { template = namespaceInPath ? URL_NAMESPACED_GET_LIST : URL_GET_LIST; } - // TODO where do we specify what the server URL and api version should be - return URI.expand(template, { - protocol: protocol, - serverUrl: SERVER_TYPE_MAP[type].hostPort, - apiPrefix: SERVER_TYPE_MAP[type].prefix, - apiVersion: SERVER_TYPE_MAP[type].version, - type: type, - id: id, - namespace: namespace, - q: params - }); + templateOptions.q = params; + return URI.expand(template, templateOptions); + }; + + DataService.prototype.url = function(options) { + if (options && options.type) { + var opts = angular.copy(options); + delete opts.type; + delete opts.id; + return this._urlForType(options.type, options.id, null, false, opts).toString(); + } + return null; }; return new DataService(); diff --git a/assets/app/views/builds.html b/assets/app/views/builds.html index 7819a8651a4c..ae7d3931611e 100644 --- a/assets/app/views/builds.html +++ b/assets/app/views/builds.html @@ -3,25 +3,160 @@