Skip to content

Commit

Permalink
Merge pull request #2162 from benjaminapetersen/bpetersen/trello/api-…
Browse files Browse the repository at this point in the history
…groups/deployments

Merged by openshift-bot
  • Loading branch information
OpenShift Bot committed Sep 27, 2017
2 parents 18330d5 + f96f9b6 commit 1f80df2
Show file tree
Hide file tree
Showing 5 changed files with 94 additions and 113 deletions.
38 changes: 17 additions & 21 deletions app/scripts/controllers/deployment.js
Expand Up @@ -11,6 +11,7 @@ angular.module('openshiftConsole')
function ($scope,
$filter,
$routeParams,
APIService,
DataService,
DeploymentsService,
HPAService,
Expand Down Expand Up @@ -42,10 +43,18 @@ angular.module('openshiftConsole')
title: $routeParams.deployment
}
];
var buildsVersion = APIService.getPreferredVersion('builds');
var replicaSetsVersion = APIService.getPreferredVersion('replicasets');
var limitRangesVersion = APIService.getPreferredVersion('limitranges');
var imageStreamsVersion = APIService.getPreferredVersion('imagestreams');
$scope.deploymentsVersion = APIService.getPreferredVersion('deployments');
$scope.eventsVersion = APIService.getPreferredVersion('events');
$scope.horizontalPodAutoscalersVersion = APIService.getPreferredVersion('horizontalpodautoscalers');

$scope.healthCheckURL = Navigate.healthCheckURL($routeParams.project,
"Deployment",
$routeParams.deployment,
"apps");
$scope.deploymentsVersion.group);
var watches = [];

ProjectsService
Expand All @@ -63,21 +72,15 @@ angular.module('openshiftConsole')
});
};

DataService.get({
group: 'apps',
resource: 'deployments'
}, $routeParams.deployment, context, { errorNotification: false }).then(
DataService.get($scope.deploymentsVersion, $routeParams.deployment, context, { errorNotification: false }).then(
// success
function(deployment) {
$scope.loaded = true;
$scope.deployment = deployment;
updateHPAWarnings();

// If we found the item successfully, watch for changes on it
watches.push(DataService.watchObject({
group: 'apps',
resource: 'deployments'
}, $routeParams.deployment, context, function(deployment, action) {
watches.push(DataService.watchObject($scope.deploymentsVersion, $routeParams.deployment, context, function(deployment, action) {
if (action === "DELETED") {
$scope.alerts["deleted"] = {
type: "warning",
Expand All @@ -92,10 +95,7 @@ angular.module('openshiftConsole')
}));

// Watch replica sets for this deployment
watches.push(DataService.watch({
group: 'extensions',
resource: 'replicasets'
}, context, function(replicaSetData) {
watches.push(DataService.watch(replicaSetsVersion, context, function(replicaSetData) {
$scope.emptyMessage = "No deployments to show";

var replicaSets = replicaSetData.by('metadata.name');
Expand Down Expand Up @@ -124,12 +124,12 @@ angular.module('openshiftConsole')

// List limit ranges in this project to determine if there is a default
// CPU request for autoscaling.
DataService.list("limitranges", context).then(function(response) {
DataService.list(limitRangesVersion, context).then(function(response) {
limitRanges = response.by("metadata.name");
updateHPAWarnings();
});

watches.push(DataService.watch("imagestreams", context, function(imageStreamData) {
watches.push(DataService.watch(imageStreamsVersion, context, function(imageStreamData) {
var imageStreams = imageStreamData.by("metadata.name");
ImageStreamResolver.buildDockerRefMapForImageStreams(imageStreams, imageStreamImageRefByDockerReference);
// If the deployment has been loaded already
Expand All @@ -139,17 +139,13 @@ angular.module('openshiftConsole')
Logger.log("imagestreams (subscribe)", $scope.imageStreams);
}));

watches.push(DataService.watch({
group: "autoscaling",
resource: "horizontalpodautoscalers",
version: "v1"
}, context, function(hpa) {
watches.push(DataService.watch($scope.horizontalPodAutoscalersVersion, context, function(hpa) {
$scope.autoscalers =
HPAService.filterHPA(hpa.by("metadata.name"), 'Deployment', $routeParams.deployment);
updateHPAWarnings();
}));

watches.push(DataService.watch("builds", context, function(builds) {
watches.push(DataService.watch(buildsVersion, context, function(builds) {
$scope.builds = builds.by("metadata.name");
Logger.log("builds (subscribe)", $scope.builds);
}));
Expand Down
4 changes: 2 additions & 2 deletions app/scripts/filters/canI.js
Expand Up @@ -20,8 +20,8 @@ angular
{group: '', resource: 'configmaps', verbs: ['update', 'delete']}
],
'deployments': [
{group: 'autoscaling', resource: 'horizontalpodautoscalers', verbs: ['create', 'update']},
{group: 'apps', resource: 'deployments', verbs: ['update', 'delete']}
_.assign({}, APIService.getPreferredVersion('horizontalpodautoscalers'), {verbs: ['create', 'update']}),
_.assign({}, APIService.getPreferredVersion('deployments'), {verbs: ['update', 'delete']})
],
'deploymentConfigs': [
{group: 'autoscaling', resource: 'horizontalpodautoscalers', verbs: ['create', 'update']},
Expand Down
40 changes: 20 additions & 20 deletions app/views/browse/deployment.html
Expand Up @@ -15,39 +15,39 @@ <h1 class="contains-actions">
class="dropdown-toggle actions-dropdown-kebab visible-xs-inline"
data-toggle="dropdown"><i class="fa fa-ellipsis-v"></i><span class="sr-only">Actions</span></a>
<ul class="dropdown-menu dropdown-menu-right actions action-button">
<li ng-if="!deployment.spec.paused && !updatingPausedState && ({ group: 'apps', resource: 'deployments' } | canI : 'update')">
<li ng-if="!deployment.spec.paused && !updatingPausedState && (deploymentsVersion | canI : 'update')">
<a href="" ng-click="setPaused(true)" role="button">Pause Rollouts</a>
</li>
<li ng-if="deployment.spec.paused && !updatingPausedState && ({ group: 'apps', resource: 'deployments' } | canI : 'update')">
<li ng-if="deployment.spec.paused && !updatingPausedState && (deploymentsVersion | canI : 'update')">
<a href="" ng-click="setPaused(false)" role="button">Resume Rollouts</a>
</li>
<li class="divider" ng-if="!updatingPausedState && ({ group: 'apps', resource: 'deployments' } | canI : 'update')"></li>
<li ng-if="{ group: 'apps', resource: 'deployments' } | canI : 'update'">
<li class="divider" ng-if="!updatingPausedState && (deploymentsVersion | canI : 'update')"></li>
<li ng-if="deploymentsVersion | canI : 'update'">
<a ng-href="project/{{project.metadata.name}}/attach-pvc?kind=Deployment&name={{deployment.metadata.name}}&group=apps"
role="button">Add Storage</a>
</li>
<li ng-if="!autoscalers.length && ({resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'create')">
<li ng-if="!autoscalers.length && (horizontalPodAutoscalersVersion | canI : 'create')">
<!-- Create a new HPA. -->
<a ng-href="project/{{projectName}}/edit/autoscaler?kind=Deployment&name={{deployment.metadata.name}}&group=apps"
role="button">Add Autoscaler</a>
</li>
<li ng-if="autoscalers.length === 1 && ({resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'update')">
<li ng-if="autoscalers.length === 1 && (horizontalPodAutoscalersVersion | canI : 'update')">
<!-- Edit an existing HPA. -->
<a ng-href="project/{{projectName}}/edit/autoscaler?kind=HorizontalPodAutoscaler&group=autoscaling&name={{autoscalers[0].metadata.name}}"
role="button">Edit Autoscaler</a>
</li>
<li ng-if="{ group: 'apps', resource: 'deployments' } | canI : 'update'">
<li ng-if="deploymentsVersion | canI : 'update'">
<a ng-href="project/{{projectName}}/set-limits?kind=Deployment&name={{deployment.metadata.name}}&group=apps"
role="button">Edit Resource Limits</a>
</li>
<li ng-if="{ group: 'apps', resource: 'deployments' } | canI : 'update'">
<li ng-if="deploymentsVersion | canI : 'update'">
<a ng-href="{{healthCheckURL}}" role="button">Edit Health Checks</a>
</li>
<li ng-if="{ group: 'apps', resource: 'deployments' } | canI : 'update'">
<li ng-if="deploymentsVersion | canI : 'update'">
<a ng-href="{{deployment | editYamlURL}}" role="button">Edit YAML</a>
</li>
<li class="divider" ng-if="{ group: 'apps', resource: 'deployments' } | canI : 'update'"></li>
<li ng-if="{ group: 'apps', resource: 'deployments' } | canI : 'delete'">
<li class="divider" ng-if="deploymentsVersion | canI : 'update'"></li>
<li ng-if="deploymentsVersion | canI : 'delete'">
<delete-link
kind="Deployment"
group="apps"
Expand Down Expand Up @@ -76,7 +76,7 @@ <h1 class="contains-actions">
<strong>{{deployment.metadata.name}} is paused.</strong>
This pauses any in-progress rollouts and stops new
rollouts from running until the deployment is resumed.
<span ng-if="!updatingPausedState && ({ group: 'apps', resource: 'deployments' } | canI : 'update')" class="nowrap">
<span ng-if="!updatingPausedState && (deploymentsVersion | canI : 'update')" class="nowrap">
<a href="" ng-click="setPaused(false)" role="button">Resume Rollouts</a>
</span>
</div>
Expand Down Expand Up @@ -217,22 +217,22 @@ <h3>Template</h3>
images-by-docker-reference="imagesByDockerReference"
builds="builds"
detailed="true"
add-health-check-url="{{ ({ group: 'apps', resource: 'deployments' } | canI : 'update') ? healthCheckURL : '' }}">
add-health-check-url="{{ (deploymentsVersion | canI : 'update') ? healthCheckURL : '' }}">
</pod-template>

</div>
<div class="col-lg-6">
<h3>Volumes</h3>
<p ng-if="!deployment.spec.template.spec.volumes.length && !({ group: 'apps', resource: 'deployments' } | canI : 'update')">
<p ng-if="!deployment.spec.template.spec.volumes.length && !(deploymentsVersion | canI : 'update')">
none
</p>
<volumes
volumes="deployment.spec.template.spec.volumes"
namespace="project.metadata.name"
can-remove="{ group: 'apps', resource: 'deployments' } | canI : 'update'"
can-remove="deploymentsVersion | canI : 'update'"
remove-fn="removeVolume(volume)">
</volumes>
<div ng-if="{ group: 'apps', resource: 'deployments' } | canI : 'update'">
<div ng-if="deploymentsVersion | canI : 'update'">
<a ng-href="project/{{project.metadata.name}}/attach-pvc?kind=Deployment&name={{deployment.metadata.name}}&group=apps">Add Storage</a>
<span class="action-divider" aria-hidden="true">|</span>
<a ng-href="project/{{project.metadata.name}}/add-config-volume?kind=Deployment&name={{deployment.metadata.name}}&group=apps">Add Config Files</a>
Expand All @@ -248,16 +248,16 @@ <h3>Autoscaling</h3>

<!-- If the CPU request is missing, add an action to set one. -->
<a ng-href="project/{{projectName}}/set-limits?kind=Deployment&name={{deployment.metadata.name}}&group=apps"
ng-if="warning.reason === 'NoCPURequest' && ({ group: 'apps', resource: 'deployments' } | canI : 'update')"
ng-if="warning.reason === 'NoCPURequest' && (deploymentsVersion | canI : 'update')"
role="button">Edit Resource
<span ng-if="!('cpu' | isRequestCalculated : project)">Requests and</span> Limits</a>
</div>

<!-- Create autoscaler -->
<div ng-if="!autoscalers.length">
<a ng-if="{resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'create'" ng-href="project/{{projectName}}/edit/autoscaler?kind=Deployment&name={{deployment.metadata.name}}&group=apps"
<a ng-if="horizontalPodAutoscalersVersion | canI : 'create'" ng-href="project/{{projectName}}/edit/autoscaler?kind=Deployment&name={{deployment.metadata.name}}&group=apps"
role="button">Add Autoscaler</a>
<span ng-if="!({resource: 'horizontalpodautoscalers', group: 'autoscaling'} | canI : 'create')">none</span>
<span ng-if="!(horizontalPodAutoscalersVersion | canI : 'create')">none</span>
</div>

<!-- HPA details -->
Expand All @@ -284,7 +284,7 @@ <h3>Autoscaling</h3>
<uib-tab-heading>Environment</uib-tab-heading>
<edit-environment-variables api-object="deployment"></edit-environment-variables>
</uib-tab>
<uib-tab active="selectedTab.events" ng-if="'events' | canI : 'watch'">
<uib-tab active="selectedTab.events" ng-if="eventsVersion | canI : 'watch'">
<uib-tab-heading>Events</uib-tab-heading>
<events api-objects="[ deployment ]" project-context="projectContext" ng-if="selectedTab.events"></events>
</uib-tab>
Expand Down

0 comments on commit 1f80df2

Please sign in to comment.