Merge "Improve Volume selection handling in LI"

This commit is contained in:
Jenkins 2016-05-04 07:29:00 +00:00 committed by Gerrit Code Review
commit bf294e4d63
5 changed files with 18 additions and 18 deletions

View File

@ -178,7 +178,7 @@
source_type: null,
source: [],
// REQUIRED for JS logic
vol_create: false,
vol_create: true,
// May be null
vol_device_name: 'vda',
vol_delete_on_instance_delete: false,

View File

@ -514,7 +514,7 @@
});
it('sets volume options appropriately', function() {
expect(model.newInstanceSpec.vol_create).toBe(false);
expect(model.newInstanceSpec.vol_create).toBe(true);
expect(model.newInstanceSpec.vol_device_name).toBe('vda');
expect(model.newInstanceSpec.vol_delete_on_instance_delete).toBe(false);
expect(model.newInstanceSpec.vol_size).toBe(1);

View File

@ -59,7 +59,6 @@
/*eslint-disable max-len */
ctrl.bootSourceTypeError = gettext('Volumes can only be attached to 1 active instance at a time. Please either set your instance count to 1 or select a different source type.');
/*eslint-enable max-len */
ctrl.volumeSizeError = gettext('Volume size is required and must be an integer');
// toggle button label/value defaults
ctrl.toggleButtonOptions = [
@ -399,7 +398,7 @@
function updateBootSourceSelection(selectedSource) {
ctrl.currentBootSource = selectedSource;
$scope.model.newInstanceSpec.vol_create = false;
$scope.model.newInstanceSpec.vol_create = true;
$scope.model.newInstanceSpec.vol_delete_on_instance_delete = false;
changeBootSource(selectedSource);
validateBootSourceType();
@ -465,14 +464,15 @@
var imageGb = source.size * 1e-9;
var imageDisk = source.min_disk;
ctrl.minVolumeSize = Math.ceil(Math.max(imageGb, imageDisk));
if ($scope.model.newInstanceSpec.vol_size < ctrl.minVolumeSize) {
$scope.model.newInstanceSpec.vol_size = ctrl.minVolumeSize;
}
var volumeSizeText = gettext('The volume size must be at least %(minVolumeSize)s GB');
var volumeSizeObj = { minVolumeSize: ctrl.minVolumeSize };
ctrl.minVolumeSizeError = interpolate(volumeSizeText, volumeSizeObj, true);
ctrl.volumeSizeError = interpolate(volumeSizeText, volumeSizeObj, true);
} else {
/*eslint-disable no-undefined */
ctrl.minVolumeSize = undefined;
/*eslint-enable no-undefined */
ctrl.minVolumeSize = 0;
ctrl.volumeSizeError = gettext('Volume size is required and must be an integer');
}
}

View File

@ -232,7 +232,7 @@
ctrl.updateBootSourceSelection(selSource);
expect(ctrl.currentBootSource).toEqual('image');
expect(scope.model.newInstanceSpec.vol_create).toBe(false);
expect(scope.model.newInstanceSpec.vol_create).toBe(true);
expect(scope.model.newInstanceSpec.vol_delete_on_instance_delete).toBe(false);
// check table data
@ -303,14 +303,14 @@
}
);
it('should set minVolumeSize to undefined if boot source is not image', function() {
it('should set minVolumeSize to 0 if boot source is not image', function() {
var selSource = 'volume';
ctrl.updateBootSourceSelection(selSource);
expect(ctrl.currentBootSource).toEqual('volume');
scope.$apply();
expect(ctrl.minVolumeSize).toBeUndefined();
expect(ctrl.minVolumeSize).toBe(0);
});
});
});

View File

@ -58,17 +58,17 @@
<span class="hz-icon-required fa fa-asterisk"></span>
</label>
<input name="volume-size"
min="0"
min="{$ ctrl.minVolumeSize $}"
id="volume-size"
type="number"
class="form-control"
ng-model="model.newInstanceSpec.vol_size"
ng-pattern="/^[0-9]+$/"
ng-required="true"
validate-number-min="{$ ctrl.minVolumeSize $}">
<span class="help-block" ng-show="launchInstanceSourceForm['volume-size'].$invalid">
{$ launchInstanceSourceForm['volume-size'].$error.validateNumberMin ? ctrl.minVolumeSizeError : ctrl.volumeSizeError $}
</span>
ng-required="true">
<span class="help-block"
ng-show="launchInstanceSourceForm['volume-size'].$invalid">
{$ launchInstanceSourceForm['volume-size'].$error.validateNumberMin ? ctrl.minVolumeSizeError : ctrl.volumeSizeError $}
</span>
</div>
</div>
</div>