提交 bd145df3 编写于 作者: M Marcin Maciaszczyk

Update validation messages

上级 e321dd06
......@@ -18,16 +18,21 @@ limitations under the License.
<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>
......
......@@ -61,6 +61,9 @@ export default class UpdateReplicasDialogController {
/** @private {!angular.$resource} */
this.resource_ = $resource;
/** @export {!angular.FormController} Initialized from the template */
this.updateReplicasForm;
}
/**
......@@ -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));
}
}
/**
......
......@@ -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}});
});
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册