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
15 changes: 10 additions & 5 deletions src/app/frontend/replicationcontrollerdetail/updatereplicas.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,21 @@
<md-dialog-content layout-padding>
<h4 class="md-title">Set desired number of pods</h4>
<div>
Replication controller {{ctrl.replicationController}} will be updated to reflect the desired count.<br/>
Replication controller {{ctrl.replicationController}} will be updated to reflect the desired
count.<br/>
<span class="kd-updatereplicas-pod-status">
Current status: {{ctrl.currentPods}}
created, {{ctrl.desiredPods}} desired
Current status: {{ctrl.currentPods}} created, {{ctrl.desiredPods}} desired
</span>
</div>
<form ng-submit="ctrl.updateReplicas()">
<form name="ctrl.updateReplicasForm" ng-submit="ctrl.updateReplicas()" novalidate>
<md-input-container class="md-block">
<label>Number of pods</label>
<input type="number" min="1" ng-model="ctrl.replicas" required>
<input name="podCount" type="number" kd-validate="integer" min="1" ng-model="ctrl.replicas"
required>
<ng-messages for="ctrl.updateReplicasForm.podCount.$error" role="alert">
<ng-message when="required">Number of pods is required.</ng-message>
<ng-message when="number,kdValid">Must be a positive integer.</ng-message>
</ng-messages>
</md-input-container>
<md-dialog-actions layout="row">
<md-button class="md-primary" ng-click="ctrl.cancel()">Cancel</md-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export default class UpdateReplicasDialogController {

/** @private {!angular.$resource} */
this.resource_ = $resource;

/** @export {!angular.FormController} Initialized from the template */
this.updateReplicasForm;
}

/**
Expand All @@ -69,17 +72,19 @@ export default class UpdateReplicasDialogController {
* @export
*/
updateReplicas() {
let resource = getReplicationControllerSpecPodsResource(
new StateParams(this.namespace_, this.replicationController), this.resource_);

/** @type {!backendApi.ReplicationControllerSpec} */
let replicationControllerSpec = {
replicas: this.replicas,
};

resource.save(
replicationControllerSpec, this.onUpdateReplicasSuccess_.bind(this),
this.onUpdateReplicasError_.bind(this));
if (this.updateReplicasForm.$valid) {
let resource = getReplicationControllerSpecPodsResource(
new StateParams(this.namespace_, this.replicationController), this.resource_);

/** @type {!backendApi.ReplicationControllerSpec} */
let replicationControllerSpec = {
replicas: this.replicas,
};

resource.save(
replicationControllerSpec, this.onUpdateReplicasSuccess_.bind(this),
this.onUpdateReplicasError_.bind(this));
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,15 @@ describe('Update Replicas controller', () => {
httpBackend = $httpBackend;
log = $log;

ctrl = $controller(UpdateReplicasDialogController, {
$resource: resource,
namespace: namespaceMock,
replicationController: replicationControllerMock,
currentPods: 1,
desiredPods: 1,
});
ctrl = $controller(
UpdateReplicasDialogController, {
$resource: resource,
namespace: namespaceMock,
replicationController: replicationControllerMock,
currentPods: 1,
desiredPods: 1,
},
{updateReplicasForm: {$valid: true}});
});
});

Expand Down