Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 27 additions & 58 deletions assets/app/scripts/controllers/overview.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ angular.module('openshiftConsole')
Logger,
ImageStreamResolver,
ObjectDescriber,
$parse) {
$parse,
$filter,
$interval) {
$scope.pods = {};
$scope.services = {};
$scope.routes = {};
Expand Down Expand Up @@ -56,6 +58,8 @@ angular.module('openshiftConsole')
// "" service key for deployment configs not under any service
$scope.deploymentConfigsByService = {};

$scope.recentBuildsByOutputImage = {};

$scope.labelSuggestions = {};
$scope.alerts = $scope.alerts || {};
$scope.emptyMessage = "Loading...";
Expand All @@ -82,6 +86,7 @@ angular.module('openshiftConsole')
$scope.topologyItems = { };
$scope.topologyRelations = [ ];

var intervals = [];
var watches = [];

watches.push(DataService.watch("pods", $scope, function(pods) {
Expand Down Expand Up @@ -311,49 +316,9 @@ angular.module('openshiftConsole')
Logger.log("imagestreams (subscribe)", $scope.imageStreams);
}));

function associateDeploymentConfigTriggersToBuild(deploymentConfig, build) {
// Make sure we have both a deploymentConfig and a build
if (!deploymentConfig || !build) {
return;
}
// Make sure the deployment config has triggers.
if (!deploymentConfig.spec.triggers) {
return;
}
// Make sure we have a build output
if (!build.spec.output.to) {
return;
}
for (var i = 0; i < deploymentConfig.spec.triggers.length; i++) {
var trigger = deploymentConfig.spec.triggers[i];
if (trigger.type === "ImageChange") {
var buildOutputImage = imageObjectRefFilter(build.spec.output.to, build.metadata.namespace);
var deploymentTriggerImage = imageObjectRefFilter(trigger.imageChangeParams.from, deploymentConfig.metadata.namespace);
if (buildOutputImage !== deploymentTriggerImage) {
continue;
}

trigger.builds = trigger.builds || {};
trigger.builds[build.metadata.name] = build;
}
}
}

// Sets up subscription for deploymentConfigs, associates builds to triggers on deploymentConfigs
watches.push(DataService.watch("deploymentconfigs", $scope, function(deploymentConfigs, action, deploymentConfig) {
watches.push(DataService.watch("deploymentconfigs", $scope, function(deploymentConfigs) {
$scope.deploymentConfigs = deploymentConfigs.by("metadata.name");
if (!action) {
angular.forEach($scope.deploymentConfigs, function(depConfig) {
angular.forEach($scope.builds, function(build) {
associateDeploymentConfigTriggersToBuild(depConfig, build);
});
});
}
else if (action !== 'DELETED') {
angular.forEach($scope.builds, function(build) {
associateDeploymentConfigTriggersToBuild(deploymentConfig, build);
});
}

deploymentConfigsByService();
// Must be called after deploymentConfigsByService()
Expand All @@ -363,24 +328,25 @@ angular.module('openshiftConsole')
Logger.log("deploymentconfigs (subscribe)", $scope.deploymentConfigs);
}));

function updateRecentBuildsByOutputImage() {
$scope.recentBuildsByOutputImage = {};
angular.forEach($scope.builds, function(build) {
// pre-filter the list to save us some time on each digest loop later
if ($filter('isRecentBuild')(build) || $filter('isOscActiveObject')(build)) {
var buildOutputImage = imageObjectRefFilter(build.spec.output.to, build.metadata.namespace);
$scope.recentBuildsByOutputImage[buildOutputImage] = $scope.recentBuildsByOutputImage[buildOutputImage] || [];
$scope.recentBuildsByOutputImage[buildOutputImage].push(build);
}
});
}

// Sets up subscription for builds, associates builds to triggers on deploymentConfigs
watches.push(DataService.watch("builds", $scope, function(builds, action, build) {
watches.push(DataService.watch("builds", $scope, function(builds) {
$scope.builds = builds.by("metadata.name");
if (!action) {
angular.forEach($scope.builds, function(bld) {
angular.forEach($scope.deploymentConfigs, function(depConfig) {
associateDeploymentConfigTriggersToBuild(depConfig, bld);
});
});
}
else if (action === 'ADDED' || action === 'MODIFIED') {
angular.forEach($scope.deploymentConfigs, function(depConfig) {
associateDeploymentConfigTriggersToBuild(depConfig, build);
});
}
else if (action === 'DELETED'){
// TODO
}
updateRecentBuildsByOutputImage();

intervals.push($interval(updateRecentBuildsByOutputImage, 5 * 60 * 1000)); // prune the list every 5 minutes

updateTopologyLater();
Logger.log("builds (subscribe)", $scope.builds);
}));
Expand Down Expand Up @@ -543,5 +509,8 @@ angular.module('openshiftConsole')
DataService.unwatchAll(watches);
window.clearTimeout(updateTimeout);
ObjectDescriber.removeResourceChangedCallback(selectionChanged);
angular.forEach(intervals, function (interval){
$interval.cancel(interval);
});
});
});
4 changes: 3 additions & 1 deletion assets/app/scripts/directives/resources.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ angular.module('openshiftConsole')
return {
restrict: 'E',
scope: {
triggers: '='
triggers: '=',
buildsByOutputImage: '=',
namespace: '='
},
link: function(scope) {
scope.isBuildHidden = function(build) {
Expand Down
4 changes: 4 additions & 0 deletions assets/app/styles/_core.less
Original file line number Diff line number Diff line change
Expand Up @@ -777,3 +777,7 @@ labels + .resource-details {
h1 small.meta {
font-size: 12px;
}

.action-divider {
color: @gray-light;
}
76 changes: 36 additions & 40 deletions assets/app/views/_triggers.html
Original file line number Diff line number Diff line change
@@ -1,47 +1,43 @@
<div class="builds-block">
<div class="builds" ng-repeat="trigger in triggers">
<div ng-repeat="build in trigger.builds track by (build | uid)"
ng-if="((build | isRecentBuild) || (build | isOscActiveObject)) && !isBuildHidden(build)"
class="build animate-repeat osc-object"
kind="Build"
resource="build">
<!-- Icon -->
<span ng-switch="build.status.phase" class="hide-ng-leave">
<span ng-switch-when="Complete" class="fa fa-check text-success" aria-hidden="true" style="margin-right: 5px;"></span>
<span ng-switch-when="Failed" class="fa fa-times text-danger" aria-hidden="true" style="margin-right: 5px;"></span>
<span ng-switch-when="Error" class="fa fa-times text-danger" aria-hidden="true" style="margin-right: 5px;"></span>
<span ng-switch-when="Cancelled" class="fa fa-ban text-warning" aria-hidden="true"></span>
<span ng-switch-when="Pending" class="spinner spinner-xs spinner-inline" aria-hidden="true" style="margin-right: 5px;"></span>
<span ng-switch-default class="fa fa-refresh fa-spin" aria-hidden="true" style="margin-right: 5px;"></span>
</span>
<!-- Message -->
Build
<span ng-if="build | annotation : 'buildNumber'">
<a ng-href="{{build | navigateResourceURL}}">
<span ng-if="build.metadata.labels.buildconfig">{{build.metadata.labels.buildconfig}}</span>
#{{build | annotation : 'buildNumber'}}
</a>
</span>
<span ng-if="!(build | annotation : 'buildNumber')">
{{build.metadata.name}}
</span>
<span ng-switch="build.status.phase" class="hide-ng-leave">
<span ng-switch-when="Complete">completed.</span>
<span ng-switch-when="Failed">failed.</span>
<span ng-switch-when="Error">encountered an error.</span>
<span ng-switch-when="Cancelled">was cancelled.</span>
<span ng-switch-default>is {{build.status.phase | lowercase}}.
<span ng-if="trigger.imageChangeParams.automatic">
A new deployment will be created automatically once the build completes.
<div ng-if="trigger.type === 'ImageChange'">
<div ng-repeat="build in buildsByOutputImage[(trigger.imageChangeParams.from | imageObjectRef : namespace)] | orderObjectsByDate track by (build | uid)"
ng-if="!isBuildHidden(build)"
class="build animate-repeat osc-object"
kind="Build"
resource="build">
<!-- Icon -->
<status-icon status="build.status.phase" style="margin-right: 5px;"></status-icon>
<!-- Message -->
Build
<span ng-if="build | annotation : 'buildNumber'">
<a ng-href="{{build | navigateResourceURL}}">
<span ng-if="build.metadata.labels.buildconfig">{{build.metadata.labels.buildconfig}}</span>
#{{build | annotation : 'buildNumber'}}
</a>
</span>
<span ng-if="!(build | annotation : 'buildNumber')">
{{build.metadata.name}}
</span>
<span ng-switch="build.status.phase" class="hide-ng-leave" style="margin-right: 5px;">
<span ng-switch-when="Complete">completed.</span>
<span ng-switch-when="Failed">failed.</span>
<span ng-switch-when="Error">encountered an error.</span>
<span ng-switch-when="Cancelled">was cancelled.</span>
<span ng-switch-default>is {{build.status.phase | lowercase}}.
<span ng-if="trigger.imageChangeParams.automatic">
A new deployment will be created automatically once the build completes.
</span>
</span>
</span>
</span>
<a
ng-if="!!['New', 'Pending'].indexOf(build.status.phase)"
ng-href="project/{{build.metadata.namespace}}/browse/builds/{{build.metadata.labels.buildconfig}}/{{build.metadata.name}}?tab=logs">
View Log
</a>
<a ng-hide="build | isIncompleteBuild" style="margin-left: 5px;" href="" ng-click="hideBuild(build)">Dismiss</a>
<a
ng-if="!!['New', 'Pending'].indexOf(build.status.phase)"
ng-href="project/{{build.metadata.namespace}}/browse/builds/{{build.metadata.labels.buildconfig}}/{{build.metadata.name}}?tab=logs">
View Log
</a>
<span class="action-divider" ng-show="!!['New', 'Pending'].indexOf(build.status.phase) && !(build | isIncompleteBuild)">|</span>
<a ng-hide="build | isIncompleteBuild" href="" ng-click="hideBuild(build)">Dismiss</a>
</div>
</div>
</div>
</div>
Expand Down
6 changes: 3 additions & 3 deletions assets/app/views/project.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ <h2 ng-if="!displayRouteByService[serviceId]">
Pods in deployments created from this deployment config will be routed to by this service.
Show things related to triggers that are about to create stuff, like builds.
-->
<triggers triggers="deploymentConfig.spec.triggers"></triggers>
<triggers triggers="deploymentConfig.spec.triggers" builds-by-output-image="recentBuildsByOutputImage" namespace="projectName"></triggers>
</div>
<!--
Iterate over all deployments for this service grouped by deploymentConfig (or lack thereof)
Expand All @@ -162,7 +162,7 @@ <h2 ng-if="!displayRouteByService[serviceId]">
Pods in deployments created from this deployment config will be routed to by this service.
Show things related to triggers that are about to create stuff, like builds.
-->
<triggers triggers="deploymentConfigsByService[serviceId][deploymentConfigId].spec.triggers"></triggers>
<triggers triggers="deploymentConfigsByService[serviceId][deploymentConfigId].spec.triggers" builds-by-output-image="recentBuildsByOutputImage" namespace="projectName"></triggers>
</div>

<div ng-repeat="deployment in deployments | orderObjectsByDate : true track by (deployment | uid)"
Expand Down Expand Up @@ -213,7 +213,7 @@ <h2 ng-if="!displayRouteByService[serviceId]">
Pods in deployments created from this deployment config will not be routed to by any service.
Show things related to triggers that are about to create stuff, like builds.
-->
<triggers triggers="deploymentConfigs[deploymentConfigId].spec.triggers"></triggers>
<triggers triggers="deploymentConfigs[deploymentConfigId].spec.triggers" builds-by-output-image="recentBuildsByOutputImage" namespace="projectName"></triggers>
</div>

<!-- Make sure deploymentConfigs are loaded before testing if the deployment config is missing. -->
Expand Down
Loading